本文整理汇总了Python中nailgun.objects.Cluster.get_default_group方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.get_default_group方法的具体用法?Python Cluster.get_default_group怎么用?Python Cluster.get_default_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Cluster
的用法示例。
在下文中一共展示了Cluster.get_default_group方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_external_network
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_default_group [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()
join_range = lambda r: (":".join(map(str, r)) if r else None)
return {
"L3": {
"subnet": public_cidr,
"gateway": public_gw,
"nameservers": [],
"floating": join_range(
cluster.network_config.floating_ranges[0]),
"enable_dhcp": False
},
"L2": {
"network_type": "flat",
"segment_id": None,
"router_ext": True,
"physnet": "physnet1"
},
"tenant": objects.Cluster.get_creds(cluster)['tenant']['value'],
"shared": False
}
示例2: get_common_attrs
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_default_group [as 别名]
def get_common_attrs(cls, cluster, attrs):
"""Cluster network attributes."""
common = cls.network_provider_cluster_attrs(cluster)
common.update(
cls.network_ranges(Cluster.get_default_group(cluster).id))
common.update({'master_ip': settings.MASTER_IP})
common['nodes'] = deepcopy(attrs['nodes'])
# Addresses
for node in get_nodes_not_for_deletion(cluster):
netw_data = node.network_data
addresses = {}
for net in node.cluster.network_groups:
if net.name == 'public' and \
not objects.Node.should_have_public(node):
continue
if net.meta.get('render_addr_mask'):
addresses.update(cls.get_addr_mask(
netw_data,
net.name,
net.meta.get('render_addr_mask')))
[n.update(addresses) for n in common['nodes']
if n['uid'] == str(node.uid)]
return common
示例3: get_common_attrs
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_default_group [as 别名]
def get_common_attrs(cls, cluster, attrs):
"""Cluster network attributes."""
common = cls.network_provider_cluster_attrs(cluster)
common.update(cls.network_ranges(Cluster.get_default_group(cluster).id))
common.update({"master_ip": settings.MASTER_IP})
common["nodes"] = deepcopy(attrs["nodes"])
common["nodes"] = cls.update_nodes_net_info(cluster, common["nodes"])
return common
示例4: assign_group
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_default_group [as 别名]
def assign_group(cls, instance):
if instance.group_id is None and instance.ip:
admin_ngs = db().query(models.NetworkGroup).filter_by(name="fuelweb_admin")
ip = IPAddress(instance.ip)
for ng in admin_ngs:
if ip in IPNetwork(ng.cidr):
instance.group_id = ng.group_id
break
if not instance.group_id:
instance.group_id = Cluster.get_default_group(instance.cluster).id
db().add(instance)
db().flush()