[Nailgun] Plugin support for network roles metadata
Provides implementation for new plugin configuration file support network_roles.yaml * New column network_roles_metadata in Plugin model * Loading network_roles.yaml to DB Implements: blueprint vip-reservation Change-Id: Id67a655bd090042b71b66d0512ff8cb9c6e9f2d7
This commit is contained in:
parent
f3a9a517d7
commit
410a2fca5f
|
@ -172,6 +172,15 @@ def vms_conf_downgrade():
|
|||
|
||||
|
||||
def extend_plugin_model_upgrade():
|
||||
op.add_column(
|
||||
'plugins',
|
||||
sa.Column(
|
||||
'network_roles_metadata',
|
||||
fields.JSON(),
|
||||
nullable=False,
|
||||
server_default='[]'
|
||||
)
|
||||
)
|
||||
op.add_column(
|
||||
'plugins',
|
||||
sa.Column(
|
||||
|
@ -241,6 +250,7 @@ def extend_plugin_model_downgrade():
|
|||
op.drop_column('plugins', 'roles_metadata')
|
||||
op.drop_column('plugins', 'volumes_metadata')
|
||||
op.drop_column('plugins', 'attributes_metadata')
|
||||
op.drop_column('plugins', 'network_roles_metadata')
|
||||
|
||||
|
||||
def upgrade_node_roles_metadata():
|
||||
|
|
|
@ -56,6 +56,7 @@ class Plugin(Base):
|
|||
attributes_metadata = Column(JSON, server_default='{}', nullable=False)
|
||||
volumes_metadata = Column(JSON, server_default='{}', nullable=False)
|
||||
roles_metadata = Column(JSON, server_default='{}', nullable=False)
|
||||
network_roles_metadata = Column(JSON, server_default='[]', nullable=False)
|
||||
deployment_tasks = Column(JSON, server_default='[]', nullable=False)
|
||||
# TODO(apopovych): To support old plugins versions we need separate
|
||||
# tasks which runs directly during deployment(stored in `deployment_tasks`
|
||||
|
|
|
@ -286,6 +286,7 @@ class PluginAdapterV3(PluginAdapterV2):
|
|||
node_roles_config_name = 'node_roles.yaml'
|
||||
volumes_config_name = 'volumes.yaml'
|
||||
deployment_tasks_config_name = 'deployment_tasks.yaml'
|
||||
network_roles_config_name = 'network_roles.yaml'
|
||||
|
||||
def sync_metadata_to_db(self):
|
||||
super(PluginAdapterV3, self).sync_metadata_to_db()
|
||||
|
@ -295,6 +296,7 @@ class PluginAdapterV3(PluginAdapterV2):
|
|||
'attributes_metadata': self.environment_config_name,
|
||||
'roles_metadata': self.node_roles_config_name,
|
||||
'volumes_metadata': self.volumes_config_name,
|
||||
'network_roles_metadata': self.network_roles_config_name,
|
||||
'deployment_tasks': self.deployment_tasks_config_name,
|
||||
'tasks': self.task_config_name
|
||||
}
|
||||
|
|
|
@ -556,6 +556,25 @@ class EnvironmentManager(object):
|
|||
volumes.update(kwargs)
|
||||
return volumes
|
||||
|
||||
def get_default_network_roles_config(self, **kwargs):
|
||||
network_roles = [
|
||||
{
|
||||
'id': 'test_network_role',
|
||||
'default_mapping': 'public',
|
||||
'properties': {
|
||||
'subnet': 'true',
|
||||
'gateway': 'false',
|
||||
'vip': [
|
||||
{'name': 'test_vip_1', 'shared': False},
|
||||
{'name': 'test_vip_2', 'shared': False}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
network_roles[0].update(kwargs)
|
||||
return network_roles
|
||||
|
||||
def get_default_plugin_deployment_tasks(self, **kwargs):
|
||||
deployment_tasks = [
|
||||
{
|
||||
|
|
|
@ -354,31 +354,21 @@ class TestPluginAttributesMigration(base.BaseAlembicMigrationTest):
|
|||
|
||||
def test_new_fields_exists_and_empty(self):
|
||||
# check attributes_metadata field exists
|
||||
result = db.execute(
|
||||
sa.select([self.meta.tables['plugins'].c.attributes_metadata]))
|
||||
# check attributes_metadata value is empty
|
||||
self.assertEqual(
|
||||
jsonutils.loads(result.fetchone()[0]), {})
|
||||
plugin_table = self.meta.tables['plugins']
|
||||
column_values = [
|
||||
(plugin_table.c.attributes_metadata, {}),
|
||||
(plugin_table.c.volumes_metadata, {}),
|
||||
(plugin_table.c.roles_metadata, {}),
|
||||
(plugin_table.c.network_roles_metadata, []),
|
||||
(plugin_table.c.deployment_tasks, []),
|
||||
(plugin_table.c.tasks, []),
|
||||
]
|
||||
result = db.execute(sa.select(
|
||||
[item[0] for item in column_values]))
|
||||
db_values = result.fetchone()
|
||||
|
||||
result = db.execute(
|
||||
sa.select([self.meta.tables['plugins'].c.volumes_metadata]))
|
||||
self.assertEqual(
|
||||
jsonutils.loads(result.fetchone()[0]), {})
|
||||
|
||||
result = db.execute(
|
||||
sa.select([self.meta.tables['plugins'].c.roles_metadata]))
|
||||
self.assertEqual(
|
||||
jsonutils.loads(result.fetchone()[0]), {})
|
||||
|
||||
result = db.execute(
|
||||
sa.select([self.meta.tables['plugins'].c.deployment_tasks]))
|
||||
self.assertEqual(
|
||||
jsonutils.loads(result.fetchone()[0]), [])
|
||||
|
||||
result = db.execute(
|
||||
sa.select([self.meta.tables['plugins'].c.tasks]))
|
||||
self.assertEqual(
|
||||
jsonutils.loads(result.fetchone()[0]), [])
|
||||
for idx, db_value in enumerate(db_values):
|
||||
self.assertEqual(jsonutils.loads(db_value), column_values[idx][1])
|
||||
|
||||
|
||||
class TestPublicIpRequired(base.BaseAlembicMigrationTest):
|
||||
|
|
|
@ -189,6 +189,7 @@ class TestPluginV3(TestPluginBase):
|
|||
attributes_metadata = self.env.get_default_plugin_env_config()
|
||||
roles_metadata = self.env.get_default_plugin_node_roles_config()
|
||||
volumes_metadata = self.env.get_default_plugin_volumes_config()
|
||||
network_roles_metadata = self.env.get_default_network_roles_config()
|
||||
deployment_tasks = self.env.get_default_plugin_deployment_tasks()
|
||||
tasks = self.env.get_default_plugin_tasks()
|
||||
|
||||
|
@ -197,6 +198,7 @@ class TestPluginV3(TestPluginBase):
|
|||
self._find_path('environment_config'): attributes_metadata,
|
||||
self._find_path('node_roles'): roles_metadata,
|
||||
self._find_path('volumes'): volumes_metadata,
|
||||
self._find_path('network_roles'): network_roles_metadata,
|
||||
self._find_path('deployment_tasks'): deployment_tasks,
|
||||
self._find_path('tasks'): tasks,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue