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


Python AutoNetkit.create_ip_overlay方法代码示例

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


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

示例1: compile

# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import create_ip_overlay [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")

        ank.create_ip_overlay(self.network)

        # 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.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()

        if self.will_deploy and not self.compile_targets['libvirt']:
            auto_compile = any( data.get("active") 
                    for data in config.settings['Libvirt Hosts'].values())
            if auto_compile:
                LOG.info("Active Netkit deployment target, automatically compiling")
                self.compile_targets['libvirt'] = True
        if self.compile_targets['libvirt']:
            #TODO: need to create per host machine, eg monster, lobster
            active_hosts = [host for host, data in config.settings['Libvirt Hosts'].items()
                    if data.get("active")]
            for host in active_hosts:
                data = config.settings['Libvirt Hosts'][host]
                libvirt_comp = ank.LibvirtCompiler(self.network, self.services,
                        host = host, file_structure = data['File Structure'],
                        script_data = data['Scripts'],
                        images = data['Images'])
                libvirt_comp.initialise()
            libvirt_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']:
#.........这里部分代码省略.........
开发者ID:medim,项目名称:autonetkit,代码行数:103,代码来源:internet.py


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