diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-16 19:14:29 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-16 20:13:46 +0100 |
commit | 69da835d04e741f4e85da3c473ba86c8801931fd (patch) | |
tree | 0cfb28cfd468a5b681f2b5af2b935c81d2221950 /python/ovh_helper.py | |
parent | c15f2234474ff8a8266e26856702b3c561050667 (diff) | |
download | Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.gz Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.zst Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.zip |
Merge install scripts
Diffstat (limited to 'python/ovh_helper.py')
-rw-r--r-- | python/ovh_helper.py | 17 |
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 @@ | |||
1 | import time | 1 | import time |
2 | import sys | ||
2 | 3 | ||
3 | def show_progress(client, vps, task_type): | 4 | def 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 | |||
22 | def 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 | ||