pci: Allow to assign pci devices in pci device list

This patch allow the pci device list constructor to
be init with list of pci devices

Change-Id: I420a79a22563c136741bda85be15f9d22d29e263
This commit is contained in:
Moshe Levi 2016-04-29 01:34:12 +03:00
parent 2b65c79934
commit fd3be6e1f2
2 changed files with 12 additions and 2 deletions

View File

@ -465,6 +465,7 @@ class PciDeviceList(base.ObjectListBase, base.NovaObject):
def __init__(self, *args, **kwargs):
super(PciDeviceList, self).__init__(*args, **kwargs)
if 'objects' not in kwargs:
self.objects = []
self.obj_reset_changes()

View File

@ -451,6 +451,15 @@ fake_pci_devs = [fake_db_dev, fake_db_dev_1]
class _TestPciDeviceListObject(object):
def test_create_pci_device_list(self):
ctxt = context.get_admin_context()
devobj = pci_device.PciDevice.create(ctxt, dev_dict)
pci_device_list = objects.PciDeviceList(
context=ctxt, objects=[devobj])
self.assertEqual(1, len(pci_device_list))
self.assertIsInstance(pci_device_list[0], pci_device.PciDevice)
def test_get_by_compute_node(self):
ctxt = context.get_admin_context()
self.mox.StubOutWithMock(db, 'pci_device_get_all_by_node')