Moved processing the cmd_line databag into update

This commit is contained in:
Ian Southam 2014-08-13 16:28:12 +02:00 committed by wilderrodrigues
parent 99dd91c565
commit 4e63119873
2 changed files with 7 additions and 24 deletions

View File

@ -685,36 +685,12 @@ def main(argv):
logging.basicConfig(filename='/var/log/cloud.log',
level=logging.DEBUG,
format='%(asctime)s %(message)s')
# we need to parse the cmd_line often, cloudstack might change it between reboots
# TODO - Take this out --------------------------------------------------------------------- #
cmdLine = dataBag()
cmdLine.setKey("cmd_line")
cmdLine.load()
cmdLineData = cmdLine.getDataBag()
db = dataBag()
db.setKey("ips")
db.load()
dbag = db.getDataBag()
if not cmdLineData["cmd_line"]["type"] in { "vpcrouter", "router"}:
logging.info("Not equipped to handle %s yet" % cmdLineData["cmd_line"]["type"])
return
if cmdLineData["cmd_line"]["type"] == "vpcrouter":
# Create "fake" dev for eth0
controlIp = dict()
controlIp["add"] = True
controlIp["public_ip"] = cmdLineData["cmd_line"]["eth0ip"]
controlIp["netmask"] = cmdLineData["cmd_line"]["eth0mask"]
controlIp["nic_dev_id"] = 0
controlIp["nw_type"] = "control"
merge(dbag, controlIp)
# ----------------------------------------------------------------------------------------- #
for dev in CsDevice('').list():
ip = CsIP(dev)
ip.compare(dbag)

View File

@ -21,6 +21,13 @@ if not (os.path.isfile(filePath) and os.access(filePath, os.R_OK)):
print "You are telling me to process %s, but i can't access it" % filePath
sys.exit(1)
# If the command line json file is unprocessed process it
# This is important or, the control interfaces will get deleted!
if os.path.isfile("filePath/%s" % "cmd_line.json"):
qf = loadQueueFile()
qf.setFile("cmd_line.json")
qf.load(None)
qf = loadQueueFile()
qf.setFile(sys.argv[1])
qf.load(None)