Merge "Add restrictions for admin bond"

This commit is contained in:
Jenkins 2015-07-13 11:42:50 +00:00 committed by Gerrit Code Review
commit ec51a0dfdd
3 changed files with 143 additions and 3 deletions

View File

@ -89,6 +89,7 @@ def upgrade():
vms_conf_upgrade()
extend_nic_model_upgrade()
upgrade_cluster_ui_settings()
upgrade_cluster_bond_settings()
def downgrade():
@ -527,3 +528,48 @@ def downgrade_cluster_ui_settings():
)
)
op.drop_column('clusters', 'ui_settings')
def upgrade_cluster_bond_settings():
connection = op.get_bind()
select = sa.sql.text(
"SELECT id, networks_metadata from releases")
update = sa.sql.text(
"""UPDATE releases
SET networks_metadata = :networks
WHERE id = :id""")
releases = connection.execute(select)
new_bond_meta = {
"linux": [
{
"values": ["balance-rr", "active-backup", "802.3ad"],
"condition": "interface:pxe == false"
},
{
"values": ["balance-xor", "broadcast", "balance-tlb",
"balance-alb"],
"condition": "interface:pxe == false and "
"'experimental' in version:feature_groups"
}
],
"ovs": [
{
"values": ["active-backup", "balance-slb",
"lacp-balance-tcp"],
"condition": "interface:pxe == false"
}
]
}
for release_id, networks_db_meta in releases:
networks_meta = jsonutils.loads(networks_db_meta)
db_bond_meta = networks_meta['bonding']['properties']
for bond_mode in new_bond_meta:
if bond_mode in db_bond_meta:
db_bond_meta[bond_mode]['mode'] = new_bond_meta[bond_mode]
connection.execute(
update,
id=release_id,
networks=jsonutils.dumps(networks_meta)
)

View File

@ -271,7 +271,10 @@
properties:
linux:
mode:
- values: ["balance-rr", "active-backup", "802.3ad"]
- values: ["balance-rr", "active-backup"]
- values: ["802.3ad"]
condition: "'experimental' in version:feature_groups or
interface:pxe == false"
- values: ["balance-xor", "broadcast", "balance-tlb", "balance-alb"]
condition: "'experimental' in version:feature_groups"
xmit_hash_policy:

View File

@ -62,7 +62,7 @@ def prepare():
meta.tables['releases'].insert(),
[{
'name': 'test_name',
'version': '2014.2-6.0',
'version': '2014.2-6.1',
'operating_system': 'ubuntu',
'state': 'available',
'roles': jsonutils.dumps([
@ -91,11 +91,65 @@ def prepare():
}
}),
'attributes_metadata': jsonutils.dumps({}),
'networks_metadata': jsonutils.dumps({}),
'networks_metadata': jsonutils.dumps({
'bonding': {
'properties': {
'linux': {
'mode': [
{
"values": ["balance-rr",
"active-backup",
"802.3ad"]
},
{
"values": ["balance-xor",
"broadcast",
"balance-tlb",
"balance-alb"],
"condition": "'experimental' in "
"version:feature_groups"
}
]
}
}
},
}),
'is_deployable': True,
}])
releaseid = result.inserted_primary_key[0]
result = db.execute(
meta.tables['releases'].insert(),
[{
'name': 'test_name_2',
'version': '2014.2-6.0',
'operating_system': 'ubuntu',
'state': 'available',
'roles': jsonutils.dumps([
'controller',
'compute',
'mongo',
]),
'roles_metadata': jsonutils.dumps({}),
'attributes_metadata': jsonutils.dumps({}),
'networks_metadata': jsonutils.dumps({
'bonding': {
'properties': {
'ovs': {
'mode': [
{
"values": ["active-backup",
"balance-slb",
"lacp-balance-tcp"]
}
]
}
}
},
}),
'is_deployable': True
}])
db.execute(
meta.tables['clusters'].insert(),
[{
@ -592,3 +646,40 @@ class TestClusterUISettingsMigration(base.BaseAlembicMigrationTest):
self.assertItemsEqual(
ui_settings['grouping'],
consts.CLUSTER_GROUPING.roles)
class TestClusterBondMetaMigration(base.BaseAlembicMigrationTest):
def test_cluster_bond_meta_field_exists_and_has_proper_value_lnx(self):
lnx_meta = [
{
"values": ["balance-rr", "active-backup", "802.3ad"],
"condition": "interface:pxe == false"
},
{
"values": ["balance-xor", "broadcast", "balance-tlb",
"balance-alb"],
"condition": "interface:pxe == false and "
"'experimental' in version:feature_groups"
}
]
# check data for linux bonds (fuel 6.1 version)
result = db.execute(
sa.select([self.meta.tables['releases'].c.networks_metadata]).
where(self.meta.tables['releases'].c.name == 'test_name'))
bond_meta = jsonutils.loads(result.fetchone()[0])['bonding']
self.assertEqual(bond_meta['properties']['linux']['mode'], lnx_meta)
def test_cluster_bond_meta_field_exists_and_has_proper_value_ovs(self):
ovs_meta = [
{
"values": ["active-backup", "balance-slb",
"lacp-balance-tcp"],
"condition": "interface:pxe == false"
}
]
# check data for ovs bonds (fuel < 6.1 version)
result = db.execute(
sa.select([self.meta.tables['releases'].c.networks_metadata]).
where(self.meta.tables['releases'].c.name == 'test_name_2'))
bond_meta = jsonutils.loads(result.fetchone()[0])['bonding']
self.assertEqual(bond_meta['properties']['ovs']['mode'], ovs_meta)