import logging\r
import threading\r
import zerorpc\r
-import site\r
-from subprocess import Popen\r
+\r
\r
logging.basicConfig(level=logging.INFO)\r
\r
logging.debug("Created monitoring API endpoint %s(%s:%d)" % (\r
self.__class__.__name__, self.ip, self.port))\r
\r
- # start Ryu controller with rest-API\r
- python_install_path = site.getsitepackages()[0]\r
- ryu_path = python_install_path + '/ryu/app/simple_switch_13.py'\r
- ryu_path2 = python_install_path + '/ryu/app/ofctl_rest.py'\r
- # change the default Openflow controller port to 6653 (official IANA-assigned port number), as used by Mininet\r
- # Ryu still uses 6633 as default\r
- ryu_option = '--ofp-tcp-listen-port'\r
- ryu_of_port = '6653'\r
- ryu_cmd = 'ryu-manager'\r
- self.ryu_process = Popen([ryu_cmd, ryu_path, ryu_path2, ryu_option, ryu_of_port])\r
-\r
def connectDCNetwork(self, net):\r
self.net = net\r
logging.info("Connected DCNetwork to API endpoint %s(%s:%d)" % (\r
s.run()\r
\r
def stop(self):\r
- # stop ryu controller\r
logging.info("Stop the monitoring API endpoint")\r
- self.ryu_process.terminate()\r
- #self.ryu_process.kill()\r
return\r
\r
\r
class DCNetworkApi(object):\r
"""\r
+ The networking and monitoring commands need the scope of the\r
+ whole DC network to find the requested vnf. So this API is intended\r
+ to work with a DCNetwork.\r
Just pass through the corresponding request to the\r
- selected data center. Do not implement provisioning\r
+ selected data center network. Do not implement provisioning\r
logic here because will will have multiple API\r
endpoint implementations at the end.\r
"""\r
"""
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
# monitoring agent
self.monitor_agent = DCNetworkMonitor(self)
+ # start Ryu controller
+ self.startRyu()
+
def addDatacenter(self, label, metadata={}):
"""
Dockernet.start(self)
def stop(self):
+ # stop Ryu controller
+ self.ryu_process.terminate()
+ #self.ryu_process.kill()
Dockernet.stop(self)
def CLI(self):
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
net.CLI()
# when the user types exit in the CLI, we stop the emulator
# we need to explicitly stop the monitoring api, so the Ryu controller is also terminated
- mon_api.stop()
+ #mon_api.stop()
net.stop()