本文整理汇总了Python中nailgun.network.manager.NetworkManager.create_networks方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.create_networks方法的具体用法?Python NetworkManager.create_networks怎么用?Python NetworkManager.create_networks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.network.manager.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.create_networks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import create_networks [as 别名]
def update(cls, cluster, network_configuration):
from nailgun.network.manager import NetworkManager
network_manager = NetworkManager()
if 'net_manager' in network_configuration:
setattr(
cluster,
'net_manager',
network_configuration['net_manager'])
if 'networks' in network_configuration:
for ng in network_configuration['networks']:
ng_db = db().query(NetworkGroup).get(ng['id'])
for key, value in ng.iteritems():
if key == "ip_ranges":
cls.__set_ip_ranges(ng['id'], value)
else:
if key == 'cidr' and \
not ng['name'] in ('public', 'floating'):
network_manager.update_ranges_from_cidr(
ng_db, value)
setattr(ng_db, key, value)
network_manager.create_networks(ng_db)
ng_db.cluster.add_pending_changes('networks')
示例2: update
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import create_networks [as 别名]
def update(cls, cluster, network_configuration):
from nailgun.network.manager import NetworkManager
network_manager = NetworkManager()
if 'net_manager' in network_configuration:
setattr(
cluster,
'net_manager',
network_configuration['net_manager'])
if 'networks' in network_configuration:
for ng in network_configuration['networks']:
ng_db = orm().query(NetworkGroup).get(ng['id'])
for key, value in ng.iteritems():
if key == "ip_ranges":
# deleting old ip ranges
map(
orm().delete,
orm().query(IPAddrRange).filter_by(
network_group_id=ng['id']
)
)
for r in value:
new_ip_range = IPAddrRange(
first=r[0],
last=r[1],
network_group_id=ng['id']
)
orm().add(new_ip_range)
orm().commit()
else:
setattr(ng_db, key, value)
network_manager.create_networks(ng_db)
ng_db.cluster.add_pending_changes('networks')