Merge "Fix mitaka online migration for PCI devices" into stable/ocata

This commit is contained in:
Jenkins 2017-04-25 19:33:33 +00:00 committed by Gerrit Code Review
commit a8792e1161
2 changed files with 36 additions and 3 deletions

View File

@ -38,9 +38,15 @@ def upgrade(migrate_engine):
raise exception.ValidationError(detail=msg)
pci_devices = Table('pci_devices', meta, autoload=True)
# Ensure that all non-deleted PCI device records have a populated
# parent address. Note that we test directly against the 'type-VF'
# enum value to prevent issues with this migration going forward
# if the definition is altered.
count = select([func.count()]).select_from(pci_devices).where(and_(
pci_devices.c.deleted == 0,
pci_devices.c.parent_addr == None)).execute().scalar() # NOQA
pci_devices.c.parent_addr == None,
pci_devices.c.dev_type == 'type-VF')).execute().scalar() # NOQA
if count > 0:
msg = WARNING_MSG % {
'count': count,

View File

@ -268,19 +268,46 @@ class TestNewtonCheck(test.TestCase):
self.assertRaises(exception.ValidationError,
self.migration.upgrade, self.engine)
def test_pci_device_not_migrated(self):
def test_pci_device_type_vf_not_migrated(self):
db_api.pci_device_update(self.context, 1, 'foo:bar',
{'parent_addr': None,
'compute_node_id': 1,
'address': 'foo:bar',
'vendor_id': '123',
'product_id': '456',
'dev_type': 'foo',
'dev_type': 'type-VF',
'label': 'foobar',
'status': 'whatisthis?'})
# type-VF devices should have a parent_addr
self.assertRaises(exception.ValidationError,
self.migration.upgrade, self.engine)
def test_pci_device_type_pf_not_migrated(self):
db_api.pci_device_update(self.context, 1, 'foo:bar',
{'parent_addr': None,
'compute_node_id': 1,
'address': 'foo:bar',
'vendor_id': '123',
'product_id': '456',
'dev_type': 'type-PF',
'label': 'foobar',
'status': 'whatisthis?'})
# blocker should not block on type-PF devices
self.migration.upgrade(self.engine)
def test_pci_device_type_pci_not_migrated(self):
db_api.pci_device_update(self.context, 1, 'foo:bar',
{'parent_addr': None,
'compute_node_id': 1,
'address': 'foo:bar',
'vendor_id': '123',
'product_id': '456',
'dev_type': 'type-PCI',
'label': 'foobar',
'status': 'whatisthis?'})
# blocker should not block on type-PCI devices
self.migration.upgrade(self.engine)
def test_deleted_not_migrated(self):
cn_values = dict(vcpus=1, memory_mb=512, local_gb=10,
vcpus_used=0, memory_mb_used=256,