Beispiel #1
0
    def compile(self):
        log.info("Compiling Netkit for %s" % self.host)
        g_phy = self.anm['phy']
        quagga_compiler = QuaggaCompiler(self.nidb, self.anm)
# TODO: this should be all l3 devices not just routers
        for phy_node in g_phy.l3devices(host=self.host, syntax='quagga'):
            folder_name = naming.network_hostname(phy_node)
            DmNode = self.nidb.node(phy_node)
            DmNode.add_stanza("render")
            #TODO: order by folder and file template src/dst
            DmNode.render.base = os.path.join("templates","quagga")
            DmNode.render.template = os.path.join("templates",
                "netkit_startup.mako")
            DmNode.render.dst_folder = os.path.join("rendered",
                self.host, "netkit")
            DmNode.render.base_dst_folder = os.path.join("rendered",
                self.host, "netkit", folder_name)
            DmNode.render.dst_file = "%s.startup" % folder_name

            DmNode.render.custom = {
                    'abc': 'def.txt'
                    }

# allocate zebra information
            DmNode.add_stanza("zebra")
            if DmNode.is_router():
                DmNode.zebra.password = "******"
            hostname = folder_name
            if hostname[0] in string.digits:
                hostname = "r" + hostname
            DmNode.hostname = hostname  # can't have . in quagga hostnames
            DmNode.add_stanza("ssh")
            DmNode.ssh.use_key = True  # TODO: make this set based on presence of key

            # Note this could take external data
            int_ids = itertools.count(0)
            for interface in DmNode.physical_interfaces:
                numeric_id = int_ids.next()
                interface.numeric_id = numeric_id
                interface.id = self.index_to_int_id(numeric_id)

# and allocate tap interface
            DmNode.add_stanza("tap")
            DmNode.tap.id = self.index_to_int_id(int_ids.next())

            quagga_compiler.compile(DmNode)

            if DmNode.bgp:
                DmNode.bgp.debug = True
                static_routes = []
                DmNode.zebra.static_routes = static_routes

        # and lab.conf
        self.allocate_tap_ips()
        self.lab_topology()
Beispiel #2
0
    def compile(self):
        log.info("Compiling Netkit for %s" % self.host)
        g_phy = self.anm['phy']
        quagga_compiler = QuaggaCompiler(self.nidb, self.anm)
# TODO: this should be all l3 devices not just routers
        for phy_node in g_phy.l3devices(host=self.host, syntax='quagga'):
            folder_name = naming.network_hostname(phy_node)
            nidb_node = self.nidb.node(phy_node)
            nidb_node.add_stanza("render")
            #TODO: order by folder and file template src/dst
            nidb_node.render.base = os.path.join("templates","quagga")
            nidb_node.render.template = os.path.join("templates",
                "netkit_startup.mako")
            nidb_node.render.dst_folder = os.path.join("rendered",
                self.host, "netkit")
            nidb_node.render.base_dst_folder = os.path.join("rendered",
                self.host, "netkit", folder_name)
            nidb_node.render.dst_file = "%s.startup" % folder_name

            nidb_node.render.custom = {
                    'abc': 'def.txt'
                    }

# allocate zebra information
            nidb_node.add_stanza("zebra")
            if nidb_node.is_router():
                nidb_node.zebra.password = "******"
            hostname = folder_name
            if hostname[0] in string.digits:
                hostname = "r" + hostname
            nidb_node.hostname = hostname  # can't have . in quagga hostnames
            nidb_node.add_stanza("ssh")
            nidb_node.ssh.use_key = True  # TODO: make this set based on presence of key

            # Note this could take external data
            int_ids = itertools.count(0)
            for interface in nidb_node.physical_interfaces:
                numeric_id = int_ids.next()
                interface.numeric_id = numeric_id
                interface.id = self.index_to_int_id(numeric_id)

# and allocate tap interface
            nidb_node.add_stanza("tap")
            nidb_node.tap.id = self.index_to_int_id(int_ids.next())

            quagga_compiler.compile(nidb_node)

            if nidb_node.bgp:
                nidb_node.bgp.debug = True
                static_routes = []
                nidb_node.zebra.static_routes = static_routes

        # and lab.conf
        self.allocate_tap_ips()
        self.lab_topology()
Beispiel #3
0
    def compile(self):
        self.copy_across_ip_addresses()

        log.info("Compiling Netkit for %s" % self.host)
        g_phy = self.anm['phy']
        quagga_compiler = QuaggaCompiler(self.nidb, self.anm)

        # todo: set platform render
        lab_topology = self.nidb.topology(self.host)
        lab_topology.render2 = PlatformRender()

        # TODO: this should be all l3 devices not just routers
        for phy_node in g_phy.l3devices(host=self.host, syntax='quagga'):
            folder_name = naming.network_hostname(phy_node)
            dm_node = self.nidb.node(phy_node)
            dm_node.add_stanza("render")
            # TODO: order by folder and file template src/dst
            dm_node.render.base = os.path.join("templates", "quagga")
            dm_node.render.template = os.path.join("templates",
                                                   "netkit_startup.mako")
            dm_node.render.dst_folder = os.path.join("rendered", self.host,
                                                     "netkit")
            dm_node.render.base_dst_folder = os.path.join(
                "rendered", self.host, "netkit", folder_name)
            dm_node.render.dst_file = "%s.startup" % folder_name

            dm_node.render.custom = {'abc': 'def.txt'}

            render2 = NodeRender()
            # TODO: dest folder also needs to be able to accept a list
            # TODO: document that use a list so can do native os.path.join on
            # target platform
            render2.add_folder(["templates", "quagga"], folder_name)
            render2.add_file(("templates", "netkit_startup.mako"),
                             "%s.startup" % folder_name)
            dm_node.render2 = render2
            lab_topology.render2.add_node(dm_node)
            # lab_topology.render2_hosts.append(phy_node)

            # allocate zebra information
            dm_node.add_stanza("zebra")
            if dm_node.is_router():
                dm_node.zebra.password = "******"
            hostname = folder_name
            if hostname[0] in string.digits:
                hostname = "r" + hostname
            dm_node.hostname = hostname  # can't have . in quagga hostnames
            dm_node.add_stanza("ssh")
            # TODO: make this set based on presence of key
            dm_node.ssh.use_key = True

            # Note this could take external data
            int_ids = itertools.count(0)
            for interface in dm_node.physical_interfaces():
                numeric_id = int_ids.next()
                interface.numeric_id = numeric_id
                interface.id = self.index_to_int_id(numeric_id)

# and allocate tap interface
            dm_node.add_stanza("tap")
            dm_node.tap.id = self.index_to_int_id(int_ids.next())

            quagga_compiler.compile(dm_node)

            if dm_node.bgp:
                dm_node.bgp.debug = True
                static_routes = []
                dm_node.zebra.static_routes = static_routes

        # and lab.conf
        self.allocate_tap_ips()
        self.allocate_lab_topology()
Beispiel #4
0
    def compile(self):
        self.copy_across_ip_addresses()

        log.info("Compiling Netkit for %s" % self.host)
        g_phy = self.anm['phy']
        quagga_compiler = QuaggaCompiler(self.nidb, self.anm)

        # todo: set platform render
        lab_topology = self.nidb.topology(self.host)
        lab_topology.render2 = PlatformRender()

# TODO: this should be all l3 devices not just routers
        for phy_node in g_phy.l3devices(host=self.host, syntax='quagga'):
            folder_name = naming.network_hostname(phy_node)
            dm_node = self.nidb.node(phy_node)
            dm_node.add_stanza("render")
            # TODO: order by folder and file template src/dst
            dm_node.render.base = os.path.join("templates", "quagga")
            dm_node.render.template = os.path.join("templates",
                                                   "netkit_startup.mako")
            dm_node.render.dst_folder = os.path.join("rendered",
                                                     self.host, "netkit")
            dm_node.render.base_dst_folder = os.path.join("rendered",
                                                          self.host, "netkit", folder_name)
            dm_node.render.dst_file = "%s.startup" % folder_name

            dm_node.render.custom = {
                'abc': 'def.txt'
            }

            render2 = NodeRender()
            # TODO: dest folder also needs to be able to accept a list
            # TODO: document that use a list so can do native os.path.join on
            # target platform
            render2.add_folder(["templates", "quagga"], folder_name)
            render2.add_file(
                ("templates", "netkit_startup.mako"), "%s.startup" % folder_name)
            dm_node.render2 = render2
            lab_topology.render2.add_node(dm_node)
            # lab_topology.render2_hosts.append(phy_node)

# allocate zebra information
            dm_node.add_stanza("zebra")
            if dm_node.is_router():
                dm_node.zebra.password = "******"
            hostname = folder_name
            if hostname[0] in string.digits:
                hostname = "r" + hostname
            dm_node.hostname = hostname  # can't have . in quagga hostnames
            dm_node.add_stanza("ssh")
            # TODO: make this set based on presence of key
            dm_node.ssh.use_key = True

            # Note this could take external data
            int_ids = itertools.count(0)
            for interface in dm_node.physical_interfaces():
                numeric_id = int_ids.next()
                interface.numeric_id = numeric_id
                interface.id = self.index_to_int_id(numeric_id)

# and allocate tap interface
            dm_node.add_stanza("tap")
            dm_node.tap.id = self.index_to_int_id(int_ids.next())

            quagga_compiler.compile(dm_node)

            if dm_node.bgp:
                dm_node.bgp.debug = True
                static_routes = []
                dm_node.zebra.static_routes = static_routes

        # and lab.conf
        self.allocate_tap_ips()
        self.allocate_lab_topology()