Skip to content

Commit

Permalink
release ip when create container failed
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyh16 committed Sep 19, 2017
1 parent 6fbcac5 commit f56b1fe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vclustermgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def create_cluster(self, clustername, username, image, user_info, setting):
logger.info ("create container with : name-%s, username-%s, clustername-%s, clusterid-%s, hostname-%s, ip-%s, gateway-%s, image-%s" % (lxc_name, username, clustername, str(clusterid), hostname, ips[i], gateway, image_json))
[success,message] = oneworker.create_container(lxc_name, proxy_public_ip, username, uid, json.dumps(setting) , clustername, str(clusterid), str(i), hostname, ips[i], gateway, image_json)
if success is False:
self.networkmgr.release_userips(username, ips[i])
logger.info("container create failed, so vcluster create failed")
return [False, message]
logger.info("container create success")
Expand Down Expand Up @@ -195,6 +196,7 @@ def scale_out_cluster(self,clustername,username, image,user_info, setting):
uid = json.loads(user_info)["data"]["id"]
[success, message] = oneworker.create_container(lxc_name, proxy_public_ip, username, uid, json.dumps(setting), clustername, clusterid, str(cid), hostname, ip, gateway, image_json)
if success is False:
self.networkmgr.release_userips(username, ip)
logger.info("create container failed, so scale out failed")
return [False, message]
if clusterinfo['status'] == "running":
Expand Down

0 comments on commit f56b1fe

Please sign in to comment.