add config creation file for deidtect

parent e4c6b018
......@@ -4,3 +4,4 @@ cscope.files
cscope.out
tags
*.pyc
*.cfg
"""
This file creates the
local site config "localSite.cfg" with
1. local enterprise controller ip
2. local cloud controller ip
remote site config "remoteSite.cfg" with
1. local enterprise controller ip
2. remote deidtect controller ip
3. wan controller ip
"""
import os
import time
import exceptions
from os import environ
from config import Config
import sys
import os.path
import socket
from optparse import OptionParser
from subprocess import Popen, PIPE
import thread
from time import sleep
#Parse command line options and dump results
def parseOptions():
"Parse command line options"
parser = OptionParser()
parser.add_option( '-s', '--site', dest='site',
default='local', help='Site config to create' )
( options, args ) = parser.parse_args()
return options, args
def createSiteConfigFile(mode):
cmdlist = []
if mode == "local":
outputfile="localSite.cfg"
localryuip = socket.gethostbyname('enterprise.deidtect-localtap.tcloud.emulab.net')
localdip = socket.gethostbyname('controller.deidtect-localtap.tcloud.emulab.net')
cmdlist.append("echo \"RYU_IP: \'%s\'\" > %s" % (localryuip,
outputfile))
cmdlist.append("echo \"CLOUD_IP:: \'%s\'\" >> %s" % (localdip,
outputfile))
else:
outputfile="remoteSite.cfg"
localryuip = socket.gethostbyname('renterprise.deidtect-localtap.tcloud.emulab.net')
wancip = socket.gethostbyname('ext.deidtect-localtap.tcloud.emulab.net')
remotedip = socket.gethostbyname('controller.deidtect-localtap.tcloud.emulab.net')
cmdlist.append("echo \"RYU_IP: \'%s\'\" > %s" % (localryuip,
outputfile))
cmdlist.append("echo \"REMOTE_IP: \'%s\'\" >> %s" % (remotedip,
outputfile))
cmdlist.append("echo \"WAN_IP: \'%s\'\" >> %s" % (wancip,
outputfile))
for cmd in cmdlist:
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
return
if __name__ == '__main__':
opts, args = parseOptions()
createSiteConfigFile(opts.site)
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