本文整理汇总了Python中nailgun.objects.Cluster.get_network_manager方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.get_network_manager方法的具体用法?Python Cluster.get_network_manager怎么用?Python Cluster.get_network_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Cluster
的用法示例。
在下文中一共展示了Cluster.get_network_manager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_from_cluster
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def remove_from_cluster(cls, instance):
Cluster.clear_pending_changes(
instance.cluster,
node_id=instance.id
)
Cluster.get_network_manager(
instance.cluster
).clear_assigned_networks(instance)
instance.cluster_id = None
instance.roles = instance.pending_roles = []
instance.reset_name_to_default()
db().flush()
db().refresh(instance)
示例2: remove_from_cluster
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def remove_from_cluster(cls, instance):
"""Remove Node from Cluster.
Also drops networks assignment for Node and clears both
roles and pending roles
:param instance: Node instance
:returns: None
"""
if instance.cluster:
Cluster.clear_pending_changes(
instance.cluster,
node_id=instance.id
)
netmanager = Cluster.get_network_manager(
instance.cluster
)
netmanager.clear_assigned_networks(instance)
netmanager.clear_bond_configuration(instance)
cls.update_roles(instance, [])
cls.update_pending_roles(instance, [])
cls.remove_replaced_params(instance)
instance.cluster_id = None
instance.group_id = None
instance.kernel_params = None
instance.primary_roles = []
instance.hostname = cls.default_slave_name(instance)
from nailgun.objects import OpenstackConfig
OpenstackConfig.disable_by_nodes([instance])
db().flush()
db().refresh(instance)
示例3: create
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def create(cls, data):
new_group = super(NodeGroup, cls).create(data)
try:
cluster = Cluster.get_by_uid(new_group.cluster_id)
nm = Cluster.get_network_manager(cluster)
nst = cluster.network_config.segmentation_type
# We have two node groups here when user adds the first custom
# node group.
if NodeGroupCollection.get_by_cluster_id(cluster.id).count() == 2:
nm.ensure_gateways_present_in_default_node_group(cluster)
nm.create_network_groups(
cluster, neutron_segment_type=nst, node_group_id=new_group.id,
set_all_gateways=True)
nm.create_admin_network_group(new_group.cluster_id, new_group.id)
except (
errors.OutOfVLANs,
errors.OutOfIPs,
errors.NoSuitableCIDR
) as exc:
db().delete(new_group)
raise errors.CannotCreate(exc.message)
db().flush()
db().refresh(cluster)
return new_group
示例4: remove_from_cluster
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def remove_from_cluster(cls, instance):
"""Remove Node from Cluster.
Also drops networks assignment for Node and clears both
roles and pending roles
:param instance: Node instance
:returns: None
"""
if instance.cluster:
Cluster.clear_pending_changes(
instance.cluster,
node_id=instance.id
)
netmanager = Cluster.get_network_manager(
instance.cluster
)
netmanager.clear_assigned_networks(instance)
netmanager.clear_bond_configuration(instance)
cls.update_roles(instance, [])
cls.update_pending_roles(instance, [])
cls.remove_replaced_params(instance)
instance.cluster_id = None
instance.group_id = None
instance.kernel_params = None
instance.reset_name_to_default()
db().flush()
db().refresh(instance)
示例5: mellanox_settings
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [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 = Cluster.get_network_manager(node.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, 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
示例6: mellanox_settings
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [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
示例7: network_provider_node_attrs
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def network_provider_node_attrs(cls, cluster, node):
"""Serialize node, then it will be merged with common attributes."""
nm = Cluster.get_network_manager(cluster)
networks = nm.get_node_networks(node)
node_attrs = {"network_scheme": cls.generate_network_scheme(node, networks)}
node_attrs = cls.mellanox_settings(node_attrs, cluster, networks)
return node_attrs
示例8: generate_network_scheme
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def generate_network_scheme(cls, node, networks):
attrs = super(NeutronNetworkDeploymentSerializer60, cls).generate_network_scheme(node, networks)
for item in attrs.get("transformations", ()):
if "tags" in item:
item["vlan_ids"] = item["tags"]
# Include information about all subnets that don't belong to this node.
# This is used during deployment to configure routes to all other
# networks in the environment.
nm = Cluster.get_network_manager(node.cluster)
other_nets = nm.get_networks_not_on_node(node, networks)
netgroup_mapping = [("storage", "br-storage"), ("management", "br-mgmt"), ("fuelweb_admin", "br-fw-admin")]
if Node.should_have_public(node):
netgroup_mapping.append(("public", "br-ex"))
for ngname, brname in netgroup_mapping:
netgroup = nm.get_network_by_netname(ngname, networks)
if netgroup.get("gateway"):
attrs["endpoints"][brname]["gateway"] = netgroup["gateway"]
attrs["endpoints"][brname]["other_nets"] = other_nets.get(ngname, [])
if Node.should_have_public(node):
attrs["endpoints"]["br-ex"]["default_gateway"] = True
else:
gw = nm.get_default_gateway(node.id)
attrs["endpoints"]["br-fw-admin"]["gateway"] = gw
attrs["endpoints"]["br-fw-admin"]["default_gateway"] = True
return attrs
示例9: reset_to_discover
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def reset_to_discover(cls, instance):
"""Flush database objects which is not consistent with actual node
configuration in the event of resetting node to discover state
:param instance: Node database object
:returns: None
"""
node_data = {
"online": False,
"status": consts.NODE_STATUSES.discover,
"pending_addition": True,
"pending_deletion": False,
}
cls.update(instance, node_data)
cls.move_roles_to_pending_roles(instance)
# when node reseted to discover:
# - cobbler system is deleted
# - mac to ip mapping from dnsmasq.conf is deleted
# imho we need to revert node to original state, as it was
# added to cluster (without any additonal state in database)
netmanager = Cluster.get_network_manager()
netmanager.clear_assigned_ips(instance)
fire_callback_on_node_reset(instance)
db().flush()
示例10: prepare_for_provisioning
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def prepare_for_provisioning(cls, instances):
"""Prepare environment for provisioning,
update fqdns, assign admin IPs
"""
cls.update_slave_nodes_fqdn(instances)
netmanager = Cluster.get_network_manager()
netmanager.assign_admin_ips(instances)
示例11: generate_network_scheme
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def generate_network_scheme(cls, node):
# create network scheme structure and fill it with static values
attrs = {
"version": "1.1",
"provider": "lnx",
"interfaces": {},
"endpoints": {},
"roles": {"fw-admin": "br-fw-admin", "storage": "br-storage", "management": "br-mgmt", "ex": "br-ex"},
}
netgroup_mapping = [
("fuelweb_admin", "br-fw-admin"),
("storage", "br-storage"),
("management", "br-mgmt"),
("public", "br-ex"),
("fixed", ""), # will be determined in code below
]
nm = Cluster.get_network_manager(node.cluster)
# populate IP address information to endpoints
netgroups = {}
nets_by_ifaces = defaultdict(list)
fixed_sub_iface = None
for ngname, brname in netgroup_mapping:
# Here we get a dict with network description for this particular
# node with its assigned IPs and device names for each network.
netgroup = nm.get_node_network_by_netname(node, ngname)
if ngname == "fixed":
vlan_id = None
if node.cluster.network_config.net_manager == consts.NOVA_NET_MANAGERS.FlatDHCPManager:
vlan_id = node.cluster.network_config.fixed_networks_vlan_start
net = {"vlan_id": vlan_id}
fixed_sub_iface = cls.subiface_name(netgroup["dev"], net)
attrs["endpoints"][fixed_sub_iface] = {"IP": "none"}
else:
nets_by_ifaces[netgroup["dev"]].append({"br_name": brname, "vlan_id": netgroup["vlan"]})
if netgroup.get("ip"):
attrs["endpoints"][brname] = {"IP": [netgroup["ip"]]}
netgroups[ngname] = netgroup
attrs["endpoints"]["br-ex"]["gateway"] = netgroups["public"]["gateway"]
# add manager-related roles
if node.cluster.network_config.net_manager == consts.NOVA_NET_MANAGERS.VlanManager:
attrs["roles"]["novanetwork/vlan"] = fixed_sub_iface
else:
attrs["roles"]["novanetwork/fixed"] = fixed_sub_iface
for iface in node.nic_interfaces:
if iface.bond:
attrs["interfaces"][iface.name] = {}
else:
attrs["interfaces"][iface.name] = nm.get_iface_properties(iface)
attrs["transformations"] = cls.generate_transformations(node, nm, nets_by_ifaces, fixed_sub_iface)
return attrs
示例12: _reassign_template_networks
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def _reassign_template_networks(cls, instance):
cluster = instance.nodegroup.cluster
if not cluster.network_config.configuration_template:
return
nm = Cluster.get_network_manager(cluster)
for node in cluster.nodes:
nm.assign_networks_by_template(node)
示例13: add_vlan_interfaces
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def add_vlan_interfaces(cls, node):
"""Assign fixed_interfaces and vlan_interface.
They should be equal.
"""
net_manager = Cluster.get_network_manager(node.cluster)
fixed_interface = net_manager._get_interface_by_network_name(node.id, "fixed")
attrs = {"fixed_interface": fixed_interface.name, "vlan_interface": fixed_interface.name}
return attrs
示例14: generate_network_metadata
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [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))
示例15: get_network_to_ip_mapping
# 需要导入模块: from nailgun.objects import Cluster [as 别名]
# 或者: from nailgun.objects.Cluster import get_network_manager [as 别名]
def get_network_to_ip_mapping(cls, node):
nm = Cluster.get_network_manager(node.cluster)
mapping = dict()
for net in cls.get_default_network_to_endpoint_mapping(node):
netgroup = nm.get_node_network_by_netname(node, net)
if netgroup.get('ip'):
mapping[net] = netgroup['ip'].split('/')[0]
return mapping