本文整理汇总了Python中nailgun.objects.Node.get_network_manager方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get_network_manager方法的具体用法?Python Node.get_network_manager怎么用?Python Node.get_network_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Node
的用法示例。
在下文中一共展示了Node.get_network_manager方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mellanox_settings
# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node 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 = 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: add_vlan_interfaces
# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import get_network_manager [as 别名]
def add_vlan_interfaces(cls, node):
"""Assign fixed_interfaces and vlan_interface.
They should be equal.
"""
net_manager = Node.get_network_manager(node)
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
示例3: get_admin_ip_w_prefix
# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import get_network_manager [as 别名]
def get_admin_ip_w_prefix(node):
"""Getting admin ip and assign prefix from admin network."""
network_manager = Node.get_network_manager(node)
admin_ip = network_manager.get_admin_ip_for_node(node.id)
admin_ip = IPNetwork(admin_ip)
# Assign prefix from admin network
admin_net = IPNetwork(
network_manager.get_admin_network_group(node.id).cidr
)
admin_ip.prefixlen = admin_net.prefixlen
return str(admin_ip)
示例4: network_provider_cluster_attrs
# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import get_network_manager [as 别名]
def network_provider_cluster_attrs(cls, cluster):
"""Cluster attributes."""
attrs = {'quantum': True,
'quantum_settings': cls.neutron_attrs(cluster)}
if cluster.mode == 'multinode':
for node in cluster.nodes:
if cls._node_has_role_by_name(node, 'controller'):
net_manager = Node.get_network_manager(node)
mgmt_cidr = net_manager.get_node_network_by_netname(
node,
'management'
)['ip']
attrs['management_vip'] = mgmt_cidr.split('/')[0]
break
return attrs
示例5: generate_network_scheme
# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node import get_network_manager [as 别名]
def generate_network_scheme(cls, node):
attrs = super(NeutronNetworkDeploymentSerializer60, cls). \
generate_network_scheme(node)
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 = Node.get_network_manager(node)
other_nets = nm.get_networks_not_on_node(node)
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_node_network_by_netname(node, ngname)
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
示例6: generate_network_scheme
# 需要导入模块: from nailgun.objects import Node [as 别名]
# 或者: from nailgun.objects.Node 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 = Node.get_network_manager(node)
# 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