コード例 #1
0
# Deployer implementation using Dreamer Extensions API.
#
# @author Pier Luigi Ventre <*****@*****.**>
# @author Giuseppe Siracusano <*****@*****.**>
# @author Stefano Salsano <*****@*****.**>
#
#

from mininet_extensions import MininetOSHI
from utility import PropertiesGenerator
from mininet.cli import CLI

if __name__ == '__main__':

    verbose = True
    net = MininetOSHI(verbose)
    generator = PropertiesGenerator(False)
    cr_os = ["cro1", "cro2", "cro3"]
    cr_properties = []
    for cr in cr_os:
        cr_properties.append({
            "domain-oshi": {
                "layer-Control": {
                    "cluster_id": "1"
                }
            },
            "loopback": ""
        })
    pe_os = ["peo1", "peo2", "peo3"]
    pe_properties = []
    for pe in pe_os:
コード例 #2
0
# @author Giuseppe Siracusano <*****@*****.**>
# @author Stefano Salsano <*****@*****.**>
#
#

from mininet_extensions import MininetOSHI
from utility import PropertiesGenerator
from mininet.cli import CLI




if __name__ == '__main__':

	verbose=True
	net = MininetOSHI(verbose)
	generator = PropertiesGenerator(False)
	cr_os = ["cro1","cro2","cro3"]
	cr_properties = []
	for cr in cr_os:
		cr_properties.append({"domain-oshi":{"layer-Control":{"cluster_id":"1"}}, "loopback": ""})
	pe_os = ["peo1","peo2","peo3"]
	pe_properties = []
	for pe in pe_os:
		pe_properties.append({"domain-oshi":{"layer-Control":{"cluster_id":"1"}}, "loopback": ""})
	ctrls = ["ctr1"]
	ct_properties = []
	for ctrl in ctrls:
		ct_properties.append({"domain-oshi":{"layer-Control":{"cluster_id":"1"}}, "tcp_port": "6633"})
	ce_os = ["cer1","cer2","cer3","cer4"]
	ce_properties = []
コード例 #3
0
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()
コード例 #4
0
def test_add_nodes_and_add_link():

	verbose=True
	net = MininetOSHI(verbose)
	generator = PropertiesGenerator(False)
	cr_os = ["cro1","cro2","cro3"]
	pe_os = ["peo1","peo2","peo3"]
	ctrls = ["ctr1","ctr2","ctr3"]
	sws = ["swi1","swi2","swi3"]
	ce_os = ["cer1","cer2","cer3"]

	net1 = [("cro1","swi1"),("swi1","cro2"),("cro3","swi1")]
	net2 = [("peo1","cro1")]
	net3 = [("cro2","peo2")]
	net4 = [("peo3","cro3")]
	net5 = [("cer1","peo1")]
	net6 = [("cer2","peo2")]
	net7 = [("cer3","peo3")]
	net8 = [("cro1","ctr1")]
	net9 = [("ctr2","cro2")]
	net10 = [("cro3","ctr3")]

	vlls = [("cer1","cer2"), ("cer2","cer3"), ("cer3","cer1")]
	
	cr_prop = generator.getVerticesProperties(cr_os)
	pe_prop = generator.getVerticesProperties(pe_os)
	ct_prop = generator.getVerticesProperties(ctrls)
	sw_prop = generator.getVerticesProperties(sws)
	ce_prop = generator.getVerticesProperties(ce_os)
	
	net1_properties = generator.getLinksProperties(net1)
	net2_properties = generator.getLinksProperties(net2)
	net3_properties = generator.getLinksProperties(net3)
	net4_properties = generator.getLinksProperties(net4)
	net5_properties = generator.getLinksProperties(net5)
	net6_properties = generator.getLinksProperties(net6)
	net7_properties = generator.getLinksProperties(net7)
	net8_properties = generator.getLinksProperties(net8)
	net9_properties = generator.getLinksProperties(net9)
	net10_properties = generator.getLinksProperties(net10)

	vlls_properties = []
	for vll in vlls:
		vll_properties = generator.getVLLsProperties(vll)
		vlls_properties.append(vll_properties)
	
	print "*** Create Core OSHI"
	i = 0
	for i in range(0, len(cr_os)):
		cr_oshi = net.addCrOSHI(name = cr_os[i], params = cr_prop[i])
		i = i + 1
	print "*** Create Provider Edge OSHI"
	i = 0
	for i in range(0, len(pe_os)):
		pe_oshi = net.addPeOSHI(name = pe_os[i], params = pe_prop[i])
		i = i + 1
	print "*** Create LegacyL2Switch"
	i = 0
	for i in range(0, len(sws)):
		switch = net.addSwitch(name = sws[i])
		i = i + 1
	print "*** Create Controllers"
	i = 0
	for i in range(0, len(cr_os)):
		ctrl = net.addController(name = ctrls[i])
		i = i + 1
	print "*** Create Customer Edge Router"
	i = 0
	for i in range(0, len(ce_os)):
		ce_router = net.addCeRouter(name = ce_os[i])
		i = i + 1

	i = 0
	for link in net1:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net1_properties[i])
		i = i + 1

	i = 0
	for link in net2:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net2_properties[i])
		i = i + 1

	i = 0
	for link in net3:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net3_properties[i])
		i = i + 1

	i = 0
	for link in net4:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net4_properties[i])
		i = i + 1

	i = 0
	for link in net5:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net5_properties[i])
		i = i + 1

	i = 0
	for link in net6:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net6_properties[i])
		i = i + 1

	i = 0
	for link in net7:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net7_properties[i])
		i = i + 1

	i = 0
	for link in net8:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net8_properties[i])
		i = i + 1

	i = 0
	for link in net9:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net9_properties[i])
		i = i + 1

	i = 0
	for link in net10:
		lhs = net.getNodeByName(link[0])
		rhs = net.getNodeByName(link[1])
		net.addLink(lhs, rhs, net10_properties[i])
		i = i + 1
	
	net.start()
	print "*** Press any key to continue"
	a=raw_input()
	net.stop()

	subprocess.call(["sudo", "mn", "-c"], stdout=None, stderr=None)
	unmountAll()
コード例 #5
0
def clean_all():
    net = MininetOSHI(True)
    net.stop()
コード例 #6
0
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()
コード例 #7
0
def clean_all():
    net = MininetOSHI(True)
    net.stop()
コード例 #8
0
def test_add_nodes_and_add_link():

    verbose = True
    net = MininetOSHI(verbose)
    generator = PropertiesGenerator(False)
    cr_os = ["cro1", "cro2", "cro3"]
    pe_os = ["peo1", "peo2", "peo3"]
    ctrls = ["ctr1", "ctr2", "ctr3"]
    sws = ["swi1", "swi2", "swi3"]
    ce_os = ["cer1", "cer2", "cer3"]

    net1 = [("cro1", "swi1"), ("swi1", "cro2"), ("cro3", "swi1")]
    net2 = [("peo1", "cro1")]
    net3 = [("cro2", "peo2")]
    net4 = [("peo3", "cro3")]
    net5 = [("cer1", "peo1")]
    net6 = [("cer2", "peo2")]
    net7 = [("cer3", "peo3")]
    net8 = [("cro1", "ctr1")]
    net9 = [("ctr2", "cro2")]
    net10 = [("cro3", "ctr3")]

    vlls = [("cer1", "cer2"), ("cer2", "cer3"), ("cer3", "cer1")]

    cr_prop = generator.getVerticesProperties(cr_os)
    pe_prop = generator.getVerticesProperties(pe_os)
    ct_prop = generator.getVerticesProperties(ctrls)
    sw_prop = generator.getVerticesProperties(sws)
    ce_prop = generator.getVerticesProperties(ce_os)

    net1_properties = generator.getLinksProperties(net1)
    net2_properties = generator.getLinksProperties(net2)
    net3_properties = generator.getLinksProperties(net3)
    net4_properties = generator.getLinksProperties(net4)
    net5_properties = generator.getLinksProperties(net5)
    net6_properties = generator.getLinksProperties(net6)
    net7_properties = generator.getLinksProperties(net7)
    net8_properties = generator.getLinksProperties(net8)
    net9_properties = generator.getLinksProperties(net9)
    net10_properties = generator.getLinksProperties(net10)

    vlls_properties = []
    for vll in vlls:
        vll_properties = generator.getVLLsProperties(vll)
        vlls_properties.append(vll_properties)

    print "*** Create Core OSHI"
    i = 0
    for i in range(0, len(cr_os)):
        cr_oshi = net.addCrOSHI(name=cr_os[i], params=cr_prop[i])
        i = i + 1
    print "*** Create Provider Edge OSHI"
    i = 0
    for i in range(0, len(pe_os)):
        pe_oshi = net.addPeOSHI(name=pe_os[i], params=pe_prop[i])
        i = i + 1
    print "*** Create LegacyL2Switch"
    i = 0
    for i in range(0, len(sws)):
        switch = net.addSwitch(name=sws[i])
        i = i + 1
    print "*** Create Controllers"
    i = 0
    for i in range(0, len(cr_os)):
        ctrl = net.addController(name=ctrls[i])
        i = i + 1
    print "*** Create Customer Edge Router"
    i = 0
    for i in range(0, len(ce_os)):
        ce_router = net.addCeRouter(name=ce_os[i])
        i = i + 1

    i = 0
    for link in net1:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net1_properties[i])
        i = i + 1

    i = 0
    for link in net2:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net2_properties[i])
        i = i + 1

    i = 0
    for link in net3:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net3_properties[i])
        i = i + 1

    i = 0
    for link in net4:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net4_properties[i])
        i = i + 1

    i = 0
    for link in net5:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net5_properties[i])
        i = i + 1

    i = 0
    for link in net6:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net6_properties[i])
        i = i + 1

    i = 0
    for link in net7:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net7_properties[i])
        i = i + 1

    i = 0
    for link in net8:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net8_properties[i])
        i = i + 1

    i = 0
    for link in net9:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net9_properties[i])
        i = i + 1

    i = 0
    for link in net10:
        lhs = net.getNodeByName(link[0])
        rhs = net.getNodeByName(link[1])
        net.addLink(lhs, rhs, net10_properties[i])
        i = i + 1

    net.start()
    print "*** Press any key to continue"
    a = raw_input()
    net.stop()

    subprocess.call(["sudo", "mn", "-c"], stdout=None, stderr=None)
    unmountAll()
コード例 #9
0
def test_properties_generator():

    verbose = True
    net = MininetOSHI(verbose)
    generator = PropertiesGenerator(False)
    cr_os = ["cro1", "cro2", "cro3"]
    pe_os = ["peo1", "peo2", "peo3"]
    ctrls = ["ctr1", "ctr2", "ctr3"]
    sws = ["swi1", "swi2", "swi3"]
    ce_os = ["cer1", "cer2", "cer3"]
    mgm_os = ["mgm1"]

    net1 = [("cro1", "swi1"), ("swi1", "cro2"), ("cro3", "swi1")]
    net2 = [("peo1", "cro1")]
    net3 = [("cro2", "peo2")]
    net4 = [("peo3", "cro3")]
    net5 = [("cer1", "peo1")]
    net6 = [("cer2", "peo2")]
    net7 = [("cer3", "peo3")]
    net8 = [("cro1", "mgm1")]

    print "Vertices Properties"
    cr_prop = generator.getVerticesProperties(cr_os)
    i = 0
    for cr_property in cr_prop:
        print "%s -> %s" % (cr_os[i], cr_property)
        i = i + 1
    i = 0
    pe_prop = generator.getVerticesProperties(pe_os)
    i = 0
    for pe_property in pe_prop:
        print "%s -> %s" % (pe_os[i], pe_property)
        i = i + 1
    i = 0
    ct_prop = generator.getVerticesProperties(ctrls)
    i = 0
    for ct_property in ct_prop:
        print "%s -> %s" % (ctrls[i], ct_property)
        i = i + 1
    i = 0
    sw_prop = generator.getVerticesProperties(sws)
    i = 0
    for sw_property in sw_prop:
        print "%s -> %s" % (sws[i], sw_property)
        i = i + 1
    i = 0
    ce_prop = generator.getVerticesProperties(ce_os)
    i = 0
    for ce_property in ce_prop:
        print "%s -> %s" % (ce_os[i], ce_property)
        i = i + 1
    i = 0
    mgm_prop = generator.getVerticesProperties(mgm_os)
    for mgm_property in mgm_prop:
        print "%s -> %s" % (mgm_os[i], mgm_property)
        i = i + 1
    print "###################################################"

    properties = generator.getLinksProperties(net1)
    print "Net1 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net1[i], l_property)
        i = i + 1

    properties = generator.getLinksProperties(net2)
    print "Net2 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net2[i], l_property)
        i = i + 1

    properties = generator.getLinksProperties(net3)
    print "Net3 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net3[i], l_property)
        i = i + 1

    properties = generator.getLinksProperties(net4)
    print "Net4 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net4[i], l_property)
        i = i + 1

    properties = generator.getLinksProperties(net5)
    print "Net5 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net5[i], l_property)
        i = i + 1

    properties = generator.getLinksProperties(net6)
    print "Net6 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net6[i], l_property)
        i = i + 1

    properties = generator.getLinksProperties(net7)
    print "Net7 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net7[i], l_property)
        i = i + 1
    properties = generator.getLinksProperties(net8)
    print "Net8 Properties"
    i = 0
    for l_property in properties:
        print "%s -> %s" % (net8[i], l_property)
        i = i + 1
    print "###################################################"

    print "VLLs Properties"
    vlls = [("cer1", "cer2"), ("cer2", "cer3"), ("cer3", "cer1")]
    for vll in vlls:
        print "%s -> %s" % (vll, generator.getVLLsProperties(vll))
    print "###################################################"

    subprocess.call(["sudo", "mn", "-c"], stdout=None, stderr=None)
    unmountAll()