Beispiel #1
0
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=True)

    dc1 = net.addDatacenter("dc1")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()
    
    s1 = net.addSwitch('s1')
    h1 = net.addHost('h1')
    h2 = net.addDocker('h2',dimage='host:server')
    net.addLink(h1, s1, delay='20ms')
    net.addLink(h2, s1, delay='20ms')
    net.addLink(dc1, s1, delay='20ms')
    
    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #2
0
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=True)

    dc1 = net.addDatacenter("dc1")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()

    s1 = net.addSwitch('s1')
    d1 = net.addDocker('d1', ip='10.100.0.1', dimage="ubuntu:trusty")
    d2 = net.addDocker('d2', ip='10.100.0.2', dimage="ubuntu:trusty")
    net.addLink(s1, d1)
    net.addLink(s1, d2)
    net.addLink(s1, dc1)

    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #3
0
def DemoTopology():
    net = DCNetwork(monitor=True, enable_learning=True)

    dc1 = net.addDatacenter("osm-pop1")
    dc2 = net.addDatacenter("osm-pop2")

    s1 = net.addSwitch("s1")

    net.addLink(dc1, s1)
    net.addLink(dc2, s1)

    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("127.0.0.1", 6001)
    api2 = OpenstackApiEndpoint("127.0.0.1", 6002)

    api1.connect_datacenter(dc1)
    api2.connect_datacenter(dc2)

    api1.start()
    api2.start()

    api1.connect_dc_network(net)
    api2.connect_dc_network(net)

    # add the command line interface endpoint to the emulated DC (REST API)
    Rapi = RestApiEndpoint("0.0.0.0", 5001)
    Rapi.connectDCNetwork(net)
    Rapi.connectDatacenter(dc1)
    Rapi.connectDatacenter(dc2)
    Rapi.start()

    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
def create_topology1():
    # create topology
    net = DCNetwork(controller=RemoteController, monitor=False, enable_learning=True)
    # add datecenters
    dc1 = net.addDatacenter("dc1")

    # add REST control endpoints to datacenter (to be used with son-emu-cli)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()
    
    # add OpenStack/like interface endpoints to dc1
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    # connect PoPs
    api1.connect_datacenter(dc1)
    # connect network
    api1.connect_dc_network(net)
    # start
    api1.start()

    # start the emulation platform
    net.start()
    net.CLI()
    net.stop()
Beispiel #5
0
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=True)

    dc1 = net.addDatacenter("dc1")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()
    
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')

    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 = net.addHost('h3')

    net.addLink(h1, s1)
    net.addLink(h2, s2)
    net.addLink(h3, s3)
    #create a switch triangle
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s1, s3)

    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
def create_topology(httpmode=False):
    net = DCNetwork(monitor=False, enable_learning=True)

    DC = net.addDatacenter("DC")

    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(DC)
    api1.start()
    api1.connect_dc_network(net)

    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(DC)
    rapi1.start()

    #Generation Switches
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')

    #Generation Hosts
    S = createHost(httpmode, net, 'S')
    GI = createGW(httpmode, net, 'GI')
    GFA = createGW(httpmode, net, 'GFA')
    DVA = createDV(httpmode, net, 'DVA')

    #Generation Links
    net.addLink(S, s1)
    net.addLink(GI, s2)
    net.addLink(GFA, s3)
    net.addLink(DVA, s3)
    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(DC, s3)

    #Run Services (in order)
    if httpmode:
        S.cmd("startup --local_ip 10.0.0.1 --local_port 8080 --local_name srv")
        GI.cmd(
            "startup  --local_ip 10.0.0.2 --local_port 8181 --local_name gwi --remote_ip 10.0.0.1 --remote_port 8080 --remote_name srv"
        )
        GFA.cmd(
            "startup  --local_ip 10.0.0.3 --local_port 8282 --local_name gwfa --remote_ip 10.0.0.2 --remote_port 8181 --remote_name gwi"
        )
        DVA.cmd(
            "startup  --local_ip 10.0.0.4 --local_port 8888 --local_name dva --remote_ip 10.0.0.3 --remote_port 8282 --remote_name gfa --send_period 3000"
        )

    #Do not remove
    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #7
0
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=True)

    dc1 = net.addDatacenter("dc1")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()

    Serv = net.addDocker('Serv',
                         ip='10.0.0.200',
                         dimage=image,
                         dcmd="sh ./server.sh")
    GI = net.addDocker('GI', ip='10.0.0.201', dimage=image, dcmd="sh ./gi.sh")
    GF1 = net.addDocker('GF1',
                        ip='10.0.0.202',
                        dimage=image,
                        dcmd="sh ./gf1.sh")
    GF2 = net.addDocker('GF2',
                        ip='10.0.0.203',
                        dimage=image,
                        dcmd="sh ./gf2.sh")
    GF3 = net.addDocker('GF3',
                        ip='10.0.0.204',
                        dimage=image,
                        dcmd="sh ./gf3.sh")

    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')

    net.addLink(Serv, s1)
    net.addLink(GI, s1)
    net.addLink(s1, s2, cls=TCLink, delay='100ms', bw=1)
    net.addLink(GF1, s2)
    net.addLink(GF2, s2)
    net.addLink(GF3, s2)
    net.addLink(dc1, s2)

    net.start()

    net.ping([GF1, GI])
    net.ping([GF2, GI])
    net.ping([GF3, GI])
    net.ping([Serv, GI])

    net.CLI()

    net.stop()
class DaemonTopology(object):
    """
    Topology with two datacenters:

        dc1 <-- 50ms --> dc2
    """
    def __init__(self):
        self.running = True
        signal.signal(signal.SIGINT, self._stop_by_signal)
        signal.signal(signal.SIGTERM, self._stop_by_signal)
        # create and start topology
        self.create_topology()
        self.start_topology()
        self.daemonize()
        self.stop_topology()

    def create_topology(self):
        self.net = DCNetwork(monitor=False, enable_learning=True)
        self.dc1 = self.net.addDatacenter("dc1")
        self.dc2 = self.net.addDatacenter("dc2")
        self.net.addLink(self.dc1, self.dc2, cls=TCLink, delay="50ms")
        # add OpenStack-like APIs to the emulated DC
        self.api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
        self.api1.connect_datacenter(self.dc1)
        self.api1.connect_dc_network(self.net)
        self.api2 = OpenstackApiEndpoint("0.0.0.0", 6002)
        self.api2.connect_datacenter(self.dc2)
        self.api2.connect_dc_network(self.net)
        # add the command line interface endpoint to the emulated DC (REST API)
        self.rapi1 = RestApiEndpoint("0.0.0.0", 5001)
        self.rapi1.connectDCNetwork(self.net)
        self.rapi1.connectDatacenter(self.dc1)
        self.rapi1.connectDatacenter(self.dc2)

    def start_topology(self):
        self.api1.start()
        self.api2.start()
        self.rapi1.start()
        self.net.start()

    def daemonize(self):
        print("Daemonizing vim-emu. Send SIGTERM or SIGKILL to stop.")
        while self.running:
            time.sleep(1)

    def _stop_by_signal(self, signum, frame):
        print("Received SIGNAL {}. Stopping.".format(signum))
        self.running = False

    def stop_topology(self):
        self.api1.stop()
        self.api2.stop()
        self.rapi1.stop()
        self.net.stop()
Beispiel #9
0
 def _create_openstack_api_endpoints(self):
     # create
     api1 = OpenstackApiEndpoint("172.31.255.1", 6001)
     api2 = OpenstackApiEndpoint("172.31.255.1", 6002)
     # connect PoPs
     api1.connect_datacenter(self.pop1)
     api2.connect_datacenter(self.pop2)
     # connect network
     api1.connect_dc_network(self)
     api2.connect_dc_network(self)
     # start
     api1.start()
     api2.start()
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=False)

    dc1 = net.addDatacenter("dc1")

    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)

    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #11
0
def create_topology(httpmode=False):
    net = DCNetwork(monitor=False, enable_learning=True)

    DC = net.addDatacenter("DC")

    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(DC)
    api1.start()
    api1.connect_dc_network(net)

    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(DC)
    rapi1.start()

    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')

    S = net.addDocker("S", dimage="host:server")
    GI = net.addDocker("GI", dimage="host:gateway")
    GFA = createHost(httpmode, net, 'GFA')
    GFB = createHost(httpmode, net, 'GFB')
    GFC = createHost(httpmode, net, 'GFC')

    net.addLink(S, s1)
    net.addLink(GI, s2)
    net.addLink(GFA, s3)
    net.addLink(GFB, s3)
    net.addLink(GFC, s4)

    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s2, s4)
    net.addLink(DC, s2)

    #Do not remove
    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #12
0
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=False)

    dc1 = net.addDatacenter("dc1")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()

    net.start()
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #13
0
 def _create_openstack_api_endpoints(self):
     # create
     api1 = OpenstackApiEndpoint("131.234.28.69", 6001)
     api2 = OpenstackApiEndpoint("131.234.28.69", 6002)
     api3 = OpenstackApiEndpoint("131.234.28.69", 6003)
     api4 = OpenstackApiEndpoint("131.234.28.69", 6004)
     # connect PoPs
     api1.connect_datacenter(self.pop1)
     api2.connect_datacenter(self.pop2)
     api3.connect_datacenter(self.pop3)
     api4.connect_datacenter(self.pop4)
     # connect network
     api1.connect_dc_network(self)
     api2.connect_dc_network(self)
     api3.connect_dc_network(self)
     api4.connect_dc_network(self)
     # start
     api1.start()
     api2.start()
     api3.start()
     api4.start()
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=True)

    dc1 = net.addDatacenter("dc1")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.start()

    info('*** Adding docker containers\n')
    srv = net.addDocker('srv',
                        ip='10.0.0.203',
                        dimage="constancegay/projet_sdci:server")

    time.sleep(5)
    GI = net.addDocker('GI',
                       ip='10.0.0.202',
                       dimage="constancegay/projet_sdci:gateway",
                       environment={
                           "loc_ip": "10.0.0.202",
                           "loc_port": "8181",
                           "loc_name": "GI",
                           "rem_ip": "10.0.0.203",
                           "rem_port": "8080",
                           "rem_name": "srv"
                       })
    time.sleep(5)

    mon = net.addDocker('mon',
                        ip='10.0.0.204',
                        dimage="constancegay/projet_sdci:mon")

    # GFs
    gf1 = net.addDocker('GF1',
                        ip='10.0.0.201',
                        dimage="constancegay/projet_sdci:gateway",
                        environment={
                            "loc_ip": "10.0.0.201",
                            "loc_port": "8282",
                            "loc_name": "GF1",
                            "rem_ip": "10.0.0.202",
                            "rem_port": "8181",
                            "rem_name": "GI"
                        })

    gf2 = net.addDocker('GF2',
                        ip='10.0.0.208',
                        dimage="constancegay/projet_sdci:gateway",
                        environment={
                            "loc_ip": "10.0.0.208",
                            "loc_port": "9004",
                            "loc_name": "GF2",
                            "rem_ip": "10.0.0.202",
                            "rem_port": "8181",
                            "rem_name": "GI"
                        })

    gf3 = net.addDocker('GF3',
                        ip='10.0.0.212',
                        dimage="constancegay/projet_sdci:gateway",
                        environment={
                            "loc_ip": "10.0.0.212",
                            "loc_port": "9008",
                            "loc_name": "GF3",
                            "rem_ip": "10.0.0.202",
                            "rem_port": "8181",
                            "rem_name": "GI"
                        })

    time.sleep(5)
    # ZONE 1 devices
    dev1 = net.addDocker('dev1',
                         ip='10.0.0.205',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.205",
                             "loc_port": "9001",
                             "loc_name": "dev1",
                             "rem_ip": "10.0.0.201",
                             "rem_port": "8282",
                             "rem_name": "GF1"
                         })
    dev2 = net.addDocker('dev2',
                         ip='10.0.0.206',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.206",
                             "loc_port": "9002",
                             "loc_name": "dev2",
                             "rem_ip": "10.0.0.201",
                             "rem_port": "8282",
                             "rem_name": "GF1"
                         })
    dev3 = net.addDocker('dev3',
                         ip='10.0.0.207',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.207",
                             "loc_port": "9003",
                             "loc_name": "dev3",
                             "rem_ip": "10.0.0.201",
                             "rem_port": "8282",
                             "rem_name": "GF1"
                         })

    # ZONE 2 devices
    dev4 = net.addDocker('dev4',
                         ip='10.0.0.209',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.209",
                             "loc_port": "9005",
                             "loc_name": "dev4",
                             "rem_ip": "10.0.0.208",
                             "rem_port": "9004",
                             "rem_name": "GF2"
                         })
    dev5 = net.addDocker('dev5',
                         ip='10.0.0.210',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.210",
                             "loc_port": "9006",
                             "loc_name": "dev5",
                             "rem_ip": "10.0.0.208",
                             "rem_port": "9004",
                             "rem_name": "GF2"
                         })
    dev6 = net.addDocker('dev6',
                         ip='10.0.0.211',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.211",
                             "loc_port": "9007",
                             "loc_name": "dev6",
                             "rem_ip": "10.0.0.208",
                             "rem_port": "9004",
                             "rem_name": "GF2"
                         })

    # ZONE 3 devices
    dev7 = net.addDocker('dev7',
                         ip='10.0.0.213',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.213",
                             "loc_port": "9009",
                             "loc_name": "dev7",
                             "rem_ip": "10.0.0.212",
                             "rem_port": "9008",
                             "rem_name": "GF3"
                         })
    dev8 = net.addDocker('dev8',
                         ip='10.0.0.214',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.214",
                             "loc_port": "9010",
                             "loc_name": "dev8",
                             "rem_ip": "10.0.0.212",
                             "rem_port": "9008",
                             "rem_name": "GF3"
                         })
    dev9 = net.addDocker('dev9',
                         ip='10.0.0.215',
                         dimage="constancegay/projet_sdci:dev",
                         environment={
                             "loc_ip": "10.0.0.215",
                             "loc_port": "9011",
                             "loc_name": "dev9",
                             "rem_ip": "10.0.0.212",
                             "rem_port": "9008",
                             "rem_name": "GF3"
                         })

    info('*** Adding switches\n')
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    s5 = net.addSwitch('s5')

    info('*** Creating links\n')
    net.addLink(s1, srv)
    net.addLink(s1, GI)
    net.addLink(s1, mon)

    net.addLink(s2, s1)
    net.addLink(s2, dc1)

    net.addLink(s3, s2)
    net.addLink(s4, s2)
    net.addLink(s5, s2)

    # ZONE 1
    net.addLink(s3, gf1)
    net.addLink(s3, dev1)
    net.addLink(s3, dev2)
    net.addLink(s3, dev3)

    # ZONE 2
    net.addLink(s4, gf2)
    net.addLink(s4, dev4)
    net.addLink(s4, dev5)
    net.addLink(s4, dev6)

    # ZONE 3
    net.addLink(s5, gf3)
    net.addLink(s5, dev7)
    net.addLink(s5, dev8)
    net.addLink(s5, dev9)

    info('*** Starting network\n')
    net.start()
    info('*** Testing connectivity\n')
    net.ping([srv, dev1])
    info('*** Running CLI\n')
    CLI(net)
    info('*** Stopping network')
    net.stop()
Beispiel #15
0
with open('osm_component_startup_%d.csv' % time.time(), 'w') as csvfile:
    fieldnames = [
        'other', 'zookeeper', 'kafka', 'mongo', 'nbi', 'ro_db', 'ro', 'lcm'
    ]
    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
    writer.writeheader()

    for i in range(COUNT):
        start = time.time()
        net = DCNetwork(monitor=False, enable_learning=True)
        api = None
        try:
            dc1 = net.addDatacenter("dc1")
            api = OpenstackApiEndpoint("0.0.0.0", 6001)
            api.connect_datacenter(dc1)
            api.connect_dc_network(net)

            s1 = net.addSwitch('s1')

            zookeeper_ip = '10.0.0.96'
            kafka_ip = '10.0.0.97'
            mongo_ip = '10.0.0.98'
            nbi_ip = '10.0.0.99'
            ro_db_ip = '10.0.0.100'
            ro_ip = '10.0.0.101'
            lcm_ip = '10.0.0.102'

            d1 = net.addDocker('d1', dimage='ubuntu:trusty')

            VERSION = 'releasefive-daily'
Beispiel #16
0
def create_topology(httpmode=False, port_default=8888, device_rate=1500):
    net = DCNetwork(monitor=False, enable_learning=True)

    DC = net.addDatacenter("DC")

    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(DC)
    api1.start()
    api1.connect_dc_network(net)

    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(DC)
    rapi1.start()

    #Generation Switch
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')

    S = createHost(httpmode, net, 'S', "host:server")
    GI = createHost(httpmode, net, 'GI', "host:gateway")
    GFA = createHost(httpmode, net, 'GFA', "host:gwfinal")
    GFB = createHost(httpmode, net, 'GFB', "host:gwfinal")
    GFC = createHost(httpmode, net, 'GFC', "host:gwfinal")

    #Genration of link
    net.addLink(S, s1)
    net.addLink(GI, s2)
    net.addLink(GFA, s3)
    net.addLink(GFB, s3)
    net.addLink(GFC, s4)

    net.addLink(s1, s2)
    net.addLink(s2, s3)
    net.addLink(s2, s4)
    net.addLink(DC, s4)

    #Do not remove
    net.start()

    #Run gateways and devices
    print("Starting Server node")
    S.cmd("startup --local_ip 10.0.0.1 --local_port 8888 --local_name srv")
    print("Waiting for server node to complete startup")
    time.sleep(2)
    print("Starting GI node")
    GI.cmd(
        "startup --local_ip 10.0.0.2 --local_port 8888 --local_name gwi --remote_ip 10.0.0.1 --remote_port 8888 --remote_name srv"
    )
    print("Waiting for GI node to complete startup")
    time.sleep(2)
    print("Starting GFA node")
    GFA.cmd(
        "startup --local_ip 10.0.0.3 --local_port 8888 --local_name gwfa --remote_ip 10.0.0.2 --remote_port 8888 --remote_name gwi"
    )
    print("Waiting for GFA node to complete startup")
    time.sleep(2)
    print("Starting GFA devices")
    GFA.cmd("start_devices 10.0.0.3 9001 {0} gwfa {1}".format(
        port_default, device_rate))
    print("Starting GFB node")
    GFB.cmd(
        "startup --local_ip 10.0.0.4 --local_port 8888 --local_name gwfb --remote_ip 10.0.0.2 --remote_port 8888 --remote_name gwi"
    )
    print("Waiting for GFB node to complete startup")
    time.sleep(2)
    print("Starting GFB devices")
    GFB.cmd("start_devices 10.0.0.4 9001 {0} gwfb {1}".format(
        port_default, device_rate))
    print("Starting GFC node")
    GFC.cmd(
        "startup --local_ip 10.0.0.5 --local_port 8888 --local_name gwfc --remote_ip 10.0.0.2 --remote_port 8888 --remote_name gwi"
    )
    print("Waiting for GFC node to complete startup")
    time.sleep(2)
    print("Starting GFC devices")
    GFC.cmd("start_devices 10.0.0.5 9001 {0} gwfc {1}".format(
        port_default, device_rate))
    #Start the command line
    net.CLI()
    # when the user types exit in the CLI, we stop the emulator
    net.stop()
Beispiel #17
0
class Topology(DCNetwork):
    def __init__(self):
        super(Topology, self).__init__(monitor=False, enable_learning=True)

    def setup_topo(self):
        self._create_dcs()
        # self._create_switches()
        self._create_links()
        self._create_openstack_api_endpoints()
        self._connect_aro()
        # self._create_hostvnf()
        self._create_vnf()

    def _create_dcs(self):
        rm = ARORM(max_cu=32, max_mu=8192)

        self.dc1 = self.addDatacenter("dc1")
        self.dc1.assignResourceModel(rm)

        self.dc2 = self.addDatacenter("dc2")
        self.dc2.assignResourceModel(rm)

    def _create_links(self):
        self.addLink(self.dc1, self.dc2)

    def _create_hostvnf(self):
        self.hostvnf1 = self.dc1.startCompute('hostvnf1',
                                              network=[{
                                                  'id': 'intf1',
                                                  'ip': '10.0.10.1/24'
                                              }],
                                              flavor_name='medium')
        self.hostvnf2 = self.dc2.startCompute('hostvnf2',
                                              network=[{
                                                  'id': 'intf1',
                                                  'ip': '10.0.10.2/24'
                                              }],
                                              flavor_name='medium')

    def _create_vnf(self):
        placement = RoundRobinDC()

        self.vnf1 = placevnf('vnf1',
                             network=[{
                                 'id': 'intf1',
                                 'ip': '10.0.10.1/24'
                             }],
                             flavor_name='medium',
                             placement=placement)
        self.vnf2 = placevnf('vnf2',
                             network=[{
                                 'id': 'intf1',
                                 'ip': '10.0.10.2/24'
                             }],
                             flavor_name='medium',
                             placement=placement)
        self.vnf3 = placevnf('vnf3',
                             network=[{
                                 'id': 'intf1',
                                 'ip': '10.0.10.3/24'
                             }],
                             flavor_name='medium',
                             placement=placement)
        self.vnf4 = placevnf('vnf4',
                             network=[{
                                 'id': 'intf1',
                                 'ip': '10.0.10.4/24'
                             }],
                             flavor_name='medium',
                             placement=placement)

    def _create_openstack_api_endpoints(self):
        self.api1 = OpenstackApiEndpoint("172.31.255.1", 6001)
        self.api1.connect_dc_network(self)
        self.api1.connect_datacenter(self.dc1)

        self.api2 = OpenstackApiEndpoint("172.31.255.1", 6002)
        self.api2.connect_dc_network(self)
        self.api2.connect_datacenter(self.dc2)

    def _connect_aro(self):
        self.aro = Endpoint("0.0.0.0", 2284, DCnetwork=self)
        self.aro.connectVIM(self.dc1)
        self.aro.connectVIM(self.dc2)

    def start_topo(self):
        self.start()
        self.api1.start()
        self.api2.start()
        self.aro.start()

    def stop_topo(self):
        self.aro.stop()
        # self.api1.stop()
        # self.api2.stop()
        self.stop()
Beispiel #18
0
def create_topology():
    net = DCNetwork(monitor=False, enable_learning=True)

    info('*** Adding datacenters\n')
    dc1 = net.addDatacenter("dc1")
    dc2 = net.addDatacenter("dc2")
    # add OpenStack-like APIs to the emulated DC
    api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
    api1.connect_datacenter(dc1)
    api1.connect_datacenter(dc2)
    api1.start()
    api1.connect_dc_network(net)
    # add the command line interface endpoint to the emulated DC (REST API)
    rapi1 = RestApiEndpoint("0.0.0.0", 5001)
    rapi1.connectDCNetwork(net)
    rapi1.connectDatacenter(dc1)
    rapi1.connectDatacenter(dc2)
    rapi1.start()

    # params
    SRV_PORT = 8080

    info('*** Adding switches\n')
    sw1 = net.addSwitch('sw1')
    sw2 = net.addSwitch('sw2')

    info('*** Adding docker containers\n')

    server = net.addDocker(
        'server',
        ip='10.100.0.10',
        dimage="alpine:4",
        dcmd=
        "node ./server.js --local_ip '127.0.0.1' --local_port 8080 --local_name 'srv' &"
    )

    GW = net.addDocker('GW', ip='10.100.0.4', dimage="alpine:4")

    GF1 = net.addDocker('GF1', ip='10.100.0.1', dimage="alpine:4")

    GF2 = net.addDocker('GF2', ip='10.100.0.2', dimage="alpine:4")
    GF3 = net.addDocker('GF3', ip='10.100.0.3', dimage="alpine:4")

    net.addLink(server, sw1)
    net.addLink(GW, sw1)
    net.addLink(sw1, sw2)
    net.addLink(GF1, sw2)
    net.addLink(GF2, sw2)
    net.addLink(GF3, sw2)

    info('*** Starting network\n')
    net.start()

    time.sleep(5)

    # launch gateway GW
    info("//// Starting GW gateway\n")
    GW.cmd(
        "node ./gateway.js --local_ip '127.0.0.1' --local_port 9000 --local_name 'GW' --remote_ip '10.100.0.10' --remote_port 8080 --remote_name 'srv' &"
    )
    info('//// started !\n')

    time.sleep(5)

    # launch gateways GFs

    info("//// Starting GF1 gateway\n")
    GF1.cmd(
        "node ./gateway.js --local_ip '127.0.0.1' --local_port 5000 --local_name 'GF1' --remote_ip '10.100.0.4' --remote_port 9000 --remote_name 'GW' &"
    )
    info('//// started !\n')

    info("//// Starting GF2 gateway\n")
    GF2.cmd(
        "node ./gateway.js --local_ip '127.0.0.1' --local_port 5000 --local_name 'GF2' --remote_ip '10.100.0.4' --remote_port 9000 --remote_name 'GW' &"
    )
    info('//// started !\n')

    info("//// Starting GF3 gateway\n")
    GF3.cmd(
        "node ./gateway.js --local_ip '127.0.0.1' --local_port 5000 --local_name 'GF3' --remote_ip '10.100.0.4' --remote_port 9000 --remote_name 'GW' &"
    )
    info('//// started !\n')

    # launch devices

    info("//// Starting devices on GF1\n")
    GF1.cmd(
        "node ./device.js --local_ip '127.0.0.1' --local_port 5001 --local_name 'device-1' --remote_ip '127.0.0.1' --remote_port 5000 --remote_name 'GF1' --send_period 3 &"
    )
    info('//// started !\n')

    info('*** Testing connectivity\n')
    net.ping([GW, GF1])
    info('*** Running CLI\n')
    net.CLI()
    info('*** Stopping network\n')
    net.stop()
Beispiel #19
0
def create_topology():
	net = DCNetwork(monitor=False, enable_learning=True,autoSetMacs=True)

	dc1 = net.addDatacenter("dc1")
	# add OpenStack-like APIs to the emulated DC
	api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
	api1.connect_datacenter(dc1)
	api1.start()
	api1.connect_dc_network(net)
	# add the command line interface endpoint to the emulated DC (REST API)
	rapi1 = RestApiEndpoint("0.0.0.0", 5001)
	rapi1.connectDCNetwork(net)
	rapi1.connectDatacenter(dc1)
	rapi1.start()

	s1 = net.addSwitch('s1')
	s2 = net.addSwitch('s2')
	s3 = net.addSwitch('s3')
	s4 = net.addSwitch('s4')

	srv = net.addDocker('srv', ip='192.168.0.1', dimage="server:latest")
	time.sleep(5)
	gwi = net.addDocker('gwi', ip='192.168.0.254', dimage="gateway:latest")
	time.sleep(5)
	#First cluster
	gwf1 = net.addDocker('gwf1', ip='192.168.0.252', dimage="gwf1:latest")
	device11 = net.addDocker('device11', ip='192.168.0.241', dimage="device1:latest")
	time.sleep(5)
	device12 = net.addDocker('device12', ip='192.168.0.242', dimage="device1:latest")
	device13 = net.addDocker('device13', ip='192.168.0.243', dimage="device1:latest")
	
	#Second cluster
	gwf2 = net.addDocker('gwf2', ip='192.168.0.251', dimage="gwf2:latest")
	time.sleep(5)
	device21 = net.addDocker('device21', ip='192.168.0.231', dimage="device2:latest")
	device22 = net.addDocker('device22', ip='192.168.0.232', dimage="device2:latest")
	device23 = net.addDocker('device23', ip='192.168.0.233', dimage="device2:latest")
	
	#Third cluster
	gwf3 = net.addDocker('gwf3', ip='192.168.0.250', dimage="gwf3:latest")
	time.sleep(5)
	device31 = net.addDocker('device31', ip='192.168.0.221', dimage="device3:latest")
	device32 = net.addDocker('device32', ip='192.168.0.222', dimage="device3:latest")
	device33 = net.addDocker('device33', ip='192.168.0.223', dimage="device3:latest")
		
	#Switch links
	net.addLink(s1, s2)
	net.addLink(s2, s3)
	net.addLink(s2, s4)
	net.addLink(s4,dc1)
	net.addLink(s1, srv)
	net.addLink(s2, gwi)

	#First cluster link
	net.addLink(s3, gwf1)
	net.addLink(gwf1,device11)
	net.addLink(gwf1,device12)
	net.addLink(gwf1,device13)
	
	#Second cluster link
	net.addLink(s3, gwf2)
	net.addLink(gwf2,device21)
	net.addLink(gwf2,device22)
	net.addLink(gwf2,device23)
	
	#Third cluster link
	net.addLink(s4, gwf3)
	net.addLink(gwf3,device31)
	net.addLink(gwf3,device32)
	net.addLink(gwf3,device33)
	

	net.start()
	"""
  srv.cmd("node srv/server.js --local_ip '192.168.0.1' --local_port 8080 --local_name 'srv'")
  time.sleep(2)

  gwi.cmd("node srv/gateway.js --local_ip '192.168.0.254' --local_port 8181 --local_name 'gwi1' --remote_ip '192.168.0.1' --remote_port 8080 --remote_name 'srv'")
  time.sleep(2)

  gwf1.cmd("node srv/gateway.js --local_ip '192.168.0.252' --local_port 8282 --local_name 'gwf1' --remote_ip '192.168.0.254' --remote_port 8181 --remote_name 'gwi1'")
  time.sleep(2)
  device11.cmd("node srv/device.js --local_ip '192.168.0.241' --local_port 9001 --local_name 'device11' --remote_ip '192.168.0.252' --remote_port 8282 --remote_name 'gwf1' --send_period 3000")
  device12.cmd("node srv/device.js --local_ip '192.168.0.242' --local_port 9001 --local_name 'device12' --remote_ip '192.168.0.252' --remote_port 8282 --remote_name 'gwf1' --send_period 3000")
  device13.cmd("node srv/device.js --local_ip '192.168.0.243' --local_port 9001 --local_name 'device13' --remote_ip '192.168.0.252' --remote_port 8282 --remote_name 'gwf1' --send_period 3000")

  gwf2.cmd("node srv/gateway.js --local_ip '192.168.0.251' --local_port 8282 --local_name 'gwf2' --remote_ip '192.168.0.254' --remote_port 8181 --remote_name 'gwi1'")
  time.sleep(2)
  device21.cmd("node srv/device.js --local_ip '192.168.0.231' --local_port 9001 --local_name 'device21' --remote_ip '192.168.0.251' --remote_port 8282 --remote_name 'gwf2' --send_period 3000")
  device22.cmd("node srv/device.js --local_ip '192.168.0.232' --local_port 9001 --local_name 'device22' --remote_ip '192.168.0.251' --remote_port 8282 --remote_name 'gwf2' --send_period 3000")
  device23.cmd("node srv/device.js --local_ip '192.168.0.233' --local_port 9001 --local_name 'device23' --remote_ip '192.168.0.251' --remote_port 8282 --remote_name 'gwf2' --send_period 3000")

  gwf3.cmd("node srv/gateway.js --local_ip '192.168.0.250' --local_port 8282 --local_name 'gwf3' --remote_ip '192.168.0.254' --remote_port 8181 --remote_name 'gwi1'")
  time.sleep(2)
  device31.cmd("node srv/device.js --local_ip '192.168.0.221' --local_port 9001 --local_name 'device31' --remote_ip '192.168.0.250' --remote_port 8282 --remote_name 'gwf3' --send_period 3000")
  device32.cmd("node srv/device.js --local_ip '192.168.0.222' --local_port 9001 --local_name 'device32' --remote_ip '192.168.0.250' --remote_port 8282 --remote_name 'gwf3' --send_period 3000")
  device33.cmd("node srv/device.js --local_ip '192.168.0.221' --local_port 9001 --local_name 'device33' --remote_ip '192.168.0.250' --remote_port 8282 --remote_name 'gwf3' --send_period 3000")
		"""
	net.CLI()
	# when the user types exit in the CLI, we stop the emulator
	net.stop()