def test_network_configuration(self):
        info = InstallationInfo()
        # Checking nova network configuration
        nova = consts.CLUSTER_NET_PROVIDERS.nova_network
        self.env.create(cluster_kwargs={
            'mode': consts.CLUSTER_MODES.ha_full,
            'net_provider': nova
        })
        clusters_info = info.get_clusters_info()
        cluster_info = clusters_info[0]
        self.assertTrue('network_configuration' in cluster_info)
        network_config = cluster_info['network_configuration']

        for field in ('fixed_network_size', 'fixed_networks_vlan_start',
                      'fixed_networks_amount', 'net_manager'):
            self.assertIn(field, network_config)

        # Checking neutron network configuration
        neutron = consts.CLUSTER_NET_PROVIDERS.neutron
        self.env.create(cluster_kwargs={
            'mode': consts.CLUSTER_MODES.ha_full,
            'net_provider': neutron
        })
        clusters_info = info.get_clusters_info()
        # Clusters info is unordered list, so we should find required
        # cluster_info
        cluster_info = filter(lambda x: x['net_provider'] == neutron,
                              clusters_info)[0]
        self.assertTrue('network_configuration' in cluster_info)
        network_config = cluster_info['network_configuration']

        for field in ('segmentation_type', 'net_l23_provider'):
            self.assertIn(field, network_config)
    def test_network_configuration(self):
        info = InstallationInfo()
        # Checking nova network configuration
        nova = consts.CLUSTER_NET_PROVIDERS.nova_network
        self.env.create(cluster_kwargs={
            'mode': consts.CLUSTER_MODES.ha_compact,
            'net_provider': nova
        })
        clusters_info = info.get_clusters_info()
        cluster_info = clusters_info[0]
        self.assertTrue('network_configuration' in cluster_info)
        network_config = cluster_info['network_configuration']

        for field in ('fixed_network_size', 'fixed_networks_vlan_start',
                      'fixed_networks_amount', 'net_manager'):
            self.assertIn(field, network_config)

        # Checking neutron network configuration
        neutron = consts.CLUSTER_NET_PROVIDERS.neutron
        self.env.create(cluster_kwargs={
            'mode': consts.CLUSTER_MODES.ha_compact,
            'net_provider': neutron
        })
        clusters_info = info.get_clusters_info()
        # Clusters info is unordered list, so we should find required
        # cluster_info
        cluster_info = filter(lambda x: x['net_provider'] == neutron,
                              clusters_info)[0]
        self.assertTrue('network_configuration' in cluster_info)
        network_config = cluster_info['network_configuration']

        for field in ('segmentation_type', 'net_l23_provider'):
            self.assertIn(field, network_config)
    def test_network_configuration(self):
        info = InstallationInfo()
        # Checking nova network configuration
        nova = consts.CLUSTER_NET_PROVIDERS.nova_network
        self.env.create(cluster_kwargs={"mode": consts.CLUSTER_MODES.ha_compact, "net_provider": nova})
        clusters_info = info.get_clusters_info()
        cluster_info = clusters_info[0]
        self.assertTrue("network_configuration" in cluster_info)
        network_config = cluster_info["network_configuration"]

        for field in ("fixed_network_size", "fixed_networks_vlan_start", "fixed_networks_amount", "net_manager"):
            self.assertIn(field, network_config)

        # Checking neutron network configuration
        neutron = consts.CLUSTER_NET_PROVIDERS.neutron
        self.env.create(cluster_kwargs={"mode": consts.CLUSTER_MODES.ha_compact, "net_provider": neutron})
        clusters_info = info.get_clusters_info()
        # Clusters info is unordered list, so we should find required
        # cluster_info
        cluster_info = filter(lambda x: x["net_provider"] == neutron, clusters_info)[0]
        self.assertTrue("network_configuration" in cluster_info)
        network_config = cluster_info["network_configuration"]

        for field in ("segmentation_type", "net_l23_provider"):
            self.assertIn(field, network_config)
    def test_clusters_info(self):
        self.env.upload_fixtures(['openstack'])
        info = InstallationInfo()
        release = ReleaseCollection.filter_by(
            None, operating_system=consts.RELEASE_OS.ubuntu)
        nodes_params = [
            {'roles': ['compute']},
            {'roles': ['compute']},
            {'roles': ['controller']}
        ]
        cluster = self.env.create(
            cluster_kwargs={
                'release_id': release[0].id,
                'mode': consts.CLUSTER_MODES.ha_compact,
                'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron},
            nodes_kwargs=nodes_params
        )
        self.env.create_node(
            {'status': consts.NODE_STATUSES.discover})
        clusters_info = info.get_clusters_info()
        self.assertEquals(1, len(clusters_info))
        cluster_info = clusters_info[0]

        self.assertEquals(len(nodes_params), len(cluster_info['nodes']))
        self.assertEquals(len(nodes_params), cluster_info['nodes_num'])

        self.assertEquals(consts.CLUSTER_MODES.ha_compact,
                          cluster_info['mode'])
        self.assertEquals(consts.CLUSTER_NET_PROVIDERS.neutron,
                          cluster_info['net_provider'])
        self.assertEquals(consts.CLUSTER_STATUSES.new,
                          cluster_info['status'])
        self.assertEquals(False,
                          cluster_info['is_customized'])

        self.assertEquals(cluster['id'],
                          cluster_info['id'])
        self.assertEquals(cluster.fuel_version,
                          cluster_info['fuel_version'])

        self.assertTrue('attributes' in cluster_info)

        self.assertTrue('release' in cluster_info)
        self.assertEquals(cluster.release.operating_system,
                          cluster_info['release']['os'])
        self.assertEquals(cluster.release.name,
                          cluster_info['release']['name'])
        self.assertEquals(cluster.release.version,
                          cluster_info['release']['version'])

        self.assertEquals(1, len(cluster_info['node_groups']))
        group_info = cluster_info['node_groups'][0]
        group = [ng for ng in cluster.node_groups][0]
        self.assertEquals(group.id,
                          group_info['id'])
        self.assertEquals(len(nodes_params),
                          len(group_info['nodes']))
        self.assertEquals(set([n.id for n in group.nodes]),
                          set(group_info['nodes']))
    def test_clusters_info(self):
        self.env.upload_fixtures(['openstack'])
        info = InstallationInfo()
        release = ReleaseCollection.filter_by(
            None, operating_system=consts.RELEASE_OS.ubuntu)
        nodes_params = [
            {'roles': ['compute']},
            {'roles': ['compute']},
            {'roles': ['controller']}
        ]
        cluster = self.env.create(
            cluster_kwargs={
                'release_id': release[0].id,
                'mode': consts.CLUSTER_MODES.ha_compact,
                'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron},
            nodes_kwargs=nodes_params
        )
        self.env.create_node(
            {'status': consts.NODE_STATUSES.discover})
        clusters_info = info.get_clusters_info()
        self.assertEquals(1, len(clusters_info))
        cluster_info = clusters_info[0]

        self.assertEquals(len(nodes_params), len(cluster_info['nodes']))
        self.assertEquals(len(nodes_params), cluster_info['nodes_num'])

        self.assertEquals(consts.CLUSTER_MODES.ha_compact,
                          cluster_info['mode'])
        self.assertEquals(consts.CLUSTER_NET_PROVIDERS.neutron,
                          cluster_info['net_provider'])
        self.assertEquals(consts.CLUSTER_STATUSES.new,
                          cluster_info['status'])
        self.assertEquals(False,
                          cluster_info['is_customized'])

        self.assertEquals(cluster['id'],
                          cluster_info['id'])
        self.assertEquals(cluster.fuel_version,
                          cluster_info['fuel_version'])

        self.assertTrue('attributes' in cluster_info)

        self.assertTrue('release' in cluster_info)
        self.assertEquals(cluster.release.operating_system,
                          cluster_info['release']['os'])
        self.assertEquals(cluster.release.name,
                          cluster_info['release']['name'])
        self.assertEquals(cluster.release.version,
                          cluster_info['release']['version'])

        self.assertEquals(1, len(cluster_info['node_groups']))
        group_info = cluster_info['node_groups'][0]
        group = [ng for ng in cluster.node_groups][0]
        self.assertEquals(group.id,
                          group_info['id'])
        self.assertEquals(len(nodes_params),
                          len(group_info['nodes']))
        self.assertEquals(set([n.id for n in group.nodes]),
                          set(group_info['nodes']))
    def test_clusters_info(self):
        self.env.upload_fixtures(["openstack"])
        info = InstallationInfo()
        release = ReleaseCollection.filter_by(None, operating_system=consts.RELEASE_OS.ubuntu)
        nodes_params = [{"roles": ["compute"]}, {"roles": ["compute"]}, {"roles": ["controller"]}]
        self.env.create(
            cluster_kwargs={
                "release_id": release[0].id,
                "mode": consts.CLUSTER_MODES.ha_compact,
                "net_provider": consts.CLUSTER_NET_PROVIDERS.nova_network,
            },
            nodes_kwargs=nodes_params,
        )
        self.env.create_node({"status": consts.NODE_STATUSES.discover})
        clusters_info = info.get_clusters_info()
        cluster = self.env.clusters[0]
        self.assertEquals(1, len(clusters_info))
        cluster_info = clusters_info[0]

        self.assertEquals(len(nodes_params), len(cluster_info["nodes"]))
        self.assertEquals(len(nodes_params), cluster_info["nodes_num"])

        self.assertEquals(consts.CLUSTER_MODES.ha_compact, cluster_info["mode"])
        self.assertEquals(consts.CLUSTER_NET_PROVIDERS.nova_network, cluster_info["net_provider"])
        self.assertEquals(consts.CLUSTER_STATUSES.new, cluster_info["status"])
        self.assertEquals(False, cluster_info["is_customized"])

        self.assertEquals(cluster.id, cluster_info["id"])
        self.assertEquals(cluster.fuel_version, cluster_info["fuel_version"])

        self.assertTrue("attributes" in cluster_info)

        self.assertTrue("release" in cluster_info)
        self.assertEquals(cluster.release.operating_system, cluster_info["release"]["os"])
        self.assertEquals(cluster.release.name, cluster_info["release"]["name"])
        self.assertEquals(cluster.release.version, cluster_info["release"]["version"])

        self.assertEquals(1, len(cluster_info["node_groups"]))
        group_info = cluster_info["node_groups"][0]
        group = [ng for ng in cluster.node_groups][0]
        self.assertEquals(group.id, group_info["id"])
        self.assertEquals(len(nodes_params), len(group_info["nodes"]))
        self.assertEquals(set([n.id for n in group.nodes]), set(group_info["nodes"]))