当前位置: 首页>>代码示例>>Python>>正文


Python Cluster.get_creds方法代码示例

本文整理汇总了Python中nailgun.objects.Cluster.get_creds方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.get_creds方法的具体用法?Python Cluster.get_creds怎么用?Python Cluster.get_creds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nailgun.objects.Cluster的用法示例。


在下文中一共展示了Cluster.get_creds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_external_network

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_creds [as 别名]
    def _generate_external_network(cls, cluster):
        public_cidr, public_gw = db().query(
            NetworkGroup.cidr,
            NetworkGroup.gateway
        ).filter_by(
            group_id=Cluster.get_default_group(cluster).id,
            name='public'
        ).first()

        return {
            "L3": {
                "subnet": public_cidr,
                "gateway": public_gw,
                "nameservers": [],
                "floating": utils.join_range(
                    cluster.network_config.floating_ranges[0]),
                "enable_dhcp": False
            },
            "L2": {
                "network_type": "flat",
                "segment_id": None,
                "router_ext": True,
                "physnet": "physnet1"
            },
            "tenant": Cluster.get_creds(cluster)['tenant']['value'],
            "shared": False
        }
开发者ID:anbangr,项目名称:fuel-web,代码行数:29,代码来源:neutron_serializers.py

示例2: generate_external_network

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_creds [as 别名]
    def generate_external_network(cls, cluster):
        floating_ranges = cluster.network_config.floating_ranges
        floating_iprange = netaddr.IPRange(floating_ranges[0][0], floating_ranges[0][1])

        floating_cidr, floating_gw = None, None
        networks = (
            db()
            .query(models.NetworkGroup.cidr, models.NetworkGroup.gateway)
            .join(models.NetworkGroup.nodegroup)
            .filter(models.NodeGroup.cluster_id == cluster.id)
        )
        for net in networks:
            if net[0] and floating_iprange in netaddr.IPNetwork(net[0]):
                floating_cidr, floating_gw = net[0], net[1]
                break

        return {
            "L3": {
                "subnet": floating_cidr,
                "gateway": floating_gw,
                "nameservers": [],
                "floating": cls.render_floating_ranges(floating_ranges),
                "enable_dhcp": False,
            },
            "L2": {"network_type": "flat", "segment_id": None, "router_ext": True, "physnet": "physnet1"},
            "tenant": Cluster.get_creds(cluster)["tenant"]["value"],
            "shared": False,
        }
开发者ID:ymkins,项目名称:fuel-web,代码行数:30,代码来源:neutron_serializers.py

示例3: test_get_auth_credentials

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_creds [as 别名]
    def test_get_auth_credentials(self):
        expected_username = "test"
        expected_password = "test"
        expected_tenant = "test"
        expected_auth_host = "0.0.0.0"
        expected_auth_url = "http://{0}:{1}/{2}/".format(
            expected_auth_host, settings.AUTH_PORT,
            settings.OPENSTACK_API_VERSION["keystone"])

        expected = (expected_username, expected_password, expected_tenant,
                    expected_auth_url)

        cluster = self.env.create_cluster(api=False)

        default_access_data = Cluster.get_creds(cluster)
        default_username = default_access_data["user"]["value"]
        default_password = default_access_data["password"]["value"]
        default_tenant = default_access_data["tenant"]["value"]

        expected_default = (default_username, default_password,
                            default_tenant, expected_auth_url)

        get_host_for_auth_path = ("nailgun.statistics.utils."
                                  "get_mgmt_ip_of_cluster_controller")

        def check_creds(updated_attrs, expected_creds):
            Cluster.update_attributes(cluster, updated_attributes)
            with patch(get_host_for_auth_path,
                       return_value=expected_auth_host):
                client_provider = helpers.ClientProvider(cluster)
                creds = client_provider.credentials

                self.assertEqual(expected_creds, creds)

        updated_attributes = {
            "editable": {
                "access": {
                    "user": {"value": default_username},
                    "password": {"value": default_password},
                    "tenant": {"value": default_tenant}
                }
            }
        }

        check_creds(updated_attributes, expected_default)

        updated_attributes = {
            "editable": {
                "workloads_collector": {
                    "user": {"value": expected_username},
                    "password": {"value": expected_password},
                    "tenant": {"value": expected_tenant}
                }
            }
        }

        check_creds(updated_attributes, expected)
开发者ID:thomasgoirand,项目名称:fuel-nailgun,代码行数:59,代码来源:test_client_provider.py

示例4: generate_external_network

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_creds [as 别名]
    def generate_external_network(
            cls, cluster, multiple_floating_ranges=False):
        floating_ranges = [
            netaddr.IPRange(r1, r2)
            for r1, r2 in cluster.network_config.floating_ranges
        ]

        floating_cidr, floating_gw = None, None
        networks = db().query(
            models.NetworkGroup.cidr,
            models.NetworkGroup.gateway
        ).join(
            models.NetworkGroup.nodegroup
        ).filter(
            models.NodeGroup.cluster_id == cluster.id
        )
        for net in networks:
            if net[0] and floating_ranges[0] in netaddr.IPNetwork(net[0]):
                floating_cidr, floating_gw = net[0], net[1]
                break

        if multiple_floating_ranges:
            floating_ranges_rendered = [
                utils.join_range(fr)
                for fr in cluster.network_config.floating_ranges]
        else:
            floating_ranges_rendered = utils.join_range(
                cluster.network_config.floating_ranges[0])

        external_network = {
            "L3": {
                "subnet": floating_cidr,
                "gateway": floating_gw,
                "nameservers": [],
                "floating": floating_ranges_rendered,
                "enable_dhcp": False
            },
            "L2": {
                "network_type": "flat",
                "segment_id": None,
                "router_ext": True,
                "physnet": "physnet1"
            },
            "tenant": Cluster.get_creds(cluster)['tenant']['value'],
            "shared": False
        }

        return external_network
开发者ID:ibelikov,项目名称:fuel-web,代码行数:50,代码来源:neutron_serializers.py

示例5: _generate_internal_network

# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_creds [as 别名]
 def _generate_internal_network(cls, cluster):
     return {
         "L3": {
             "subnet": cluster.network_config.internal_cidr,
             "gateway": cluster.network_config.internal_gateway,
             "nameservers": cluster.network_config.dns_nameservers,
             "floating": None,
             "enable_dhcp": True,
         },
         "L2": {
             "network_type": cluster.network_config.segmentation_type,
             "segment_id": None,
             "router_ext": False,
             "physnet": "physnet2" if cluster.network_config.segmentation_type == "vlan" else None,
         },
         "tenant": Cluster.get_creds(cluster)["tenant"]["value"],
         "shared": False,
     }
开发者ID:ymkins,项目名称:fuel-web,代码行数:20,代码来源:neutron_serializers.py


注:本文中的nailgun.objects.Cluster.get_creds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。