mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
General update
This commit is contained in:
parent
4cc23ad918
commit
dcc0babb73
4 changed files with 28 additions and 16 deletions
|
@ -8,9 +8,9 @@
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
### Requirement:
|
### Requirement:
|
||||||
* A proxmox server
|
* proxmox server
|
||||||
* A administrative pve user (full access)
|
* administrative pve user (full access)
|
||||||
* A Vztemplate uploaded
|
* Vztemplate uploaded
|
||||||
|
|
||||||
### Init:
|
### Init:
|
||||||
``` bash
|
``` bash
|
||||||
|
|
|
@ -103,6 +103,9 @@ class Core:
|
||||||
""" FIND NEXT INSTANCE ID AVAILABLE AND INCREMENT IT"""
|
""" FIND NEXT INSTANCE ID AVAILABLE AND INCREMENT IT"""
|
||||||
next_instance_id = int(get_info_system["instances_number"]+1)
|
next_instance_id = int(get_info_system["instances_number"]+1)
|
||||||
|
|
||||||
|
""" TEST THIS ID """
|
||||||
|
|
||||||
|
|
||||||
""" FIND LAST LAST IP USE AND INCREMENT IT"""
|
""" FIND LAST LAST IP USE AND INCREMENT IT"""
|
||||||
if not get_info_system["IP_free"]:
|
if not get_info_system["IP_free"]:
|
||||||
get_instance_ip = get_info_system["IP_current"]
|
get_instance_ip = get_info_system["IP_current"]
|
||||||
|
|
|
@ -11,8 +11,6 @@ from core.modules.mod_proxmox import *
|
||||||
from core.modules.mod_database import *
|
from core.modules.mod_database import *
|
||||||
from core.libs.hcrypt import *
|
from core.libs.hcrypt import *
|
||||||
import time
|
import time
|
||||||
import operator
|
|
||||||
import random
|
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,8 +55,15 @@ class Crawler:
|
||||||
value_nodes_list["node"], instancetype)["value"]
|
value_nodes_list["node"], instancetype)["value"]
|
||||||
|
|
||||||
for key_list_instances, value_list_instances in list_instances.items():
|
for key_list_instances, value_list_instances in list_instances.items():
|
||||||
for instances in value_list_instances:
|
for instance in value_list_instances:
|
||||||
instances["node"] = value_nodes_list["node"]
|
instance["cluster"] = cluster["name"]
|
||||||
print(instances)
|
instance["node"] = value_nodes_list["node"]
|
||||||
|
# Test si l'instance existe
|
||||||
|
if not self.mongo.get_instance(instance["vmid"], instance["node"]):
|
||||||
|
# si non existante, alors il s'agit d'une instance manuelle
|
||||||
|
instance["commandid"] = "000000"
|
||||||
|
self.mongo.insert_instance(instance)
|
||||||
|
# Si elle existe déjà, on l'update:
|
||||||
|
else:
|
||||||
|
self.mongo.update_instance(instance, instance["vmid"], instance["node"])
|
||||||
return
|
return
|
|
@ -211,14 +211,18 @@ class MongoDB:
|
||||||
def insert_instance(self, data):
|
def insert_instance(self, data):
|
||||||
return self.db[self.collection_instance].insert(data)
|
return self.db[self.collection_instance].insert(data)
|
||||||
|
|
||||||
def update_instance(self, vmid, data):
|
def update_instance(self, data, vmid, node):
|
||||||
self.db[self.collection_instance].update({"vmid": int(vmid)}, {'$set': data}, upsert=False)
|
return self.db[self.collection_instance].update(
|
||||||
|
{"vmid": int(vmid), "node": node}, {'$set': data}, upsert=False
|
||||||
|
)
|
||||||
|
|
||||||
def delete_instance(self, vmid):
|
def delete_instance(self, vmid, node):
|
||||||
self.db[self.collection_instance].remove({"vmid": int(vmid)})
|
self.db[self.collection_instance].remove({"vmid": int(vmid), "node": node})
|
||||||
|
|
||||||
def get_instance(self, vmid):
|
def get_instance(self, vmid, node):
|
||||||
try:
|
try:
|
||||||
return json.loads(dumps(self.db[self.collection_instance].find_one({"vmid": int(vmid)})))
|
return json.loads(dumps(
|
||||||
|
self.db[self.collection_instance].find_one(
|
||||||
|
{"vmid": int(vmid), "node": node})))
|
||||||
except BaseException as serr:
|
except BaseException as serr:
|
||||||
raise ("MongoDB error on {0}:{1} ({2})".format(self.server, self.port, serr))
|
raise ("MongoDB error on {0}:{1} ({2})".format(self.server, self.port, serr))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue