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


Python NetworkManager.get_allowed_nic_networkgroups方法代码示例

本文整理汇总了Python中nailgun.network.manager.NetworkManager.get_allowed_nic_networkgroups方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.get_allowed_nic_networkgroups方法的具体用法?Python NetworkManager.get_allowed_nic_networkgroups怎么用?Python NetworkManager.get_allowed_nic_networkgroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nailgun.network.manager.NetworkManager的用法示例。


在下文中一共展示了NetworkManager.get_allowed_nic_networkgroups方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_default

# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_allowed_nic_networkgroups [as 别名]
    def get_default(self, node):
        nics = []
        network_manager = NetworkManager()
        for nic in node.interfaces:
            nic_dict = {
                "id": nic.id,
                "name": nic.name,
                "mac": nic.mac,
                "max_speed": nic.max_speed,
                "current_speed": nic.current_speed
            }

            assigned_ngs = network_manager.get_default_nic_networkgroups(
                node, nic)

            for ng in assigned_ngs:
                nic_dict.setdefault('assigned_networks', []).append(
                    {'id': ng.id, 'name': ng.name})

            allowed_ngs = network_manager.get_allowed_nic_networkgroups(
                node, nic)

            for ng in allowed_ngs:
                nic_dict.setdefault('allowed_networks', []).append(
                    {'id': ng.id, 'name': ng.name})

            nics.append(nic_dict)
        return nics
开发者ID:loles,项目名称:fuelweb,代码行数:30,代码来源:node.py

示例2: get_default

# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_allowed_nic_networkgroups [as 别名]
    def get_default(self, node):
        nics = []
        network_manager = NetworkManager()
        for nic in node.interfaces:
            nic_dict = {
                "id": nic.id,
                "name": nic.name,
                "mac": nic.mac,
                "max_speed": nic.max_speed,
                "current_speed": nic.current_speed
            }

            assigned_ng_ids = network_manager.get_default_nic_networkgroups(
                node.id,
                nic.id
            )
            for ng_id in assigned_ng_ids:
                ng = db().query(NetworkGroup).get(ng_id)
                nic_dict.setdefault("assigned_networks", []).append(
                    {"id": ng_id, "name": ng.name}
                )

            allowed_ng_ids = network_manager.get_allowed_nic_networkgroups(
                node.id,
                nic.id
            )
            for ng_id in allowed_ng_ids:
                ng = db().query(NetworkGroup).get(ng_id)
                nic_dict.setdefault("allowed_networks", []).append(
                    {"id": ng_id, "name": ng.name}
                )

            nics.append(nic_dict)
        return nics
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:36,代码来源:node.py

示例3: _is_assignment_allowed_for_node

# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_allowed_nic_networkgroups [as 别名]
 def _is_assignment_allowed_for_node(cls, node):
     db_node = db().query(Node).filter_by(id=node['id']).first()
     interfaces = node['interfaces']
     db_interfaces = db_node.interfaces
     for iface in interfaces:
         db_iface = filter(
             lambda i: i.id == iface['id'],
             db_interfaces
         )
         db_iface = db_iface[0]
         allowed_network_ids = \
             [n.id
              for n in NetworkManager.get_allowed_nic_networkgroups(
                  db_node,
                  db_iface
              )]
         for net in iface['assigned_networks']:
             if net['id'] not in allowed_network_ids:
                 return False
     return True
开发者ID:stamak,项目名称:fuel-web,代码行数:22,代码来源:topology.py


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