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


Python Node.all_roles方法代码示例

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


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

示例1: generate_network_metadata

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import all_roles [as 别名]
    def generate_network_metadata(cls, cluster):
        nodes = dict()
        nm = Cluster.get_network_manager(cluster)

        for n in Cluster.get_nodes_not_for_deletion(cluster):
            name = Node.get_slave_name(n)
            node_roles = Node.all_roles(n)

            ip_by_net = {"fuelweb_admin": None, "storage": None, "management": None, "public": None}
            for net in ip_by_net:
                netgroup = nm.get_node_network_by_netname(n, net)
                if netgroup.get("ip"):
                    ip_by_net[net] = netgroup["ip"].split("/")[0]

            netw_roles = {
                "admin/pxe": ip_by_net["fuelweb_admin"],
                "fw-admin": ip_by_net["fuelweb_admin"],
                "keystone/api": ip_by_net["management"],
                "swift/api": ip_by_net["management"],
                "sahara/api": ip_by_net["management"],
                "ceilometer/api": ip_by_net["management"],
                "cinder/api": ip_by_net["management"],
                "glance/api": ip_by_net["management"],
                "heat/api": ip_by_net["management"],
                "nova/api": ip_by_net["management"],
                "murano/api": ip_by_net["management"],
                "horizon": ip_by_net["management"],
                "management": ip_by_net["management"],
                "mgmt/api": ip_by_net["management"],
                "mgmt/database": ip_by_net["management"],
                "mgmt/messaging": ip_by_net["management"],
                "mgmt/corosync": ip_by_net["management"],
                "mgmt/memcache": ip_by_net["management"],
                "mgmt/vip": ip_by_net["management"],
                "mongo/db": ip_by_net["management"],
                "ceph/public": ip_by_net["management"],
                "storage": ip_by_net["storage"],
                "ceph/replication": ip_by_net["storage"],
                "swift/replication": ip_by_net["storage"],
                "cinder/iscsi": ip_by_net["storage"],
                "ex": ip_by_net["public"],
                "public/vip": ip_by_net["public"],
                "ceph/radosgw": ip_by_net["public"],
            }

            nodes[name] = {
                "uid": n.uid,
                "fqdn": n.fqdn,
                "name": name,
                "user_node_name": n.name,
                "swift_zone": n.uid,
                "node_roles": node_roles,
                "network_roles": netw_roles,
            }

        return dict(nodes=nodes, vips=nm.assign_vips_for_net_groups(cluster))
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:58,代码来源:nova_serializers.py

示例2: generate_network_metadata

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import all_roles [as 别名]
    def generate_network_metadata(cls, cluster):
        nodes = dict()
        nm = Cluster.get_network_manager(cluster)

        for node in Cluster.get_nodes_not_for_deletion(cluster):
            name = Node.get_slave_name(node)
            node_roles = Node.all_roles(node)
            network_roles = cls.get_network_role_mapping_to_ip(node)

            nodes[name] = {
                "uid": node.uid,
                "fqdn": Node.get_node_fqdn(node),
                "name": name,
                "user_node_name": node.name,
                "swift_zone": node.uid,
                "node_roles": node_roles,
                "network_roles": network_roles,
            }

        return dict(nodes=nodes, vips=nm.assign_vips_for_net_groups(cluster))
开发者ID:ymkins,项目名称:fuel-web,代码行数:22,代码来源:neutron_serializers.py

示例3: generate_vmware_data

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import all_roles [as 别名]
    def generate_vmware_data(self, node):
        """Extend serialize data with vmware attributes
        """
        vmware_data = {}
        allowed_roles = ["controller", "primary-controller", "cinder-vmware"]
        all_roles = Node.all_roles(node)
        use_vcenter = node.cluster.attributes.editable.get("common", {}).get("use_vcenter", {}).get("value")

        if use_vcenter and any(role in allowed_roles for role in all_roles):
            compute_instances = []
            cinder_instances = []

            vmware_attributes = node.cluster.vmware_attributes.editable.get("value", {})
            availability_zones = vmware_attributes.get("availability_zones", {})
            glance_instance = vmware_attributes.get("glance", {})
            network = vmware_attributes.get("network", {})

            for zone in availability_zones:

                vc_user = self.escape_dollar(zone.get("vcenter_username", ""))
                vc_password = self.escape_dollar(zone.get("vcenter_password", ""))

                for compute in zone.get("nova_computes", {}):
                    datastore_regex = self.escape_dollar(compute.get("datastore_regex", ""))

                    compute_item = {
                        "availability_zone_name": zone.get("az_name", ""),
                        "vc_host": zone.get("vcenter_host", ""),
                        "vc_user": vc_user,
                        "vc_password": vc_password,
                        "service_name": compute.get("service_name", ""),
                        "vc_cluster": compute.get("vsphere_cluster", ""),
                        "datastore_regex": datastore_regex,
                    }

                    compute_instances.append(compute_item)

                cinder_item = {
                    "availability_zone_name": zone.get("az_name", ""),
                    "vc_host": zone.get("vcenter_host", ""),
                    "vc_user": vc_user,
                    "vc_password": vc_password,
                }
                cinder_instances.append(cinder_item)

            vmware_data["use_vcenter"] = True

            if compute_instances:
                vmware_data["vcenter"] = {
                    "esxi_vlan_interface": network.get("esxi_vlan_interface", ""),
                    "computes": compute_instances,
                }

            if cinder_instances:
                vmware_data["cinder"] = {"instances": cinder_instances}

            if glance_instance:
                glance_username = self.escape_dollar(glance_instance.get("vcenter_username", ""))
                glance_password = self.escape_dollar(glance_instance.get("vcenter_password", ""))

                vmware_data["glance"] = {
                    "vc_host": glance_instance.get("vcenter_host", ""),
                    "vc_user": glance_username,
                    "vc_password": glance_password,
                    "vc_datacenter": glance_instance.get("datacenter", ""),
                    "vc_datastore": glance_instance.get("datastore", ""),
                }

        return vmware_data
开发者ID:nebril,项目名称:fuel-web,代码行数:71,代码来源:base_serializers.py

示例4: generate_network_metadata

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import all_roles [as 别名]
    def generate_network_metadata(cls, cluster):
        nodes = dict()
        nm = Cluster.get_network_manager(cluster)

        for n in Cluster.get_nodes_not_for_deletion(cluster):
            name = Node.get_slave_name(n)
            node_roles = Node.all_roles(n)
            # Use permanent identifier as a node key
            key = Node.permanent_id(n)

            ip_by_net = {
                'fuelweb_admin': None,
                'storage': None,
                'management': None,
                'public': None
            }
            networks = nm.get_node_networks(n)
            for net in ip_by_net:
                netgroup = nm.get_network_by_netname(net, networks)
                if netgroup.get('ip'):
                    ip_by_net[net] = netgroup['ip'].split('/')[0]

            netw_roles = {
                'admin/pxe': ip_by_net['fuelweb_admin'],
                'fw-admin': ip_by_net['fuelweb_admin'],

                'keystone/api': ip_by_net['management'],
                'swift/api': ip_by_net['management'],
                'sahara/api': ip_by_net['management'],
                'ceilometer/api': ip_by_net['management'],
                'cinder/api': ip_by_net['management'],
                'glance/api': ip_by_net['management'],
                'heat/api': ip_by_net['management'],
                'nova/api': ip_by_net['management'],
                'murano/api': ip_by_net['management'],
                'horizon': ip_by_net['management'],

                'management': ip_by_net['management'],
                'mgmt/database': ip_by_net['management'],
                'mgmt/messaging': ip_by_net['management'],
                'mgmt/corosync': ip_by_net['management'],
                'mgmt/memcache': ip_by_net['management'],
                'mgmt/vip': ip_by_net['management'],

                'mongo/db': ip_by_net['management'],

                'ceph/public': ip_by_net['management'],

                'storage': ip_by_net['storage'],
                'ceph/replication': ip_by_net['storage'],
                'swift/replication': ip_by_net['storage'],
                'cinder/iscsi': ip_by_net['storage'],

                'ex': ip_by_net['public'],
                'public/vip': ip_by_net['public'],
                'ceph/radosgw': ip_by_net['public'],
            }

            nodes[key] = {
                "uid": n.uid,
                "fqdn": Node.get_node_fqdn(n),
                "name": name,
                "user_node_name": n.name,
                "swift_zone": n.uid,
                "node_roles": node_roles,
                "network_roles": netw_roles
            }

        return dict(
            nodes=nodes,
            vips=nm.assign_vips_for_net_groups(cluster)
        )
开发者ID:ekorekin,项目名称:fuel-web,代码行数:74,代码来源:nova_serializers.py

示例5: generate_vmware_data

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import all_roles [as 别名]
    def generate_vmware_data(self, node):
        """Extend serialize data with vmware attributes
        """
        vmware_data = {}
        allowed_roles = [
            'controller',
            'primary-controller',
            'compute-vmware',
            'cinder-vmware'
        ]

        all_roles = Node.all_roles(node)
        use_vcenter = node.cluster.attributes.editable.get('common', {}) \
            .get('use_vcenter', {}).get('value')

        if (use_vcenter and any(role in allowed_roles for role in all_roles)):
            compute_instances = []
            cinder_instances = []

            vmware_attributes = node.cluster.vmware_attributes.editable \
                .get('value', {})
            availability_zones = vmware_attributes \
                .get('availability_zones', {})
            glance_instance = vmware_attributes.get('glance', {})
            network = vmware_attributes.get('network', {})

            for zone in availability_zones:

                vc_user = self.escape_dollar(zone.get('vcenter_username', ''))
                vc_password = self.escape_dollar(zone.get('vcenter_password',
                                                          ''))

                for compute in zone.get('nova_computes', {}):
                    datastore_regex = \
                        self.escape_dollar(compute.get('datastore_regex', ''))

                    compute_item = {
                        'availability_zone_name': zone.get('az_name', ''),
                        'vc_host': zone.get('vcenter_host', ''),
                        'vc_user': vc_user,
                        'vc_password': vc_password,
                        'service_name': compute.get('service_name', ''),
                        'vc_cluster': compute.get('vsphere_cluster', ''),
                        'datastore_regex': datastore_regex,
                        'target_node': compute.get('target_node', {}).get(
                            'current', {}).get('id', 'controllers')
                    }

                    compute_instances.append(compute_item)

                cinder_item = {
                    'availability_zone_name': zone.get('az_name', ''),
                    'vc_host': zone.get('vcenter_host', ''),
                    'vc_user': vc_user,
                    'vc_password': vc_password
                }
                cinder_instances.append(cinder_item)

            vmware_data['use_vcenter'] = True

            if compute_instances:
                vmware_data['vcenter'] = {
                    'esxi_vlan_interface':
                    network.get('esxi_vlan_interface', ''),
                    'computes': compute_instances
                }

            if cinder_instances:
                vmware_data['cinder'] = {
                    'instances': cinder_instances
                }

            if glance_instance:
                glance_username = \
                    self.escape_dollar(glance_instance
                                       .get('vcenter_username', ''))
                glance_password = \
                    self.escape_dollar(glance_instance
                                       .get('vcenter_password', ''))

                vmware_data['glance'] = {
                    'vc_host': glance_instance.get('vcenter_host', ''),
                    'vc_user': glance_username,
                    'vc_password': glance_password,
                    'vc_datacenter': glance_instance.get('datacenter', ''),
                    'vc_datastore': glance_instance.get('datastore', '')
                }

        return vmware_data
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:91,代码来源:base_serializers.py

示例6: generate_network_metadata

# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import all_roles [as 别名]
    def generate_network_metadata(cls, cluster):
        nodes = dict()
        nm = Cluster.get_network_manager(cluster)

        for n in Cluster.get_nodes_not_for_deletion(cluster):
            name = Node.make_slave_name(n)
            node_roles = Node.all_roles(n)

            ip_by_net = {
                'fuelweb_admin': None,
                'storage': None,
                'management': None,
                'public': None
            }
            for net in ip_by_net:
                netgroup = nm.get_node_network_by_netname(n, net)
                if netgroup.get('ip'):
                    ip_by_net[net] = netgroup['ip'].split('/')[0]

            netw_roles = {
                'admin/pxe': ip_by_net['fuelweb_admin'],
                'fw-admin': ip_by_net['fuelweb_admin'],

                'keystone/api': ip_by_net['management'],
                'neutron/api': ip_by_net['management'],
                'swift/api': ip_by_net['management'],
                'sahara/api': ip_by_net['management'],
                'ceilometer/api': ip_by_net['management'],
                'cinder/api': ip_by_net['management'],
                'glance/api': ip_by_net['management'],
                'heat/api': ip_by_net['management'],
                'nova/api': ip_by_net['management'],
                'murano/api': ip_by_net['management'],
                'horizon': ip_by_net['management'],

                'management': ip_by_net['management'],
                'mgmt/api': ip_by_net['management'],
                'mgmt/database': ip_by_net['management'],
                'mgmt/messaging': ip_by_net['management'],
                'mgmt/corosync': ip_by_net['management'],
                'mgmt/memcache': ip_by_net['management'],
                'mgmt/vip': ip_by_net['management'],

                'mongo/db': ip_by_net['management'],

                'neutron/mesh': ip_by_net['management'],

                'ceph/public': ip_by_net['management'],

                'neutron/private': None,
                'neutron/floating': None,

                'storage': ip_by_net['storage'],
                'ceph/replication': ip_by_net['storage'],
                'swift/replication': ip_by_net['storage'],
                'cinder/iscsi': ip_by_net['storage'],

            }
            if Node.should_have_public(n):
                netw_roles.update({
                    'ex': ip_by_net['public'],
                    'public/vip': ip_by_net['public'],
                    'ceph/radosgw': ip_by_net['public'],
                })

            nodes[name] = {
                "uid": n.uid,
                "fqdn": n.fqdn,
                "name": name,
                "user_node_name": n.name,
                "swift_zone": n.uid,
                "node_roles": node_roles,
                "network_roles": netw_roles
            }

        return dict(
            nodes=nodes,
            vips=nm.assign_vips_for_net_groups(cluster)
        )
开发者ID:nebril,项目名称:fuel-web,代码行数:81,代码来源:neutron_serializers.py


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