net10_properties = generator.getLinksProperties(net10) net11_properties = generator.getLinksProperties(net11) vlls_properties = [] for vll in vlls: vll_properties = generator.getVLLProperties(vll) vlls_properties.append(vll_properties) pws_properties = [] for pw in pws: pw_properties = generator.getVLLProperties(pw) pws_properties.append(pw_properties) vss_properties = [] for vs in vss: vs_properties = generator.getVSProperties(vs) vss_properties.append(vs_properties) print "*** Create Core OSHI" i = 0 for i in range(0, len(cr_os)): cr_oshi = net.addCrOSHI(cr_properties[i], name = cr_os[i]) i = i + 1 print "*** Create Provider Edge OSHI" i = 0 for i in range(0, len(pe_os)): pe_oshi = net.addPeOSHI(pe_properties[i], name = pe_os[i]) i = i + 1 print "*** Create Controllers" i = 0 for i in range(0, len(ctrls)):
def topo(topology): """Builds Topology from a json file generated by Topology3D It also creates Configuration File for VLL pusher it saves a json files with all the node details (default in /tmp/overall_info.json) so that node.js can parse it and update the web gui """ verbose = True if verbose: print "*** Build Topology From Parsed File" print "*** Topology file : ", topology print "*** NodeInfo file: ", overall_info_file print "*** Topology format version: ", tf_version parser = TopoParser(topology, verbose=True, version=tf_version) ppsubnets = parser.getsubnets() #NB a submet could include multiple links if a legacy switch is used # currently only the first link is considered, therefore # legacy switches are not supported vlls = parser.getVLLs() pws = parser.getPWs() vss = parser.getVSs() # XXX if parser.generated == False: if verbose: print "*** No Autogenerated" generator = PropertiesGenerator(False) if verbose: print "*** Build Vertices Properties" cr_oshis_properties = generator.getVerticesProperties( parser.cr_oshis) for parser_cr_property, cr_property in zip( parser.cr_oshis_properties, cr_oshis_properties): parser_cr_property['loopback'] = cr_property.loopback pe_oshis_properties = generator.getVerticesProperties( parser.pe_oshis) for parser_pe_property, pe_property in zip( parser.pe_oshis_properties, pe_oshis_properties): parser_pe_property['loopback'] = pe_property.loopback #cers_properties = generator.getVerticesProperties(parser.cers) if verbose: print "*** Build Point-To-Point Links Properties" pp_properties = [] for ppsubnet in ppsubnets: pp_properties.append(generator.getLinksProperties(ppsubnet.links)) if verbose: print "*** Build VLLs Properties" vlls_properties = [] for vll in vlls: vlls_properties.append(generator.getVLLProperties(vll)) if verbose: print "*** Build PWs Properties" pws_properties = [] for pw in pws: pws_properties.append(generator.getVLLProperties(pw)) if verbose: print "*** Build VSs Properties" vss_properties = [] for vs in vss: vs_properties = generator.getVSProperties(vs) vss_properties.append(vs_properties) set_cr_oshis = parser.cr_oshis set_pe_oshis = parser.pe_oshis set_cers = parser.cers set_ctrls = parser.ctrls set_all_nodes = [] set_all_nodes.extend(set_cr_oshis) set_all_nodes.extend(set_pe_oshis) set_all_nodes.extend(set_cers) set_all_nodes.extend(set_ctrls) net = MininetOSHI(verbose) if verbose: print "*** Build OSHI CRs" i = 0 for croshi in set_cr_oshis: net.addCrOSHI(parser.cr_oshis_properties[i], croshi) if verbose: print "*** %s - %s" % (croshi, parser.cr_oshis_properties[i]) i = i + 1 if verbose: print "*** Build OSHI PEs" i = 0 for peoshi in set_pe_oshis: net.addPeOSHI(parser.pe_oshis_properties[i], peoshi) if verbose: print "*** %s - %s" % (peoshi, parser.pe_oshis_properties[i]) i = i + 1 net.addCoexistenceMechanism("COEXH", 0) if verbose: print "*** Build CONTROLLERS" i = 0 for ctrl in set_ctrls: net.addController(parser.ctrls_properties[i], ctrl) if verbose: print "*** %s - %s" % (ctrl, parser.ctrls_properties[i]) i = i + 1 if verbose: print "*** Build CERS" i = 0 for cer in set_cers: net.addCeRouter(0, parser.cers_properties[i], name=cer) if verbose: print "*** %s - %s" % (cer, parser.cers_properties[i]) i = i + 1 if verbose: print "*** Build node for management network" mgmt = net.addManagement(name="mgm1") if SINGLE_CONNECTION: croshi = net.getNodeByName(croshi) linkproperties = generator.getLinksProperties([(croshi.name, mgmt.name) ]) net.addLink(croshi, mgmt, linkproperties[0]) if verbose: print "*** MANAGEMENT CONNECTION: ", mgmt.name, "To", croshi.name, "-", linkproperties[ 0] else: i = 0 for a_node in set_all_nodes: a_node = net.getNodeByName(a_node) linkproperties = generator.getLinksProperties([(a_node.name, mgmt.name)]) net.addLink(a_node, mgmt, linkproperties[0]) if verbose: print "*** MANAGEMENT CONNECTION: ", a_node.name, "To", mgmt.name, "-", linkproperties[ 0] i = i + 1 if verbose: print "*** Create Point To Point Networks" i = 0 for ppsubnet in ppsubnets: links = ppsubnet.links #if a ppsubnet has more than one link, only the first one is considered if verbose: print "*** Subnet: Node %s - Links %s" % (ppsubnet.nodes, links) node1 = net.getNodeByName(links[0][0]) node2 = net.getNodeByName(links[0][1]) net.addLink(node1, node2, pp_properties[i][0]) if verbose: #print "*** Connect", node1, "To", node2 print "*** Link Properties", pp_properties[i][0] i = i + 1 i = 0 for vll in vlls: node1 = net.getNodeByName(vll[0]) node2 = net.getNodeByName(vll[1]) net.addVLL(node1, node2, vlls_properties[i]) if verbose: print "*** VLLs Properties", vlls_properties[i] i = i + 1 i = 0 for pw in pws: node1 = net.getNodeByName(pw[0]) node2 = net.getNodeByName(pw[1]) net.addPW(node1, node2, pws_properties[i]) if verbose: print "*** PWs Properties", pws_properties[i] i = i + 1 i = 0 for vs in vss: endnodes = [] for node in vs: endnodes.append(net.getNodeByName(node)) net.addVS(endnodes, vss_properties[i]) if verbose: print "*** VSs Properties", vss_properties[i] i = i + 1 # Cycle over all nodes and start grpc servers if parser.path_grpc != "": net.grpc_path = parser.path_grpc my_info = net.start() store_overall_info(my_info) if tf_version == 1: CLI(net) net.stop()
net10_properties = generator.getLinksProperties(net10) net11_properties = generator.getLinksProperties(net11) vlls_properties = [] for vll in vlls: vll_properties = generator.getVLLProperties(vll) vlls_properties.append(vll_properties) pws_properties = [] for pw in pws: pw_properties = generator.getVLLProperties(pw) pws_properties.append(pw_properties) vss_properties = [] for vs in vss: vs_properties = generator.getVSProperties(vs) vss_properties.append(vs_properties) print "*** Create Core OSHI" i = 0 for i in range(0, len(cr_os)): cr_oshi = net.addCrOSHI(cr_properties[i], name=cr_os[i]) i = i + 1 print "*** Create Provider Edge OSHI" i = 0 for i in range(0, len(pe_os)): pe_oshi = net.addPeOSHI(pe_properties[i], name=pe_os[i]) i = i + 1 print "*** Create Controllers" i = 0 for i in range(0, len(ctrls)):
def topo(topology): """Builds Topology from a json file generated by Topology3D It also creates Configuration File for VLL pusher it saves a json files with all the node details (default in /tmp/overall_info.json) so that node.js can parse it and update the web gui """ verbose = True if verbose: print "*** Build Topology From Parsed File" print "*** Topology file : ", topology print "*** NodeInfo file: ", overall_info_file print "*** Topology format version: ", tf_version parser = TopoParser(topology, verbose = True, version=tf_version) ppsubnets = parser.getsubnets() #NB a submet could include multiple links if a legacy switch is used # currently only the first link is considered, therefore # legacy switches are not supported vlls = parser.getVLLs() pws = parser.getPWs() vss = parser.getVSs() # XXX if parser.generated == False: if verbose: print "*** No Autogenerated" generator = PropertiesGenerator(False) if verbose: print "*** Build Vertices Properties" cr_oshis_properties = generator.getVerticesProperties(parser.cr_oshis) for parser_cr_property, cr_property in zip(parser.cr_oshis_properties, cr_oshis_properties): parser_cr_property['loopback'] = cr_property.loopback pe_oshis_properties = generator.getVerticesProperties(parser.pe_oshis) for parser_pe_property, pe_property in zip(parser.pe_oshis_properties, pe_oshis_properties): parser_pe_property['loopback'] = pe_property.loopback #cers_properties = generator.getVerticesProperties(parser.cers) if verbose: print "*** Build Point-To-Point Links Properties" pp_properties = [] for ppsubnet in ppsubnets: pp_properties.append(generator.getLinksProperties(ppsubnet.links)) if verbose: print "*** Build VLLs Properties" vlls_properties = [] for vll in vlls: vlls_properties.append(generator.getVLLProperties(vll)) if verbose: print "*** Build PWs Properties" pws_properties = [] for pw in pws: pws_properties.append(generator.getVLLProperties(pw)) if verbose: print "*** Build VSs Properties" vss_properties = [] for vs in vss: vs_properties = generator.getVSProperties(vs) vss_properties.append(vs_properties) set_cr_oshis = parser.cr_oshis set_pe_oshis = parser.pe_oshis set_cers = parser.cers set_ctrls = parser.ctrls set_all_nodes = [] set_all_nodes.extend(set_cr_oshis) set_all_nodes.extend(set_pe_oshis) set_all_nodes.extend(set_cers) set_all_nodes.extend(set_ctrls) net = MininetOSHI(verbose) if verbose: print "*** Build OSHI CRs" i = 0 for croshi in set_cr_oshis: net.addCrOSHI(parser.cr_oshis_properties[i], croshi) if verbose: print "*** %s - %s" %(croshi, parser.cr_oshis_properties[i]) i = i + 1 if verbose: print "*** Build OSHI PEs" i = 0 for peoshi in set_pe_oshis: net.addPeOSHI(parser.pe_oshis_properties[i], peoshi) if verbose: print "*** %s - %s" %(peoshi, parser.pe_oshis_properties[i]) i = i + 1 net.addCoexistenceMechanism("COEXH", 0) if verbose: print "*** Build CONTROLLERS" i = 0 for ctrl in set_ctrls: net.addController(parser.ctrls_properties[i], ctrl) if verbose: print "*** %s - %s" %(ctrl, parser.ctrls_properties[i]) i = i + 1 if verbose: print "*** Build CERS" i = 0 for cer in set_cers: net.addCeRouter(0, parser.cers_properties[i], name = cer) if verbose: print "*** %s - %s" %(cer, parser.cers_properties[i]) i = i + 1 if verbose: print "*** Build node for management network" mgmt = net.addManagement(name="mgm1") if SINGLE_CONNECTION: croshi = net.getNodeByName(croshi) linkproperties = generator.getLinksProperties([(croshi.name, mgmt.name)]) net.addLink(croshi, mgmt, linkproperties[0]) if verbose: print "*** MANAGEMENT CONNECTION: ", mgmt.name, "To", croshi.name, "-", linkproperties[0] else: i = 0 for a_node in set_all_nodes: a_node = net.getNodeByName(a_node) linkproperties = generator.getLinksProperties([(a_node.name, mgmt.name)]) net.addLink(a_node, mgmt, linkproperties[0]) if verbose: print "*** MANAGEMENT CONNECTION: ", a_node.name, "To", mgmt.name, "-", linkproperties[0] i = i + 1 if verbose: print "*** Create Point To Point Networks" i = 0 for ppsubnet in ppsubnets: links = ppsubnet.links #if a ppsubnet has more than one link, only the first one is considered if verbose: print "*** Subnet: Node %s - Links %s" %(ppsubnet.nodes, links) node1 = net.getNodeByName(links[0][0]) node2 = net.getNodeByName(links[0][1]) net.addLink(node1, node2, pp_properties[i][0]) if verbose: #print "*** Connect", node1, "To", node2 print "*** Link Properties", pp_properties[i][0] i = i + 1 i = 0 for vll in vlls: node1 = net.getNodeByName(vll[0]) node2 = net.getNodeByName(vll[1]) net.addVLL(node1, node2, vlls_properties[i]) if verbose: print "*** VLLs Properties", vlls_properties[i] i = i + 1 i = 0 for pw in pws: node1 = net.getNodeByName(pw[0]) node2 = net.getNodeByName(pw[1]) net.addPW(node1, node2, pws_properties[i]) if verbose: print "*** PWs Properties", pws_properties[i] i = i + 1 i = 0 for vs in vss: endnodes = [] for node in vs: endnodes.append(net.getNodeByName(node)) net.addVS(endnodes, vss_properties[i]) if verbose: print "*** VSs Properties", vss_properties[i] i = i + 1 my_info = net.start() store_overall_info(my_info) if not no_cli: CLI(net) net.stop()