本文整理汇总了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
示例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
示例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