1
0
Fork 0
mirror of https://github.com/ThomasGsp/HyperProxmox.git synced 2025-02-12 19:22:30 +00:00

Return correct error on insert_new_cluster.

Require to apply the same patch on all fct.
This commit is contained in:
thomas.guiseppin 2017-10-25 20:46:51 +02:00
parent e4b14f520d
commit ac4ec9d1fa

View file

@ -116,7 +116,13 @@ class MongoDB:
return json.loads(dumps(self.db[self.collection_clusters].find({})))
def insert_new_cluster(self, data):
return self.db[self.collection_clusters].insert(data)
try:
self.db[self.collection_clusters].insert(data)
result = {"value": "{0} {1}".format(data["name"], "is now available")}
except BaseException as e:
result = {"value": "{0} {1}".format("Invalid request", e)}
return result
def update_cluster(self, cluster, data):
return self.db[self.collection_clusters].update({"vmid": str(cluster)}, {'$set': data}, upsert=False)