diff options
Diffstat (limited to 'nova/virt')
-rw-r--r-- | nova/virt/baremetal/driver.py | 8 | ||||
-rw-r--r-- | nova/virt/baremetal/volume_driver.py | 34 | ||||
-rw-r--r-- | nova/virt/driver.py | 4 | ||||
-rw-r--r-- | nova/virt/fake.py | 7 | ||||
-rw-r--r-- | nova/virt/hyperv/driver.py | 8 | ||||
-rw-r--r-- | nova/virt/libvirt/driver.py | 6 | ||||
-rw-r--r-- | nova/virt/vmwareapi/driver.py | 4 | ||||
-rw-r--r-- | nova/virt/xenapi/driver.py | 8 |
8 files changed, 34 insertions, 45 deletions
diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py index e517b399d..1d46e85a3 100644 --- a/nova/virt/baremetal/driver.py +++ b/nova/virt/baremetal/driver.py @@ -308,14 +308,14 @@ class BareMetalDriver(driver.ComputeDriver): def get_volume_connector(self, instance): return self.volume_driver.get_volume_connector(instance) - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): return self.volume_driver.attach_volume(connection_info, - instance_name, mountpoint) + instance, mountpoint) @exception.wrap_exception() - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): return self.volume_driver.detach_volume(connection_info, - instance_name, mountpoint) + instance, mountpoint) def get_info(self, instance): # NOTE(deva): compute/manager.py expects to get NotFound exception diff --git a/nova/virt/baremetal/volume_driver.py b/nova/virt/baremetal/volume_driver.py index 7f59ec517..09088dd53 100644 --- a/nova/virt/baremetal/volume_driver.py +++ b/nova/virt/baremetal/volume_driver.py @@ -50,22 +50,9 @@ CONF.import_opt('libvirt_volume_drivers', 'nova.virt.libvirt.driver') LOG = logging.getLogger(__name__) -def _get_baremetal_node_by_instance_name(virtapi, instance_name): +def _get_baremetal_node_by_instance_uuid(instance_uuid): context = nova_context.get_admin_context() - # TODO(deva): optimize this DB query. - # I don't think it should be _get_all - for node in bmdb.bm_node_get_all(context, service_host=CONF.host): - if not node['instance_uuid']: - continue - try: - inst = virtapi.instance_get_by_uuid(context, node['instance_uuid']) - if inst['name'] == instance_name: - return node - except exception.InstanceNotFound: - continue - - # raise exception if we found no matching instance - raise exception.InstanceNotFound(instance_name) + return bmdb.bm_node_get_by_instance_uuid(context, instance_uuid) def _create_iscsi_export_tgtadm(path, tid, iqn): @@ -200,10 +187,10 @@ class VolumeDriver(object): 'host': CONF.host, } - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): raise NotImplementedError() - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): raise NotImplementedError() @@ -227,22 +214,21 @@ class LibvirtVolumeDriver(VolumeDriver): method = getattr(driver, method_name) return method(connection_info, *args, **kwargs) - def attach_volume(self, connection_info, instance_name, mountpoint): - node = _get_baremetal_node_by_instance_name(self.virtapi, - instance_name) + def attach_volume(self, connection_info, instance, mountpoint): + node = _get_baremetal_node_by_instance_uuid(instance['uuid']) ctx = nova_context.get_admin_context() pxe_ip = bmdb.bm_pxe_ip_get_by_bm_node_id(ctx, node['id']) if not pxe_ip: if not CONF.baremetal.use_unsafe_iscsi: raise exception.NovaException(_( - 'No fixed PXE IP is associated to %s') % instance_name) + 'No fixed PXE IP is associated to %s') % instance['uuid']) mount_device = mountpoint.rpartition("/")[2] self._volume_driver_method('connect_volume', connection_info, mount_device) device_path = connection_info['data']['device_path'] - iqn = _get_iqn(instance_name, mountpoint) + iqn = _get_iqn(instance['name'], mountpoint) tid = _get_next_tid() _create_iscsi_export_tgtadm(device_path, tid, iqn) @@ -259,10 +245,10 @@ class LibvirtVolumeDriver(VolumeDriver): _allow_iscsi_tgtadm(tid, 'ALL') @exception.wrap_exception() - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): mount_device = mountpoint.rpartition("/")[2] try: - iqn = _get_iqn(instance_name, mountpoint) + iqn = _get_iqn(instance['name'], mountpoint) tid = _find_tid(iqn) if tid is not None: _delete_iscsi_export_tgtadm(tid) diff --git a/nova/virt/driver.py b/nova/virt/driver.py index da4a9475c..a3fe68586 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -272,11 +272,11 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): """Attach the disk to the instance at mountpoint using info""" raise NotImplementedError() - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): """Detach the disk attached to the instance""" raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 348675fe2..f719b1a74 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -199,17 +199,18 @@ class FakeDriver(driver.ComputeDriver): {'key': key, 'inst': self.instances}, instance=instance) - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): """Attach the disk to the instance at mountpoint using info""" + instance_name = instance['name'] if not instance_name in self._mounts: self._mounts[instance_name] = {} self._mounts[instance_name][mountpoint] = connection_info return True - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): """Detach the disk attached to the instance""" try: - del self._mounts[instance_name][mountpoint] + del self._mounts[instance['name']][mountpoint] except KeyError: pass return True diff --git a/nova/virt/hyperv/driver.py b/nova/virt/hyperv/driver.py index 62cb46f2f..9599bca33 100644 --- a/nova/virt/hyperv/driver.py +++ b/nova/virt/hyperv/driver.py @@ -105,16 +105,16 @@ class HyperVDriver(driver.ComputeDriver): def get_info(self, instance): return self._vmops.get_info(instance) - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): """Attach volume storage to VM instance""" return self._volumeops.attach_volume(connection_info, - instance_name, + instance['name'], mountpoint) - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance""" return self._volumeops.detach_volume(connection_info, - instance_name, + instance['name'], mountpoint) def get_volume_connector(self, instance): diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index d90a34123..4a642922a 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -658,7 +658,8 @@ class LibvirtDriver(driver.ComputeDriver): return method(connection_info, *args, **kwargs) @exception.wrap_exception() - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): + instance_name = instance['name'] virt_dom = self._lookup_by_name(instance_name) mount_device = mountpoint.rpartition("/")[2] conf = self.volume_driver_method('connect_volume', @@ -712,7 +713,8 @@ class LibvirtDriver(driver.ComputeDriver): return xml @exception.wrap_exception() - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): + instance_name = instance['name'] mount_device = mountpoint.rpartition("/")[2] try: virt_dom = self._lookup_by_name(instance_name) diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py index ce8005861..ff6291fe5 100644 --- a/nova/virt/vmwareapi/driver.py +++ b/nova/virt/vmwareapi/driver.py @@ -179,11 +179,11 @@ class VMWareESXDriver(driver.ComputeDriver): 'host': None } - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): """Attach volume storage to VM instance.""" pass - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance.""" pass diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py index 1b60faa9f..21affe72c 100644 --- a/nova/virt/xenapi/driver.py +++ b/nova/virt/xenapi/driver.py @@ -357,16 +357,16 @@ class XenAPIDriver(driver.ComputeDriver): xs_url = urlparse.urlparse(CONF.xenapi_connection_url) return xs_url.netloc - def attach_volume(self, connection_info, instance_name, mountpoint): + def attach_volume(self, connection_info, instance, mountpoint): """Attach volume storage to VM instance""" return self._volumeops.attach_volume(connection_info, - instance_name, + instance['name'], mountpoint) - def detach_volume(self, connection_info, instance_name, mountpoint): + def detach_volume(self, connection_info, instance, mountpoint): """Detach volume storage to VM instance""" return self._volumeops.detach_volume(connection_info, - instance_name, + instance['name'], mountpoint) def get_console_pool_info(self, console_type): |