本文整理汇总了Python中nailgun.objects.Cluster.get_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.get_attributes方法的具体用法?Python Cluster.get_attributes怎么用?Python Cluster.get_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Cluster
的用法示例。
在下文中一共展示了Cluster.get_attributes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mellanox_settings
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def mellanox_settings(cls, node_attrs, node):
"""Serialize mellanox node attrs, then it will be
merged with common attributes, if mellanox plugin or iSER storage
enabled.
"""
# Get Mellanox data
neutron_mellanox_data = \
Cluster.get_attributes(node.cluster).editable\
.get('neutron_mellanox', {})
# Get storage data
storage_data = \
Cluster.get_attributes(node.cluster).editable.get('storage', {})
# Get network manager
nm = objects.Node.get_network_manager(node)
# Init mellanox dict
node_attrs['neutron_mellanox'] = {}
# Find Physical port for VFs generation
if 'plugin' in neutron_mellanox_data and \
neutron_mellanox_data['plugin']['value'] == 'ethernet':
node_attrs = cls.set_mellanox_ml2_config(node_attrs, node, nm)
# Fix network scheme to have physical port for RDMA if iSER enabled
if 'iser' in storage_data and storage_data['iser']['value']:
node_attrs = cls.fix_iser_port(node_attrs, node, nm)
return node_attrs
示例2: mellanox_settings
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def mellanox_settings(cls, node_attrs, cluster, networks):
"""Mellanox settings
Serialize mellanox node attrsthen it will be
merged with common attributes, if mellanox plugin or iSER storage
enabled.
"""
# Get Mellanox data
neutron_mellanox_data = Cluster.get_attributes(cluster).editable.get("neutron_mellanox", {})
# Get storage data
storage_data = Cluster.get_attributes(cluster).editable.get("storage", {})
# Get network manager
nm = Cluster.get_network_manager(cluster)
# Init mellanox dict
node_attrs["neutron_mellanox"] = {}
# Find Physical port for VFs generation
if "plugin" in neutron_mellanox_data and neutron_mellanox_data["plugin"]["value"] == "ethernet":
node_attrs = cls.set_mellanox_ml2_config(node_attrs, nm, networks)
# Fix network scheme to have physical port for RDMA if iSER enabled
if "iser" in storage_data and storage_data["iser"]["value"]:
node_attrs = cls.fix_iser_port(node_attrs, nm, networks)
return node_attrs
示例3: generate_l2
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def generate_l2(cls, cluster):
join_range = lambda r: (":".join(map(str, r)) if r else None)
res = {
"base_mac": cluster.network_config.base_mac,
"segmentation_type": cluster.network_config.segmentation_type,
"phys_nets": {
"physnet1": {
"bridge": "br-ex",
"vlan_range": None
}
}
}
if cluster.network_config.segmentation_type == 'gre':
res["tunnel_id_ranges"] = join_range(
cluster.network_config.gre_id_range)
elif cluster.network_config.segmentation_type == 'vlan':
res["phys_nets"]["physnet2"] = {
"bridge": "br-prv",
"vlan_range": join_range(cluster.network_config.vlan_range)
}
# Set non-default ml2 configurations
attrs = Cluster.get_attributes(cluster).editable
if 'neutron_mellanox' in attrs and \
attrs['neutron_mellanox']['plugin']['value'] == 'ethernet':
res['mechanism_drivers'] = 'mlnx,openvswitch'
seg_type = cluster.network_config.segmentation_type
res['tenant_network_types'] = seg_type
res['type_drivers'] = '{0},flat,local'.format(seg_type)
return res
示例4: generate_l2
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def generate_l2(cls, cluster):
res = {
"base_mac": cluster.network_config.base_mac,
"segmentation_type": cluster.network_config.segmentation_type,
"phys_nets": {
"physnet1": {
"bridge": "br-ex",
"vlan_range": None
}
}
}
if cluster.network_config.segmentation_type in \
(consts.NEUTRON_SEGMENT_TYPES.gre,
consts.NEUTRON_SEGMENT_TYPES.tun):
res["tunnel_id_ranges"] = utils.join_range(
cluster.network_config.gre_id_range)
elif cluster.network_config.segmentation_type == \
consts.NEUTRON_SEGMENT_TYPES.vlan:
res["phys_nets"]["physnet2"] = {
"bridge": "br-prv",
"vlan_range": utils.join_range(
cluster.network_config.vlan_range)
}
# Set non-default ml2 configurations
attrs = Cluster.get_attributes(cluster).editable
if 'neutron_mellanox' in attrs and \
attrs['neutron_mellanox']['plugin']['value'] == 'ethernet':
res['mechanism_drivers'] = 'mlnx,openvswitch'
seg_type = cluster.network_config.segmentation_type
res['tenant_network_types'] = seg_type
res['type_drivers'] = '{0},flat,local'.format(seg_type)
return res
示例5: generate_l2
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def generate_l2(cls, cluster):
res = {
"base_mac": cluster.network_config.base_mac,
"segmentation_type": cluster.network_config.segmentation_type,
"phys_nets": {"physnet1": {"bridge": "br-ex", "vlan_range": None}},
}
if cluster.network_config.segmentation_type in (
consts.NEUTRON_SEGMENT_TYPES.gre,
consts.NEUTRON_SEGMENT_TYPES.tun,
):
res["tunnel_id_ranges"] = utils.join_range(cluster.network_config.gre_id_range)
elif cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan:
res["phys_nets"]["physnet2"] = {
"bridge": "br-prv",
"vlan_range": utils.join_range(cluster.network_config.vlan_range),
}
# Set non-default ml2 configurations
attrs = Cluster.get_attributes(cluster).editable
if "neutron_mellanox" in attrs and attrs["neutron_mellanox"]["plugin"]["value"] == "ethernet":
res["mechanism_drivers"] = "mlnx,openvswitch"
seg_type = cluster.network_config.segmentation_type
res["tenant_network_types"] = seg_type
res["type_drivers"] = "{0},flat,local".format(seg_type)
return res
示例6: generate_l3
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def generate_l3(cls, cluster):
l3 = {"use_namespaces": True}
attrs = Cluster.get_attributes(cluster).editable
if "nsx_plugin" in attrs and attrs["nsx_plugin"]["metadata"]["enabled"]:
dhcp_attrs = l3.setdefault("dhcp_agent", {})
dhcp_attrs["enable_isolated_metadata"] = True
dhcp_attrs["enable_metadata_network"] = True
return l3
示例7: generate_l3
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def generate_l3(cls, cluster):
l3 = {
"use_namespaces": True
}
attrs = Cluster.get_attributes(cluster).editable
if 'nsx_plugin' in attrs and \
attrs['nsx_plugin']['metadata']['enabled']:
dhcp_attrs = l3.setdefault('dhcp_agent', {})
dhcp_attrs['enable_isolated_metadata'] = True
dhcp_attrs['enable_metadata_network'] = True
return l3
示例8: neutron_attrs
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def neutron_attrs(cls, cluster):
"""Network configuration for Neutron."""
attrs = {}
attrs['L3'] = cls.generate_l3(cluster)
attrs['L2'] = cls.generate_l2(cluster)
attrs['predefined_networks'] = \
cls.generate_predefined_networks(cluster)
if cluster.release.operating_system == 'RHEL':
attrs['amqp'] = {'provider': 'qpid-rh'}
cluster_attrs = Cluster.get_attributes(cluster).editable
if 'nsx_plugin' in cluster_attrs and \
cluster_attrs['nsx_plugin']['metadata']['enabled']:
attrs['L2']['provider'] = 'nsx'
return attrs
示例9: neutron_attrs
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def neutron_attrs(cls, cluster):
"""Network configuration for Neutron
"""
nm = objects.Cluster.get_network_manager(cluster)
attrs = {}
attrs['L3'] = nm.generate_l3(cluster)
attrs['L2'] = nm.generate_l2(cluster)
attrs['predefined_networks'] = nm.generate_predefined_networks(cluster)
if cluster.release.operating_system == 'RHEL':
attrs['amqp'] = {'provider': 'qpid-rh'}
cluster_attrs = Cluster.get_attributes(cluster).editable
if 'nsx_plugin' in cluster_attrs and \
cluster_attrs['nsx_plugin']['metadata']['enabled']:
server_attrs = attrs.setdefault('server', {})
server_attrs['core_plugin'] = 'vmware'
return attrs
示例10: neutron_attrs
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_attributes [as 别名]
def neutron_attrs(cls, cluster):
"""Network configuration for Neutron."""
internal_name = cluster.network_config.internal_name
floating_name = cluster.network_config.floating_name
attrs = {
"L3": cls.generate_l3(cluster),
"L2": cls.generate_l2(cluster),
"predefined_networks": cls.generate_predefined_networks(cluster),
"default_private_net": internal_name,
"default_floating_net": floating_name,
}
if cluster.release.operating_system == "RHEL":
attrs["amqp"] = {"provider": "qpid-rh"}
cluster_attrs = Cluster.get_attributes(cluster).editable
if "nsx_plugin" in cluster_attrs and cluster_attrs["nsx_plugin"]["metadata"]["enabled"]:
attrs["L2"]["provider"] = "nsx"
return attrs