本文整理汇总了Python中AutoNetkit.allocate_subnets方法的典型用法代码示例。如果您正苦于以下问题:Python AutoNetkit.allocate_subnets方法的具体用法?Python AutoNetkit.allocate_subnets怎么用?Python AutoNetkit.allocate_subnets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoNetkit
的用法示例。
在下文中一共展示了AutoNetkit.allocate_subnets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile
# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import allocate_subnets [as 别名]
def compile(self):
"""Compile into device configuration files.
Args:
None
Returns:
None
Example usage:
>>> inet = ank.internet.Internet()
>>> inet.compile()
>>> inet = ank.internet.Internet()
>>> inet.compile()
"""
#TODO: fix import order problem with doctests:
#No handlers could be found for logger "ANK"
LOG.info("Compiling")
# Sanity check
if self.network.graph.number_of_nodes() == 0:
LOG.warn("Cannot compile empty network")
return
# Clean up old archives
ank.tidy_archives()
#TODO:
#config.get_plugin("Inv Cap").run(self.network)
#ank.inv_cap_weights(self.network)
#config.get_plugin("Test").run()
ank.initialise_bgp(self.network)
# Ensure nodes have a type set
self.network.update_node_type(default_type="netkit_router")
ank.allocate_dns_servers(self.network)
# Allocations
ank.allocate_subnets(self.network, IPNetwork("10.0.0.0/8"))
ank.alloc_interfaces(self.network)
ank.alloc_tap_hosts(self.network, self.tapsn)
if self.policy_file:
LOG.info("Applying BGP policy from %s" % self.policy_file)
pol_parser = ank.BgpPolicyParser(self.network)
pol_parser.apply_policy_file(self.policy_file)
if self.rpki_file:
LOG.info("Applying RPKI structure from %s" % self.rpki_file)
rpki_parser = ank.RpkiSetsParser(self.network)
rpki_parser.apply_rpki_file(self.rpki_file)
if self.will_deploy and not self.compile_targets['netkit']:
auto_compile = any( data.get("active")
for data in config.settings['Netkit Hosts'].values())
if auto_compile:
LOG.info("Active Netkit deployment target, automatically compiling")
self.compile_targets['netkit'] = True
if self.compile_targets['netkit']:
nk_comp = ank.NetkitCompiler(self.network, self.services)
nk_comp.initialise()
nk_comp.configure()
auto_compile = any( data.get("active")
for data in config.settings['Dynagen Hosts'].values())
if auto_compile:
LOG.info("Active Dynagen deployment target, automatically compiling")
self.compile_targets['dynagen'] = True
if self.compile_targets['dynagen']:
dynagen_comp = ank.dynagenCompiler(self.network, services = self.services,
igp = self.igp,
image = config.settings['Dynagen']['image'],
hypervisor_server = config.settings['Dynagen']['Hypervisor']['server'],
hypervisor_port = config.settings['Dynagen']['Hypervisor']['port'],
)
dynagen_comp.initialise()
dynagen_comp.configure()
if self.compile_targets['junosphere']:
junos_comp = ank.JunosCompiler(self.network, self.services, self.igp, target="junosphere")
junos_comp.initialise()
junos_comp.configure()
if self.compile_targets['junosphere_olive']:
LOG.warn("Junosphere Olive not currently supported")
#junos_comp = ank.JunosCompiler(self.network, self.services, self.igp, target="junosphere_olive")
#junos_comp.initialise()
#junos_comp.configure()
if self.will_deploy and not self.compile_targets['olive']:
auto_compile = any( data.get("active")
for data in config.settings['Olive Hosts'].values())
if auto_compile:
self.compile_targets['olive'] = True
LOG.info("Active Olive deployment target, automatically compiling")
#.........这里部分代码省略.........