replace LOG with prints

parent f6194623
import logging as LOG
from config import Config
import sys
import binascii
......@@ -7,10 +8,13 @@ import socket
import requests, json
import idsSpinup as dIds
import eventlet
import datetime
from eventlet import wsgi
from cgi import parse_qs, escape
from routes import Mapper
LOG.basicConfig(level=LOG.INFO)
PORT='100/'
COMPUTE='computehelper/'
NETWORK='networkhelper/'
......@@ -47,12 +51,13 @@ def wsgiresponder(environ, start_response):
if result is not None:
print result
print "called.. %s" % result['action']
LOG.info("called.. %s", result['action'])
return globals()[result['action']](result, start_response, environ)
return sendError(start_response)
def delIDS(dic, start_response,environ):
print "got delIDS request.."
LOG.info("got delIDS request..")
LOG.info("%s", datetime.datetime.now())
name = dic.get('name',None)
vlan = dic.get('vlanid', None)
tun = dic.get('tunid',None)
......@@ -67,7 +72,8 @@ def delIDS(dic, start_response,environ):
return actionIDS(start_response, "del" , name, vlanid, tunid);
def setupIDS(dic, start_response,environ):
print "got setupIDS request.."
LOG.info("got setupIDS request..")
LOG.info("%s", datetime.datetime.now())
name = dic.get('name',None)
vlan = dic.get('vlanid', None)
......@@ -90,7 +96,7 @@ def setupIDS(dic, start_response,environ):
def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None, site='local'):
print "performing action.."
LOG.info("performing ids action..")
if cmd == "add":
dIds.spinUpIDS(0,name, cip=ryuip, \
site=site)
......@@ -106,8 +112,8 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None,
break;
if ids is None:
print "No IDS found"
return;
LOG.info("No IDS found")
return sendOK(start_response);
ids_dict = vars(ids);
network_info = ids_dict['addresses']
......@@ -119,8 +125,8 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None,
hexIP = binascii.hexlify(socket.inet_aton(computeTunnelHostIP))
networkGreTunName = "gre-"+hexIP
print "Server: %s" % ids.name
print "Host: %s" % computeHost
LOG.info("Server: %s" , ids.name)
LOG.info("Host: %s" , computeHost)
allnet = network_info['test-net-2'] #rename to ids network to be generic
global VMIP, VMMAC;
......@@ -129,10 +135,10 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None,
VMIP = net['addr']
VMMAC = net['OS-EXT-IPS-MAC:mac_addr']
break;
print "Send Data to Network Node@%s" % networkMgmtIP
print "vlan ID :%d, greTun ID:%d" % (vlan,tunid)
print "<Optional Host Tun IP: %s>" % computeTunnelHostIP
print "Network TunName: %s" % networkGreTunName
LOG.info("Send Data to Network Node@%s" , networkMgmtIP)
LOG.info("vlan ID :%d, greTun ID:%d" , vlan,tunid)
LOG.info("<Optional Host Tun IP: %s>" , computeTunnelHostIP)
LOG.info("Network TunName: %s" , networkGreTunName)
if cmd == "add":
helpercmd= 'add/'
......@@ -141,23 +147,23 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None,
neturl = 'http://'+str(networkMgmtIP)+':'+PORT+ \
NETWORK+helpercmd+str(vlan)+'/'+networkGreTunName+'/'+str(tunid)
print neturl
LOG.info("%s",neturl)
r = requests.get(neturl)
print r.status_code
LOG.info("%s", r.status_code)
print "Send Data to Compute Node@%s" % computeMgmtHostIP
print "vlan ID :%d, greTun ID:%d" % (vlan,tunid)
print "VM : %s@%s" % (VMIP,VMMAC)
LOG.info("Send Data to Compute Node@%s" % computeMgmtHostIP)
LOG.info("vlan ID :%d, greTun ID:%d" , vlan,tunid)
LOG.info("VM : %s@%s" , VMIP,VMMAC)
computeurl = 'http://'+str(computeMgmtHostIP)+':'+PORT+ \
COMPUTE+helpercmd+str(vlan)+'/'+str(tunid)+'/'+str(VMMAC)
print computeurl
LOG.info("%s", computeurl)
if cmd == "del":
dIds.spinDownIDS(name);
r = requests.get(computeurl)
print r.status_code
LOG.info("%s", r.status_code)
if cmd =="add":
floating_ip = ids.addresses['test-net-1'][1]['addr']
return sendOK(start_response, floating_ip);
......@@ -166,10 +172,9 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None,
def start_controller_server(port):
global mapper
hostip = socket.gethostbyname('controller.deidtect-localtap.tcloud.emulab.net')
print hostip
mapper = Mapper()
route_name = 'controllerhelper'
print "Server : Controller Helper for DEIDtect Started.."
LOG.info("Server : Controller Helper for DEIDtect Started..@ %s", hostip)
uri = '/controllerhelper/add/{name}/{vlanid}/{tunid}/{switch}/{ryuip}/{site}'
mapper.connect(route_name, uri, controller="home",
......@@ -182,7 +187,7 @@ def start_controller_server(port):
conditions=dict(method=['GET']))
wsgi.server(eventlet.listen((hostip, port)), wsgiresponder)
print "Server : Controller Helper for DEIDtect Stopped"
LOG.info("Server : Controller Helper for DEIDtect Stopped")
if __name__ == '__main__':
start_controller_server(123);
......
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