当前位置: 首页>>代码示例>>Python>>正文


Python NetworkManager.get_admin_ips_for_interfaces方法代码示例

本文整理汇总了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)
开发者ID:andrey-borisov,项目名称:fuel-web,代码行数:14,代码来源:deployment_serializers.py

示例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}
开发者ID:AlexeyKasatkin,项目名称:fuel-web,代码行数:42,代码来源:provisioning_serializers.py


注:本文中的nailgun.network.manager.NetworkManager.get_admin_ips_for_interfaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。