def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                }
            })
        }]
    )
    releaseid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '8.0',
            'deployment_tasks': '[]',
            'replaced_deployment_info': '{}'
        }])

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-10.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': '{}',
            'roles': '{}',
            'roles_metadata': '{}',
            'is_deployable': True,
            'required_component_types': ['network', 'storage']
        }]
    )

    release_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test',
            'release_id': release_id,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '10.0',
        }]
    )
    cluster_id = result.inserted_primary_key[0]

    TestPluginLinksConstraints.prepare(meta, cluster_id)
Пример #3
0
    def test_set_attributes(self):
        meta = base.reflect_db_metadata()
        bond_config = self.env.get_default_plugin_bond_config()
        self.env.create_plugin(
            name='plugin_a_with_bond_attributes',
            package_version='5.0.0',
            bond_attributes_metadata=bond_config)
        cluster = self._create_test_cluster(
            nodes=[{'roles': ['controller']}])

        bond_config.update({
            'type__': {'value': consts.BOND_TYPES.linux},
            'mode': {'value': {'value': consts.BOND_MODES.balance_rr}}})
        for node in cluster.nodes:
            nic_names = [iface.name for iface in node.nic_interfaces]
            self.env.make_bond_via_api(
                'lnx_bond', '', nic_names, node.id, attrs=bond_config)

        node_bond_interface_cluster_plugin = self.db.execute(
            meta.tables['node_bond_interface_cluster_plugins'].select()
        ).fetchall()[0]

        _id = node_bond_interface_cluster_plugin.id
        attributes = {'test_attr': 'a'}
        NodeBondInterfaceClusterPlugin.set_attributes(_id, attributes)

        node_bond_interface_cluster_plugin = self.db.execute(
            meta.tables['node_bond_interface_cluster_plugins'].select()
        ).fetchall()[0]

        self.assertDictEqual(
            attributes,
            jsonutils.loads(node_bond_interface_cluster_plugin[1]))
Пример #4
0
    def test_add_cluster_plugin_for_node_bond(self):
        meta = base.reflect_db_metadata()
        plugin_bond_config = self.env.get_default_plugin_bond_config()
        self.env.create_plugin(
            name='plugin_a_with_bond_attributes',
            package_version='5.0.0',
            bond_attributes_metadata=plugin_bond_config)
        self.env.create_plugin(
            name='plugin_b_with_bond_attributes',
            package_version='5.0.0',
            bond_attributes_metadata={})
        cluster = self._create_test_cluster(
            nodes=[{'roles': ['controller']}, {'roles': ['compute']}])
        bond_config = {
            'type__': {'value': consts.BOND_TYPES.linux},
            'mode': {'value': {'value': consts.BOND_MODES.balance_rr}}}
        for node in cluster.nodes:
            nic_names = [iface.name for iface in node.nic_interfaces]
            self.env.make_bond_via_api(
                'lnx_bond', '', nic_names, node.id, attrs=bond_config)

        node_bond_interface_cluster_plugins = self.db.execute(
            meta.tables['node_bond_interface_cluster_plugins'].select()
        ).fetchall()

        self.assertEqual(2, len(node_bond_interface_cluster_plugins))
        for item in node_bond_interface_cluster_plugins:
            self.assertDictEqual(
                plugin_bond_config, jsonutils.loads(item.attributes))
Пример #5
0
 def test_connect_to_cluster(self):
     meta = base.reflect_db_metadata()
     self._create_test_plugins()
     self._create_test_cluster()
     cluster_plugins = self.db.execute(
         meta.tables['cluster_plugins'].select()).fetchall()
     self.assertEqual(len(cluster_plugins), 5)
Пример #6
0
    def test_add_nodes_for_cluster_plugin_with_empty_attributes(self):
        meta = base.reflect_db_metadata()
        self.env.create_node(
            cluster_id=self.cluster.id,
            roles=['compute']
        )
        plugin = Plugin.create({
            'name': 'plugin_a_with_node_attributes',
            'title': 'Test Plugin',
            'package_version': '5.0.0',
            'version': '1.0.0',
            'node_attributes_metadata': {}
        })
        cluster_plugin = ClusterPlugin.create({
            'cluster_id': self.cluster.id,
            'plugin_id': plugin.id,
            'enabled': False,
            'attributes': plugin.node_attributes_metadata
        })

        NodeClusterPlugin.add_nodes_for_cluster_plugin(cluster_plugin)

        node_cluster_plugins = self.db.execute(
            meta.tables['node_cluster_plugins'].select()
        ).fetchall()
        self.assertEqual(0, len(node_cluster_plugins))
def prepare():
    meta = base.reflect_db_metadata()

    # Fill in migration table with data
    db.execute(
        meta.tables[extensions_migration_buffer_table_name].insert(),
        [{
            'extension_name': 'volume_manager',
            'data': jsonutils.dumps({
                'node_id': 1,
                'volumes': [{
                    'volume': 1
                }]
            })
        }, {
            'extension_name': 'volume_manager',
            'data': jsonutils.dumps({
                'node_id': 2,
                'volumes': [{
                    'volume': 2
                }]
            })
        }, {
            'extension_name': 'some_different_extension',
            'data': 'some_data'
        }])

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-10.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': '{}',
            'roles': '{}',
            'roles_metadata': '{}',
            'is_deployable': True,
        }]
    )

    release_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test',
            'release_id': release_id,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '10.0',
        }]
    )
    cluster_id = result.inserted_primary_key[0]

    TestPluginLinksConstraints.prepare(meta, cluster_id)
Пример #9
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                }
            })
        }]
    )
    releaseid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '8.0',
            'deployment_tasks': '[]',
            'replaced_deployment_info': '{}'
        }])

    db.commit()
Пример #10
0
    def test_set_attributes(self):
        meta = base.reflect_db_metadata()
        nic_config = self.env.get_default_plugin_nic_config()
        self.env.create_plugin(
            name='plugin_a_with_nic_attributes',
            package_version='5.0.0',
            nic_attributes_metadata=nic_config)
        cluster = self._create_test_cluster()
        self.env.create_nodes_w_interfaces_count(
            1, 1, **{"cluster_id": cluster.id})[0]

        node_nic_interface_cluster_plugin = self.db.execute(
            meta.tables['node_nic_interface_cluster_plugins'].select()
        ).fetchall()[0]

        _id = node_nic_interface_cluster_plugin.id
        attributes = {'test_attr': 'a'}
        NodeNICInterfaceClusterPlugin.set_attributes(_id, attributes)

        node_nic_interface_cluster_plugin = self.db.execute(
            meta.tables['node_nic_interface_cluster_plugins'].select()
        ).fetchall()[0]

        self.assertDictEqual(
            attributes,
            jsonutils.loads(node_nic_interface_cluster_plugin[1]))
Пример #11
0
def prepare():
    meta = base.reflect_db_metadata()

    releaseid = insert_table_row(
        meta.tables["releases"],
        {"name": "test_name", "version": "2014.2.2-6.1", "operating_system": "ubuntu", "state": "available"},
    )

    clusterid = insert_table_row(
        meta.tables["clusters"],
        {
            "name": "test_env",
            "release_id": releaseid,
            "mode": "ha_compact",
            "status": "new",
            "net_provider": "neutron",
            "grouping": "roles",
            "fuel_version": "6.1",
        },
    )

    db.execute(
        meta.tables["nodegroups"].insert(),
        [
            {"cluster_id": clusterid, "name": "test_nodegroup_a"},
            {"cluster_id": clusterid, "name": "test_nodegroup_a"},
            {"cluster_id": clusterid, "name": "test_nodegroup_b"},
            {"cluster_id": clusterid, "name": "test_nodegroup_b"},
        ],
    )

    db.commit()
def get_master_node_settings():
    meta = base.reflect_db_metadata()
    master_node_settings_table = meta.tables['master_node_settings']

    settings = db.execute(sa.select(
        [master_node_settings_table.c.settings])).scalar()
    db().commit()
    return settings
Пример #13
0
 def test_connect_to_cluster(self):
     meta = base.reflect_db_metadata()
     self._create_test_plugins()
     self._create_test_cluster()
     cluster_plugins = self.db.execute(
         meta.tables['cluster_plugins'].select()
     ).fetchall()
     self.assertEqual(len(cluster_plugins), 5)
Пример #14
0
def get_master_node_settings():
    meta = base.reflect_db_metadata()
    master_node_settings_table = meta.tables['master_node_settings']

    settings = db.execute(sa.select(
        [master_node_settings_table.c.settings])).scalar()
    db().commit()
    return settings
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                }
            }),
            'volumes_metadata': jsonutils.dumps({})
        }])

    db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
            'cluster_id': None,
            'group_id': None,
            'status': 'discover',
            'meta': '{}',
            'mac': 'aa:aa:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow(),
        }]
    )

    db.execute(
        meta.tables['tasks'].insert(),
        [
            {
                'id': 55,
                'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
                'name': 'deployment',
                'status': 'running',
                'deployment_info': jsonutils.dumps({})
            },
        ]
    )
    db.execute(
        meta.tables['deployment_history'].insert(),
        [
            {
                'uuid': 'fake_uuid_0',
                'deployment_graph_task_name': 'fake',
                'node_id': 'fake_node_id',
                'task_id': 55,
                'status': 'pending',
                'summary': jsonutils.dumps({'fake': 'fake'}),
            }
        ]
    )

    db.commit()
    def test_set_plugin_attributes(self):
        meta = base.reflect_db_metadata()
        self._create_test_plugins()
        cluster = self._create_test_cluster()

        plugin = ClusterPlugin.get_connected_plugins(cluster).first()
        ClusterPlugin.set_attributes(cluster.id, plugin.id, enabled=True)

        columns = meta.tables["cluster_plugins"].c
        enabled = self.db.execute(
            sa.select([columns.enabled]).where(columns.cluster_id == cluster.id).where(columns.plugin_id == plugin.id)
        ).fetchone()
        self.assertTrue(enabled[0])
def prepare():
    meta = base.reflect_db_metadata()

    # Fill in migration table with data
    db.execute(
        meta.tables[extensions_migration_buffer_table_name].insert(),
        [{'extension_name': 'volume_manager',
          'data': jsonutils.dumps({'node_id': 1, 'volumes': [{'volume': 1}]})},
         {'extension_name': 'volume_manager',
          'data': jsonutils.dumps({'node_id': 2, 'volumes': [{'volume': 2}]})},
         {'extension_name': 'some_different_extension',
          'data': 'some_data'}])

    db.commit()
Пример #18
0
    def test_set_plugin_attributes(self):
        meta = base.reflect_db_metadata()
        self._create_test_plugins()
        cluster = self._create_test_cluster()

        plugin = ClusterPlugins.get_connected_plugins(cluster).first()
        ClusterPlugins.set_attributes(cluster.id, plugin.id, enabled=True)

        columns = meta.tables['cluster_plugins'].c
        enabled = self.db.execute(
            sa.select([columns.enabled
                       ]).where(columns.cluster_id == cluster.id).where(
                           columns.plugin_id == plugin.id)).fetchone()
        self.assertTrue(enabled[0])
Пример #19
0
    def test_populate_nic_with_empty_plugin_attributes(self):
        # create cluster with 2 nodes
        # install plugin without nic attributes which compatible with cluster
        meta = base.reflect_db_metadata()
        self._create_test_cluster(
            nodes=[{'roles': ['controller']}, {'roles': ['compute']}])
        self.env.create_plugin(
            name='plugin_b_with_nic_attributes',
            package_version='5.0.0',
            nic_attributes_metadata={})

        node_nic_interface_cluster_plugins = self.db.execute(
            meta.tables['node_nic_interface_cluster_plugins'].select()
        ).fetchall()

        self.assertEqual(0, len(node_nic_interface_cluster_plugins))
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                }
            }),
            'volumes_metadata': jsonutils.dumps({})
        }])
    db.commit()
Пример #21
0
    def test_populate_nic_with_plugin_attributes(self):
        # create cluster with 2 nodes
        # install plugin with nic attributes which compatible with cluster
        meta = base.reflect_db_metadata()
        nic_config = self.env.get_default_plugin_nic_config()
        self._create_test_cluster(
            nodes=[{'roles': ['controller']}, {'roles': ['compute']}])
        self.env.create_plugin(
            name='plugin_a_with_nic_attributes',
            package_version='5.0.0',
            nic_attributes_metadata=nic_config)

        node_nic_interface_cluster_plugins = self.db.execute(
            meta.tables['node_nic_interface_cluster_plugins'].select()
        ).fetchall()

        self.assertEqual(4, len(node_nic_interface_cluster_plugins))
        for item in node_nic_interface_cluster_plugins:
            self.assertDictEqual(nic_config, jsonutils.loads(item.attributes))
Пример #22
0
    def test_set_attributes(self):
        meta = base.reflect_db_metadata()
        self.env.create_plugin(
            cluster=self.cluster,
            name='plugin_a_with_node_attributes',
            package_version='5.0.0',
            node_attributes_metadata=self.node_attributes)

        node_attributes_cluster_plugin = self.db.execute(
            meta.tables['node_cluster_plugins'].select()
        ).fetchall()[0]

        _id = node_attributes_cluster_plugin.id
        attributes = {'test_attr': 'a'}
        NodeClusterPlugin.set_attributes(_id, attributes)

        node_attributes_cluster_plugin = self.db.execute(
            meta.tables['node_cluster_plugins'].select()
        ).fetchall()[0]

        self.assertDictEqual(
            attributes,
            jsonutils.loads(node_attributes_cluster_plugin[1]))
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-10.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': jsonutils.dumps(JSON_TASKS),
            'roles': jsonutils.dumps([
                'controller',
                'compute',
                'virt',
                'compute-vmware',
                'ironic',
                'cinder',
                'cinder-block-device',
                'cinder-vmware',
                'ceph-osd',
                'mongo',
                'base-os',
            ]),
            'roles_metadata': jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                },
                'compute': {
                    'name': 'Compute',
                },
                'virt': {
                    'name': 'Virtual',
                },
                'compute-vmware': {
                    'name': 'Compute VMware',
                },
                'ironic': {
                    'name': 'Ironic',
                },
                'cinder': {
                    'name': 'Cinder',
                },
                'cinder-block-device': {
                    'name': 'Cinder Block Device',
                },
                'cinder-vmware': {
                    'name': 'Cinder Proxy to VMware Datastore',
                },
                'ceph-osd': {
                    'name': 'Ceph OSD',
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                },
                'base-os': {
                    'name': 'Operating System',
                }
            }),
            'is_deployable': True
        }])

    release_id = result.inserted_primary_key[0]

    cluster_ids = []
    for cluster_name in ['test_env1', 'test_env2']:
        result = db.execute(
            meta.tables['clusters'].insert(),
            [{
                'name': cluster_name,
                'release_id': release_id,
                'mode': 'ha_compact',
                'status': 'new',
                'net_provider': 'neutron',
                'grouping': 'roles',
                'fuel_version': '10.0',
                'deployment_tasks': jsonutils.dumps(JSON_TASKS)
            }])
        cluster_ids.append(result.inserted_primary_key[0])

    result = db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
            'cluster_id': None,
            'group_id': None,
            'status': 'discover',
            'meta': '{}',
            'mac': 'aa:aa:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow(),
        }]
    )
    node_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_a',
            'title': 'Test plugin A',
            'version': '2.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '5.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'deployment_tasks': jsonutils.dumps(JSON_TASKS),
            'fuel_version': jsonutils.dumps(['10.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip1',
                            'namespace': 'my-namespace1',
                        },
                        {
                            'name': 'my-vip2',
                            'namespace': 'my-namespace2',
                        }
                    ]
                }
            }])
        }]
    )
    plugin_a_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_b',
            'title': 'Test plugin B',
            'version': '2.0.0',
            'description': 'Test plugin B for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '5.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['10.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip3',
                            'namespace': 'my-namespace3',
                        },
                        {
                            'name': 'my-vip4',
                            'namespace': 'my-namespace4',
                        }
                    ]
                }
            }])
        }]
    )
    plugin_b_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['cluster_plugin_links'].insert(),
        [
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'cluster_id': cluster_ids[1],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            },
            # duplicate by URL but in another cluster, should
            # not be deleted
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            }
        ]
    )

    db.execute(
        meta.tables['cluster_plugins'].insert(),
        [
            {'cluster_id': cluster_ids[0], 'plugin_id': plugin_a_id},
            {'cluster_id': cluster_ids[0], 'plugin_id': plugin_b_id}
        ]
    )

    db.execute(
        meta.tables['plugin_links'].insert(),
        [
            {
                'plugin_id': plugin_a_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'plugin_id': plugin_b_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            }
        ]
    )

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'id': 1,
            'node_id': node_id,
            'name': 'test_interface',
            'mac': '00:00:00:00:00:01',
            'max_speed': 200,
            'current_speed': 100,
            'ip_addr': '10.20.0.2',
            'netmask': '255.255.255.0',
            'state': 'test_state',
            'interface_properties': jsonutils.dumps(
                {'test_property': 'test_value'}),
            'driver': 'test_driver',
            'bus_info': 'some_test_info'
        }]
    )

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps(
                {'test_property': 'test_value'})
        }]
    )

    result = db.execute(
        meta.tables['tasks'].insert(),
        [
            {
                'id': 55,
                'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
                'name': 'deployment',
                'status': 'running',
                'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[55])
            },
            {
                'id': 56,
                'uuid': 'a45fbbcd-792c-4245-a619-f4fb2f094d38',
                'name': 'deployment',
                'status': 'running',
                'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[56])
            }
        ]
    )
    TestRequiredComponentTypesField.prepare(meta)
    db.commit()
Пример #24
0
def prepare():
    meta = base.reflect_db_metadata()

    db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin',
        'title':
        'Test plugin',
        'version':
        '1.0.0',
        'description':
        'Test plugin for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '3.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['6.1', '7.0']),
    }])

    db.execute(meta.tables['releases'].insert(), [_RELEASE])

    db.execute(meta.tables['nodes'].insert(),
               [{
                   'node_id': 1,
                   'uuid': 'test_uuid',
                   'status': 'ready',
                   'mac': '00:00:00:00:00:01',
                   'timestamp': '2015-07-01 12:34:56.123',
               }])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': 1,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps({'test_property': 'test_value'})
        }])

    db.execute(meta.tables['node_nic_interfaces'].insert(), [{
        'node_id':
        1,
        'name':
        'test_interface',
        'mac':
        '00:00:00:00:00:01',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.20.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'parent_id':
        1,
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }])

    db.commit()
Пример #25
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'version':
        '2015.1-8.0',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'roles':
        jsonutils.dumps([
            'controller',
            'compute',
            'virt',
            'compute-vmware',
            'ironic',
            'cinder',
            'cinder-block-device',
            'cinder-vmware',
            'ceph-osd',
            'mongo',
            'base-os',
        ]),
        'roles_metadata':
        jsonutils.dumps({
            'controller': {
                'name': 'Controller',
            },
            'compute': {
                'name': 'Compute',
            },
            'virt': {
                'name': 'Virtual',
            },
            'compute-vmware': {
                'name': 'Compute VMware',
            },
            'ironic': {
                'name': 'Ironic',
            },
            'cinder': {
                'name': 'Cinder',
            },
            'cinder-block-device': {
                'name': 'Cinder Block Device',
            },
            'cinder-vmware': {
                'name': 'Cinder Proxy to VMware Datastore',
            },
            'ceph-osd': {
                'name': 'Ceph OSD',
            },
            'mongo': {
                'name': 'Telemetry - MongoDB',
            },
            'base-os': {
                'name': 'Operating System',
            }
        }),
        'networks_metadata':
        jsonutils.dumps({
            'neutron': {
                'networks': [
                    {
                        'assign_vip': True,
                    },
                ]
            },
            'nova_network': {
                'networks': [
                    {
                        'assign_vip': False,
                    },
                ]
            },
        }),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'release-vip1',
                }, {
                    'name': 'release-vip2',
                    'namespace': 'release-vip2-namespace'
                }]
            }
        }]),
        'is_deployable':
        True,
        'attributes_metadata':
        jsonutils.dumps({'editable': editable})
    }])
    releaseid = result.inserted_primary_key[0]

    db.execute(meta.tables['clusters'].insert(),
               [{
                   'name': 'test_env',
                   'release_id': releaseid,
                   'mode': 'ha_compact',
                   'status': 'new',
                   'net_provider': 'neutron',
                   'grouping': 'roles',
                   'fuel_version': '8.0',
                   'deployment_tasks': jsonutils.dumps(JSON_TASKS)
               }])
    cluster_id = result.inserted_primary_key[0]

    db.execute(meta.tables['attributes'].insert(),
               [{
                   'cluster_id': cluster_id,
                   'editable': jsonutils.dumps(editable)
               }])

    db.execute(meta.tables['nodes'].insert(),
               [{
                   'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
                   'cluster_id': None,
                   'group_id': None,
                   'status': 'discover',
                   'meta': '{}',
                   'mac': 'aa:aa:aa:aa:aa:aa',
                   'timestamp': datetime.datetime.utcnow(),
               }])
    node_id = result.inserted_primary_key[0]

    db.execute(meta.tables['node_attributes'].insert(), [{
        'node_id':
        node_id,
        'vms_conf':
        jsonutils.dumps([
            {
                'cpu': 1,
                'mem': 2
            },
            {
                'cpu': 1,
                'mem': 2
            },
        ])
    }])

    db.execute(meta.tables['ip_addrs'].insert(), [{
        'ip_addr': '192.168.0.2',
        'vip_type': 'management'
    }, {
        'ip_addr': '192.168.1.2',
        'vip_type': 'haproxy'
    }, {
        'ip_addr': '192.168.11.2',
        'vip_type': 'my-vip1',
        'namespace': 'my-namespace1'
    }, {
        'ip_addr': '192.168.12.2',
        'vip_type': 'my-vip2',
        'namespace': 'my-namespace2'
    }, {
        'ip_addr': '192.168.13.2',
        'vip_type': 'my-vip3',
        'namespace': 'my-namespace3'
    }, {
        'ip_addr': '192.168.14.2',
        'vip_type': 'my-vip4',
        'namespace': 'my-namespace4'
    }, {
        'ip_addr': '192.168.15.2',
        'vip_type': 'release-vip2'
    }])

    db.execute(meta.tables['network_groups'].insert(),
               [{
                   'name': 'public',
                   'release': releaseid,
                   'meta': jsonutils.dumps({'assign_vip': True})
               }])

    db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_a',
        'title':
        'Test plugin A',
        'version':
        '2.0.0',
        'description':
        'Test plugin A for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '4.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'fuel_version':
        jsonutils.dumps(['8.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip1',
                    'namespace': 'my-namespace1',
                }, {
                    'name': 'my-vip2',
                    'namespace': 'my-namespace2',
                }]
            }
        }])
    }])

    db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_b',
        'title':
        'Test plugin B',
        'version':
        '2.0.0',
        'description':
        'Test plugin B for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '4.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['8.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip3',
                    'namespace': 'my-namespace3',
                }, {
                    'name': 'my-vip4',
                    'namespace': 'my-namespace4',
                }]
            }
        }])
    }])

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(
        meta.tables["plugins"].insert(),
        [
            {
                "name": "test_plugin",
                "title": "Test plugin",
                "version": "1.0.0",
                "description": "Test plugin for Fuel",
                "homepage": "http://fuel_plugins.test_plugin.com",
                "package_version": "3.0.0",
                "groups": jsonutils.dumps(["tgroup"]),
                "authors": jsonutils.dumps(["tauthor"]),
                "licenses": jsonutils.dumps(["tlicense"]),
                "releases": jsonutils.dumps([{"repository_path": "repositories/ubuntu"}]),
                "fuel_version": jsonutils.dumps(["6.1", "7.0"]),
            }
        ],
    )

    result = db.execute(
        meta.tables["releases"].insert(),
        [
            {
                "name": "test_name",
                "version": "2014.2.2-6.1",
                "operating_system": "ubuntu",
                "state": "available",
                "roles": jsonutils.dumps(["controller", "compute", "mongo"]),
                "roles_metadata": jsonutils.dumps(
                    {
                        "controller": {"name": "Controller", "description": "Controller role", "has_primary": True},
                        "zabbix-server": {"name": "Zabbix Server", "description": "Zabbix Server role"},
                        "cinder": {"name": "Cinder", "description": "Cinder role"},
                        "mongo": {"name": "Telemetry - MongoDB", "description": "mongo is", "has_primary": True},
                    }
                ),
                "attributes_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,
            }
        ],
    )

    result = db.execute(
        meta.tables["clusters"].insert(),
        [
            {
                "name": "test_env",
                "release_id": releaseid,
                "mode": "ha_compact",
                "status": "new",
                "net_provider": "neutron",
                "grouping": "roles",
                "fuel_version": "6.1",
            }
        ],
    )
    clusterid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables["networking_configs"].insert(),
        [{"cluster_id": None, "dns_nameservers": ["8.8.8.8"], "floating_ranges": [], "configuration_template": None}],
    )
    db.execute(
        meta.tables["neutron_config"].insert(),
        [
            {
                "id": result.inserted_primary_key[0],
                "vlan_range": [],
                "gre_id_range": [],
                "base_mac": "00:00:00:00:00:00",
                "internal_cidr": "10.10.10.00/24",
                "internal_gateway": "10.10.10.01",
                "segmentation_type": "vlan",
                "net_l23_provider": "ovs",
            }
        ],
    )

    result = db.execute(
        meta.tables["nodes"].insert(),
        [
            {
                "uuid": "one",
                "cluster_id": clusterid,
                "group_id": None,
                "status": "ready",
                "meta": "{}",
                "mac": "aa:aa:aa:aa:aa:aa",
                "pending_addition": True,
                "pending_deletion": False,
                "timestamp": datetime.datetime.utcnow(),
            }
        ],
    )
    nodeid_a = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables["nodes"].insert(),
        [
            {
                "uuid": "two",
                "cluster_id": clusterid,
                "group_id": None,
                "status": "discover",
                "meta": "{}",
                "mac": "bb:bb:bb:bb:bb:bb",
                "pending_addition": True,
                "pending_deletion": False,
                "timestamp": datetime.datetime.utcnow(),
            }
        ],
    )
    nodeid_b = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables["nodes"].insert(),
        [
            {
                "uuid": "three",
                "cluster_id": None,
                "group_id": None,
                "status": "discover",
                "meta": "{}",
                "mac": "cc:cc:cc:cc:cc:cc",
                "pending_addition": True,
                "pending_deletion": False,
                "timestamp": datetime.datetime.utcnow(),
            }
        ],
    )
    nodeid_c = result.inserted_primary_key[0]

    db.execute(
        meta.tables["node_attributes"].insert(),
        [
            {"node_id": nodeid_a, "volumes": jsonutils.dumps([{"volume": nodeid_a}])},
            {"node_id": nodeid_b, "volumes": jsonutils.dumps([{"volume": nodeid_b}])},
            {"node_id": nodeid_c, "volumes": jsonutils.dumps([{"volume": nodeid_c}])},
        ],
    )

    result = db.execute(meta.tables["roles"].insert(), [{"release_id": releaseid, "name": "controller"}])
    controllerroleid = result.inserted_primary_key[0]

    result = db.execute(meta.tables["roles"].insert(), [{"release_id": releaseid, "name": "mongo"}])
    mongoroleid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables["node_roles"].insert(),
        [
            {"role": controllerroleid, "node": nodeid_a, "primary": False},
            {"role": controllerroleid, "node": nodeid_b, "primary": False},
            {"role": controllerroleid, "node": nodeid_c, "primary": True},
            {"role": mongoroleid, "node": nodeid_a, "primary": False},
        ],
    )

    result = db.execute(
        meta.tables["pending_node_roles"].insert(),
        [
            {"role": mongoroleid, "node": nodeid_b, "primary": True},
            {"role": mongoroleid, "node": nodeid_c, "primary": False},
        ],
    )

    db.execute(
        meta.tables["node_nic_interfaces"].insert(),
        [
            {
                "id": 1,
                "node_id": nodeid_a,
                "name": "test_interface",
                "mac": "00:00:00:00:00:01",
                "max_speed": 200,
                "current_speed": 100,
                "ip_addr": "10.20.0.2",
                "netmask": "255.255.255.0",
                "state": "test_state",
                "interface_properties": jsonutils.dumps({"test_property": "test_value"}),
                "driver": "test_driver",
                "bus_info": "some_test_info",
            },
            {
                "id": 2,
                "node_id": nodeid_a,
                "name": "test_interface_2",
                "mac": "00:00:00:00:00:02",
                "max_speed": 200,
                "current_speed": 100,
                "ip_addr": "10.30.0.2",
                "netmask": "255.255.255.0",
                "state": "test_state",
                "interface_properties": jsonutils.dumps({"test_property": "test_value"}),
                "driver": "test_driver",
                "bus_info": "some_test_info",
            },
            {
                "id": 3,
                "node_id": nodeid_a,
                "name": "test_interface_3",
                "mac": "00:00:00:00:00:03",
                "max_speed": 200,
                "current_speed": 100,
                "ip_addr": "10.30.0.2",
                "netmask": "255.255.255.0",
                "state": "test_state",
                "interface_properties": jsonutils.dumps({"test_property": "test_value"}),
                "driver": "test_driver",
                "bus_info": "some_test_info",
            },
        ],
    )

    db.execute(
        meta.tables["node_bond_interfaces"].insert(),
        [
            {
                "node_id": nodeid_a,
                "name": "test_bond_interface",
                "mode": "active-backup",
                "bond_properties": jsonutils.dumps({"test_property": "test_value"}),
            }
        ],
    )

    db.execute(
        meta.tables["network_groups"].insert(),
        [
            {"id": 1, "name": "fuelweb_admin", "vlan_start": None, "cidr": "10.20.0.0/24", "gateway": "10.20.0.200"},
            {"id": 2, "name": "public", "vlan_start": None, "cidr": "10.30.0.0/24", "gateway": "10.30.0.200"},
        ],
    )

    db.execute(
        meta.tables["net_nic_assignments"].insert(),
        [
            {"network_id": 1, "interface_id": 1},
            {"network_id": 2, "interface_id": 2},
            {"network_id": 2, "interface_id": 3},
        ],
    )

    db.commit()
Пример #27
0
def prepare():
    meta = base.reflect_db_metadata()
    TestNodeErrorMessageDowngrade.prepare(meta)
Пример #28
0
def prepare():
    meta = base.reflect_db_metadata()
    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-9.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': jsonutils.dumps(JSON_TASKS),
            'roles': jsonutils.dumps([
                'controller',
                'compute',
                'virt',
                'compute-vmware',
                'ironic',
                'cinder',
                'cinder-block-device',
                'cinder-vmware',
                'ceph-osd',
                'mongo',
                'base-os',
            ]),
            'roles_metadata': jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                },
                'compute': {
                    'name': 'Compute',
                },
                'virt': {
                    'name': 'Virtual',
                },
                'compute-vmware': {
                    'name': 'Compute VMware',
                },
                'ironic': {
                    'name': 'Ironic',
                },
                'cinder': {
                    'name': 'Cinder',
                },
                'cinder-block-device': {
                    'name': 'Cinder Block Device',
                },
                'cinder-vmware': {
                    'name': 'Cinder Proxy to VMware Datastore',
                },
                'ceph-osd': {
                    'name': 'Ceph OSD',
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                },
                'base-os': {
                    'name': 'Operating System',
                }
            }),
            'is_deployable': True,
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                },
                'dpdk_drivers': {
                    'igb_uio': ['qwe']
                },
            }),
            'volumes_metadata': jsonutils.dumps({}),
            'attributes_metadata': jsonutils.dumps(ATTRIBUTES_METADATA),
            'vmware_attributes_metadata':
                jsonutils.dumps(VMWARE_ATTRIBUTES_METADATA)
        }])

    release_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_old',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': jsonutils.dumps(JSON_TASKS),
            'roles': '[]',
            'roles_metadata': '{}',
            'is_deployable': True,
            'networks_metadata': '{}',
        }]
    )

    cluster_ids = []
    for cluster_name in ['test_env1', 'test_env2']:
        result = db.execute(
            meta.tables['clusters'].insert(),
            [{
                'name': cluster_name,
                'release_id': release_id,
                'mode': 'ha_compact',
                'status': 'new',
                'net_provider': 'neutron',
                'grouping': 'roles',
                'fuel_version': '9.0',
                'deployment_tasks': jsonutils.dumps(JSON_TASKS)
            }])
        cluster_ids.append(result.inserted_primary_key[0])

    result = db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
            'cluster_id': None,
            'group_id': None,
            'status': 'discover',
            'meta': '{}',
            'mac': 'aa:aa:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow(),
        }]
    )
    node_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_a',
            'title': 'Test plugin A',
            'version': '2.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '5.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'deployment_tasks': jsonutils.dumps(JSON_TASKS),
            'fuel_version': jsonutils.dumps(['9.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip1',
                            'namespace': 'my-namespace1',
                        },
                        {
                            'name': 'my-vip2',
                            'namespace': 'my-namespace2',
                        }
                    ]
                }
            }])
        }]
    )
    plugin_a_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_b',
            'title': 'Test plugin B',
            'version': '2.0.0',
            'description': 'Test plugin B for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '5.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['9.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip3',
                            'namespace': 'my-namespace3',
                        },
                        {
                            'name': 'my-vip4',
                            'namespace': 'my-namespace4',
                        }
                    ]
                }
            }])
        }]
    )
    plugin_b_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['cluster_plugins'].insert(),
        [
            {'cluster_id': cluster_ids[0], 'plugin_id': plugin_a_id},
            {'cluster_id': cluster_ids[0], 'plugin_id': plugin_b_id}
        ]
    )

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'id': 1,
            'node_id': node_id,
            'name': 'test_interface',
            'mac': '00:00:00:00:00:01',
            'max_speed': 200,
            'current_speed': 100,
            'ip_addr': '10.20.0.2',
            'netmask': '255.255.255.0',
            'state': 'test_state',
            'interface_properties': jsonutils.dumps(
                {'test_property': 'test_value'}),
            'driver': 'test_driver',
            'bus_info': 'some_test_info'
        }]
    )

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps(
                {'test_property': 'test_value'})
        }]
    )

    db.execute(
        meta.tables['tasks'].insert(),
        [
            {
                'id': 55,
                'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
                'name': 'deployment',
                'status': 'running',
                'deployment_info': jsonutils.dumps({}),
            },
        ]
    )
    db.execute(
        meta.tables['deployment_history'].insert(),
        [
            {
                'uuid': 'fake_uuid_0',
                'deployment_graph_task_name': 'fake',
                'node_id': 'fake_node_id',
                'task_id': 55,
                'status': 'pending',
                'summary': jsonutils.dumps({'fake': 'fake'}),
            }
        ]
    )

    result = db.execute(
        meta.tables['tasks'].insert(),
        [
            {
                'id': 102,
                'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
                'name': 'deployment',
                'status': 'running',
                'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[102])
            },
            {
                'id': 103,
                'uuid': 'a45fbbcd-792c-4245-a619-f4fb2f094d38',
                'name': 'deployment',
                'status': 'running',
                'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[103])
            }
        ]
    )

    db.commit()
Пример #29
0
 def setUp(self):
     self.meta = base.reflect_db_metadata()
Пример #30
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'version':
        '2015.1-10.0',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'roles':
        jsonutils.dumps([
            'controller',
            'compute',
            'virt',
            'compute-vmware',
            'ironic',
            'cinder',
            'cinder-block-device',
            'cinder-vmware',
            'ceph-osd',
            'mongo',
            'base-os',
        ]),
        'roles_metadata':
        jsonutils.dumps({
            'controller': {
                'name': 'Controller',
            },
            'compute': {
                'name': 'Compute',
            },
            'virt': {
                'name': 'Virtual',
            },
            'compute-vmware': {
                'name': 'Compute VMware',
            },
            'ironic': {
                'name': 'Ironic',
            },
            'cinder': {
                'name': 'Cinder',
            },
            'cinder-block-device': {
                'name': 'Cinder Block Device',
            },
            'cinder-vmware': {
                'name': 'Cinder Proxy to VMware Datastore',
            },
            'ceph-osd': {
                'name': 'Ceph OSD',
            },
            'mongo': {
                'name': 'Telemetry - MongoDB',
            },
            'base-os': {
                'name': 'Operating System',
            }
        }),
        'is_deployable':
        True
    }])

    release_id = result.inserted_primary_key[0]

    cluster_ids = []
    for cluster_name in ['test_env1', 'test_env2']:
        result = db.execute(meta.tables['clusters'].insert(),
                            [{
                                'name': cluster_name,
                                'release_id': release_id,
                                'mode': 'ha_compact',
                                'status': 'new',
                                'net_provider': 'neutron',
                                'grouping': 'roles',
                                'fuel_version': '10.0',
                                'deployment_tasks': jsonutils.dumps(JSON_TASKS)
                            }])
        cluster_ids.append(result.inserted_primary_key[0])

    node_id = 1
    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'id': node_id,
                            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'aa:aa:aa:aa:aa:aa',
                            'timestamp': datetime.datetime.utcnow(),
                        }])

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_a',
        'title':
        'Test plugin A',
        'version':
        '2.0.0',
        'description':
        'Test plugin A for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'fuel_version':
        jsonutils.dumps(['10.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip1',
                    'namespace': 'my-namespace1',
                }, {
                    'name': 'my-vip2',
                    'namespace': 'my-namespace2',
                }]
            }
        }])
    }])
    plugin_a_id = result.inserted_primary_key[0]

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_b',
        'title':
        'Test plugin B',
        'version':
        '2.0.0',
        'description':
        'Test plugin B for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['10.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip3',
                    'namespace': 'my-namespace3',
                }, {
                    'name': 'my-vip4',
                    'namespace': 'my-namespace4',
                }]
            }
        }])
    }])
    plugin_b_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['cluster_plugin_links'].insert(),
        [
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'cluster_id': cluster_ids[1],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            },
            # duplicate by URL but in another cluster, should
            # not be deleted
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            }
        ])

    db.execute(meta.tables['cluster_plugins'].insert(),
               [{
                   'cluster_id': cluster_ids[0],
                   'plugin_id': plugin_a_id
               }, {
                   'cluster_id': cluster_ids[0],
                   'plugin_id': plugin_b_id
               }])

    db.execute(
        meta.tables['plugin_links'].insert(),
        [
            {
                'plugin_id': plugin_a_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'plugin_id': plugin_b_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            }
        ])

    db.execute(meta.tables['node_nic_interfaces'].insert(), [{
        'id':
        1,
        'node_id':
        node_id,
        'name':
        'test_interface',
        'mac':
        '00:00:00:00:00:01',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.20.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps({'test_property': 'test_value'})
        }])

    result = db.execute(
        meta.tables['tasks'].insert(),
        [{
            'id': 55,
            'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
            'name': 'deployment',
            'status': 'running',
            'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[55])
        }, {
            'id': 56,
            'uuid': 'a45fbbcd-792c-4245-a619-f4fb2f094d38',
            'name': 'deployment',
            'status': 'running',
            'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[56])
        }])

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'id': 2,
                            'uuid': 'fcd49872-3917-4a18-98f9-3f5acfe3fdec',
                            'cluster_id': cluster_ids[0],
                            'group_id': None,
                            'status': 'ready',
                            'roles': ['controller', 'ceph-osd'],
                            'meta': '{}',
                            'mac': 'bb:aa:aa:aa:aa:aa',
                            'timestamp': datetime.datetime.utcnow(),
                        }])

    TestRequiredComponentTypesField.prepare(meta)
    db.commit()
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [
                        {
                            'assign_vip': True,
                        },
                    ]
                },
                'nova_network': {
                    'networks': [
                        {
                            'assign_vip': False,
                        },
                    ]
                },

            }),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'release-vip1',
                        },
                        {
                            'name': 'release-vip2',
                            'namespace': 'release-vip2-namespace'
                        }
                    ]
                }
            }]),
            'is_deployable': True,
        }])
    releaseid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '8.0',
        }])

    db.execute(
        meta.tables['ip_addrs'].insert(),
        [
            {
                'ip_addr': '192.168.0.2',
                'vip_type': 'management'
            },
            {
                'ip_addr': '192.168.1.2',
                'vip_type': 'haproxy'
            },
            {
                'ip_addr': '192.168.11.2',
                'vip_type': 'my-vip1',
                'namespace': 'my-namespace1'
            },
            {
                'ip_addr': '192.168.12.2',
                'vip_type': 'my-vip2',
                'namespace': 'my-namespace2'
            },
            {
                'ip_addr': '192.168.13.2',
                'vip_type': 'my-vip3',
                'namespace': 'my-namespace3'
            },
            {
                'ip_addr': '192.168.14.2',
                'vip_type': 'my-vip4',
                'namespace': 'my-namespace4'
            },
            {
                'ip_addr': '192.168.15.2',
                'vip_type': 'release-vip2'
            }
        ])

    db.execute(
        meta.tables['network_groups'].insert(),
        [{
            'name': 'public',
            'release': releaseid,
            'meta': jsonutils.dumps({'assign_vip': True})
        }])

    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_a',
            'title': 'Test plugin A',
            'version': '2.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '4.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['8.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip1',
                            'namespace': 'my-namespace1',
                        },
                        {
                            'name': 'my-vip2',
                            'namespace': 'my-namespace2',
                        }
                    ]
                }
            }])
        }]
    )

    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_b',
            'title': 'Test plugin B',
            'version': '2.0.0',
            'description': 'Test plugin B for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '4.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['8.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip3',
                            'namespace': 'my-namespace3',
                        },
                        {
                            'name': 'my-vip4',
                            'namespace': 'my-namespace4',
                        }
                    ]
                }
            }])
        }]
    )

    db.commit()
Пример #32
0
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin',
            'title': 'Test plugin',
            'version': '1.0.0',
            'description': 'Test plugin for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '3.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['6.1', '7.0']),
        }])

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2014.2-6.1',
            'operating_system': 'ubuntu',
            'state': 'available',
            'roles': jsonutils.dumps([
                'controller',
                'compute',
                'mongo',
            ]),
            'roles_metadata': jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                    'description': 'Controller role',
                    'has_primary': True,
                },
                'zabbix-server': {
                    'name': 'Zabbix Server',
                    'description': 'Zabbix Server role'
                },
                'cinder': {
                    'name': 'Cinder',
                    'description': 'Cinder role'
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                    'description': 'mongo is',
                    'has_primary': True,
                }
            }),
            'attributes_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(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '6.1',
        }])

    result = db.execute(
        meta.tables['nodes'].insert(),
        [
            {
                'uuid': 'one',
                'cluster_id': None,
                'group_id': None,
                'status': 'ready',
                'meta': '{}',
                'mac': 'aa:aa:aa:aa:aa:aa',
                'pending_addition': True,
                'pending_deletion': False,
                'timestamp': datetime.datetime.utcnow(),
            }
        ])
    nodeid_a = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['nodes'].insert(),
        [
            {
                'uuid': 'two',
                'cluster_id': None,
                'group_id': None,
                'status': 'discover',
                'meta': '{}',
                'mac': 'bb:bb:bb:bb:bb:bb',
                'pending_addition': True,
                'pending_deletion': False,
                'timestamp': datetime.datetime.utcnow(),
            }
        ])
    nodeid_b = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['nodes'].insert(),
        [
            {
                'uuid': 'three',
                'cluster_id': None,
                'group_id': None,
                'status': 'discover',
                'meta': '{}',
                'mac': 'cc:cc:cc:cc:cc:cc',
                'pending_addition': True,
                'pending_deletion': False,
                'timestamp': datetime.datetime.utcnow(),
            }
        ])
    nodeid_c = result.inserted_primary_key[0]

    db.execute(
        meta.tables['node_attributes'].insert(),
        [
            {
                'node_id': nodeid_a,
                'volumes': jsonutils.dumps([{'volume': nodeid_a}])
            },
            {
                'node_id': nodeid_b,
                'volumes': jsonutils.dumps([{'volume': nodeid_b}])
            },
            {
                'node_id': nodeid_c,
                'volumes': jsonutils.dumps([{'volume': nodeid_c}])
            },
        ])

    result = db.execute(
        meta.tables['roles'].insert(),
        [
            {'release_id': releaseid, 'name': 'controller'},
        ])
    controllerroleid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['roles'].insert(),
        [
            {'release_id': releaseid, 'name': 'mongo'},
        ])
    mongoroleid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['node_roles'].insert(),
        [
            {'role': controllerroleid, 'node': nodeid_a, 'primary': False},
            {'role': controllerroleid, 'node': nodeid_b, 'primary': False},
            {'role': controllerroleid, 'node': nodeid_c, 'primary': True},
            {'role': mongoroleid, 'node': nodeid_a, 'primary': False},
        ])

    result = db.execute(
        meta.tables['pending_node_roles'].insert(),
        [
            {'role': mongoroleid, 'node': nodeid_b, 'primary': True},
            {'role': mongoroleid, 'node': nodeid_c, 'primary': False},
        ])

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [
            {
                'id': 1,
                'node_id': nodeid_a,
                'name': 'test_interface',
                'mac': '00:00:00:00:00:01',
                'max_speed': 200,
                'current_speed': 100,
                'ip_addr': '10.20.0.2',
                'netmask': '255.255.255.0',
                'state': 'test_state',
                'interface_properties': jsonutils.dumps(
                    {'test_property': 'test_value'}),
                'driver': 'test_driver',
                'bus_info': 'some_test_info'
            },
            {
                'id': 2,
                'node_id': nodeid_a,
                'name': 'test_interface_2',
                'mac': '00:00:00:00:00:02',
                'max_speed': 200,
                'current_speed': 100,
                'ip_addr': '10.30.0.2',
                'netmask': '255.255.255.0',
                'state': 'test_state',
                'interface_properties': jsonutils.dumps(
                    {'test_property': 'test_value'}),
                'driver': 'test_driver',
                'bus_info': 'some_test_info'
            },
            {
                'id': 3,
                'node_id': nodeid_a,
                'name': 'test_interface_3',
                'mac': '00:00:00:00:00:03',
                'max_speed': 200,
                'current_speed': 100,
                'ip_addr': '10.30.0.2',
                'netmask': '255.255.255.0',
                'state': 'test_state',
                'interface_properties': jsonutils.dumps(
                    {'test_property': 'test_value'}),
                'driver': 'test_driver',
                'bus_info': 'some_test_info'
            }])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': nodeid_a,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps(
                {'test_property': 'test_value'})
        }])

    db.execute(
        meta.tables['network_groups'].insert(),
        [
            {
                'id': 1,
                'name': 'fuelweb_admin',
                'vlan_start': None,
                'cidr': '10.20.0.0/24',
                'gateway': '10.20.0.200',
            },
            {
                'id': 2,
                'name': 'public',
                'vlan_start': None,
                'cidr': '10.30.0.0/24',
                'gateway': '10.30.0.200'
            }
        ]
    )

    db.execute(
        meta.tables['net_nic_assignments'].insert(),
        [
            {
                'network_id': 1,
                'interface_id': 1
            },
            {
                'network_id': 2,
                'interface_id': 2
            },
            {
                'network_id': 2,
                'interface_id': 3
            }
        ]
    )

    db.commit()
Пример #33
0
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin',
            'title': 'Test plugin',
            'version': '1.0.0',
            'description': 'Test plugin for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '3.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['6.1', '7.0']),
        }])

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2014.2-6.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'roles': jsonutils.dumps([
                'controller',
                'compute',
                'mongo',
            ]),
            'roles_metadata': jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                    'description': 'Controller role',
                    'has_primary': True,
                },
                'zabbix-server': {
                    'name': 'Zabbix Server',
                    'description': 'Zabbix Server role'
                },
                'cinder': {
                    'name': 'Cinder',
                    'description': 'Cinder role'
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                    'description': 'mongo is',
                    'has_primary': True,
                }
            }),
            'attributes_metadata': jsonutils.dumps({}),
            'networks_metadata': jsonutils.dumps({}),
            'is_deployable': True,
        }])
    releaseid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['nodes'].insert(),
        [
            {
                'uuid': 'one',
                'cluster_id': None,
                'group_id': None,
                'status': 'ready',
                'meta': '{}',
                'mac': 'aa:aa:aa:aa:aa:aa',
                'pending_addition': True,
                'pending_deletion': False,
                'timestamp': datetime.datetime.utcnow(),
            }
        ])
    nodeid_a = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['nodes'].insert(),
        [
            {
                'uuid': 'two',
                'cluster_id': None,
                'group_id': None,
                'status': 'discover',
                'meta': '{}',
                'mac': 'bb:bb:bb:bb:bb:bb',
                'pending_addition': True,
                'pending_deletion': False,
                'timestamp': datetime.datetime.utcnow(),
            }
        ])
    nodeid_b = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['nodes'].insert(),
        [
            {
                'uuid': 'three',
                'cluster_id': None,
                'group_id': None,
                'status': 'discover',
                'meta': '{}',
                'mac': 'cc:cc:cc:cc:cc:cc',
                'pending_addition': True,
                'pending_deletion': False,
                'timestamp': datetime.datetime.utcnow(),
            }
        ])
    nodeid_c = result.inserted_primary_key[0]

    db.execute(
        meta.tables['node_attributes'].insert(),
        [
            {
                'node_id': nodeid_a,
                'volumes': jsonutils.dumps([{'volume': nodeid_a}])
            },
            {
                'node_id': nodeid_b,
                'volumes': jsonutils.dumps([{'volume': nodeid_b}])
            },
            {
                'node_id': nodeid_c,
                'volumes': jsonutils.dumps([{'volume': nodeid_c}])
            },
        ])

    result = db.execute(
        meta.tables['roles'].insert(),
        [
            {'release_id': releaseid, 'name': 'controller'},
        ])
    controllerroleid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['roles'].insert(),
        [
            {'release_id': releaseid, 'name': 'mongo'},
        ])
    mongoroleid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['node_roles'].insert(),
        [
            {'role': controllerroleid, 'node': nodeid_a, 'primary': False},
            {'role': controllerroleid, 'node': nodeid_b, 'primary': False},
            {'role': controllerroleid, 'node': nodeid_c, 'primary': True},
            {'role': mongoroleid, 'node': nodeid_a, 'primary': False},
        ])

    result = db.execute(
        meta.tables['pending_node_roles'].insert(),
        [
            {'role': mongoroleid, 'node': nodeid_b, 'primary': True},
            {'role': mongoroleid, 'node': nodeid_c, 'primary': False},
        ])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': nodeid_a,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps(
                {'test_property': 'test_value'})
        }])

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': nodeid_a,
            'name': 'test_interface',
            'mac': '00:00:00:00:00:01',
            'max_speed': 200,
            'current_speed': 100,
            'ip_addr': '10.20.0.2',
            'netmask': '255.255.255.0',
            'state': 'test_state',
            'interface_properties': jsonutils.dumps(
                {'test_property': 'test_value'}),
            'parent_id': 1,
            'driver': 'test_driver',
            'bus_info': 'some_test_info'
        }])

    db.commit()
Пример #34
0
def prepare():
    meta = base.reflect_db_metadata()

    releaseid = insert_table_row(
        meta.tables['releases'], {
            'name':
            'test_name',
            'version':
            '2014.2.2-6.1',
            'operating_system':
            'ubuntu',
            'state':
            'available',
            'networks_metadata':
            jsonutils.dumps({'neutron': {
                'networks': [],
                'config': {}
            }})
        })

    clusterid = insert_table_row(
        meta.tables['clusters'], {
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '7.0',
        })

    db.execute(meta.tables['nodegroups'].insert(), [
        {
            'cluster_id': clusterid,
            'name': 'test_nodegroup_a'
        },
        {
            'cluster_id': clusterid,
            'name': 'test_nodegroup_a'
        },
        {
            'cluster_id': clusterid,
            'name': 'test_nodegroup_b'
        },
        {
            'cluster_id': clusterid,
            'name': 'test_nodegroup_b'
        },
    ])

    netconfigid = insert_table_row(
        meta.tables['networking_configs'], {
            'cluster_id': None,
            'dns_nameservers': ['8.8.8.8'],
            'floating_ranges': [],
            'configuration_template': None,
        })

    db.execute(meta.tables['neutron_config'].insert(),
               [{
                   'id': netconfigid,
                   'vlan_range': [],
                   'gre_id_range': [],
                   'base_mac': '00:00:00:00:00:00',
                   'internal_cidr': '10.10.10.00/24',
                   'internal_gateway': '10.10.10.01',
                   'segmentation_type': 'vlan',
                   'net_l23_provider': 'ovs'
               }])

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_a',
        'title':
        'Test plugin A',
        'version':
        '1.0.0',
        'description':
        'Test plugin A for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '3.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['6.1', '7.0']),
    }])
    pluginid_a = result.inserted_primary_key[0]

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_b',
        'title':
        'Test plugin B',
        'version':
        '1.0.0',
        'description':
        'Test plugin B for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '3.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['6.1', '7.0']),
    }])
    pluginid_b = result.inserted_primary_key[0]

    db.execute(meta.tables['cluster_plugins'].insert(),
               [{
                   'cluster_id': clusterid,
                   'plugin_id': pluginid_a
               }, {
                   'cluster_id': clusterid,
                   'plugin_id': pluginid_b
               }])

    db.execute(meta.tables['attributes'].insert(), [{
        'cluster_id':
        clusterid,
        'editable':
        jsonutils.dumps({
            'test_plugin_a': {
                'metadata': {
                    'plugin_id': pluginid_a,
                    'enabled': True,
                    'toggleable': True,
                    'weight': 70,
                },
                'attribute': {
                    'value': 'value',
                    'type': 'text',
                    'description': 'description',
                    'weight': 25,
                    'label': 'label'
                }
            },
            'test_plugin_b': {
                'metadata': {
                    'plugin_id': pluginid_b,
                    'enabled': False,
                    'toggleable': True,
                    'weight': 80,
                }
            }
        }),
        'generated':
        jsonutils.dumps({}),
    }])

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()

    roles_metadata = jsonutils.dumps(
        {"mongo": {
            "name": "Mongo",
            "description": "Mongo role"
        }})

    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'version':
        '2014.2-6.0',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'roles_metadata':
        roles_metadata,
        'attributes_metadata':
        jsonutils.dumps({
            'editable': {
                'storage': {
                    'volumes_lvm': {},
                },
                'common': {},
            },
            'generated': {
                'cobbler': {
                    'profile': {
                        'generator_arg': 'ubuntu_1204_x86_64'
                    }
                }
            },
        }),
        'networks_metadata':
        jsonutils.dumps({
            'neutron': {
                'networks': [
                    {
                        'assign_vip': True,
                    },
                ]
            },
            'nova_network': {
                'networks': [
                    {
                        'assign_vip': False,
                    },
                ]
            },
        }),
        'is_deployable':
        True,
    }])
    releaseid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['release_orchestrator_data'].insert(), [{
        'release_id':
        releaseid,
        'puppet_manifests_source':
        'rsync://0.0.0.0:/puppet/manifests',
        'puppet_modules_source':
        'rsync://0.0.0.0:/puppet/modules',
        'repo_metadata':
        jsonutils.dumps({
            'base': 'http://baseuri base-suite main',
            'test': 'http://testuri test-suite main',
        })
    }])

    result = db.execute(meta.tables['clusters'].insert(),
                        [{
                            'name': 'test_env',
                            'release_id': releaseid,
                            'mode': 'ha_compact',
                            'status': 'new',
                            'net_provider': 'neutron',
                            'grouping': 'roles',
                            'fuel_version': '6.0',
                        }])
    clusterid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['attributes'].insert(),
        [{
            'cluster_id': clusterid,
            'editable': '{"common": {}}',
            'generated': '{"cobbler": {"profile": "ubuntu_1204_x86_64"}}',
        }])

    db.execute(meta.tables['ip_addrs'].insert(), [{
        'ip_addr': '192.168.0.2',
    }])

    db.execute(meta.tables['network_groups'].insert(),
               [{
                   'name': 'public',
                   'release': releaseid,
                   'meta': jsonutils.dumps({'assign_vip': True})
               }])

    db.commit()
Пример #36
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'roles': jsonutils.dumps([
                'controller',
                'compute',
                'virt',
                'compute-vmware',
                'ironic',
                'cinder',
                'cinder-block-device',
                'cinder-vmware',
                'ceph-osd',
                'mongo',
                'base-os',
            ]),
            'roles_metadata': jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                },
                'compute': {
                    'name': 'Compute',
                },
                'virt': {
                    'name': 'Virtual',
                },
                'compute-vmware': {
                    'name': 'Compute VMware',
                },
                'ironic': {
                    'name': 'Ironic',
                },
                'cinder': {
                    'name': 'Cinder',
                },
                'cinder-block-device': {
                    'name': 'Cinder Block Device',
                },
                'cinder-vmware': {
                    'name': 'Cinder Proxy to VMware Datastore',
                },
                'ceph-osd': {
                    'name': 'Ceph OSD',
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                },
                'base-os': {
                    'name': 'Operating System',
                }
            }),
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [
                        {
                            'assign_vip': True,
                        },
                    ]
                },
                'nova_network': {
                    'networks': [
                        {
                            'assign_vip': False,
                        },
                    ]
                },

            }),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'release-vip1',
                        },
                        {
                            'name': 'release-vip2',
                            'namespace': 'release-vip2-namespace'
                        }
                    ]
                }
            }]),
            'is_deployable': True,
        }])
    releaseid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '8.0',
        }])

    db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
            'cluster_id': None,
            'group_id': None,
            'status': 'discover',
            'meta': '{}',
            'mac': 'aa:aa:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow(),
        }]
    )
    node_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['node_attributes'].insert(),
        [{
            'node_id': node_id,
            'vms_conf': jsonutils.dumps([
                {'cpu': 1, 'mem': 2},
                {'cpu': 1, 'mem': 2},
            ])
        }]
    )

    db.execute(
        meta.tables['ip_addrs'].insert(),
        [
            {
                'ip_addr': '192.168.0.2',
                'vip_type': 'management'
            },
            {
                'ip_addr': '192.168.1.2',
                'vip_type': 'haproxy'
            },
            {
                'ip_addr': '192.168.11.2',
                'vip_type': 'my-vip1',
                'namespace': 'my-namespace1'
            },
            {
                'ip_addr': '192.168.12.2',
                'vip_type': 'my-vip2',
                'namespace': 'my-namespace2'
            },
            {
                'ip_addr': '192.168.13.2',
                'vip_type': 'my-vip3',
                'namespace': 'my-namespace3'
            },
            {
                'ip_addr': '192.168.14.2',
                'vip_type': 'my-vip4',
                'namespace': 'my-namespace4'
            },
            {
                'ip_addr': '192.168.15.2',
                'vip_type': 'release-vip2'
            }
        ])

    db.execute(
        meta.tables['network_groups'].insert(),
        [{
            'name': 'public',
            'release': releaseid,
            'meta': jsonutils.dumps({'assign_vip': True})
        }])

    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_a',
            'title': 'Test plugin A',
            'version': '2.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '4.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['8.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip1',
                            'namespace': 'my-namespace1',
                        },
                        {
                            'name': 'my-vip2',
                            'namespace': 'my-namespace2',
                        }
                    ]
                }
            }])
        }]
    )

    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_b',
            'title': 'Test plugin B',
            'version': '2.0.0',
            'description': 'Test plugin B for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '4.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['8.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip3',
                            'namespace': 'my-namespace3',
                        },
                        {
                            'name': 'my-vip4',
                            'namespace': 'my-namespace4',
                        }
                    ]
                }
            }])
        }]
    )

    db.commit()
Пример #37
0
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2015.1-8.0',
            'operating_system': 'ubuntu',
            'state': 'available',
        }])
    release_id = result.inserted_primary_key[0]

    cluster_ids = []
    for cluster_name in ['test_env1', 'test_env2']:
        result = db.execute(
            meta.tables['clusters'].insert(),
            [{
                'name': cluster_name,
                'release_id': release_id,
                'mode': 'ha_compact',
                'status': 'new',
                'net_provider': 'neutron',
                'grouping': 'roles',
                'fuel_version': '10.0'
            }])
        cluster_ids.append(result.inserted_primary_key[0])

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_a',
            'title': 'Test plugin A',
            'version': '2.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '4.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'deployment_tasks': jsonutils.dumps(JSON_TASKS),
            'fuel_version': jsonutils.dumps(['8.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip1',
                            'namespace': 'my-namespace1',
                        },
                        {
                            'name': 'my-vip2',
                            'namespace': 'my-namespace2',
                        }
                    ]
                }
            }])
        }]
    )
    plugin_a_id = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_b',
            'title': 'Test plugin B',
            'version': '2.0.0',
            'description': 'Test plugin B for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '4.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['8.0']),
            'network_roles_metadata': jsonutils.dumps([{
                'id': 'admin/vip',
                'default_mapping': 'fuelweb_admin',
                'properties': {
                    'subnet': True,
                    'gateway': False,
                    'vip': [
                        {
                            'name': 'my-vip3',
                            'namespace': 'my-namespace3',
                        },
                        {
                            'name': 'my-vip4',
                            'namespace': 'my-namespace4',
                        }
                    ]
                }
            }])
        }]
    )
    plugin_b_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['cluster_plugin_links'].insert(),
        [
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'cluster_id': cluster_ids[1],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            },
            # duplicate by URL but in another cluster, should
            # not be deleted
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            }
        ]
    )

    db.execute(
        meta.tables['plugin_links'].insert(),
        [
            {
                'plugin_id': plugin_a_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'plugin_id': plugin_b_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            }
        ]
    )

    db.commit()
Пример #38
0
 def setUp(self):
     self.meta = base.reflect_db_metadata()
def prepare():
    meta = base.reflect_db_metadata()

    roles_metadata = jsonutils.dumps({
        "mongo": {
            "name": "Mongo",
            "description": "Mongo role"
        }
    })

    result = db.execute(
        meta.tables['releases'].insert(),
        [{
            'name': 'test_name',
            'version': '2014.2-6.0',
            'operating_system': 'ubuntu',
            'state': 'available',
            'roles_metadata': roles_metadata,
            'attributes_metadata': jsonutils.dumps({
                'editable': {
                    'storage': {
                        'volumes_lvm': {},
                    },
                    'common': {},
                },
                'generated': {
                    'cobbler': {'profile': {
                        'generator_arg': 'ubuntu_1204_x86_64'}}},
            }),
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [
                        {
                            'assign_vip': True,
                        },
                    ]
                },
                'nova_network': {
                    'networks': [
                        {
                            'assign_vip': False,
                        },
                    ]
                },

            }),
            'is_deployable': True,
        }])
    releaseid = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['release_orchestrator_data'].insert(),
        [{
            'release_id': releaseid,
            'puppet_manifests_source': 'rsync://0.0.0.0:/puppet/manifests',
            'puppet_modules_source': 'rsync://0.0.0.0:/puppet/modules',
            'repo_metadata': jsonutils.dumps({
                'base': 'http://baseuri base-suite main',
                'test': 'http://testuri test-suite main',
            })
        }])

    result = db.execute(
        meta.tables['clusters'].insert(),
        [{
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '6.0',
        }])
    clusterid = result.inserted_primary_key[0]

    db.execute(
        meta.tables['attributes'].insert(),
        [{
            'cluster_id': clusterid,
            'editable': '{"common": {}}',
            'generated': '{"cobbler": {"profile": "ubuntu_1204_x86_64"}}',
        }])

    db.execute(
        meta.tables['ip_addrs'].insert(),
        [{
            'ip_addr': '192.168.0.2',
        }])

    db.execute(
        meta.tables['network_groups'].insert(),
        [{
            'name': 'public',
            'release': releaseid,
            'meta': jsonutils.dumps({'assign_vip': True})
        }])

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()

    releaseid = insert_table_row(
        meta.tables['releases'],
        {
            'name': 'test_name',
            'version': '2014.2.2-6.1',
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': jsonutils.dumps({
                'neutron': {
                    'networks': [],
                    'config': {}
                }
            })
        }
    )

    clusterid = insert_table_row(
        meta.tables['clusters'],
        {
            'name': 'test_env',
            'release_id': releaseid,
            'mode': 'ha_compact',
            'status': 'new',
            'net_provider': 'neutron',
            'grouping': 'roles',
            'fuel_version': '7.0',
        }
    )

    db.execute(
        meta.tables['nodegroups'].insert(),
        [
            {'cluster_id': clusterid, 'name': 'test_nodegroup_a'},
            {'cluster_id': clusterid, 'name': 'test_nodegroup_a'},
            {'cluster_id': clusterid, 'name': 'test_nodegroup_b'},
            {'cluster_id': clusterid, 'name': 'test_nodegroup_b'},
            {'cluster_id': clusterid, 'name': consts.NODE_GROUPS.default},
        ])

    netconfigid = insert_table_row(
        meta.tables['networking_configs'],
        {
            'cluster_id': None,
            'dns_nameservers': ['8.8.8.8'],
            'floating_ranges': [],
            'configuration_template': None,
        })

    db.execute(
        meta.tables['neutron_config'].insert(),
        [{
            'id': netconfigid,
            'vlan_range': [],
            'gre_id_range': [],
            'base_mac': '00:00:00:00:00:00',
            'internal_cidr': '10.10.10.00/24',
            'internal_gateway': '10.10.10.01',
            'segmentation_type': 'vlan',
            'net_l23_provider': 'ovs'
        }])

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_a',
            'title': 'Test plugin A',
            'version': '1.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '3.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['6.1', '7.0']),
        }]
    )
    pluginid_a = result.inserted_primary_key[0]

    result = db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin_b',
            'title': 'Test plugin B',
            'version': '1.0.0',
            'description': 'Test plugin B for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '3.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['6.1', '7.0']),
        }]
    )
    pluginid_b = result.inserted_primary_key[0]

    db.execute(
        meta.tables['cluster_plugins'].insert(),
        [
            {
                'cluster_id': clusterid,
                'plugin_id': pluginid_a
            },
            {
                'cluster_id': clusterid,
                'plugin_id': pluginid_b
            }
        ]
    )

    db.execute(
        meta.tables['attributes'].insert(),
        [{
            'cluster_id': clusterid,
            'editable': jsonutils.dumps({
                'test_plugin_a': {
                    'metadata': {
                        'plugin_id': pluginid_a,
                        'enabled': True,
                        'toggleable': True,
                        'weight': 70,
                    },
                    'attribute': {
                        'value': 'value',
                        'type': 'text',
                        'description': 'description',
                        'weight': 25,
                        'label': 'label'
                    }
                },
                'test_plugin_b': {
                    'metadata': {
                        'plugin_id': pluginid_b,
                        'enabled': False,
                        'toggleable': True,
                        'weight': 80,
                    }
                }
            }),
            'generated': jsonutils.dumps({}),
        }])

    db.commit()
Пример #41
0
def prepare():
    meta = base.reflect_db_metadata()

    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_plugin',
            'title': 'Test plugin',
            'version': '1.0.0',
            'description': 'Test plugin for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '3.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'fuel_version': jsonutils.dumps(['6.1', '7.0']),
        }])

    db.execute(meta.tables['releases'].insert(), [_RELEASE])

    db.execute(
        meta.tables['nodes'].insert(),
        [{
            'node_id': 1,
            'uuid': 'test_uuid',
            'status': 'ready',
            'mac': '00:00:00:00:00:01',
            'timestamp': '2015-07-01 12:34:56.123',

        }])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': 1,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps(
                {'test_property': 'test_value'})
        }])

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': 1,
            'name': 'test_interface',
            'mac': '00:00:00:00:00:01',
            'max_speed': 200,
            'current_speed': 100,
            'ip_addr': '10.20.0.2',
            'netmask': '255.255.255.0',
            'state': 'test_state',
            'interface_properties': jsonutils.dumps(
                {'test_property': 'test_value'}),
            'parent_id': 1,
            'driver': 'test_driver',
            'bus_info': 'some_test_info'
        }])

    db.commit()
Пример #42
0
def prepare():
    meta = base.reflect_db_metadata()
    for release_name, env_version, cluster_name, uuid, mac in zip(
            ('release_1', 'release_2'),
            ('liberty-8.0', 'mitaka-9.0'),
            ('cluster_1', 'cluster_2'),
            ('fcd49872-3917-4a18-98f9-3f5acfe3fde',
             'fcd49872-3917-4a18-98f9-3f5acfe3fdd'),
            ('bb:aa:aa:aa:aa:aa', 'bb:aa:aa:aa:aa:cc')
    ):
        release = {
            'name': release_name,
            'version': env_version,
            'operating_system': 'ubuntu',
            'state': 'available',
            'networks_metadata': '{}',
            'attributes_metadata': jsonutils.dumps(ATTRIBUTES_METADATA),
            'deployment_tasks': '{}',
            'roles': jsonutils.dumps([
                'controller',
                'compute',
                'virt',
                'compute-vmware',
                'ironic',
                'cinder',
                'cinder-block-device',
                'cinder-vmware',
                'ceph-osd',
                'mongo',
                'base-os',
            ]),
            'roles_metadata': jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                },
                'compute': {
                    'name': 'Compute',
                },
                'virt': {
                    'name': 'Virtual',
                },
                'compute-vmware': {
                    'name': 'Compute VMware',
                },
                'ironic': {
                    'name': 'Ironic',
                },
                'cinder': {
                    'name': 'Cinder',
                },
                'cinder-block-device': {
                    'name': 'Cinder Block Device',
                },
                'cinder-vmware': {
                    'name': 'Cinder Proxy to VMware Datastore',
                },
                'ceph-osd': {
                    'name': 'Ceph OSD',
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                },
                'base-os': {
                    'name': 'Operating System',
                }
            }),
            'is_deployable': True,
            'vmware_attributes_metadata':
                jsonutils.dumps(VMWARE_ATTRIBUTES_METADATA)
        }
        result = db.execute(meta.tables['releases'].insert(), [release])
        release_id = result.inserted_primary_key[0]

        result = db.execute(
            meta.tables['clusters'].insert(),
            [{
                'name': cluster_name,
                'release_id': release_id,
                'mode': 'ha_compact',
                'status': 'new',
                'net_provider': 'neutron',
                'grouping': 'roles',
                'fuel_version': '9.0',
                'deployment_tasks': '{}'
            }])

        cluster_id = result.inserted_primary_key[0]
        editable = ATTRIBUTES_METADATA.get('editable', {})
        db.execute(
            meta.tables['attributes'].insert(),
            [{
                'cluster_id': cluster_id,
                'editable': jsonutils.dumps(editable)
            }]
        )
        db.execute(
            meta.tables['nodes'].insert(),
            [{
                'uuid': uuid,
                'cluster_id': cluster_id,
                'group_id': None,
                'status': 'ready',
                'roles': ['controller', 'ceph-osd'],
                'primary_roles': ['controller'],
                'meta': jsonutils.dumps({
                    'interfaces': [{
                        'mac': '00:00:00:00:00:01'
                    }]
                }),
                'mac': mac,
                'timestamp': datetime.datetime.utcnow(),
            }]
        )

    node_interface_properties = copy.deepcopy(NODE_NIC_PROPERTIES)
    node_interface_properties['dpdk'].pop('available')
    result = db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': 'fcd49872-3917-4a18-98f9-3f5acfe3fdec',
            'cluster_id': cluster_id,
            'group_id': None,
            'status': 'ready',
            'roles': ['controller', 'ceph-osd'],
            'meta': jsonutils.dumps({
                'interfaces': [
                    {
                        'name': 'test_nic_empty_attributes',
                        'mac': '00:00:00:00:00:01',
                        'interface_properties': {}
                    },
                    {
                        'name': 'test_nic_attributes',
                        'mac': '00:00:00:00:00:02',
                        'interface_properties': node_interface_properties,
                        'offloading_modes': NODE_OFFLOADING_MODES
                    },
                    {
                        'name': 'test_nic_attributes_2',
                        'mac': '00:00:00:00:00:03',
                        'interface_properties': node_interface_properties,
                        'offloading_modes': [
                            {
                                'state': True,
                                'name': 'tx-checksumming',
                                'sub': [{
                                    'state': False,
                                    'name': 'tx-checksum-sctp',
                                    'sub': []
                                }]
                            }, {
                                'state': True,
                                'name': 'rx-checksumming',
                                'sub': []
                            }, {
                                'state': False,
                                'name': 'rx-vlan-offload',
                                'sub': []
                            }
                        ]
                    }
                ]
            }),
            'mac': 'bb:bb:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow(),
            'hostname': 'test_node'
        }]
    )
    node_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps(
                {'test_property': 'test_value'})
        }]
    )

    bond = db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface_attributes',
            'mode': '802.3ad',
            'bond_properties': jsonutils.dumps(
                {'lacp_rate': 'slow', 'type__': 'linux',
                 'mode': '802.3ad', 'xmit_hash_policy': 'layer2'}),
            'interface_properties': jsonutils.dumps(
                {'mtu': 2000, 'disable_offloading': False,
                 'dpdk': {'available': True, 'enabled': True}})
        }]
    )
    bond_id = bond.inserted_primary_key[0]

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_nic_empty_attributes',
            'mac': '00:00:00:00:00:01',
            'interface_properties': "{}",
            'offloading_modes': "[]"
        }]
    )

    changed_offloading_modes = copy.deepcopy(NODE_OFFLOADING_MODES)
    changed_offloading_modes[0]['state'] = False
    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': node_id,
            'parent_id': bond_id,
            'name': 'test_nic_attributes',
            'mac': '00:00:00:00:00:02',
            'interface_properties': jsonutils.dumps(NODE_NIC_PROPERTIES),
            'offloading_modes': jsonutils.dumps(changed_offloading_modes)
        }]
    )

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': node_id,
            'parent_id': bond_id,
            'name': 'test_nic_attributes_2',
            'mac': '00:00:00:00:00:03',
            'interface_properties': jsonutils.dumps(NODE_NIC_PROPERTIES),
            'offloading_modes': jsonutils.dumps([
                {
                    'state': True,
                    'name': 'tx-checksumming',
                    'sub': [{
                        'state': True,
                        'name': 'tx-checksum-sctp',
                        'sub': []
                    }]
                }, {
                    'state': True,
                    'name': 'rx-checksumming',
                    'sub': []
                }, {
                    'state': False,
                    'name': 'rx-vlan-offload',
                    'sub': []
                }
            ])
        }]
    )

    db.execute(
        meta.tables['plugins'].insert(),
        [{
            'name': 'test_tags',
            'title': 'Test tags plugin',
            'version': '2.0.0',
            'description': 'Test plugin A for Fuel',
            'homepage': 'http://fuel_plugins.test_plugin.com',
            'package_version': '5.0.0',
            'groups': jsonutils.dumps(['tgroup']),
            'authors': jsonutils.dumps(['tauthor']),
            'licenses': jsonutils.dumps(['tlicense']),
            'releases': jsonutils.dumps([
                {'repository_path': 'repositories/ubuntu'}
            ]),
            'deployment_tasks': jsonutils.dumps([]),
            'fuel_version': jsonutils.dumps(['9.2']),
            'network_roles_metadata': jsonutils.dumps([]),
            'roles_metadata': jsonutils.dumps({
                'plugin-tags-controller': {
                    'name': 'Plugin Tags Controller',
                },
            }),
        }]
    )

    db.commit()
Пример #43
0
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin',
        'title':
        'Test plugin',
        'version':
        '1.0.0',
        'description':
        'Test plugin for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '3.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['6.1', '7.0']),
    }])

    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'version':
        '2014.2-6.0',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'roles':
        jsonutils.dumps([
            'controller',
            'compute',
            'mongo',
        ]),
        'roles_metadata':
        jsonutils.dumps({
            'controller': {
                'name': 'Controller',
                'description': 'Controller role',
                'has_primary': True,
            },
            'zabbix-server': {
                'name': 'Zabbix Server',
                'description': 'Zabbix Server role'
            },
            'cinder': {
                'name': 'Cinder',
                'description': 'Cinder role'
            },
            'mongo': {
                'name': 'Telemetry - MongoDB',
                'description': 'mongo is',
                'has_primary': True,
            }
        }),
        'attributes_metadata':
        jsonutils.dumps({}),
        'networks_metadata':
        jsonutils.dumps({}),
        'is_deployable':
        True,
    }])
    releaseid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': 'one',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'ready',
                            'meta': '{}',
                            'mac': 'aa:aa:aa:aa:aa:aa',
                            'pending_addition': True,
                            'pending_deletion': False,
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    nodeid_a = result.inserted_primary_key[0]

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': 'two',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'bb:bb:bb:bb:bb:bb',
                            'pending_addition': True,
                            'pending_deletion': False,
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    nodeid_b = result.inserted_primary_key[0]

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': 'three',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'cc:cc:cc:cc:cc:cc',
                            'pending_addition': True,
                            'pending_deletion': False,
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    nodeid_c = result.inserted_primary_key[0]

    db.execute(meta.tables['node_attributes'].insert(), [
        {
            'node_id': nodeid_a,
            'volumes': jsonutils.dumps([{
                'volume': nodeid_a
            }])
        },
        {
            'node_id': nodeid_b,
            'volumes': jsonutils.dumps([{
                'volume': nodeid_b
            }])
        },
        {
            'node_id': nodeid_c,
            'volumes': jsonutils.dumps([{
                'volume': nodeid_c
            }])
        },
    ])

    result = db.execute(meta.tables['roles'].insert(), [
        {
            'release_id': releaseid,
            'name': 'controller'
        },
    ])
    controllerroleid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['roles'].insert(), [
        {
            'release_id': releaseid,
            'name': 'mongo'
        },
    ])
    mongoroleid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['node_roles'].insert(), [
        {
            'role': controllerroleid,
            'node': nodeid_a,
            'primary': False
        },
        {
            'role': controllerroleid,
            'node': nodeid_b,
            'primary': False
        },
        {
            'role': controllerroleid,
            'node': nodeid_c,
            'primary': True
        },
        {
            'role': mongoroleid,
            'node': nodeid_a,
            'primary': False
        },
    ])

    result = db.execute(meta.tables['pending_node_roles'].insert(), [
        {
            'role': mongoroleid,
            'node': nodeid_b,
            'primary': True
        },
        {
            'role': mongoroleid,
            'node': nodeid_c,
            'primary': False
        },
    ])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': nodeid_a,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps({'test_property': 'test_value'})
        }])

    db.execute(meta.tables['node_nic_interfaces'].insert(), [{
        'node_id':
        nodeid_a,
        'name':
        'test_interface',
        'mac':
        '00:00:00:00:00:01',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.20.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'parent_id':
        1,
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }])

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()
    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'version':
        '2015.1-9.0',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'roles':
        jsonutils.dumps([
            'controller',
            'compute',
            'virt',
            'compute-vmware',
            'ironic',
            'cinder',
            'cinder-block-device',
            'cinder-vmware',
            'ceph-osd',
            'mongo',
            'base-os',
        ]),
        'roles_metadata':
        jsonutils.dumps({
            'controller': {
                'name': 'Controller',
            },
            'compute': {
                'name': 'Compute',
            },
            'virt': {
                'name': 'Virtual',
            },
            'compute-vmware': {
                'name': 'Compute VMware',
            },
            'ironic': {
                'name': 'Ironic',
            },
            'cinder': {
                'name': 'Cinder',
            },
            'cinder-block-device': {
                'name': 'Cinder Block Device',
            },
            'cinder-vmware': {
                'name': 'Cinder Proxy to VMware Datastore',
            },
            'ceph-osd': {
                'name': 'Ceph OSD',
            },
            'mongo': {
                'name': 'Telemetry - MongoDB',
            },
            'base-os': {
                'name': 'Operating System',
            }
        }),
        'is_deployable':
        True,
        'networks_metadata':
        jsonutils.dumps({
            'neutron': {
                'networks': [],
                'config': {}
            },
            'dpdk_drivers': {
                'igb_uio': ['qwe']
            },
        }),
        'volumes_metadata':
        jsonutils.dumps({}),
        'attributes_metadata':
        jsonutils.dumps(ATTRIBUTES_METADATA),
        'vmware_attributes_metadata':
        jsonutils.dumps(VMWARE_ATTRIBUTES_METADATA)
    }])

    release_id = result.inserted_primary_key[0]

    db.execute(meta.tables['releases'].insert(),
               [{
                   'name': 'test_old',
                   'version': '2015.1-8.0',
                   'operating_system': 'ubuntu',
                   'state': 'available',
                   'deployment_tasks': jsonutils.dumps(JSON_TASKS),
                   'roles': '[]',
                   'roles_metadata': '{}',
                   'is_deployable': True,
                   'networks_metadata': '{}',
               }])

    cluster_ids = []
    for cluster_name in ['test_env1', 'test_env2']:
        result = db.execute(meta.tables['clusters'].insert(),
                            [{
                                'name': cluster_name,
                                'release_id': release_id,
                                'mode': 'ha_compact',
                                'status': 'new',
                                'net_provider': 'neutron',
                                'grouping': 'roles',
                                'fuel_version': '9.0',
                                'deployment_tasks': jsonutils.dumps(JSON_TASKS)
                            }])
        cluster_ids.append(result.inserted_primary_key[0])

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'aa:aa:aa:aa:aa:aa',
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    node_id = result.inserted_primary_key[0]

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_a',
        'title':
        'Test plugin A',
        'version':
        '2.0.0',
        'description':
        'Test plugin A for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'fuel_version':
        jsonutils.dumps(['9.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip1',
                    'namespace': 'my-namespace1',
                }, {
                    'name': 'my-vip2',
                    'namespace': 'my-namespace2',
                }]
            }
        }])
    }])
    plugin_a_id = result.inserted_primary_key[0]

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_b',
        'title':
        'Test plugin B',
        'version':
        '2.0.0',
        'description':
        'Test plugin B for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['9.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip3',
                    'namespace': 'my-namespace3',
                }, {
                    'name': 'my-vip4',
                    'namespace': 'my-namespace4',
                }]
            }
        }])
    }])
    plugin_b_id = result.inserted_primary_key[0]

    db.execute(meta.tables['cluster_plugins'].insert(),
               [{
                   'cluster_id': cluster_ids[0],
                   'plugin_id': plugin_a_id
               }, {
                   'cluster_id': cluster_ids[0],
                   'plugin_id': plugin_b_id
               }])

    db.execute(meta.tables['node_nic_interfaces'].insert(), [{
        'id':
        1,
        'node_id':
        node_id,
        'name':
        'test_interface',
        'mac':
        '00:00:00:00:00:01',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.20.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps({'test_property': 'test_value'})
        }])

    db.execute(meta.tables['tasks'].insert(), [
        {
            'id': 55,
            'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
            'name': 'deployment',
            'status': 'running',
            'deployment_info': jsonutils.dumps({}),
        },
    ])
    db.execute(meta.tables['deployment_history'].insert(),
               [{
                   'uuid': 'fake_uuid_0',
                   'deployment_graph_task_name': 'fake',
                   'node_id': 'fake_node_id',
                   'task_id': 55,
                   'status': 'pending',
                   'summary': jsonutils.dumps({'fake': 'fake'}),
               }])

    result = db.execute(
        meta.tables['tasks'].insert(),
        [{
            'id': 102,
            'uuid': '219eaafe-01a1-4f26-8edc-b9d9b0df06b3',
            'name': 'deployment',
            'status': 'running',
            'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[102])
        }, {
            'id': 103,
            'uuid': 'a45fbbcd-792c-4245-a619-f4fb2f094d38',
            'name': 'deployment',
            'status': 'running',
            'deployment_info': jsonutils.dumps(DEPLOYMENT_INFO[103])
        }])

    db.commit()
Пример #45
0
def prepare():
    meta = base.reflect_db_metadata()
    db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin',
        'title':
        'Test plugin',
        'version':
        '1.0.0',
        'description':
        'Test plugin for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '3.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['6.1', '7.0']),
    }])

    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'version':
        '2014.2.2-6.1',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'roles':
        jsonutils.dumps([
            'controller',
            'compute',
            'mongo',
        ]),
        'roles_metadata':
        jsonutils.dumps({
            'controller': {
                'name': 'Controller',
                'description': 'Controller role',
                'has_primary': True,
            },
            'zabbix-server': {
                'name': 'Zabbix Server',
                'description': 'Zabbix Server role'
            },
            'cinder': {
                'name': 'Cinder',
                'description': 'Cinder role'
            },
            'mongo': {
                'name': 'Telemetry - MongoDB',
                'description': 'mongo is',
                'has_primary': True,
            }
        }),
        'attributes_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
    }])

    result = db.execute(meta.tables['clusters'].insert(),
                        [{
                            'name': 'test_env',
                            'release_id': releaseid,
                            'mode': 'ha_compact',
                            'status': 'new',
                            'net_provider': 'neutron',
                            'grouping': 'roles',
                            'fuel_version': '6.1',
                        }])
    clusterid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['networking_configs'].insert(),
                        [{
                            'cluster_id': None,
                            'dns_nameservers': ['8.8.8.8'],
                            'floating_ranges': [],
                            'configuration_template': None,
                        }])
    db.execute(meta.tables['neutron_config'].insert(),
               [{
                   'id': result.inserted_primary_key[0],
                   'vlan_range': [],
                   'gre_id_range': [],
                   'base_mac': '00:00:00:00:00:00',
                   'internal_cidr': '10.10.10.00/24',
                   'internal_gateway': '10.10.10.01',
                   'segmentation_type': 'vlan',
                   'net_l23_provider': 'ovs'
               }])

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': 'one',
                            'cluster_id': clusterid,
                            'group_id': None,
                            'status': 'ready',
                            'meta': '{}',
                            'mac': 'aa:aa:aa:aa:aa:aa',
                            'pending_addition': True,
                            'pending_deletion': False,
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    nodeid_a = result.inserted_primary_key[0]

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': 'two',
                            'cluster_id': clusterid,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'bb:bb:bb:bb:bb:bb',
                            'pending_addition': True,
                            'pending_deletion': False,
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    nodeid_b = result.inserted_primary_key[0]

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': 'three',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'cc:cc:cc:cc:cc:cc',
                            'pending_addition': True,
                            'pending_deletion': False,
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    nodeid_c = result.inserted_primary_key[0]

    db.execute(meta.tables['node_attributes'].insert(), [
        {
            'node_id': nodeid_a,
            'volumes': jsonutils.dumps([{
                'volume': nodeid_a
            }])
        },
        {
            'node_id': nodeid_b,
            'volumes': jsonutils.dumps([{
                'volume': nodeid_b
            }])
        },
        {
            'node_id': nodeid_c,
            'volumes': jsonutils.dumps([{
                'volume': nodeid_c
            }])
        },
    ])

    result = db.execute(meta.tables['roles'].insert(), [
        {
            'release_id': releaseid,
            'name': 'controller'
        },
    ])
    controllerroleid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['roles'].insert(), [
        {
            'release_id': releaseid,
            'name': 'mongo'
        },
    ])
    mongoroleid = result.inserted_primary_key[0]

    result = db.execute(meta.tables['node_roles'].insert(), [
        {
            'role': controllerroleid,
            'node': nodeid_a,
            'primary': False
        },
        {
            'role': controllerroleid,
            'node': nodeid_b,
            'primary': False
        },
        {
            'role': controllerroleid,
            'node': nodeid_c,
            'primary': True
        },
        {
            'role': mongoroleid,
            'node': nodeid_a,
            'primary': False
        },
    ])

    result = db.execute(meta.tables['pending_node_roles'].insert(), [
        {
            'role': mongoroleid,
            'node': nodeid_b,
            'primary': True
        },
        {
            'role': mongoroleid,
            'node': nodeid_c,
            'primary': False
        },
    ])

    db.execute(meta.tables['node_nic_interfaces'].insert(), [{
        'id':
        1,
        'node_id':
        nodeid_a,
        'name':
        'test_interface',
        'mac':
        '00:00:00:00:00:01',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.20.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }, {
        'id':
        2,
        'node_id':
        nodeid_a,
        'name':
        'test_interface_2',
        'mac':
        '00:00:00:00:00:02',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.30.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }, {
        'id':
        3,
        'node_id':
        nodeid_a,
        'name':
        'test_interface_3',
        'mac':
        '00:00:00:00:00:03',
        'max_speed':
        200,
        'current_speed':
        100,
        'ip_addr':
        '10.30.0.2',
        'netmask':
        '255.255.255.0',
        'state':
        'test_state',
        'interface_properties':
        jsonutils.dumps({'test_property': 'test_value'}),
        'driver':
        'test_driver',
        'bus_info':
        'some_test_info'
    }])

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': nodeid_a,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps({'test_property': 'test_value'})
        }])

    db.execute(meta.tables['network_groups'].insert(),
               [{
                   'id': 1,
                   'name': 'fuelweb_admin',
                   'vlan_start': None,
                   'cidr': '10.20.0.0/24',
                   'gateway': '10.20.0.200',
               }, {
                   'id': 2,
                   'name': 'public',
                   'vlan_start': None,
                   'cidr': '10.30.0.0/24',
                   'gateway': '10.30.0.200'
               }])

    db.execute(meta.tables['net_nic_assignments'].insert(), [{
        'network_id': 1,
        'interface_id': 1
    }, {
        'network_id': 2,
        'interface_id': 2
    }, {
        'network_id': 2,
        'interface_id': 3
    }])

    db.commit()
Пример #46
0
def prepare():
    meta = base.reflect_db_metadata()
    for release_name, env_version, cluster_name, uuid, mac in zip(
        ('release_1', 'release_2'), ('liberty-8.0', 'mitaka-9.0'),
        ('cluster_1', 'cluster_2'), ('fcd49872-3917-4a18-98f9-3f5acfe3fde',
                                     'fcd49872-3917-4a18-98f9-3f5acfe3fdd'),
        ('bb:aa:aa:aa:aa:aa', 'bb:aa:aa:aa:aa:cc')):
        release = {
            'name':
            release_name,
            'version':
            env_version,
            'operating_system':
            'ubuntu',
            'state':
            'available',
            'networks_metadata':
            '{}',
            'attributes_metadata':
            jsonutils.dumps(ATTRIBUTES_METADATA),
            'deployment_tasks':
            '{}',
            'roles':
            jsonutils.dumps([
                'controller',
                'compute',
                'virt',
                'compute-vmware',
                'ironic',
                'cinder',
                'cinder-block-device',
                'cinder-vmware',
                'ceph-osd',
                'mongo',
                'base-os',
            ]),
            'roles_metadata':
            jsonutils.dumps({
                'controller': {
                    'name': 'Controller',
                },
                'compute': {
                    'name': 'Compute',
                },
                'virt': {
                    'name': 'Virtual',
                },
                'compute-vmware': {
                    'name': 'Compute VMware',
                },
                'ironic': {
                    'name': 'Ironic',
                },
                'cinder': {
                    'name': 'Cinder',
                },
                'cinder-block-device': {
                    'name': 'Cinder Block Device',
                },
                'cinder-vmware': {
                    'name': 'Cinder Proxy to VMware Datastore',
                },
                'ceph-osd': {
                    'name': 'Ceph OSD',
                },
                'mongo': {
                    'name': 'Telemetry - MongoDB',
                },
                'base-os': {
                    'name': 'Operating System',
                }
            }),
            'is_deployable':
            True,
            'vmware_attributes_metadata':
            jsonutils.dumps(VMWARE_ATTRIBUTES_METADATA)
        }
        result = db.execute(meta.tables['releases'].insert(), [release])
        release_id = result.inserted_primary_key[0]

        result = db.execute(meta.tables['clusters'].insert(),
                            [{
                                'name': cluster_name,
                                'release_id': release_id,
                                'mode': 'ha_compact',
                                'status': 'new',
                                'net_provider': 'neutron',
                                'grouping': 'roles',
                                'fuel_version': '9.0',
                                'deployment_tasks': '{}'
                            }])

        cluster_id = result.inserted_primary_key[0]
        editable = ATTRIBUTES_METADATA.get('editable', {})
        db.execute(meta.tables['attributes'].insert(),
                   [{
                       'cluster_id': cluster_id,
                       'editable': jsonutils.dumps(editable)
                   }])
        db.execute(meta.tables['nodes'].insert(), [{
            'uuid':
            uuid,
            'cluster_id':
            cluster_id,
            'group_id':
            None,
            'status':
            'ready',
            'roles': ['controller', 'ceph-osd'],
            'primary_roles': ['controller'],
            'meta':
            jsonutils.dumps({'interfaces': [{
                'mac': '00:00:00:00:00:01'
            }]}),
            'mac':
            mac,
            'timestamp':
            datetime.datetime.utcnow(),
        }])

    node_interface_properties = copy.deepcopy(NODE_NIC_PROPERTIES)
    node_interface_properties['dpdk'].pop('available')
    result = db.execute(meta.tables['nodes'].insert(), [{
        'uuid':
        'fcd49872-3917-4a18-98f9-3f5acfe3fdec',
        'cluster_id':
        cluster_id,
        'group_id':
        None,
        'status':
        'ready',
        'roles': ['controller', 'ceph-osd'],
        'meta':
        jsonutils.dumps({
            'interfaces': [{
                'name': 'test_nic_empty_attributes',
                'mac': '00:00:00:00:00:01',
                'interface_properties': {}
            }, {
                'name': 'test_nic_attributes',
                'mac': '00:00:00:00:00:02',
                'interface_properties': node_interface_properties,
                'offloading_modes': NODE_OFFLOADING_MODES
            }, {
                'name':
                'test_nic_attributes_2',
                'mac':
                '00:00:00:00:00:03',
                'interface_properties':
                node_interface_properties,
                'offloading_modes': [{
                    'state':
                    True,
                    'name':
                    'tx-checksumming',
                    'sub': [{
                        'state': False,
                        'name': 'tx-checksum-sctp',
                        'sub': []
                    }]
                }, {
                    'state': True,
                    'name': 'rx-checksumming',
                    'sub': []
                }, {
                    'state': False,
                    'name': 'rx-vlan-offload',
                    'sub': []
                }]
            }]
        }),
        'mac':
        'bb:bb:aa:aa:aa:aa',
        'timestamp':
        datetime.datetime.utcnow(),
        'hostname':
        'test_node'
    }])
    node_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'active-backup',
            'bond_properties': jsonutils.dumps({'test_property': 'test_value'})
        }])

    bond = db.execute(meta.tables['node_bond_interfaces'].insert(), [{
        'node_id':
        node_id,
        'name':
        'test_bond_interface_attributes',
        'mode':
        '802.3ad',
        'bond_properties':
        jsonutils.dumps({
            'lacp_rate': 'slow',
            'type__': 'linux',
            'mode': '802.3ad',
            'xmit_hash_policy': 'layer2'
        }),
        'interface_properties':
        jsonutils.dumps({
            'mtu': 2000,
            'disable_offloading': False,
            'dpdk': {
                'available': True,
                'enabled': True
            }
        })
    }])
    bond_id = bond.inserted_primary_key[0]

    db.execute(meta.tables['node_nic_interfaces'].insert(),
               [{
                   'node_id': node_id,
                   'name': 'test_nic_empty_attributes',
                   'mac': '00:00:00:00:00:01',
                   'interface_properties': "{}",
                   'offloading_modes': "[]"
               }])

    changed_offloading_modes = copy.deepcopy(NODE_OFFLOADING_MODES)
    changed_offloading_modes[0]['state'] = False
    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': node_id,
            'parent_id': bond_id,
            'name': 'test_nic_attributes',
            'mac': '00:00:00:00:00:02',
            'interface_properties': jsonutils.dumps(NODE_NIC_PROPERTIES),
            'offloading_modes': jsonutils.dumps(changed_offloading_modes)
        }])

    db.execute(meta.tables['node_nic_interfaces'].insert(), [{
        'node_id':
        node_id,
        'parent_id':
        bond_id,
        'name':
        'test_nic_attributes_2',
        'mac':
        '00:00:00:00:00:03',
        'interface_properties':
        jsonutils.dumps(NODE_NIC_PROPERTIES),
        'offloading_modes':
        jsonutils.dumps(
            [{
                'state': True,
                'name': 'tx-checksumming',
                'sub': [{
                    'state': True,
                    'name': 'tx-checksum-sctp',
                    'sub': []
                }]
            }, {
                'state': True,
                'name': 'rx-checksumming',
                'sub': []
            }, {
                'state': False,
                'name': 'rx-vlan-offload',
                'sub': []
            }])
    }])

    db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_tags',
        'title':
        'Test tags plugin',
        'version':
        '2.0.0',
        'description':
        'Test plugin A for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'deployment_tasks':
        jsonutils.dumps([]),
        'fuel_version':
        jsonutils.dumps(['9.2']),
        'network_roles_metadata':
        jsonutils.dumps([]),
        'roles_metadata':
        jsonutils.dumps({
            'plugin-tags-controller': {
                'name': 'Plugin Tags Controller',
            },
        }),
    }])

    db.commit()
Пример #47
0
def prepare():
    meta = base.reflect_db_metadata()
    attrs_with_sec_group = deepcopy(ATTRIBUTES_METADATA)
    attrs_with_sec_group.setdefault('editable', {}).setdefault(
        'common', {}).setdefault('security_groups', SECURITY_GROUPS)
    plugin = {
        'name': 'Test_P',
        'version': '3.0.0',
        'title': 'Test Plugin',
        'package_version': '5.0.0',
        'roles_metadata': jsonutils.dumps(PLUGIN_ROLE_META),
        'tags_metadata': jsonutils.dumps(PLUGIN_TAGS_META)
    }
    result = db.execute(meta.tables['plugins'].insert(), [plugin])

    for release_name, env_version, cluster_name, attrs in zip(
            ('release_1', 'release_2', 'release_3'),
            ('mitaka-9.0', 'liberty-8.0', 'mitaka-9.0'),
            ('cluster_1', 'cluster_2', 'cluster_3'),
            (ATTRIBUTES_METADATA, ATTRIBUTES_METADATA, attrs_with_sec_group)
    ):
        release = {
            'name': release_name,
            'version': env_version,
            'operating_system': 'ubuntu',
            'state': 'available',
            'deployment_tasks': '[]',
            'roles_metadata': jsonutils.dumps(ROLES_META),
            'tags_matadata': jsonutils.dumps(TAGS_META),
            'is_deployable': True,
            'networks_metadata': '{}',
            'attributes_metadata': jsonutils.dumps(attrs)
        }
        result = db.execute(meta.tables['releases'].insert(), [release])
        release_id = result.inserted_primary_key[0]

        result = db.execute(
            meta.tables['clusters'].insert(),
            [{
                'name': cluster_name,
                'release_id': release_id,
                'mode': 'ha_compact',
                'status': 'new',
                'net_provider': 'neutron',
                'grouping': 'roles',
                'fuel_version': '9.0',
                'deployment_tasks': '[]',
                'roles_metadata': jsonutils.dumps(ROLES_META),
                'tags_metadata': '{}',
            }])

        cluster_id = result.inserted_primary_key[0]
        editable = attrs.get('editable', {})
        db.execute(
            meta.tables['attributes'].insert(),
            [{
                'cluster_id': cluster_id,
                'editable': jsonutils.dumps(editable)
            }]
        )

    db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': 'fcd49872-3917-4a18-98f9-3f5acfe3fdec',
            'cluster_id': cluster_id,
            'group_id': None,
            'status': 'ready',
            'roles': ['role_x', 'role_y'],
            'primary_tags': ['role_y', 'test'],
            'meta': '{}',
            'mac': 'bb:aa:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow(),
        }]
    )

    new_node = db.execute(
        meta.tables['nodes'].insert(),
        [{
            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765481',
            'cluster_id': None,
            'group_id': None,
            'status': 'discover',
            'mac': 'aa:aa:aa:aa:aa:aa',
            'timestamp': datetime.datetime.utcnow()
        }]
    )
    node_id = new_node.inserted_primary_key[0]

    bond_interface = db.execute(
        meta.tables['node_bond_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_bond_interface',
            'mode': 'balance-tlb',
            'attributes': jsonutils.dumps({
                'lacp_rate': {'value': {'value': ''}},
                'xmit_hash_policy': {'value': {'value': 'layer2'}},
                'offloading': {
                    'disable': {'value': True},
                    'modes': {'value': {'tx-checksumming': None,
                                        'tx-checksum-sctp': None}}
                },
                'mtu': {'value': {'value': 50}},
                'lacp': {'value': {'value': ''}},
                'mode': {'value': {'value': 'balance-tlb'}},
                'type__': {'value': 'linux'},
                'dpdk': {'enabled': {'value': False}}
            })
        }]
    )
    bond_id = bond_interface.inserted_primary_key[0]

    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_nic_empty_attributes',
            'mac': '00:00:00:00:00:01',
            'attributes': jsonutils.dumps({}),
            'meta': jsonutils.dumps({})
        }]
    )
    db.execute(
        meta.tables['node_nic_interfaces'].insert(),
        [{
            'node_id': node_id,
            'name': 'test_nic_attributes',
            'parent_id': bond_id,
            'mac': '00:00:00:00:00:01',
            'attributes': jsonutils.dumps({
                'offloading': {
                    'disable': {'value': 'test_disable_offloading'},
                    'modes': {
                        'value': {
                            'tx-checksum-ipv4': 'IPV4_STATE',
                            'tx-checksumming': 'TX_STATE',
                            'rx-checksumming': 'RX_STATE',
                            'tx-checksum-ipv6': 'IPV6_STATE'
                        }
                    }
                },
                'mtu': {
                    'value': {'value': 'test_mtu'}
                },
                'sriov': {
                    'numvfs': {'value': 'test_sriov_numfs'},
                    'enabled': {'value': 'test_sriov_enabled'},
                    'physnet': {'value': 'test_sriov_physnet'}
                },
                'dpdk': {
                    'enabled': {'value': 'test_dpdk_enabled'}
                }
            }),
            'meta': jsonutils.dumps({
                'offloading_modes': [{
                    'state': None,
                    'name': 'tx-checksumming',
                    'sub': [
                        {'state': False, 'name': 'tx-checksum-sctp',
                         'sub': []},
                        {'state': None, 'name': 'tx-checksum-ipv6',
                         'sub': []},
                        {'state': None, 'name': 'tx-checksum-ipv4',
                         'sub': []}
                    ]
                }, {
                    'state': None, 'name': 'rx-checksumming', 'sub': []
                }],
                'numa_node': 12345,
                'pci_id': 'test_pci_id',
                'sriov': {
                    'available': 'test_sriov_available',
                    'totalvfs': 6789,
                    'pci_id': 'test_sriov_pci_id'
                },
                'dpdk': {'available': True}
            })
        }]
    )

    db.commit()
def prepare():
    meta = base.reflect_db_metadata()

    result = db.execute(meta.tables['releases'].insert(), [{
        'name':
        'test_name',
        'vmware_attributes_metadata':
        'test_meta',
        'version':
        '2015.1-10.0',
        'operating_system':
        'ubuntu',
        'state':
        'available',
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'roles':
        jsonutils.dumps([
            'controller',
            'compute',
            'virt',
            'compute-vmware',
            'ironic',
            'cinder',
            'cinder-block-device',
            'cinder-vmware',
            'ceph-osd',
            'mongo',
            'base-os',
        ]),
        'roles_metadata':
        jsonutils.dumps({
            'controller': {
                'name': 'Controller',
            },
            'compute': {
                'name': 'Compute',
            },
            'virt': {
                'name': 'Virtual',
            },
            'compute-vmware': {
                'name': 'Compute VMware',
            },
            'ironic': {
                'name': 'Ironic',
            },
            'cinder': {
                'name': 'Cinder',
            },
            'cinder-block-device': {
                'name': 'Cinder Block Device',
            },
            'cinder-vmware': {
                'name': 'Cinder Proxy to VMware Datastore',
            },
            'ceph-osd': {
                'name': 'Ceph OSD',
            },
            'mongo': {
                'name': 'Telemetry - MongoDB',
            },
            'base-os': {
                'name': 'Operating System',
            }
        }),
        'is_deployable':
        True
    }])

    release_id = result.inserted_primary_key[0]

    cluster_ids = []
    for cluster_name in ['test_env1', 'test_env2']:
        result = db.execute(meta.tables['clusters'].insert(),
                            [{
                                'name': cluster_name,
                                'release_id': release_id,
                                'mode': 'ha_compact',
                                'status': 'new',
                                'net_provider': 'neutron',
                                'grouping': 'roles',
                                'fuel_version': '10.0',
                                'deployment_tasks': jsonutils.dumps(JSON_TASKS)
                            }])
        cluster_ids.append(result.inserted_primary_key[0])

    result = db.execute(meta.tables['nodes'].insert(),
                        [{
                            'uuid': '26b508d0-0d76-4159-bce9-f67ec2765480',
                            'cluster_id': None,
                            'group_id': None,
                            'status': 'discover',
                            'meta': '{}',
                            'mac': 'aa:aa:aa:aa:aa:aa',
                            'timestamp': datetime.datetime.utcnow(),
                        }])
    node_id = result.inserted_primary_key[0]

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_a',
        'title':
        'Test plugin A',
        'version':
        '2.0.0',
        'description':
        'Test plugin A for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'deployment_tasks':
        jsonutils.dumps(JSON_TASKS),
        'fuel_version':
        jsonutils.dumps(['10.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip1',
                    'namespace': 'my-namespace1',
                }, {
                    'name': 'my-vip2',
                    'namespace': 'my-namespace2',
                }]
            }
        }])
    }])
    plugin_a_id = result.inserted_primary_key[0]

    result = db.execute(meta.tables['plugins'].insert(), [{
        'name':
        'test_plugin_b',
        'title':
        'Test plugin B',
        'version':
        '2.0.0',
        'description':
        'Test plugin B for Fuel',
        'homepage':
        'http://fuel_plugins.test_plugin.com',
        'package_version':
        '5.0.0',
        'groups':
        jsonutils.dumps(['tgroup']),
        'authors':
        jsonutils.dumps(['tauthor']),
        'licenses':
        jsonutils.dumps(['tlicense']),
        'releases':
        jsonutils.dumps([{
            'repository_path': 'repositories/ubuntu'
        }]),
        'fuel_version':
        jsonutils.dumps(['10.0']),
        'network_roles_metadata':
        jsonutils.dumps([{
            'id': 'admin/vip',
            'default_mapping': 'fuelweb_admin',
            'properties': {
                'subnet':
                True,
                'gateway':
                False,
                'vip': [{
                    'name': 'my-vip3',
                    'namespace': 'my-namespace3',
                }, {
                    'name': 'my-vip4',
                    'namespace': 'my-namespace4',
                }]
            }
        }])
    }])
    plugin_b_id = result.inserted_primary_key[0]

    db.execute(
        meta.tables['cluster_plugin_links'].insert(),
        [
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'cluster_id': cluster_ids[1],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            },
            # duplicate by URL but in another cluster, should
            # not be deleted
            {
                'cluster_id': cluster_ids[0],
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            }
        ])

    db.execute(meta.tables['cluster_plugins'].insert(),
               [{
                   'cluster_id': cluster_ids[0],
                   'plugin_id': plugin_a_id
               }, {
                   'cluster_id': cluster_ids[0],
                   'plugin_id': plugin_b_id
               }])

    db.execute(
        meta.tables['plugin_links'].insert(),
        [
            {
                'plugin_id': plugin_a_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description',
                'hidden': False
            },
            # this is duplicate, should be deleted during migration
            {
                'plugin_id': plugin_b_id,
                'title': 'title',
                'url': 'http://www.zzz.com',
                'description': 'description_duplicate',
                'hidden': False
            }
        ])

    db.execute(meta.tables['cluster_changes'].insert(),
               [{
                   'cluster_id': cluster_ids[0],
                   'node_id': node_id,
                   'name': 'networks',
                   'vmware_attributes': 'vmware_attributes'
               }])

    db.execute(meta.tables['vmware_attributes'].insert(),
               [{
                   'cluster_id': cluster_ids[0],
                   'editable': 'test_data'
               }])

    TestRequiredComponentTypesField.prepare(meta)
    db.commit()