本文整理汇总了Python中nailgun.network.manager.NetworkManager.get_admin_ips_for_interfaces方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.get_admin_ips_for_interfaces方法的具体用法?Python NetworkManager.get_admin_ips_for_interfaces怎么用?Python NetworkManager.get_admin_ips_for_interfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.network.manager.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.get_admin_ips_for_interfaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_admin_ip
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_admin_ips_for_interfaces [as 别名]
def get_admin_ip(cls, node):
"""Getting admin ip and assign prefix from admin network."""
network_manager = NetworkManager()
admin_ip = network_manager.get_admin_ips_for_interfaces(
node)[node.admin_interface.name]
admin_ip = IPNetwork(admin_ip)
# Assign prefix from admin network
admin_net = IPNetwork(network_manager.get_admin_network().cidr)
admin_ip.prefixlen = admin_net.prefixlen
return str(admin_ip)
示例2: serialize_interfaces
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_admin_ips_for_interfaces [as 别名]
def serialize_interfaces(cls, node):
interfaces = {}
interfaces_extra = {}
net_manager = NetworkManager()
admin_ips = net_manager.get_admin_ips_for_interfaces(node)
admin_netmask = net_manager.get_admin_network_group().netmask
for interface in node.meta.get('interfaces', []):
name = interface['name']
interfaces[name] = {
'mac_address': interface['mac'],
'static': '0',
'netmask': admin_netmask,
'ip_address': admin_ips[name]}
# interfaces_extra field in cobbler ks_meta
# means some extra data for network interfaces
# configuration. It is used by cobbler snippet.
# For example, cobbler interface model does not
# have 'peerdns' field, but we need this field
# to be configured. So we use interfaces_extra
# branch in order to set this unsupported field.
interfaces_extra[name] = {
'peerdns': 'no',
'onboot': 'no'}
# We want node to be able to PXE boot via any of its
# interfaces. That is why we add all discovered
# interfaces into cobbler system. But we want
# assignted fqdn to be resolved into one IP address
# because we don't completely support multiinterface
# configuration yet.
if interface['mac'] == node.mac:
interfaces[name]['dns_name'] = node.fqdn
interfaces_extra[name]['onboot'] = 'yes'
return {
'interfaces': interfaces,
'interfaces_extra': interfaces_extra}