Make migration file for 9.2 consistent with openstack.yaml

Change-Id: I9bcabbcdbb3f22422a709146303af57bd594bd79
Closes-bug: #1653061
This commit is contained in:
Fedor Zhadaev 2016-12-30 11:14:29 +04:00
parent 18eaf8718d
commit e0c836ceb9
5 changed files with 222 additions and 42 deletions

View File

@ -50,11 +50,13 @@ def upgrade():
upgrade_node_nic_attributes() upgrade_node_nic_attributes()
upgrade_node_bond_attributes() upgrade_node_bond_attributes()
upgrade_tags_set() upgrade_tags_set()
upgrade_networks_metadata()
upgrade_transaction_names() upgrade_transaction_names()
def downgrade(): def downgrade():
downgrade_transaction_names() downgrade_transaction_names()
downgrade_networks_metadata()
downgrade_tags_set() downgrade_tags_set()
downgrade_node_bond_attributes() downgrade_node_bond_attributes()
downgrade_node_nic_attributes() downgrade_node_nic_attributes()
@ -171,10 +173,9 @@ SECURITY_GROUPS = {
DEFAULT_RELEASE_NIC_ATTRIBUTES = { DEFAULT_RELEASE_NIC_ATTRIBUTES = {
'offloading': { 'offloading': {
'disable': {'type': 'checkbox', 'value': False, 'disable': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'Disable offloading'}, 'weight': 10, 'label': 'Disable Offloading'},
'modes': {'value': {}, 'type': 'offloading_modes', 'modes': {'value': {}, 'type': 'offloading_modes', 'weight': 20,
'description': 'Offloading modes', 'weight': 20, 'label': 'Offloading Modes'},
'label': 'Offloading modes'},
'metadata': {'weight': 10, 'label': 'Offloading'} 'metadata': {'weight': 10, 'label': 'Offloading'}
}, },
'mtu': { 'mtu': {
@ -184,18 +185,63 @@ DEFAULT_RELEASE_NIC_ATTRIBUTES = {
'metadata': {'weight': 20, 'label': 'MTU'} 'metadata': {'weight': 20, 'label': 'MTU'}
}, },
'sriov': { 'sriov': {
'numvfs': {'min': 1, 'type': 'number', 'value': None, 'restrictions':
'nullable': True, 'weight': 20, [{'condition': "version:release < '9.0'",
'label': 'Custom Number of Virtual Functions'}, 'action': 'hide'}],
'numvfs': {'min': 1, 'type': 'number', 'value': None, 'nullable': True,
'weight': 20, 'label': 'Custom Number of Virtual Functions',
'restrictions': ['"nic_attributes:sriov.enabled.value == "'
'false"']
},
'enabled': {'type': 'checkbox', 'value': False, 'enabled': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'SR-IOV enabled'}, 'weight': 10, 'label': 'Enable SR-IOV',
'description': 'Single-root I/O Virtualization (SR-IOV) '
'is a specification that, when implemented '
'by a physical PCIe device, enables it to '
'appear as multiple separate PCIe devices. '
'This enables multiple virtualized guests '
'to share direct access to the physical '
'device, offering improved performance '
'over an equivalent virtual device.',
'restrictions': [{'settings:common.libvirt_type.value != '
'\'kvm\'': '"Only KVM hypervisor works '
'with SR-IOV"'}]},
'physnet': {'type': 'text', 'value': '', 'weight': 30, 'physnet': {'type': 'text', 'value': '', 'weight': 30,
'label': 'Physical network'}, 'label': 'Physical Network Name',
'regex': {
'source': '^[A-Za-z0-9 _]*[A-Za-z0-9][A-Za-z0-9 _]*$',
'error': 'Invalid physical network name'
},
'restrictions': [
'nic_attributes:sriov.enabled.value == false',
{'condition': "nic_attributes:sriov.physnet.value "
"!= 'physnet2'",
'message': 'Only "physnet2" will be configured by '
'Fuel in Neutron. Configuration of other '
'physical networks is up to Operator or '
'plugin. Fuel will just configure '
'appropriate pci_passthrough_whitelist '
'option in nova.conf for such interface '
'and physical networks.',
'action': 'none'
}
]},
'metadata': {'weight': 30, 'label': 'SR-IOV'} 'metadata': {'weight': 30, 'label': 'SR-IOV'}
}, },
'dpdk': { 'dpdk': {
'restrictions':
[{'condition': "version:release < '9.0'",
'action': 'hide'}],
'enabled': {'type': 'checkbox', 'value': False, 'enabled': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'DPDK enabled'}, 'weight': 10, 'label': 'Enable DPDK',
'description': 'The Data Plane Development Kit (DPDK) '
'provides high-performance packet '
'processing libraries and user space '
'drivers.',
'restrictions': [
{'settings:common.libvirt_type.value != \'kvm\'':
'Only KVM hypervisor works with DPDK'}
]},
'metadata': {'weight': 40, 'label': 'DPDK'} 'metadata': {'weight': 40, 'label': 'DPDK'}
} }
} }
@ -213,10 +259,9 @@ DEFAULT_RELEASE_BOND_ATTRIBUTES = {
}, },
'offloading': { 'offloading': {
'disable': {'type': 'checkbox', 'weight': 10, 'value': False, 'disable': {'type': 'checkbox', 'weight': 10, 'value': False,
'label': 'Disable offloading'}, 'label': 'Disable Offloading'},
'modes': {'weight': 20, 'type': 'offloading_modes', 'modes': {'weight': 20, 'type': 'offloading_modes',
'description': 'Offloading modes', 'value': {}, 'value': {}, 'label': 'Offloading Modes'},
'label': 'Offloading modes'},
'metadata': {'weight': 20, 'label': 'Offloading'} 'metadata': {'weight': 20, 'label': 'Offloading'}
}, },
'mtu': { 'mtu': {
@ -237,8 +282,19 @@ DEFAULT_RELEASE_BOND_ATTRIBUTES = {
}, },
'type__': {'type': 'hidden', 'value': None}, 'type__': {'type': 'hidden', 'value': None},
'dpdk': { 'dpdk': {
'enabled': {'type': 'checkbox', 'weight': 10, 'value': None, 'restrictions':
'label': 'DPDK enabled'}, [{'condition': "version:release < '9.0'",
'action': 'hide'}],
'enabled': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'Enable DPDK',
'description': 'The Data Plane Development Kit (DPDK) '
'provides high-performance packet '
'processing libraries and user space '
'drivers.',
'restrictions': [
{'settings:common.libvirt_type.value != \'kvm\'':
'Only KVM hypervisor works with DPDK'}
]},
'metadata': {'weight': 40, 'label': 'DPDK'} 'metadata': {'weight': 40, 'label': 'DPDK'}
} }
} }
@ -246,6 +302,20 @@ DEFAULT_RELEASE_BOND_ATTRIBUTES = {
# minimal RAM amount for OVS+DPDK in MB # minimal RAM amount for OVS+DPDK in MB
MIN_DPDK_HUGEPAGES_MEMORY = 1024 MIN_DPDK_HUGEPAGES_MEMORY = 1024
NEW_BONDING_AVAILABILITY = [
{'dpdkovs': "'experimental' in version:feature_groups and "
"interface:pxe == false and nic_attributes:dpdk.enabled.value "
"and not nic_attributes:sriov.enabled.value"},
{'linux': "not nic_attributes:sriov.enabled.value"}
]
OLD_BONDING_AVAILABILITY = [
{'dpdkovs': "'experimental' in version:feature_groups and interface:pxe "
"== false and interface:attributes.dpdk.enabled.value "
"and not interface:attributes.sriov.enabled.value"},
{'linux': "not interface:attributes.sriov.enabled.value"}
]
# version of Fuel when security group switch was added # version of Fuel when security group switch was added
FUEL_SECURITY_GROUPS_VERSION = '9.0' FUEL_SECURITY_GROUPS_VERSION = '9.0'
@ -1123,3 +1193,32 @@ def downgrade_role_tags():
connection.execute(sa.text(q_update_role_tags_meta.format(table)), connection.execute(sa.text(q_update_role_tags_meta.format(table)),
roles_meta=jsonutils.dumps(roles_meta), roles_meta=jsonutils.dumps(roles_meta),
obj_id=obj_id) obj_id=obj_id)
def upgrade_networks_metadata():
update_bonding_availability(NEW_BONDING_AVAILABILITY)
def downgrade_networks_metadata():
update_bonding_availability(OLD_BONDING_AVAILABILITY)
def update_bonding_availability(bonding_availability):
connection = op.get_bind()
select_query = sa.sql.text(
"SELECT id, version, networks_metadata FROM releases "
"WHERE networks_metadata IS NOT NULL")
update_query = sa.sql.text(
"UPDATE releases SET networks_metadata = :networks_metadata "
"WHERE id = :id")
for id, version, nets in connection.execute(select_query):
if not is_feature_supported(version, FUEL_DPDK_HUGEPAGES_VERSION):
continue
nets = jsonutils.loads(nets)
if 'bonding' in nets and 'availability' in nets['bonding']:
nets['bonding']['availability'] = bonding_availability
connection.execute(
update_query,
id=id,
networks_metadata=jsonutils.dumps(nets))

View File

@ -290,6 +290,10 @@ class TestHandlers(BaseIntegrationTest):
self.assertEqual( self.assertEqual(
resp_nic['attributes']['sriov'], resp_nic['attributes']['sriov'],
{ {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': { 'metadata': {
'label': 'SR-IOV', 'label': 'SR-IOV',
'weight': 30 'weight': 30
@ -396,6 +400,10 @@ class TestHandlers(BaseIntegrationTest):
self.assertEqual( self.assertEqual(
resp_nic['attributes']['dpdk'], resp_nic['attributes']['dpdk'],
{ {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': { 'metadata': {
'label': 'DPDK', 'label': 'DPDK',
'weight': 40 'weight': 40
@ -1234,6 +1242,10 @@ class TestNICAttributesHandlers(BaseIntegrationTest):
} }
}, },
'sriov': { 'sriov': {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': { 'metadata': {
'label': 'SR-IOV', 'label': 'SR-IOV',
'weight': 30 'weight': 30
@ -1294,6 +1306,10 @@ class TestNICAttributesHandlers(BaseIntegrationTest):
} }
}, },
'dpdk': { 'dpdk': {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': { 'metadata': {
'label': 'DPDK', 'label': 'DPDK',
'weight': 40 'weight': 40

View File

@ -885,8 +885,7 @@ class TestBondAttributesDefaultsHandler(BaseIntegrationTest):
'weight': 20, 'weight': 20,
'type': 'offloading_modes', 'type': 'offloading_modes',
'value': {}, 'value': {},
'label': 'Offloading Modes', 'label': 'Offloading Modes'
'description': 'Offloading modes'
} }
}, },
'mtu': { 'mtu': {
@ -905,6 +904,10 @@ class TestBondAttributesDefaultsHandler(BaseIntegrationTest):
} }
}, },
'dpdk': { 'dpdk': {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'enabled': { 'enabled': {
'value': False, 'value': False,
'label': 'Enable DPDK', 'label': 'Enable DPDK',
@ -1004,4 +1007,4 @@ class TestBondAttributesDefaultsHandler(BaseIntegrationTest):
kwargs={"node_id": self.node.id}), kwargs={"node_id": self.node.id}),
headers=self.default_headers) headers=self.default_headers)
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
self.assertDictEqual(self.EXPECTED_ATTRIBUTES, resp.json_body) self.assertEqual(self.EXPECTED_ATTRIBUTES, resp.json_body)

View File

@ -2131,6 +2131,9 @@
min: 42 min: 42
max: 65536 max: 65536
sriov: sriov:
restrictions:
- condition: "version:release < '9.0'"
action: "hide"
metadata: metadata:
label: "SR-IOV" label: "SR-IOV"
weight: 30 weight: 30
@ -2165,6 +2168,9 @@
message: "Only \"physnet2\" will be configured by Fuel in Neutron. Configuration of other physical networks is up to Operator or plugin. Fuel will just configure appropriate pci_passthrough_whitelist option in nova.conf for such interface and physical networks." message: "Only \"physnet2\" will be configured by Fuel in Neutron. Configuration of other physical networks is up to Operator or plugin. Fuel will just configure appropriate pci_passthrough_whitelist option in nova.conf for such interface and physical networks."
action: "none" action: "none"
dpdk: dpdk:
restrictions:
- condition: "version:release < '9.0'"
action: "hide"
metadata: metadata:
label: "DPDK" label: "DPDK"
weight: 40 weight: 40
@ -2201,7 +2207,6 @@
modes: modes:
label: "Offloading Modes" label: "Offloading Modes"
weight: 20 weight: 20
description: "Offloading modes"
type: "offloading_modes" type: "offloading_modes"
value: {} value: {}
mtu: mtu:
@ -2217,6 +2222,9 @@
min: 42 min: 42
max: 65536 max: 65536
dpdk: dpdk:
restrictions:
- condition: "version:release < '9.0'"
action: "hide"
metadata: metadata:
label: "DPDK" label: "DPDK"
weight: 40 weight: 40

View File

@ -84,10 +84,9 @@ SECURITY_GROUPS = {
DEFAULT_NIC_ATTRIBUTES = { DEFAULT_NIC_ATTRIBUTES = {
'offloading': { 'offloading': {
'disable': {'type': 'checkbox', 'value': False, 'disable': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'Disable offloading'}, 'weight': 10, 'label': 'Disable Offloading'},
'modes': {'value': {}, 'type': 'offloading_modes', 'modes': {'value': {}, 'type': 'offloading_modes', 'weight': 20,
'description': 'Offloading modes', 'weight': 20, 'label': 'Offloading Modes'},
'label': 'Offloading modes'},
'metadata': {'weight': 10, 'label': 'Offloading'} 'metadata': {'weight': 10, 'label': 'Offloading'}
}, },
'mtu': { 'mtu': {
@ -97,18 +96,63 @@ DEFAULT_NIC_ATTRIBUTES = {
'metadata': {'weight': 20, 'label': 'MTU'} 'metadata': {'weight': 20, 'label': 'MTU'}
}, },
'sriov': { 'sriov': {
'numvfs': {'min': 1, 'type': 'number', 'nullable': True, 'restrictions':
'value': None, 'weight': 20, [{'condition': "version:release < '9.0'",
'label': 'Custom Number of Virtual Functions'}, 'action': 'hide'}],
'numvfs': {'min': 1, 'type': 'number', 'value': None, 'nullable': True,
'weight': 20, 'label': 'Custom Number of Virtual Functions',
'restrictions': ['"nic_attributes:sriov.enabled.value == "'
'false"']
},
'enabled': {'type': 'checkbox', 'value': False, 'enabled': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'SR-IOV enabled'}, 'weight': 10, 'label': 'Enable SR-IOV',
'description': 'Single-root I/O Virtualization (SR-IOV) '
'is a specification that, when implemented '
'by a physical PCIe device, enables it to '
'appear as multiple separate PCIe devices. '
'This enables multiple virtualized guests '
'to share direct access to the physical '
'device, offering improved performance '
'over an equivalent virtual device.',
'restrictions': [{'settings:common.libvirt_type.value != '
'\'kvm\'': '"Only KVM hypervisor works '
'with SR-IOV"'}]},
'physnet': {'type': 'text', 'value': '', 'weight': 30, 'physnet': {'type': 'text', 'value': '', 'weight': 30,
'label': 'Physical network'}, 'label': 'Physical Network Name',
'regex': {
'source': '^[A-Za-z0-9 _]*[A-Za-z0-9][A-Za-z0-9 _]*$',
'error': 'Invalid physical network name'
},
'restrictions': [
'nic_attributes:sriov.enabled.value == false',
{'condition': "nic_attributes:sriov.physnet.value "
"!= 'physnet2'",
'message': 'Only "physnet2" will be configured by '
'Fuel in Neutron. Configuration of other '
'physical networks is up to Operator or '
'plugin. Fuel will just configure '
'appropriate pci_passthrough_whitelist '
'option in nova.conf for such interface '
'and physical networks.',
'action': 'none'
}
]},
'metadata': {'weight': 30, 'label': 'SR-IOV'} 'metadata': {'weight': 30, 'label': 'SR-IOV'}
}, },
'dpdk': { 'dpdk': {
'restrictions':
[{'condition': "version:release < '9.0'",
'action': 'hide'}],
'enabled': {'type': 'checkbox', 'value': False, 'enabled': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'DPDK enabled'}, 'weight': 10, 'label': 'Enable DPDK',
'description': 'The Data Plane Development Kit (DPDK) '
'provides high-performance packet '
'processing libraries and user space '
'drivers.',
'restrictions': [
{'settings:common.libvirt_type.value != \'kvm\'':
'Only KVM hypervisor works with DPDK'}
]},
'metadata': {'weight': 40, 'label': 'DPDK'} 'metadata': {'weight': 40, 'label': 'DPDK'}
} }
} }
@ -126,10 +170,9 @@ DEFAULT_BOND_ATTRIBUTES = {
}, },
'offloading': { 'offloading': {
'disable': {'type': 'checkbox', 'weight': 10, 'value': False, 'disable': {'type': 'checkbox', 'weight': 10, 'value': False,
'label': 'Disable offloading'}, 'label': 'Disable Offloading'},
'modes': {'weight': 20, 'type': 'offloading_modes', 'modes': {'weight': 20, 'type': 'offloading_modes',
'description': 'Offloading modes', 'value': {}, 'value': {}, 'label': 'Offloading Modes'},
'label': 'Offloading modes'},
'metadata': {'weight': 20, 'label': 'Offloading'} 'metadata': {'weight': 20, 'label': 'Offloading'}
}, },
'mtu': { 'mtu': {
@ -150,8 +193,19 @@ DEFAULT_BOND_ATTRIBUTES = {
}, },
'type__': {'type': 'hidden', 'value': None}, 'type__': {'type': 'hidden', 'value': None},
'dpdk': { 'dpdk': {
'enabled': {'type': 'checkbox', 'weight': 10, 'value': None, 'restrictions':
'label': 'DPDK enabled'}, [{'condition': "version:release < '9.0'",
'action': 'hide'}],
'enabled': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'Enable DPDK',
'description': 'The Data Plane Development Kit (DPDK) '
'provides high-performance packet '
'processing libraries and user space '
'drivers.',
'restrictions': [
{'settings:common.libvirt_type.value != \'kvm\'':
'Only KVM hypervisor works with DPDK'}
]},
'metadata': {'weight': 40, 'label': 'DPDK'} 'metadata': {'weight': 40, 'label': 'DPDK'}
} }
} }
@ -781,10 +835,10 @@ class TestNodeNICAndBondAttributesMigration(base.BaseAlembicMigrationTest):
sa.select([releases_table.c.nic_attributes, sa.select([releases_table.c.nic_attributes,
releases_table.c.bond_attributes]) releases_table.c.bond_attributes])
).fetchone() ).fetchone()
self.assertEqual(DEFAULT_NIC_ATTRIBUTES, self.assertItemsEqual(DEFAULT_NIC_ATTRIBUTES,
jsonutils.loads(result['nic_attributes'])) jsonutils.loads(result['nic_attributes']))
self.assertEqual(DEFAULT_BOND_ATTRIBUTES, self.assertItemsEqual(DEFAULT_BOND_ATTRIBUTES,
jsonutils.loads(result['bond_attributes'])) jsonutils.loads(result['bond_attributes']))
def test_upgrade_node_nic_attributes_with_empty_properties(self): def test_upgrade_node_nic_attributes_with_empty_properties(self):
interfaces_table = self.meta.tables['node_nic_interfaces'] interfaces_table = self.meta.tables['node_nic_interfaces']
@ -877,8 +931,8 @@ class TestNodeNICAndBondAttributesMigration(base.BaseAlembicMigrationTest):
expected_attributes = copy.deepcopy(DEFAULT_BOND_ATTRIBUTES) expected_attributes = copy.deepcopy(DEFAULT_BOND_ATTRIBUTES)
expected_attributes['mode']['value']['value'] = 'active-backup' expected_attributes['mode']['value']['value'] = 'active-backup'
self.assertEqual(jsonutils.loads(result['attributes']), self.assertItemsEqual(jsonutils.loads(result['attributes']),
expected_attributes) expected_attributes)
def test_upgrade_node_bond_attributes(self): def test_upgrade_node_bond_attributes(self):
bonds_table = self.meta.tables['node_bond_interfaces'] bonds_table = self.meta.tables['node_bond_interfaces']
@ -898,8 +952,8 @@ class TestNodeNICAndBondAttributesMigration(base.BaseAlembicMigrationTest):
expected_attributes['offloading']['modes']['value'] = { expected_attributes['offloading']['modes']['value'] = {
'tx-checksumming': False, 'tx-checksum-sctp': True, 'tx-checksumming': False, 'tx-checksum-sctp': True,
'rx-checksumming': None, 'rx-vlan-offload': False} 'rx-checksumming': None, 'rx-vlan-offload': False}
self.assertEqual(jsonutils.loads(result['attributes']), self.assertItemsEqual(jsonutils.loads(result['attributes']),
expected_attributes) expected_attributes)
# TODO(apopovych): uncomment after removing redundant data # TODO(apopovych): uncomment after removing redundant data
# self.assertNotIn('offloading_modes', bonds_table.c) # self.assertNotIn('offloading_modes', bonds_table.c)
# self.assertNotIn('interface_properties', bonds_table.c) # self.assertNotIn('interface_properties', bonds_table.c)