def compile_network(anm): nidb = NIDB() G_phy = anm.overlay.phy G_ip = anm.overlay.ip G_graphics = anm.overlay.graphics #TODO: build this on a platform by platform basis nidb.add_nodes_from(G_phy, retain=['label', 'host', 'platform']) nidb.add_nodes_from(G_ip.nodes("collision_domain"), retain=['label', 'host'], collision_domain = True) # add edges to switches edges_to_add = [edge for edge in G_phy.edges() if edge.src.is_switch or edge.dst.is_switch] edges_to_add += [edge for edge in G_ip.edges() if edge.src.collision_domain or edge.dst.collision_domain] nidb.add_edges_from(edges_to_add, retain='edge_id') #TODO: boundaries is still a work in progress... for node in nidb: graphics_node = G_graphics.node(node) node.graphics.x = graphics_node.x node.graphics.y = graphics_node.y node.graphics.device_type = graphics_node.device_type node.device_type = graphics_node.device_type host = "nectar1" #junosphere_compiler = compiler.JunosphereCompiler(nidb, anm, host) #junosphere_compiler.compile() netkit_compiler = compiler.NetkitCompiler(nidb, anm, host) netkit_compiler.compile() #dynagen_compiler = compiler.DynagenCompiler(nidb, anm, host) #dynagen_compiler.compile() #cisco_compiler = compiler.CiscoCompiler(nidb, anm, host) #cisco_compiler.compile() return nidb
def compile_network(anm): nidb = NIDB() G_phy = anm.overlay.phy G_ip = anm.overlay.ip G_graphics = anm.overlay.graphics #TODO: build this on a platform by platform basis nidb.add_nodes_from(G_phy, retain=['label', 'host', 'platform']) nidb.add_nodes_from(G_ip.nodes("collision_domain"), retain=['label', 'host'], collision_domain=True) # add edges to switches edges_to_add = [ edge for edge in G_phy.edges() if edge.src.is_switch or edge.dst.is_switch ] edges_to_add += [ edge for edge in G_ip.edges() if edge.src.collision_domain or edge.dst.collision_domain ] nidb.add_edges_from(edges_to_add, retain='edge_id') #TODO: boundaries is still a work in progress... for node in nidb: graphics_node = G_graphics.node(node) node.graphics.x = graphics_node.x node.graphics.y = graphics_node.y node.graphics.device_type = graphics_node.device_type node.device_type = graphics_node.device_type host = "nectar1" #junosphere_compiler = compiler.JunosphereCompiler(nidb, anm, host) #junosphere_compiler.compile() netkit_compiler = compiler.NetkitCompiler(nidb, anm, host) netkit_compiler.compile() #dynagen_compiler = compiler.DynagenCompiler(nidb, anm, host) #dynagen_compiler.compile() #cisco_compiler = compiler.CiscoCompiler(nidb, anm, host) #cisco_compiler.compile() return nidb
def compile_network(anm): nidb = NIDB() G_phy = anm.overlay.phy G_ip = anm.overlay.ip G_graphics = anm.overlay.graphics #TODO: build this on a platform by platform basis nidb.add_nodes_from(G_phy, retain=['label', 'host', 'platform', 'Network', 'update']) cd_nodes = [n for n in G_ip.nodes("collision_domain") if not n.is_switch] # Only add created cds - otherwise overwrite host of switched nidb.add_nodes_from(cd_nodes, retain=['label', 'host'], collision_domain = True) # add edges to switches edges_to_add = [edge for edge in G_phy.edges() if edge.src.is_switch or edge.dst.is_switch] edges_to_add += [edge for edge in G_ip.edges() if edge.src.collision_domain or edge.dst.collision_domain] nidb.add_edges_from(edges_to_add, retain='edge_id') #TODO: boundaries is still a work in progress... nidb.copy_graphics(G_graphics) #junosphere_compiler = compiler.JunosphereCompiler(nidb, anm, host) #junosphere_compiler.compile() #host = "nectar1" #netkit_compiler = compiler.NetkitCompiler(nidb, anm, host) #netkit_compiler.compile() for target, target_data in config.settings['Compile Targets'].items(): host = target_data['host'] platform = target_data['platform'] if platform == "netkit": platform_compiler = compiler.NetkitCompiler(nidb, anm, host) elif platform == "cisco": platform_compiler = compiler.CiscoCompiler(nidb, anm, host) if any(G_phy.nodes(host = host, platform = platform)): log.info("Compile for %s on %s" % (platform, host)) platform_compiler.compile() # only compile if hosts set else: log.debug("No devices set for %s on %s" % (platform, host)) return nidb