attach/detach_volume() take instance as a parameter

Previously the methods take instance['name'] as a parameter.
With this change, ComputeDriver can lookup informations about
the instance from hypervisor (in bare-metal driver, it is a local DB)
by any other attributes of the instance.

blueprint general-bare-metal-provisioning-framework

Change-Id: Ibd0567f34ed5053909ce1a408f9cbf87516ba597
This commit is contained in:
Arata Notsu
2012-12-20 21:29:13 +09:00
parent 8f45a12670
commit c2b958ba80
4 changed files with 10 additions and 10 deletions

View File

@@ -508,7 +508,7 @@ class HyperVAPITestCase(basetestcase.BaseTestCase):
self._volume_target_portal, self._volume_id)
self._conn.attach_volume(connection_info,
self._instance_data["name"], '/dev/sdc')
self._instance_data, '/dev/sdc')
def test_attach_volume(self):
self._attach_volume()
@@ -527,7 +527,7 @@ class HyperVAPITestCase(basetestcase.BaseTestCase):
self._volume_target_portal, self._volume_id)
self._conn.detach_volume(connection_info,
self._instance_data["name"], '/dev/sdc')
self._instance_data, '/dev/sdc')
(_, volumes_paths, _) = self._hypervutils.get_vm_disks(
self._instance_data["name"])

View File

@@ -1707,8 +1707,8 @@ class LibvirtConnTestCase(test.TestCase):
self.assertRaises(exception.VolumeDriverNotFound,
conn.attach_volume,
{"driver_volume_type": "badtype"},
"fake",
"/dev/fake")
{"name": "fake-instance"},
"/dev/fake")
def test_multi_nic(self):
instance_data = dict(self.test_instance)

View File

@@ -379,10 +379,10 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
def test_attach_detach_volume(self):
instance_ref, network_info = self._get_running_instance()
self.connection.attach_volume({'driver_volume_type': 'fake'},
instance_ref['name'],
instance_ref,
'/mnt/nova/something')
self.connection.detach_volume({'driver_volume_type': 'fake'},
instance_ref['name'],
instance_ref,
'/mnt/nova/something')
@catch_notimplementederror
@@ -390,11 +390,11 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
instance_ref, network_info = self._get_running_instance()
self.connection.power_off(instance_ref)
self.connection.attach_volume({'driver_volume_type': 'fake'},
instance_ref['name'],
instance_ref,
'/mnt/nova/something')
self.connection.power_on(instance_ref)
self.connection.detach_volume({'driver_volume_type': 'fake'},
instance_ref['name'],
instance_ref,
'/mnt/nova/something')
@catch_notimplementederror

View File

@@ -271,7 +271,7 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase):
instance = db.instance_create(self.context, self.instance_values)
vm = xenapi_fake.create_vm(instance['name'], 'Running')
result = conn.attach_volume(self._make_connection_info(),
instance['name'], '/dev/sdc')
instance, '/dev/sdc')
# check that the VM has a VBD attached to it
# Get XenAPI record for VBD
@@ -290,7 +290,7 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase):
self.assertRaises(exception.VolumeDriverNotFound,
conn.attach_volume,
{'driver_volume_type': 'nonexist'},
instance['name'],
instance,
'/dev/sdc')