Merge "Make migration file for 9.2 consistent with openstack.yaml"

This commit is contained in:
Jenkins 2017-01-16 11:36:00 +00:00 committed by Gerrit Code Review
commit 90d7ea3cd5
5 changed files with 222 additions and 42 deletions

View File

@ -50,11 +50,13 @@ def upgrade():
upgrade_node_nic_attributes()
upgrade_node_bond_attributes()
upgrade_tags_set()
upgrade_networks_metadata()
upgrade_transaction_names()
def downgrade():
downgrade_transaction_names()
downgrade_networks_metadata()
downgrade_tags_set()
downgrade_node_bond_attributes()
downgrade_node_nic_attributes()
@ -171,10 +173,9 @@ SECURITY_GROUPS = {
DEFAULT_RELEASE_NIC_ATTRIBUTES = {
'offloading': {
'disable': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'Disable offloading'},
'modes': {'value': {}, 'type': 'offloading_modes',
'description': 'Offloading modes', 'weight': 20,
'label': 'Offloading modes'},
'weight': 10, 'label': 'Disable Offloading'},
'modes': {'value': {}, 'type': 'offloading_modes', 'weight': 20,
'label': 'Offloading Modes'},
'metadata': {'weight': 10, 'label': 'Offloading'}
},
'mtu': {
@ -184,18 +185,63 @@ DEFAULT_RELEASE_NIC_ATTRIBUTES = {
'metadata': {'weight': 20, 'label': 'MTU'}
},
'sriov': {
'numvfs': {'min': 1, 'type': 'number', 'value': None,
'nullable': True, 'weight': 20,
'label': 'Custom Number of Virtual Functions'},
'restrictions':
[{'condition': "version:release < '9.0'",
'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,
'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,
'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'}
},
'dpdk': {
'restrictions':
[{'condition': "version:release < '9.0'",
'action': 'hide'}],
'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'}
}
}
@ -213,10 +259,9 @@ DEFAULT_RELEASE_BOND_ATTRIBUTES = {
},
'offloading': {
'disable': {'type': 'checkbox', 'weight': 10, 'value': False,
'label': 'Disable offloading'},
'label': 'Disable Offloading'},
'modes': {'weight': 20, 'type': 'offloading_modes',
'description': 'Offloading modes', 'value': {},
'label': 'Offloading modes'},
'value': {}, 'label': 'Offloading Modes'},
'metadata': {'weight': 20, 'label': 'Offloading'}
},
'mtu': {
@ -237,8 +282,19 @@ DEFAULT_RELEASE_BOND_ATTRIBUTES = {
},
'type__': {'type': 'hidden', 'value': None},
'dpdk': {
'enabled': {'type': 'checkbox', 'weight': 10, 'value': None,
'label': 'DPDK enabled'},
'restrictions':
[{'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'}
}
}
@ -246,6 +302,20 @@ DEFAULT_RELEASE_BOND_ATTRIBUTES = {
# minimal RAM amount for OVS+DPDK in MB
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
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)),
roles_meta=jsonutils.dumps(roles_meta),
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(
resp_nic['attributes']['sriov'],
{
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': {
'label': 'SR-IOV',
'weight': 30
@ -396,6 +400,10 @@ class TestHandlers(BaseIntegrationTest):
self.assertEqual(
resp_nic['attributes']['dpdk'],
{
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': {
'label': 'DPDK',
'weight': 40
@ -1234,6 +1242,10 @@ class TestNICAttributesHandlers(BaseIntegrationTest):
}
},
'sriov': {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': {
'label': 'SR-IOV',
'weight': 30
@ -1294,6 +1306,10 @@ class TestNICAttributesHandlers(BaseIntegrationTest):
}
},
'dpdk': {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'metadata': {
'label': 'DPDK',
'weight': 40

View File

@ -885,8 +885,7 @@ class TestBondAttributesDefaultsHandler(BaseIntegrationTest):
'weight': 20,
'type': 'offloading_modes',
'value': {},
'label': 'Offloading Modes',
'description': 'Offloading modes'
'label': 'Offloading Modes'
}
},
'mtu': {
@ -905,6 +904,10 @@ class TestBondAttributesDefaultsHandler(BaseIntegrationTest):
}
},
'dpdk': {
'restrictions': [{
'condition': "version:release < '9.0'",
'action': 'hide'
}],
'enabled': {
'value': False,
'label': 'Enable DPDK',
@ -1004,4 +1007,4 @@ class TestBondAttributesDefaultsHandler(BaseIntegrationTest):
kwargs={"node_id": self.node.id}),
headers=self.default_headers)
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
max: 65536
sriov:
restrictions:
- condition: "version:release < '9.0'"
action: "hide"
metadata:
label: "SR-IOV"
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."
action: "none"
dpdk:
restrictions:
- condition: "version:release < '9.0'"
action: "hide"
metadata:
label: "DPDK"
weight: 40
@ -2201,7 +2207,6 @@
modes:
label: "Offloading Modes"
weight: 20
description: "Offloading modes"
type: "offloading_modes"
value: {}
mtu:
@ -2217,6 +2222,9 @@
min: 42
max: 65536
dpdk:
restrictions:
- condition: "version:release < '9.0'"
action: "hide"
metadata:
label: "DPDK"
weight: 40

View File

@ -84,10 +84,9 @@ SECURITY_GROUPS = {
DEFAULT_NIC_ATTRIBUTES = {
'offloading': {
'disable': {'type': 'checkbox', 'value': False,
'weight': 10, 'label': 'Disable offloading'},
'modes': {'value': {}, 'type': 'offloading_modes',
'description': 'Offloading modes', 'weight': 20,
'label': 'Offloading modes'},
'weight': 10, 'label': 'Disable Offloading'},
'modes': {'value': {}, 'type': 'offloading_modes', 'weight': 20,
'label': 'Offloading Modes'},
'metadata': {'weight': 10, 'label': 'Offloading'}
},
'mtu': {
@ -97,18 +96,63 @@ DEFAULT_NIC_ATTRIBUTES = {
'metadata': {'weight': 20, 'label': 'MTU'}
},
'sriov': {
'numvfs': {'min': 1, 'type': 'number', 'nullable': True,
'value': None, 'weight': 20,
'label': 'Custom Number of Virtual Functions'},
'restrictions':
[{'condition': "version:release < '9.0'",
'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,
'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,
'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'}
},
'dpdk': {
'restrictions':
[{'condition': "version:release < '9.0'",
'action': 'hide'}],
'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'}
}
}
@ -126,10 +170,9 @@ DEFAULT_BOND_ATTRIBUTES = {
},
'offloading': {
'disable': {'type': 'checkbox', 'weight': 10, 'value': False,
'label': 'Disable offloading'},
'label': 'Disable Offloading'},
'modes': {'weight': 20, 'type': 'offloading_modes',
'description': 'Offloading modes', 'value': {},
'label': 'Offloading modes'},
'value': {}, 'label': 'Offloading Modes'},
'metadata': {'weight': 20, 'label': 'Offloading'}
},
'mtu': {
@ -150,8 +193,19 @@ DEFAULT_BOND_ATTRIBUTES = {
},
'type__': {'type': 'hidden', 'value': None},
'dpdk': {
'enabled': {'type': 'checkbox', 'weight': 10, 'value': None,
'label': 'DPDK enabled'},
'restrictions':
[{'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'}
}
}
@ -781,10 +835,10 @@ class TestNodeNICAndBondAttributesMigration(base.BaseAlembicMigrationTest):
sa.select([releases_table.c.nic_attributes,
releases_table.c.bond_attributes])
).fetchone()
self.assertEqual(DEFAULT_NIC_ATTRIBUTES,
jsonutils.loads(result['nic_attributes']))
self.assertEqual(DEFAULT_BOND_ATTRIBUTES,
jsonutils.loads(result['bond_attributes']))
self.assertItemsEqual(DEFAULT_NIC_ATTRIBUTES,
jsonutils.loads(result['nic_attributes']))
self.assertItemsEqual(DEFAULT_BOND_ATTRIBUTES,
jsonutils.loads(result['bond_attributes']))
def test_upgrade_node_nic_attributes_with_empty_properties(self):
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['mode']['value']['value'] = 'active-backup'
self.assertEqual(jsonutils.loads(result['attributes']),
expected_attributes)
self.assertItemsEqual(jsonutils.loads(result['attributes']),
expected_attributes)
def test_upgrade_node_bond_attributes(self):
bonds_table = self.meta.tables['node_bond_interfaces']
@ -898,8 +952,8 @@ class TestNodeNICAndBondAttributesMigration(base.BaseAlembicMigrationTest):
expected_attributes['offloading']['modes']['value'] = {
'tx-checksumming': False, 'tx-checksum-sctp': True,
'rx-checksumming': None, 'rx-vlan-offload': False}
self.assertEqual(jsonutils.loads(result['attributes']),
expected_attributes)
self.assertItemsEqual(jsonutils.loads(result['attributes']),
expected_attributes)
# TODO(apopovych): uncomment after removing redundant data
# self.assertNotIn('offloading_modes', bonds_table.c)
# self.assertNotIn('interface_properties', bonds_table.c)