X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=emuvim%2Fdcemulator%2Fnet.py;h=20ab33a72b2d25fd49ad0d7c827ed67cb83f6230;hb=a38de012a7a59661484805036eb9cce3c5cddf16;hp=609d46c89436118dbf28129d9dc1ffb0c1fe1ca6;hpb=3c54d667e0af7b7d9f54ed1e1e2bdcc61b601cfb;p=osm%2Fvim-emu.git diff --git a/emuvim/dcemulator/net.py b/emuvim/dcemulator/net.py index 609d46c..20ab33a 100755 --- a/emuvim/dcemulator/net.py +++ b/emuvim/dcemulator/net.py @@ -4,6 +4,10 @@ Distributed Cloud Emulator (dcemulator) """ import logging +import site +from subprocess import Popen +import os + from mininet.net import Dockernet from mininet.node import Controller, OVSSwitch, OVSKernelSwitch, Switch, Docker, Host, RemoteController from mininet.cli import CLI @@ -27,9 +31,11 @@ class DCNetwork(Dockernet): self.dcs = {} # create a Mininet/Dockernet network # call original Docker.__init__ and setup default controller + #Dockernet.__init__( + # self, controller=RemoteController, switch=OVSKernelSwitch, **kwargs) Dockernet.__init__( self, controller=RemoteController, switch=OVSKernelSwitch, **kwargs) - self.addController('c0') + self.addController('c0', controller=RemoteController) # graph of the complete DC network self.DCNetwork_graph=nx.DiGraph() @@ -37,6 +43,9 @@ class DCNetwork(Dockernet): # monitoring agent self.monitor_agent = DCNetworkMonitor(self) + # start Ryu controller + self.startRyu() + def addDatacenter(self, label, metadata={}): """ @@ -131,6 +140,9 @@ class DCNetwork(Dockernet): Dockernet.start(self) def stop(self): + # stop Ryu controller + self.ryu_process.terminate() + #self.ryu_process.kill() Dockernet.stop(self) def CLI(self): @@ -177,4 +189,18 @@ class DCNetwork(Dockernet): current_hop = next_hop - return "destination node: {0} not reached".format(vnf_dst_name) \ No newline at end of file + return "destination node: {0} not reached".format(vnf_dst_name) + + # start Ryu Openflow controller as Remote Controller for the DCNetwork + def startRyu(self): + # start Ryu controller with rest-API + python_install_path = site.getsitepackages()[0] + ryu_path = python_install_path + '/ryu/app/simple_switch_13.py' + ryu_path2 = python_install_path + '/ryu/app/ofctl_rest.py' + # change the default Openflow controller port to 6653 (official IANA-assigned port number), as used by Mininet + # Ryu still uses 6633 as default + ryu_option = '--ofp-tcp-listen-port' + ryu_of_port = '6653' + ryu_cmd = 'ryu-manager' + FNULL = open(os.devnull, 'w') + self.ryu_process = Popen([ryu_cmd, ryu_path, ryu_path2, ryu_option, ryu_of_port], stdout=FNULL, stderr=FNULL) \ No newline at end of file