mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
MongoIndex
This commit is contained in:
parent
22479eeded
commit
199a72b4e4
2 changed files with 73 additions and 16 deletions
|
@ -17,6 +17,7 @@ import threading
|
|||
import time
|
||||
import base64
|
||||
import hashlib
|
||||
import pymongo
|
||||
|
||||
def RunAnalyse(generalconf, logger):
|
||||
play = Analyse(generalconf, logger)
|
||||
|
@ -56,6 +57,9 @@ class Core:
|
|||
if self.mongo.client and self.redis_msg.connect() and self.redis_cache.connect():
|
||||
self.mongo.db = self.mongo.client.db
|
||||
|
||||
""" Create indexes"""
|
||||
self.setupindexes()
|
||||
|
||||
""" Others """
|
||||
# value
|
||||
self.concurrencydeploy = generalconf["deploy"]["concurrencydeploy"]
|
||||
|
@ -528,6 +532,30 @@ class Core:
|
|||
|
||||
return data
|
||||
|
||||
|
||||
def setupindexes(self):
|
||||
self.mongo.set_indexes("disks",
|
||||
[('date', pymongo.ASCENDING), ("cluster", pymongo.ASCENDING),
|
||||
("node", pymongo.ASCENDING), ("vmid", pymongo.ASCENDING)])
|
||||
self.mongo.set_indexes("storages",
|
||||
[('date', pymongo.ASCENDING), ("cluster", pymongo.ASCENDING), ("node", pymongo.ASCENDING)])
|
||||
self.mongo.set_indexes("instances",
|
||||
[('date', pymongo.ASCENDING), ("cluster", pymongo.ASCENDING),
|
||||
("node", pymongo.ASCENDING), ("vmid", pymongo.ASCENDING)])
|
||||
self.mongo.set_indexes("nodes",
|
||||
[('date', pymongo.ASCENDING), ("cluster", pymongo.ASCENDING), ("node", pymongo.ASCENDING)])
|
||||
self.mongo.set_indexes("clusters",
|
||||
[('date', pymongo.ASCENDING), ("cluster", pymongo.ASCENDING)])
|
||||
self.mongo.set_indexes("cluster_conf", [('name', pymongo.ASCENDING)])
|
||||
|
||||
indexes_result = {
|
||||
"value": "{0}".format("All indexes created"),
|
||||
"result": "OK",
|
||||
"type": "HYPERPROXMOX"
|
||||
}
|
||||
|
||||
return indexes_result
|
||||
|
||||
"""
|
||||
#######################
|
||||
# STORAGES MANAGEMENT #
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue