mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
Add error managment
This commit is contained in:
parent
a47d251612
commit
d9de9384a2
5 changed files with 182 additions and 92 deletions
|
@ -25,34 +25,65 @@ class Cluster:
|
||||||
def GET(self, cluster=None):
|
def GET(self, cluster=None):
|
||||||
try:
|
try:
|
||||||
if cluster:
|
if cluster:
|
||||||
result = core.get_cluster(cluster)
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": core.get_cluster(cluster)
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
result = core.get_cluster()
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": core.get_cluster()
|
||||||
|
}
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
result = {"value": "{0} {1}".format("Invalid request", e)}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PYTHON - API",
|
||||||
|
"value": "{0} {1}".format("Invalid request:", e)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def POST(self):
|
def POST(self):
|
||||||
try:
|
try:
|
||||||
data = json.loads(web.data().decode('utf-8'))
|
data = json.loads(web.data().decode('utf-8'))
|
||||||
result = core.insert_cluster(data)
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": core.insert_cluster(data)
|
||||||
|
}
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
result = {"value": "{0} {1}".format("Invalid request", e)}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PYTHON - API",
|
||||||
|
"value": "{0} {1}".format("Invalid request:", e)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def PUT(self, cluster):
|
def PUT(self, cluster):
|
||||||
try:
|
try:
|
||||||
data = json.loads(web.data().decode('utf-8'))
|
data = json.loads(web.data().decode('utf-8'))
|
||||||
result = core.change_cluster(cluster, data)
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": core.change_cluster(cluster, data)
|
||||||
|
}
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
result = {"value": "{0} {1}".format("Invalid request", e)}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PYTHON - API",
|
||||||
|
"value": "{0} {1}".format("Invalid request:", e)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def DELETE(self, cluster):
|
def DELETE(self, cluster):
|
||||||
try:
|
try:
|
||||||
result = core.delete_cluste(cluster)
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": core.delete_cluste(cluster)
|
||||||
|
}
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
result = {"value": "{0} {1}".format("Invalid request", e)}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PYTHON - API",
|
||||||
|
"value": "{0} {1}".format("Invalid request:", e)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ class Core:
|
||||||
|
|
||||||
""" LOAD REDIS """
|
""" LOAD REDIS """
|
||||||
self.redis_msg = Lredis
|
self.redis_msg = Lredis
|
||||||
#self.redis_msg.co = self.redis_msg.connect()
|
|
||||||
|
|
||||||
if self.mongo.client and self.redis_msg.connect():
|
if self.mongo.client and self.redis_msg.connect():
|
||||||
self.mongo.db = self.mongo.client.db
|
self.mongo.db = self.mongo.client.db
|
||||||
|
@ -52,7 +51,7 @@ class Core:
|
||||||
self.delayrounddeploy = generalconf["deploy"]["delayrounddeploy"]
|
self.delayrounddeploy = generalconf["deploy"]["delayrounddeploy"]
|
||||||
|
|
||||||
""" RUN THE ANALYZER IN DEDICATED THEARD"""
|
""" RUN THE ANALYZER IN DEDICATED THEARD"""
|
||||||
self.clusters_conf = self.mongo.get_clusters_conf()
|
self.clusters_conf = self.mongo.get_clusters_conf()["value"]
|
||||||
|
|
||||||
thc = threading.Thread(name="Update statistics",
|
thc = threading.Thread(name="Update statistics",
|
||||||
target=RunAnalyse,
|
target=RunAnalyse,
|
||||||
|
@ -69,12 +68,15 @@ class Core:
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
lastkeyvalid = self.mongo.get_last_datekey()
|
lastkeyvalid = self.mongo.get_last_datekey()
|
||||||
node_informations = self.mongo.get_nodes_informations((int(lastkeyvalid["value"])), target)
|
node_informations = self.mongo.get_nodes_informations((int(lastkeyvalid["value"])), target)
|
||||||
cluster_informations = self.mongo.get_clusters_conf(node_informations["cluster"])
|
cluster_informations = self.mongo.get_clusters_conf(node_informations["cluster"])["value"]
|
||||||
|
|
||||||
proxmox_cluster_url = cluster_informations["url"]
|
proxmox_cluster_url = cluster_informations["url"]
|
||||||
proxmox_cluster_port = cluster_informations["port"]
|
proxmox_cluster_port = cluster_informations["port"]
|
||||||
proxmox_cluster_user = pdecrypt(cluster_informations["user"],self.generalconf["keys"]["key_pvt"])
|
proxmox_cluster_user = pdecrypt(base64.b64decode(cluster["user"]),
|
||||||
proxmox_cluster_pwd = pdecrypt(cluster_informations["password"], self.generalconf["keys"]["key_pvt"])
|
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||||
|
|
||||||
|
proxmox_cluster_pwd = pdecrypt(base64.b64decode(cluster["password"]),
|
||||||
|
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||||
|
|
||||||
proxmox_template = cluster_informations["template"]
|
proxmox_template = cluster_informations["template"]
|
||||||
proxmox_storage_disk = cluster_informations["storage_disk"]
|
proxmox_storage_disk = cluster_informations["storage_disk"]
|
||||||
|
@ -169,7 +171,7 @@ class Core:
|
||||||
instance_informations = self.mongo.get_instance(vmid)
|
instance_informations = self.mongo.get_instance(vmid)
|
||||||
|
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])
|
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||||
|
|
||||||
proxmox_cluster_url = cluster_informations["url"]
|
proxmox_cluster_url = cluster_informations["url"]
|
||||||
proxmox_cluster_port = cluster_informations["port"]
|
proxmox_cluster_port = cluster_informations["port"]
|
||||||
|
@ -190,8 +192,12 @@ class Core:
|
||||||
self.mongo.delete_instance(vmid)
|
self.mongo.delete_instance(vmid)
|
||||||
self.mongo.update_system_free_ip(instance_informations['ip'])
|
self.mongo.update_system_free_ip(instance_informations['ip'])
|
||||||
|
|
||||||
except BaseException:
|
except IndexError as ierror:
|
||||||
result = {"value": "{0} {1}".format(vmid, "is not a valid VMID")}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PROXMOX - VALUES",
|
||||||
|
"value": "{0} is not a valid VMID: {1}".format(vmid, ierror)
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -201,7 +207,7 @@ class Core:
|
||||||
instance_informations = self.mongo.get_instance(vmid)
|
instance_informations = self.mongo.get_instance(vmid)
|
||||||
|
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])
|
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||||
|
|
||||||
proxmox_cluster_url = cluster_informations["url"]
|
proxmox_cluster_url = cluster_informations["url"]
|
||||||
proxmox_cluster_port = cluster_informations["port"]
|
proxmox_cluster_port = cluster_informations["port"]
|
||||||
|
@ -221,8 +227,12 @@ class Core:
|
||||||
"lxc",
|
"lxc",
|
||||||
vmid, action)
|
vmid, action)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError as ierror:
|
||||||
result = {"value": "{0} {1}".format(vmid, "is not a valid VMID")}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PROXMOX - VALUES",
|
||||||
|
"value": "{0} is not a valid VMID: {1}".format(vmid, ierror)
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -232,7 +242,7 @@ class Core:
|
||||||
instance_informations = self.mongo.get_instance(vmid)
|
instance_informations = self.mongo.get_instance(vmid)
|
||||||
|
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])
|
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||||
|
|
||||||
proxmox_cluster_url = cluster_informations["url"]
|
proxmox_cluster_url = cluster_informations["url"]
|
||||||
proxmox_cluster_port = cluster_informations["port"]
|
proxmox_cluster_port = cluster_informations["port"]
|
||||||
|
@ -252,8 +262,12 @@ class Core:
|
||||||
"lxc",
|
"lxc",
|
||||||
vmid)
|
vmid)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError as ierror:
|
||||||
result = {"value": "{0} {1}".format(vmid, "is not a valid VMID")}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PROXMOX - VALUES",
|
||||||
|
"value": "{0} is not a valid VMID: {1}".format(vmid, ierror)
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -263,7 +277,7 @@ class Core:
|
||||||
instance_informations = self.mongo.get_instance(vmid)
|
instance_informations = self.mongo.get_instance(vmid)
|
||||||
|
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])
|
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||||
|
|
||||||
proxmox_cluster_url = cluster_informations["url"]
|
proxmox_cluster_url = cluster_informations["url"]
|
||||||
proxmox_cluster_port = cluster_informations["port"]
|
proxmox_cluster_port = cluster_informations["port"]
|
||||||
|
@ -287,8 +301,12 @@ class Core:
|
||||||
if result['result'] == "OK":
|
if result['result'] == "OK":
|
||||||
self.mongo.update_instance(vmid, data)
|
self.mongo.update_instance(vmid, data)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError as ierror:
|
||||||
result = {"value": "{0} {1}".format(vmid, "is not a valid VMID")}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PROXMOX - VALUES",
|
||||||
|
"value": "{0} is not a valid VMID: {1}".format(vmid, ierror)
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -300,14 +318,14 @@ class Core:
|
||||||
|
|
||||||
def get_cluster(self, cluster=None):
|
def get_cluster(self, cluster=None):
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
cluster_informations = self.mongo.get_clusters_conf(cluster)
|
cluster_informations = self.mongo.get_clusters_conf(cluster)["value"]
|
||||||
return cluster_informations
|
return cluster_informations
|
||||||
|
|
||||||
def insert_cluster(self, data):
|
def insert_cluster(self, data):
|
||||||
testdata = valid_cluster_data(data)
|
testdata = valid_cluster_data(data)
|
||||||
|
|
||||||
if not testdata:
|
if not testdata:
|
||||||
if not self.mongo.get_clusters_conf(data["name"]):
|
if not self.mongo.get_clusters_conf(data["name"])["value"]:
|
||||||
data["user"] = base64.b64encode(pcrypt(data["user"], self.generalconf["keys"]["key_pvt"])["data"]).decode('utf-8')
|
data["user"] = base64.b64encode(pcrypt(data["user"], self.generalconf["keys"]["key_pvt"])["data"]).decode('utf-8')
|
||||||
data["password"] = base64.b64encode(pcrypt(data["password"], self.generalconf["keys"]["key_pvt"])["data"]).decode('utf-8')
|
data["password"] = base64.b64encode(pcrypt(data["password"], self.generalconf["keys"]["key_pvt"])["data"]).decode('utf-8')
|
||||||
new_cluster = self.mongo.insert_new_cluster(data)
|
new_cluster = self.mongo.insert_new_cluster(data)
|
||||||
|
|
|
@ -57,23 +57,23 @@ class Analyse:
|
||||||
for cluster in self.clusters_conf:
|
for cluster in self.clusters_conf:
|
||||||
""" Decode data """
|
""" Decode data """
|
||||||
|
|
||||||
user = pdecrypt(base64.b64decode(cluster["user"]),
|
proxmox_cluster_user = pdecrypt(base64.b64decode(cluster["user"]),
|
||||||
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||||
|
|
||||||
password = pdecrypt(base64.b64decode(cluster["password"]),
|
proxmox_cluster_pwd = pdecrypt(base64.b64decode(cluster["password"]),
|
||||||
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||||
|
|
||||||
""" AUTH """
|
""" AUTH """
|
||||||
proxmox = Proxmox("Analyse")
|
proxmox = Proxmox("Analyse")
|
||||||
proxmox.get_ticket("{0}:{1}".format(cluster["url"], int(cluster["port"])), user, password)
|
proxmox.get_ticket("{0}:{1}".format(cluster["url"], int(cluster["port"])), proxmox_cluster_user, proxmox_cluster_pwd)
|
||||||
|
|
||||||
""" Get excluded nodes """
|
""" Get excluded nodes """
|
||||||
exclude_nodes = cluster["exclude_nodes"]
|
exclude_nodes = cluster["exclude_nodes"]
|
||||||
|
|
||||||
""" UPDATE NODES LIST """
|
""" UPDATE NODES LIST """
|
||||||
nodes_list = proxmox.get_nodes("{0}:{1}".format(cluster["url"], int(cluster["port"])))["value"]
|
nodes_list = proxmox.get_nodes("{0}:{1}".format(cluster["url"], int(cluster["port"])))
|
||||||
|
if nodes_list["result"] == "OK":
|
||||||
for value_nodes_list in nodes_list["data"]:
|
for value_nodes_list in nodes_list["value"]["data"]:
|
||||||
if value_nodes_list["node"] not in exclude_nodes:
|
if value_nodes_list["node"] not in exclude_nodes:
|
||||||
""" TOTAL COUNT CPU and RAM allocate"""
|
""" TOTAL COUNT CPU and RAM allocate"""
|
||||||
list_instances = proxmox.get_instance("{0}:{1}".format(cluster["url"], int(cluster["port"])),
|
list_instances = proxmox.get_instance("{0}:{1}".format(cluster["url"], int(cluster["port"])),
|
||||||
|
@ -105,8 +105,10 @@ class Analyse:
|
||||||
|
|
||||||
self.mongo.insert_node(value_nodes_list)
|
self.mongo.insert_node(value_nodes_list)
|
||||||
|
|
||||||
self.mongo.update_datekey(int(insert_time), "OK")
|
else:
|
||||||
|
print(nodes_list)
|
||||||
|
|
||||||
|
self.mongo.update_datekey(int(insert_time), "OK")
|
||||||
return
|
return
|
||||||
|
|
||||||
def set_attribution(self, count):
|
def set_attribution(self, count):
|
||||||
|
|
|
@ -110,26 +110,65 @@ class MongoDB:
|
||||||
|
|
||||||
""" CLUSTER """
|
""" CLUSTER """
|
||||||
def get_clusters_conf(self, cluster=None):
|
def get_clusters_conf(self, cluster=None):
|
||||||
|
try:
|
||||||
if cluster:
|
if cluster:
|
||||||
return json.loads(dumps(self.db[self.collection_clusters].find_one({"name": cluster})))
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": json.loads(dumps(self.db[self.collection_clusters].find_one({"name": cluster})))
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
return json.loads(dumps(self.db[self.collection_clusters].find({})))
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": json.loads(dumps(self.db[self.collection_clusters].find({})))
|
||||||
|
}
|
||||||
|
except BaseException as e:
|
||||||
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"value": "{0} {1}".format("Invalid request", e)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
def insert_new_cluster(self, data):
|
def insert_new_cluster(self, data):
|
||||||
try:
|
try:
|
||||||
self.db[self.collection_clusters].insert(data)
|
self.db[self.collection_clusters].insert(data)
|
||||||
result = {"value": "{0} {1}".format(data["name"], "is now available")}
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": "{0} {1}".format(data["name"], "is now available")
|
||||||
|
}
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
result = {"value": "{0} {1}".format("Invalid request", e)}
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"value": "{0} {1}".format("Invalid request", e)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def update_cluster(self, cluster, data):
|
def update_cluster(self, cluster, data):
|
||||||
return self.db[self.collection_clusters].update({"vmid": str(cluster)}, {'$set': data}, upsert=False)
|
try:
|
||||||
|
self.db[self.collection_clusters].update({"vmid": str(cluster)}, {'$set': data}, upsert=False)
|
||||||
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": "{0} {1}".format(data["name"], "has been updated")
|
||||||
|
}
|
||||||
|
except BaseException as e:
|
||||||
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"value": "{0} {1}".format("Invalid request", e)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
def delete_cluster(self, cluster):
|
def delete_cluster(self, cluster):
|
||||||
return self.db[self.collection_clusters].remove({"cluster": str(cluster)})
|
try:
|
||||||
|
self.db[self.collection_clusters].remove({"cluster": str(cluster)})
|
||||||
|
result = {
|
||||||
|
"result": "OK",
|
||||||
|
"value": "{0} {1}".format(cluster, "has been deleted")
|
||||||
|
}
|
||||||
|
except BaseException as e:
|
||||||
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"value": "{0} {1}".format("Invalid request", e)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
""" SYSTEM """
|
""" SYSTEM """
|
||||||
def get_system_info(self):
|
def get_system_info(self):
|
||||||
|
|
|
@ -47,16 +47,16 @@ class Proxmox:
|
||||||
self.csrf = {'CSRFPreventionToken': self.ticket.json()['data']['CSRFPreventionToken']}
|
self.csrf = {'CSRFPreventionToken': self.ticket.json()['data']['CSRFPreventionToken']}
|
||||||
else:
|
else:
|
||||||
result = {"result": "ERROR",
|
result = {"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(request),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error nodes informations. Bad HTTP Status code : "
|
"value": "Error nodes informations. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(self.ticket.status_code, self.ticket.text)
|
"{0} -- {1}".format(self.ticket.status_code, self.ticket.text)
|
||||||
}
|
}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
result = {"result": "ERROR",
|
result = {"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(url),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot get ticket session {0} ({1})".format(url, e)}
|
"value": "Cannot get ticket session {0} ({1})".format(url, e)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -79,18 +79,18 @@ class Proxmox:
|
||||||
else:
|
else:
|
||||||
result = {
|
result = {
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(request),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error nodes informations. Bad HTTP Status code : "
|
"value": "Error nodes informations. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(nodes.status_code, nodes.text)
|
"{0} -- {1}".format(nodes.status_code, nodes.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
result = {
|
result = {
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(request),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot get node information for {0} ({1})".format(url, e)
|
"value": "Cannot get node information for {0} ({1})".format(url, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -107,7 +107,7 @@ class Proxmox:
|
||||||
result = {"result": "OK"}
|
result = {"result": "OK"}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
result = {"result": "ERROR", "target": "[{3}]",
|
result = {"result": "ERROR", "target": "[{3}]",
|
||||||
"customerror": "Cannot get node information for {0} ({1})".format(url, e, nodename)}
|
"value": "Cannot get node information for {0} ({1})".format(url, e, nodename)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class Proxmox:
|
||||||
result = {"result": "OK"}
|
result = {"result": "OK"}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
result = {"result": "ERROR", "target": "[{3}]",
|
result = {"result": "ERROR", "target": "[{3}]",
|
||||||
"customerror": "Cannot get storage information for {0} ({1})".format(url, e, nodename)}
|
"value": "Cannot get storage information for {0} ({1})".format(url, e, nodename)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class Proxmox:
|
||||||
result = {"result": "OK"}
|
result = {"result": "OK"}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
result = {"result": "ERROR", "target": "[{3}]",
|
result = {"result": "ERROR", "target": "[{3}]",
|
||||||
"customerror": "Cannot get disks information for {0} ({1})".format(url, e, nodename)}
|
"value": "Cannot get disks information for {0} ({1})".format(url, e, nodename)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(url),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error nodes informations. Bad HTTP Status code : "
|
"value": "Error nodes informations. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(instances.status_code, instances.text)
|
"{0} -- {1}".format(instances.status_code, instances.text)
|
||||||
}
|
}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
|
@ -175,7 +175,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(url),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot get VM information for {0} {1} ({2})".format(url, nodename, e)
|
"value": "Cannot get VM information for {0} {1} ({2})".format(url, nodename, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -201,7 +201,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(url),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error nodes informations. Bad HTTP Status code : "
|
"value": "Error nodes informations. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(config.status_code, config.text)
|
"{0} -- {1}".format(config.status_code, config.text)
|
||||||
}
|
}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
|
@ -209,7 +209,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(url),
|
"target": "{0}".format(url),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot get VM information for {0} {1} ({2})".format(url, nodename, e)
|
"value": "Cannot get VM information for {0} {1} ({2})".format(url, nodename, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -241,7 +241,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error creating Container. Bad HTTP Status code : "
|
"value": "Error creating Container. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(createvm.status_code, createvm.text)
|
"{0} -- {1}".format(createvm.status_code, createvm.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ class Proxmox:
|
||||||
result = {"result": "ERROR",
|
result = {"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot create this instance on {0} : ({1})".format(url, e)}
|
"value": "Cannot create this instance on {0} : ({1})".format(url, e)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error delete Container. Bad HTTP Status code : "
|
"value": "Error delete Container. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(deletevm.status_code, deletevm.text)
|
"{0} -- {1}".format(deletevm.status_code, deletevm.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ class Proxmox:
|
||||||
result = {"result": "ERROR",
|
result = {"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot delete Container ({2}) on {0} : ({1})".format(url, e, vmid)}
|
"value": "Cannot delete Container ({2}) on {0} : ({1})".format(url, e, vmid)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error action Container. Bad HTTP Status code : "
|
"value": "Error action Container. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(statusm.status_code, statusm.text)
|
"{0} -- {1}".format(statusm.status_code, statusm.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ class Proxmox:
|
||||||
result = {"result": "ERROR",
|
result = {"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot do this action this instance ({2}) on {0} : ({1})".format(url, e, vmid)}
|
"value": "Cannot do this action this instance ({2}) on {0} : ({1})".format(url, e, vmid)}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error resizing container. Bad HTTP Status code : "
|
"value": "Error resizing container. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(resizevm.status_code, resizevm.text)
|
"{0} -- {1}".format(resizevm.status_code, resizevm.text)
|
||||||
}
|
}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
|
@ -374,7 +374,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot resize this instance {2} on {0} : ({1})".format(url, e, instanceid)
|
"value": "Cannot resize this instance {2} on {0} : ({1})".format(url, e, instanceid)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -401,7 +401,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PROXMOX - STATUS CODE",
|
"type": "PROXMOX - STATUS CODE",
|
||||||
"customerror": "Error to find statistic for instance {2}. Bad HTTP Status code : "
|
"value": "Error to find statistic for instance {2}. Bad HTTP Status code : "
|
||||||
"{0} -- {1}".format(statsvm.status_code, statsvm.text, instanceid)
|
"{0} -- {1}".format(statsvm.status_code, statsvm.text, instanceid)
|
||||||
}
|
}
|
||||||
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
except (TypeError, ValueError, requests.exceptions.RequestException) as e:
|
||||||
|
@ -409,7 +409,7 @@ class Proxmox:
|
||||||
"result": "ERROR",
|
"result": "ERROR",
|
||||||
"target": "{0}".format(nodename),
|
"target": "{0}".format(nodename),
|
||||||
"type": "PYTHON",
|
"type": "PYTHON",
|
||||||
"customerror": "Cannot find statistic for this instance {2} on {0} : ({1})".format(url, e, instanceid)
|
"value": "Cannot find statistic for this instance {2} on {0} : ({1})".format(url, e, instanceid)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue