def discover_one(self, uuid): compute_client = clients.compute_client(self.cloud) try: raw_server = self.retry(compute_client.servers.get, uuid, expected_exceptions=[exceptions.NotFound]) except exceptions.NotFound: raise discover.NotFound() # Check if server host is available avail_hosts = self._list_available_compute_hosts(compute_client) host = getattr(raw_server, EXT_ATTR_HOST) if host not in avail_hosts: LOG.warning('Skipping server %s, host not available.', host) return None # Convert server data to model conforming format server = self.load_from_cloud(raw_server) with remote.RemoteExecutor(self.cloud, server.hypervisor_host) as remote_executor: _populate_ephemeral_disks(remote_executor, server) # Store server with model.Session() as session: session.store(server) if _need_image_membership(server): image_member_uuid = image.ImageMember.make_uuid( server.image, server.tenant) server.image_membership = self.find_obj( image.ImageMember, image_member_uuid) return server
def discover_one(self, uuid): try: raw_obj = self.retry(self._manager.get, uuid, expected_exceptions=[exceptions.NotFound]) with model.Session() as session: obj = self.load_from_cloud(raw_obj) session.store(obj) return obj except exceptions.NotFound: raise discover.NotFound()
def discover_one(self, uuid): network_client = clients.network_client(self.cloud) try: raw_object = self.get(network_client, uuid) with model.Session() as session: obj = self.load_from_cloud(raw_object) session.store(obj) return obj except neutron_exceptions.NotFound: raise discover.NotFound()
def discover_one(self, uuid): volume_client = clients.volume_client(self.cloud) try: volume = self.load_from_cloud( self.retry(volume_client.volumes.get, uuid, expected_exceptions=[cinder_exceptions.NotFound])) with model.Session() as session: session.store(volume) return volume except cinder_exceptions.NotFound: raise discover.NotFound()
def discover_one(self, uuid): identity_client = clients.identity_client(self.cloud) try: raw_tenant = self.retry(identity_client.tenants.get, uuid, expected_exceptions=[exceptions.NotFound]) tenant = self.load_from_cloud(raw_tenant) with model.Session() as session: session.store(tenant) return tenant except exceptions.NotFound: raise discover.NotFound()
def discover_one(self, uuid): image_client = clients.image_client(self.cloud) try: raw_image = self.retry( image_client.images.get, uuid, expected_exceptions=[glance_exc.HTTPNotFound]) img = self.load_from_cloud(raw_image) with model.Session() as session: session.store(img) self._populate_members(img, image_client) return img except glance_exc.HTTPNotFound: raise discover.NotFound()
def discover_one(self, uuid): server_id, volume_id = uuid.split(':') compute_client = clients.compute_client(self.cloud) try: raw_attachment = self.retry( compute_client.volumes.get_server_volume, server_id, volume_id, expected_exceptions=[nova_exceptions.NotFound]) attachment = self.load_from_cloud(raw_attachment) with model.Session() as session: session.store(attachment) return attachment except nova_exceptions.NotFound: raise discover.NotFound()
def get(self, network_client, uuid): net = self._get(network_client.show_network, uuid, 'network') if not net['tenant_id']: raise discover.NotFound() return net
def get(self, network_client, uuid): subnet = self._get(network_client.show_subnet, uuid, 'subnet') if not subnet['tenant_id']: raise discover.NotFound() return subnet