Commit d9d74c4a authored by Praveen Kumar Shanmugam's avatar Praveen Kumar Shanmugam

add distributed capability : handles one site as of now, can be extended to...

add distributed capability : handles one site as of now, can be extended to handle multiple sites, we wont do that for the current implementation as it is a proof of concept
parent aadd9896
...@@ -2,8 +2,6 @@ from os import environ ...@@ -2,8 +2,6 @@ from os import environ
from config import Config from config import Config
import sys import sys
import binascii import binascii
from neutronclient.v2_0 import client as neutronclient
from novaclient.client import Client
import socket import socket
from optparse import OptionParser from optparse import OptionParser
import requests, json import requests, json
...@@ -64,6 +62,22 @@ class deidtect: ...@@ -64,6 +62,22 @@ class deidtect:
out, err = p.communicate() out, err = p.communicate()
print out,err print out,err
def sendRemoteDeidTectReq(self, cmd, name, switch, port, vlan, tunid,ryuip):
print "Sending Remote DEIDtect Request.."
rDeidtectIP = self.cfg['REMOTE_IP']
pCmd = "curl -v http://%s:120/deidtect/remote/\'%s\'/\'%s\'/\'%s\'/\'%s\'/%d/%d/%d" \
% (rDeidtectIP,cmd,name,ryuip,switch,port,vlan,tunid)
print pCmd
p = Popen(pCmd, shell=True, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
print out,err
def sendRemReq(self, name="test", cmd="add", ryuip='localhost', switch='0000000000000001', port=3,vlan=100,tunid=5):
print "Received Remote request..."
self.sendLocalCloudReq(cmd,name,switch,port,vlan,tunid,ryuip)
def sendLocalCloudReq(self, cmd, name, switch, port, vlan, tunid,ryuip): def sendLocalCloudReq(self, cmd, name, switch, port, vlan, tunid,ryuip):
print "Local Cloud VM req sending.." print "Local Cloud VM req sending.."
cloudCtrlIP = self.cfg['CLOUD_IP'] cloudCtrlIP = self.cfg['CLOUD_IP']
...@@ -76,6 +90,17 @@ class deidtect: ...@@ -76,6 +90,17 @@ class deidtect:
out, err = p.communicate() out, err = p.communicate()
print out,err print out,err
def sendWanReq(self, cmd, vlan):
print "Sending WAN Ctrl Request.."
wanIP = self.cfg['WAN_IP']
pCmd = "curl -v http://%s:100/wanhelper/\'%s\'/%d" \
% (wanIP, cmd,vlan)
print pCmd
p = Popen(pCmd, shell=True, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
print out,err
def sendReq(self, name="test", cmd="add", switch='0000000000000001', port=3,vlan=100,tunid=5): def sendReq(self, name="test", cmd="add", switch='0000000000000001', port=3,vlan=100,tunid=5):
if self.isLocal(): if self.isLocal():
#follow the order #follow the order
...@@ -87,8 +112,12 @@ class deidtect: ...@@ -87,8 +112,12 @@ class deidtect:
else: else:
#follow the order #follow the order
print "Sending cloud req remote deidtect controller" print "Sending cloud req remote deidtect controller"
ryuip = self.cfg['RYU_IP']
self.sendRemoteDeidTectReq(cmd,name,switch,port,vlan,tunid,ryuip)
print "Sending tunnel setup req to WAN controller" print "Sending tunnel setup req to WAN controller"
self.sendWanReq(cmd, vlan);
print "Sending tap rq to local enterprise controller" print "Sending tap rq to local enterprise controller"
self.sendLocalTapReq(cmd, switch,port,vlan,None);
''' '''
wsgi functions wsgi functions
...@@ -141,18 +170,22 @@ def start_deidtect_server(port): ...@@ -141,18 +170,22 @@ def start_deidtect_server(port):
route_name = 'deidtect' route_name = 'deidtect'
print "Server : DEIDtect Core active.." print "Server : DEIDtect Core active.."
uri = '/deidtect/{site}/{cmd}/{idsname}/{switchdpid}/{port}/{vlanid}/{tunid}' uri = '/deidtect/{cmd}/{idsname}/{switchdpid}/{port}/{vlanid}/{tunid}'
mapper.connect(route_name, uri, controller="home", mapper.connect(route_name, uri, controller="home",
action='deidtectAction', action='deidtectAction',
conditions=dict(method=['GET'])) conditions=dict(method=['GET']))
uri = '/deidtect/remote/{cmd}/{idsname}/{ryuip}/{switchdpid}/{port}/{vlanid}/{tunid}'
mapper.connect(route_name, uri, controller="home",
action='deidtectRemAction',
conditions=dict(method=['GET']))
wsgi.server(eventlet.listen((serverip, port)), networkapp) wsgi.server(eventlet.listen((serverip, port)), networkapp)
print "Server : DEIDtect Core Stopped" print "Server : DEIDtect Core Stopped"
def deidtectAction(dic, start_response): def deidtectAction(dic, start_response):
print "got deidtectAction request.." print "got deidtectAction request.."
print dic print dic
site = dic.get('site',None)
cmd = dic.get('cmd',None) cmd = dic.get('cmd',None)
idsname = dic.get('idsname',None) idsname = dic.get('idsname',None)
switchdpid = dic.get('switchdpid',None) switchdpid = dic.get('switchdpid',None)
...@@ -164,10 +197,25 @@ def deidtectAction(dic, start_response): ...@@ -164,10 +197,25 @@ def deidtectAction(dic, start_response):
vlanid = int(vlanid) vlanid = int(vlanid)
tunid = int(tunid) tunid = int(tunid)
if site == "local": d.sendReq(cmd=cmd, name=idsname, switch=switchdpid, port=port,
d.sendReq(cmd=cmd, name=idsname, switch=switchdpid, port=port,
vlan=vlanid, tunid=tunid) vlan=vlanid, tunid=tunid)
return sendOK(start_response);
def deidtectRemAction(dic, start_response):
cmd = dic.get('cmd',None)
idsname = dic.get('idsname',None)
ryuip = dic.get('ryuip',None)
switchdpid = dic.get('switchdpid',None)
port = dic.get('port',None)
vlanid = dic.get('vlanid',None)
tunid = dic.get('tunid',None)
port = int(port)
vlanid = int(vlanid)
tunid = int(tunid)
d.sendRemReq(cmd=cmd, name=idsname, ryuip=ryuip, switch=switchdpid, port=port,
vlan=vlanid, tunid=tunid)
return sendOK(start_response); return sendOK(start_response);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment