mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
Multiples fix
This commit is contained in:
parent
97bc2a0248
commit
1955d0e65c
3 changed files with 21 additions and 14 deletions
|
@ -18,8 +18,8 @@ import time
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
def RunAnalyse(clusters_conf, generalconf, logger):
|
def RunAnalyse(generalconf, logger):
|
||||||
play = Analyse(clusters_conf, generalconf, logger)
|
play = Analyse(generalconf, logger)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
""" Instances types availables: lxc/qemu/all"""
|
""" Instances types availables: lxc/qemu/all"""
|
||||||
|
@ -63,8 +63,6 @@ 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()["value"]
|
|
||||||
|
|
||||||
""" Clean previous lockers """
|
""" Clean previous lockers """
|
||||||
self.logger.write({"thread": threading.get_ident(), "result": "INFO", "type": "HYPERPROXMOX",
|
self.logger.write({"thread": threading.get_ident(), "result": "INFO", "type": "HYPERPROXMOX",
|
||||||
"value": "Clean Locker"})
|
"value": "Clean Locker"})
|
||||||
|
@ -73,7 +71,7 @@ class Core:
|
||||||
|
|
||||||
thc = threading.Thread(name="Update statistics",
|
thc = threading.Thread(name="Update statistics",
|
||||||
target=RunAnalyse,
|
target=RunAnalyse,
|
||||||
args=(self.clusters_conf, self.generalconf, self.logger))
|
args=(self.generalconf, self.logger))
|
||||||
thc.start()
|
thc.start()
|
||||||
else:
|
else:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -448,10 +446,13 @@ class Core:
|
||||||
|
|
||||||
return new_cluster
|
return new_cluster
|
||||||
|
|
||||||
def change_clusters_conf(self, cluster, data):
|
|
||||||
clusters_update = self.mongo.update_clusters_conf(cluster, data)
|
|
||||||
return clusters_update
|
|
||||||
|
|
||||||
|
def change_clusters_conf(self, cluster, data):
|
||||||
|
if data["user"]:
|
||||||
|
data["user"] = base64.b64encode(pcrypt(data["user"], self.generalconf["keys"]["key_pvt"])["value"]).decode('utf-8')
|
||||||
|
if data["password"]:
|
||||||
|
data["password"] = base64.b64encode(pcrypt(data["password"], self.generalconf["keys"]["key_pvt"])["value"]).decode('utf-8')
|
||||||
|
return self.mongo.update_clusters_conf(cluster, data)
|
||||||
|
|
||||||
def delete_clusters_conf(self, cluster):
|
def delete_clusters_conf(self, cluster):
|
||||||
""" Find cluster informations from node """
|
""" Find cluster informations from node """
|
||||||
|
|
|
@ -41,13 +41,12 @@ def distribution(n, tokens_in_slots, slot_distributions):
|
||||||
|
|
||||||
|
|
||||||
class Analyse:
|
class Analyse:
|
||||||
def __init__(self, clusters_conf, generalconf, logger):
|
def __init__(self, generalconf, logger):
|
||||||
"""
|
"""
|
||||||
:param clusters_conf: Proxmox configurations
|
:param clusters_conf: Proxmox configurations
|
||||||
:param generalconf : General configuration
|
:param generalconf : General configuration
|
||||||
"""
|
"""
|
||||||
self.generalconf = generalconf
|
self.generalconf = generalconf
|
||||||
self.clusters_conf = clusters_conf
|
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
|
||||||
""" LOAD MONGODB """
|
""" LOAD MONGODB """
|
||||||
|
@ -55,6 +54,8 @@ class Analyse:
|
||||||
self.mongo.client = self.mongo.connect()
|
self.mongo.client = self.mongo.connect()
|
||||||
self.mongo.db = self.mongo.client.db
|
self.mongo.db = self.mongo.client.db
|
||||||
|
|
||||||
|
self.clusters_conf = self.mongo.get_clusters_conf()["value"]
|
||||||
|
|
||||||
def run(self, instancetype="all"):
|
def run(self, instancetype="all"):
|
||||||
""" Active logger"""
|
""" Active logger"""
|
||||||
self.logger.write({"thread":threading.get_ident(), "result": "INFO", "type": "HYPERPROXMOX", "value": "Start logger - Analyst Module"})
|
self.logger.write({"thread":threading.get_ident(), "result": "INFO", "type": "HYPERPROXMOX", "value": "Start logger - Analyst Module"})
|
||||||
|
@ -83,7 +84,12 @@ class Analyse:
|
||||||
|
|
||||||
""" AUTH """
|
""" AUTH """
|
||||||
proxmox = Proxmox("Analyse")
|
proxmox = Proxmox("Analyse")
|
||||||
proxmox.get_ticket("{0}:{1}".format(cluster["url"], int(cluster["port"])), proxmox_clusters_user, proxmox_clusters_pwd)
|
connection = proxmox.get_ticket("{0}:{1}".format(cluster["url"], int(cluster["port"])), proxmox_clusters_user, proxmox_clusters_pwd)
|
||||||
|
|
||||||
|
""" ByPass and log if connection has failed """
|
||||||
|
if connection["result"] != "OK":
|
||||||
|
self.logger.write({"thread": threading.get_ident(), "result": "ERROR", "type": "HYPERPROXMOX", "value": connection})
|
||||||
|
continue
|
||||||
|
|
||||||
"""
|
"""
|
||||||
##############
|
##############
|
||||||
|
|
|
@ -202,7 +202,7 @@ class API_Gen_HTML
|
||||||
if($last_clust != $qemu->cluster)
|
if($last_clust != $qemu->cluster)
|
||||||
{
|
{
|
||||||
$last_clust = $qemu->cluster;
|
$last_clust = $qemu->cluster;
|
||||||
$clusters_info = json_decode($d->GET_clusters_conf($qemu->cluster), true)['value'][0];
|
$clusters_info = json_decode($d->GET_clusters_conf($qemu->cluster), true)['value'];
|
||||||
$clusters_info = (object) $clusters_info;
|
$clusters_info = (object) $clusters_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ class API_Gen_HTML
|
||||||
if($last_clust != $node->cluster)
|
if($last_clust != $node->cluster)
|
||||||
{
|
{
|
||||||
$last_clust = $node->cluster;
|
$last_clust = $node->cluster;
|
||||||
$clusters_info = json_decode($q->GET_clusters_conf($node->cluster), true)['value'][0];
|
$clusters_info = json_decode($q->GET_clusters_conf($node->cluster), true)['value'];
|
||||||
$clusters_info = (object) $clusters_info;
|
$clusters_info = (object) $clusters_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ class API_Gen_HTML
|
||||||
if($last_clust != $sto->cluster)
|
if($last_clust != $sto->cluster)
|
||||||
{
|
{
|
||||||
$last_clust = $sto->cluster;
|
$last_clust = $sto->cluster;
|
||||||
$clusters_info = json_decode($q->GET_clusters_conf($sto->cluster), true)['value'][0];
|
$clusters_info = json_decode($q->GET_clusters_conf($sto->cluster), true)['value'];
|
||||||
$clusters_info = (object) $clusters_info;
|
$clusters_info = (object) $clusters_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue