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
|
||||
|
||||
### Requirement:
|
||||
* A proxmox server
|
||||
* A administrative pve user (full access)
|
||||
* A Vztemplate uploaded
|
||||
* proxmox server
|
||||
* administrative pve user (full access)
|
||||
* Vztemplate uploaded
|
||||
|
||||
### Init:
|
||||
``` bash
|
||||
|
|
|
@ -103,6 +103,9 @@ class Core:
|
|||
""" FIND NEXT INSTANCE ID AVAILABLE AND INCREMENT IT"""
|
||||
next_instance_id = int(get_info_system["instances_number"]+1)
|
||||
|
||||
""" TEST THIS ID """
|
||||
|
||||
|
||||
""" FIND LAST LAST IP USE AND INCREMENT IT"""
|
||||
if not get_info_system["IP_free"]:
|
||||
get_instance_ip = get_info_system["IP_current"]
|
||||
|
@ -284,7 +287,7 @@ class Core:
|
|||
|
||||
return result
|
||||
|
||||
def change_instance(self, vmid, data, instancetype="lxc"):
|
||||
def change_instance(self, vmid, data, instancetype="lxc"):
|
||||
""" Find node/cluster informations from vmid """
|
||||
try:
|
||||
instance_informations = self.mongo.get_instance(vmid)
|
||||
|
|
|
@ -11,8 +11,6 @@ from core.modules.mod_proxmox import *
|
|||
from core.modules.mod_database import *
|
||||
from core.libs.hcrypt import *
|
||||
import time
|
||||
import operator
|
||||
import random
|
||||
import base64
|
||||
|
||||
|
||||
|
@ -57,8 +55,15 @@ class Crawler:
|
|||
value_nodes_list["node"], instancetype)["value"]
|
||||
|
||||
for key_list_instances, value_list_instances in list_instances.items():
|
||||
for instances in value_list_instances:
|
||||
instances["node"] = value_nodes_list["node"]
|
||||
print(instances)
|
||||
|
||||
for instance in value_list_instances:
|
||||
instance["cluster"] = cluster["name"]
|
||||
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
|
|
@ -211,14 +211,18 @@ class MongoDB:
|
|||
def insert_instance(self, data):
|
||||
return self.db[self.collection_instance].insert(data)
|
||||
|
||||
def update_instance(self, vmid, data):
|
||||
self.db[self.collection_instance].update({"vmid": int(vmid)}, {'$set': data}, upsert=False)
|
||||
def update_instance(self, data, vmid, node):
|
||||
return self.db[self.collection_instance].update(
|
||||
{"vmid": int(vmid), "node": node}, {'$set': data}, upsert=False
|
||||
)
|
||||
|
||||
def delete_instance(self, vmid):
|
||||
self.db[self.collection_instance].remove({"vmid": int(vmid)})
|
||||
def delete_instance(self, vmid, node):
|
||||
self.db[self.collection_instance].remove({"vmid": int(vmid), "node": node})
|
||||
|
||||
def get_instance(self, vmid):
|
||||
def get_instance(self, vmid, node):
|
||||
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:
|
||||
raise ("MongoDB error on {0}:{1} ({2})".format(self.server, self.port, serr))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue