Add device bus and type to virt attach_volume call

These two can be passed in the API when booting instances, and this
patch adds them to the relevant virt driver calls, so that they can be
passed when attaching volumes.

Part of the blueprint: use-new-bdm-format-in-attach

Change-Id: Ia961cae2b4bb3554f8d360c67144eb135df5528f
This commit is contained in:
Nikola Dipanov
2014-01-10 15:59:14 +01:00
parent 61e6f5b1e1
commit e404bb9522
9 changed files with 14 additions and 9 deletions

View File

@@ -317,11 +317,15 @@ class TestDriverBlockDevice(test.NoDBTestCase):
self.virt_driver.attach_volume(
elevated_context, expected_conn_info, instance,
bdm_dict['device_name'],
disk_bus=bdm_dict['disk_bus'],
device_type=bdm_dict['device_type'],
encryption=enc_data).AndReturn(None)
else:
self.virt_driver.attach_volume(
elevated_context, expected_conn_info, instance,
bdm_dict['device_name'],
disk_bus=bdm_dict['disk_bus'],
device_type=bdm_dict['device_type'],
encryption=enc_data).AndRaise(test.TestingException)
self.volume_api.terminate_connection(
elevated_context, fake_volume['id'],

View File

@@ -416,7 +416,7 @@ class BareMetalDriver(driver.ComputeDriver):
return self.volume_driver.get_volume_connector(instance)
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
return self.volume_driver.attach_volume(connection_info,
instance, mountpoint)

View File

@@ -236,7 +236,8 @@ class DriverVolumeBlockDevice(DriverBlockDevice):
try:
virt_driver.attach_volume(
context, connection_info, instance,
self['mount_device'], encryption=encryption)
self['mount_device'], disk_bus=self['disk_bus'],
device_type=self['device_type'], encryption=encryption)
except Exception: # pylint: disable=W0702
with excutils.save_and_reraise_exception():
LOG.exception(_("Driver failed to attach volume "

View File

@@ -398,7 +398,7 @@ class ComputeDriver(object):
raise NotImplementedError()
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
"""Attach the disk to the instance at mountpoint using info."""
raise NotImplementedError()

View File

@@ -217,7 +217,7 @@ class FakeDriver(driver.ComputeDriver):
pass
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
"""Attach the disk to the instance at mountpoint using info."""
instance_name = instance['name']
if instance_name not in self._mounts:

View File

@@ -72,7 +72,7 @@ class HyperVDriver(driver.ComputeDriver):
return self._vmops.get_info(instance)
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
return self._volumeops.attach_volume(connection_info,
instance['name'])

View File

@@ -1150,7 +1150,7 @@ class LibvirtDriver(driver.ComputeDriver):
return encryptor
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
instance_name = instance['name']
virt_dom = self._lookup_by_name(instance_name)
disk_dev = mountpoint.rpartition("/")[2]

View File

@@ -252,7 +252,7 @@ class VMwareESXDriver(driver.ComputeDriver):
return self._host_ip
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
"""Attach volume storage to VM instance."""
return self._volumeops.attach_volume(connection_info,
instance,
@@ -588,7 +588,7 @@ class VMwareVCDriver(VMwareESXDriver):
admin_password, network_info, block_device_info)
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
"""Attach volume storage to VM instance."""
_volumeops = self._get_volumeops_for_compute_node(instance['node'])
return _volumeops.attach_volume(connection_info,

View File

@@ -430,7 +430,7 @@ class XenAPIDriver(driver.ComputeDriver):
return xs_url.netloc
def attach_volume(self, context, connection_info, instance, mountpoint,
encryption=None):
disk_bus=None, device_type=None, encryption=None):
"""Attach volume storage to VM instance."""
return self._volumeops.attach_volume(connection_info,
instance['name'],