mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
Fix duplicate vmid issue
This commit is contained in:
parent
e82ef279db
commit
1c91761921
3 changed files with 30 additions and 30 deletions
|
@ -173,14 +173,14 @@ class Core:
|
|||
|
||||
return
|
||||
|
||||
def delete_instance(self, vmid, instancetype="lxc"):
|
||||
def delete_instance(self, vmid, node, cluster, instancetype="lxc"):
|
||||
|
||||
try:
|
||||
""" Find node/cluster informations from vmid """
|
||||
instance_informations = self.mongo.get_instance(vmid)
|
||||
# instance_informations = self.mongo.get_instance(vmid, node, cluster)
|
||||
|
||||
""" Find cluster informations from node """
|
||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||
cluster_informations = self.mongo.get_clusters_conf(cluster)["value"]
|
||||
|
||||
proxmox_cluster_url = cluster_informations["url"]
|
||||
proxmox_cluster_port = cluster_informations["port"]
|
||||
|
@ -190,7 +190,7 @@ class Core:
|
|||
proxmox_cluster_pwd = pdecrypt(base64.b64decode(cluster_informations["password"]),
|
||||
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||
""" LOAD PROXMOX """
|
||||
proxmox = Proxmox(instance_informations['node'])
|
||||
proxmox = Proxmox(node)
|
||||
proxmox.get_ticket("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
proxmox_cluster_user,
|
||||
|
@ -198,10 +198,10 @@ class Core:
|
|||
|
||||
result = proxmox.delete_instance("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
instance_informations['node'], instancetype, vmid)
|
||||
node, instancetype, vmid)
|
||||
|
||||
if result['result'] == "OK":
|
||||
self.mongo.delete_instance(vmid)
|
||||
self.mongo.delete_instance(vmid, node, cluster)
|
||||
self.mongo.update_system_free_ip(instance_informations['ip'])
|
||||
|
||||
except IndexError as ierror:
|
||||
|
@ -213,13 +213,13 @@ class Core:
|
|||
|
||||
return result
|
||||
|
||||
def status_instance(self, vmid, action, instancetype="lxc"):
|
||||
def status_instance(self, vmid, node, cluster, action, instancetype="lxc"):
|
||||
""" Find node/cluster informations from vmid """
|
||||
try:
|
||||
instance_informations = self.mongo.get_instance(vmid)
|
||||
#instance_informations = self.mongo.get_instance(vmid, node, cluster)
|
||||
|
||||
""" Find cluster informations from node """
|
||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||
cluster_informations = self.mongo.get_clusters_conf(cluster)["value"]
|
||||
|
||||
proxmox_cluster_url = cluster_informations["url"]
|
||||
proxmox_cluster_port = cluster_informations["port"]
|
||||
|
@ -229,7 +229,7 @@ class Core:
|
|||
proxmox_cluster_pwd = pdecrypt(base64.b64decode(cluster_informations["password"]),
|
||||
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||
""" LOAD PROXMOX """
|
||||
proxmox = Proxmox(instance_informations['node'])
|
||||
proxmox = Proxmox(node)
|
||||
proxmox.get_ticket("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
proxmox_cluster_user,
|
||||
|
@ -237,7 +237,7 @@ class Core:
|
|||
|
||||
result = proxmox.status_instance("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
instance_informations['node'],
|
||||
node,
|
||||
instancetype,
|
||||
vmid, action)
|
||||
|
||||
|
@ -250,13 +250,13 @@ class Core:
|
|||
|
||||
return result
|
||||
|
||||
def info_instance(self, vmid, instancetype="lxc"):
|
||||
def info_instance(self, vmid, node, cluster, instancetype="lxc"):
|
||||
""" Find node/cluster informations from vmid """
|
||||
try:
|
||||
instance_informations = self.mongo.get_instance(vmid)
|
||||
#instance_informations = self.mongo.get_instance(vmid, node, cluster)
|
||||
|
||||
""" Find cluster informations from node """
|
||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||
cluster_informations = self.mongo.get_clusters_conf(cluster)["value"]
|
||||
|
||||
proxmox_cluster_url = cluster_informations["url"]
|
||||
proxmox_cluster_port = cluster_informations["port"]
|
||||
|
@ -266,7 +266,7 @@ class Core:
|
|||
proxmox_cluster_pwd = pdecrypt(base64.b64decode(cluster_informations["password"]),
|
||||
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||
""" LOAD PROXMOX """
|
||||
proxmox = Proxmox(instance_informations['node'])
|
||||
proxmox = Proxmox(node)
|
||||
proxmox.get_ticket("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
proxmox_cluster_user,
|
||||
|
@ -274,7 +274,7 @@ class Core:
|
|||
|
||||
result = proxmox.get_config("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
instance_informations['node'],
|
||||
node,
|
||||
instancetype,
|
||||
vmid)
|
||||
|
||||
|
@ -287,13 +287,13 @@ class Core:
|
|||
|
||||
return result
|
||||
|
||||
def change_instance(self, vmid, data, instancetype="lxc"):
|
||||
def change_instance(self, vmid, node, cluster, data, instancetype="lxc"):
|
||||
""" Find node/cluster informations from vmid """
|
||||
try:
|
||||
instance_informations = self.mongo.get_instance(vmid)
|
||||
#instance_informations = self.mongo.get_instance(vmid, node, cluster)
|
||||
|
||||
""" Find cluster informations from node """
|
||||
cluster_informations = self.mongo.get_clusters_conf(instance_informations['cluster'])["value"]
|
||||
cluster_informations = self.mongo.get_clusters_conf(cluster)["value"]
|
||||
|
||||
proxmox_cluster_url = cluster_informations["url"]
|
||||
proxmox_cluster_port = cluster_informations["port"]
|
||||
|
@ -304,7 +304,7 @@ class Core:
|
|||
self.generalconf["keys"]["key_pvt"])["data"].decode('utf-8')
|
||||
|
||||
""" LOAD PROXMOX """
|
||||
proxmox = Proxmox(instance_informations['node'])
|
||||
proxmox = Proxmox(node)
|
||||
proxmox.get_ticket("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
proxmox_cluster_user,
|
||||
|
@ -312,12 +312,12 @@ class Core:
|
|||
|
||||
result = proxmox.resize_instance("{0}:{1}".format(proxmox_cluster_url,
|
||||
int(proxmox_cluster_port)),
|
||||
instance_informations['node'],
|
||||
node,
|
||||
instancetype,
|
||||
vmid, data)
|
||||
|
||||
if result['result'] == "OK":
|
||||
self.mongo.update_instance(vmid, data)
|
||||
self.mongo.update_instance(data, vmid, instance_informations['node'], instance_informations['cluster'])
|
||||
|
||||
except IndexError as ierror:
|
||||
result = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue