mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-02-12 11:12:10 +00:00
- logs text
- wrapper status instance
This commit is contained in:
parent
6dab8bc932
commit
afaf640f0e
2 changed files with 52 additions and 29 deletions
|
@ -18,7 +18,7 @@ class Purge:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return json.dumps(result)
|
||||
|
@ -30,7 +30,7 @@ class General_Search:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return json.dumps(result)
|
||||
|
@ -38,11 +38,13 @@ class General_Search:
|
|||
class QueryCache_Infra:
|
||||
def GET(self, dest, date, cluster=None, node=None, vmid=None):
|
||||
try:
|
||||
if date == "last":
|
||||
date = core.getkey(date)["value"]
|
||||
result = core.generalquerycacheinfra(dest, date, cluster, node, vmid)
|
||||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,7 @@ class QueryDates:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return json.dumps(result)
|
||||
|
@ -72,7 +74,7 @@ class Cluster:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
|
||||
|
@ -96,7 +98,7 @@ class Cluster:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid insert request: {0}".format(e)
|
||||
}
|
||||
return result
|
||||
|
@ -108,7 +110,7 @@ class Cluster:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid update request: {0}".format(e)
|
||||
}
|
||||
return result
|
||||
|
@ -119,11 +121,29 @@ class Cluster:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid delete request: {0}".format(e)
|
||||
}
|
||||
return result
|
||||
|
||||
class InstanceBc:
|
||||
""" Convert to Instance """
|
||||
def GET(self, date, cluster, node, vmid, action):
|
||||
try:
|
||||
if date == "last":
|
||||
date = core.getkey(date)["value"]
|
||||
idmongo = core.generalquerycacheinfra("instances", date, cluster, node, vmid)["value"][0]["_id"]["$oid"]
|
||||
I = Instance()
|
||||
result = json.loads(I.GET(idmongo, action))["value"]
|
||||
|
||||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "API",
|
||||
"value": "(bc) Invalid request: {0}".format(e)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
class Instance:
|
||||
def GET(self, id, action=None):
|
||||
|
@ -137,7 +157,7 @@ class Instance:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return json.dumps(result)
|
||||
|
@ -187,7 +207,7 @@ class Instance:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return result
|
||||
|
@ -199,7 +219,7 @@ class Instance:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return result
|
||||
|
@ -210,7 +230,7 @@ class Instance:
|
|||
except BaseException as e:
|
||||
result = {
|
||||
"result": "ERROR",
|
||||
"type": "PYTHON - API",
|
||||
"type": "API",
|
||||
"value": "Invalid request: {0}".format(e)
|
||||
}
|
||||
return result
|
||||
|
|
|
@ -70,7 +70,7 @@ if __name__ == "__main__":
|
|||
"\n - Private Key: {0} "
|
||||
"\n - Public Key: {1}"
|
||||
.format(localconf['system']['key_pvt'], localconf['system']['key_pub']))
|
||||
print("Passphrase HASH: {0}".format(passhash))
|
||||
# print("Passphrase HASH: {0}".format(passhash))
|
||||
print("You MUST save your passphrase in a security place !")
|
||||
key_pvt = CritConf.read_private_key(localconf['system']['key_pvt'], passhash)
|
||||
else:
|
||||
|
@ -111,6 +111,9 @@ if __name__ == "__main__":
|
|||
'/api/v1/instance/([0-9]+)', 'Instance',
|
||||
'/api/v1/instance/id/([a-z0-9]+)/status/(start|stop|current|reset|shutdown)', 'Instance',
|
||||
|
||||
# Instance by cache
|
||||
'/api/v1/static/instances/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+)/(start|stop|current|reset|shutdown)', 'InstanceBc',
|
||||
|
||||
# AUTH
|
||||
# '/api/v1/login', 'Login'
|
||||
|
||||
|
@ -125,30 +128,30 @@ if __name__ == "__main__":
|
|||
# CACHE DATA (MONGO)
|
||||
# date/cluster/node/vmid
|
||||
# Disks mapping
|
||||
'/api/v1/static/(disks)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(disks)/([0-9]+|last)/', 'QueryCache_Infra',
|
||||
|
||||
# Storages mapping
|
||||
'/api/v1/static/(storages)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(storages)/([0-9]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(storages)/([0-9]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(storages)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(storages)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(storages)/([0-9]+|last)/', 'QueryCache_Infra',
|
||||
|
||||
# Instances mapping
|
||||
'/api/v1/static/(instances)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(instances)/([0-9]+|last)/', 'QueryCache_Infra',
|
||||
|
||||
# Nodes mapping
|
||||
'/api/v1/static/(nodes)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(nodes)/([0-9]+)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(nodes)/([0-9]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(nodes)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(nodes)/([0-9]+|last)/([0-9a-zA-Z\_\-]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(nodes)/([0-9]+|last)/', 'QueryCache_Infra',
|
||||
|
||||
# cluster mapping
|
||||
'/api/v1/static/(clusters)/([0-9]+)/(?:[0-9a-zA-Z\_\-]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(clusters)/([0-9]+)/', 'QueryCache_Infra',
|
||||
'/api/v1/static/(clusters)/([0-9]+|last)/(?:[0-9a-zA-Z\_\-]+)', 'QueryCache_Infra',
|
||||
'/api/v1/static/(clusters)/([0-9]+|last)/', 'QueryCache_Infra',
|
||||
|
||||
# date
|
||||
'/api/v1/static/dates/(all|last)', 'QueryDates',
|
||||
|
|
Loading…
Reference in a new issue