aboutsummaryrefslogtreecommitdiff
path: root/python/ovh_helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/ovh_helper.py')
-rw-r--r--python/ovh_helper.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/ovh_helper.py b/python/ovh_helper.py
index a49a245..19834ae 100644
--- a/python/ovh_helper.py
+++ b/python/ovh_helper.py
@@ -1,4 +1,5 @@
1import time 1import time
2import sys
2 3
3def show_progress(client, vps, task_type): 4def show_progress(client, vps, task_type):
4 running_task_id = client.get("/vps/{}/tasks?type={}".format(vps, task_type))[0] 5 running_task_id = client.get("/vps/{}/tasks?type={}".format(vps, task_type))[0]
@@ -17,3 +18,19 @@ def show_progress(client, vps, task_type):
17 time.sleep(3) 18 time.sleep(3)
18 19
19 print("\rFinished") 20 print("\rFinished")
21
22def find_cloud_instance(client, instance_id):
23 projects_list = client.get('/cloud/project/')
24 instances_list = []
25 for project in projects_list:
26 instances_list += list(map(lambda x: [project, x],
27 client.get('/cloud/project/{}/instance'.format(project))))
28 instances = dict(map(lambda x: (x[1]["id"], x), instances_list))
29 if instance_id in instances:
30 project_instance = instances[instance_id]
31 else:
32 print("Instance not in list:")
33 for instance in instances_list:
34 print("{}: {}".format(instance[1]["name"], instance[1]["id"]))
35 sys.exit(1)
36 return project_instance