add del tap for taking out the flows and vm gracefully

parent 4b3c2d64
......@@ -29,8 +29,8 @@ COMPUTE='computehelper/'
NETWORK='networkhelper/'
class deidtect:
def __init__(self,opts):
f = file(opts.file);
def __init__(self,filename):
f = file(filename);
self.cfg = Config(f);
print self.cfg;
......@@ -62,26 +62,32 @@ class deidtect:
def sendLocalCloudReq(self, cmd, name, switch, port, vlan, tunid,ryuip):
print "Local Cloud VM req sending.."
cloudCtrlIP = self.cfg['CLOUD_IP']
pCmd = "curl -v http://%s:123/controllerhelper/\'%s\'/\'%s\'/%d/%d/\'%s\'/\'%s\'" % (cloudCtrlIP,cmd,name,vlan,tunid,switch,ryuip)
if cmd == "add":
pCmd = "curl -v http://%s:123/controllerhelper/\'%s\'/\'%s\'/%d/%d/\'%s\'/\'%s\'" % (cloudCtrlIP,cmd,name,vlan,tunid,switch,ryuip)
else:
pCmd = "curl -v http://%s:123/controllerhelper/\'%s\'/\'%s\'/%d/%d" % (cloudCtrlIP,cmd,name,vlan,tunid)
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=1):
def sendReq(self, name="test", cmd="add", switch='0000000000000001', port=3,vlan=100,tunid=5):
if self.isLocal():
print "Sending tap rq to local enterprise controller"
self.sendLocalTapReq(cmd, switch,port,vlan,None);
#follow the order
print "Send local cloud init req to the cloudcontroller"
ryuip = self.cfg['RYU_IP']
self.sendLocalCloudReq(cmd,name,switch,port,vlan,tunid,ryuip)
else:
print "Sending tap rq to local enterprise controller"
print "Sending tunnel setup req to WAN controller"
self.sendLocalTapReq(cmd, switch,port,vlan,None);
else:
#follow the order
print "Sending cloud req remote deidtect controller"
print "Sending tunnel setup req to WAN controller"
print "Sending tap rq to local enterprise controller"
if __name__ == '__main__':
opts, args = parseOptions()
d = deidtect(opts);
d.sendReq()
d = deidtect(opts.file);
d.sendReq(cmd="add")
#d.sendReq(cmd="del")
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