Merge "Remove unused code in pci_manager.get_instance_pci_devs()"

This commit is contained in:
Jenkins
2014-10-15 12:55:48 +00:00
committed by Gerrit Code Review
5 changed files with 5 additions and 25 deletions
+1 -6
View File
@@ -276,11 +276,6 @@ def get_instance_pci_devs(inst, request_id=None):
instance need to be returned. Refer to libvirt driver that handles
soft_reboot and hard_boot of 'xen' instances.
"""
if isinstance(inst, objects.Instance):
pci_devices = inst.pci_devices
else:
ctxt = context.get_admin_context()
pci_devices = objects.PciDeviceList.get_by_instance_uuid(
ctxt, inst['uuid'])
pci_devices = inst.pci_devices
return [device for device in pci_devices if
device.request_id == request_id or request_id == 'all']
-12
View File
@@ -344,18 +344,6 @@ class PciDevTrackerTestCase(test.TestCase):
class PciGetInstanceDevs(test.TestCase):
def test_get_devs_non_object(self):
def _fake_pci_device_get_by_instance_uuid(context, uuid):
self._get_by_uuid = True
return []
instance = fakes.stub_instance(id=1)
self.stubs.Set(db, 'pci_device_get_all_by_instance_uuid',
_fake_pci_device_get_by_instance_uuid)
self._get_by_uuid = False
pci_manager.get_instance_pci_devs(instance)
self.assertEqual(self._get_by_uuid, True)
def test_get_devs_object(self):
def _fake_obj_load_attr(foo, attrname):
if attrname == 'pci_devices':
+2 -6
View File
@@ -7353,9 +7353,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.reboot_create_called = True
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = {"name": "instancename", "id": "instanceid",
"uuid": "875a8070-d0b9-4949-8b31-104d125c9a64",
"pci_devices": []}
instance = objects.Instance(**self.test_instance)
self.stubs.Set(conn, '_lookup_by_name', fake_lookup_by_name)
self.stubs.Set(conn, '_create_domain', fake_create_domain)
self.stubs.Set(loopingcall, 'FixedIntervalLoopingCall',
@@ -7398,9 +7396,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
pass
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
instance = {"name": "instancename", "id": "instanceid",
"uuid": "875a8070-d0b9-4949-8b31-104d125c9a64",
"pci_devices": []}
instance = objects.Instance(**self.test_instance)
self.stubs.Set(conn, '_lookup_by_name', fake_lookup_by_name)
self.stubs.Set(greenthread, 'sleep', fake_sleep)
self.stubs.Set(conn, '_hard_reboot', fake_hard_reboot)
+1 -1
View File
@@ -218,7 +218,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
self.stubs.Set(imagebackend.Image, 'resolve_driver_format',
imagebackend.Image._get_driver_format)
def _get_running_instance(self, obj=False):
def _get_running_instance(self, obj=True):
instance_ref = test_utils.get_test_instance(obj=obj)
network_info = test_utils.get_test_network_info()
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
+1
View File
@@ -206,6 +206,7 @@ def get_create_system_metadata(context, instance_type_id):
def create_instance_with_system_metadata(context, instance_values):
instance_values['system_metadata'] = get_create_system_metadata(
context, instance_values['instance_type_id'])
instance_values['pci_devices'] = []
return db.instance_create(context, instance_values)