]>
git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - python/ovh_helper.py
4 def show_progress(client
, vps
, task_type
):
5 running_task_id
= client
.get("/vps/{}/tasks?type={}".format(vps
, task_type
))[0]
10 while state
!= "done":
11 old_progress
= progress
12 task
= client
.get("/vps/{}/tasks/{}".format(vps
, running_task_id
))
13 progress
= task
["progress"]
16 if progress
!= old_progress
:
17 print("\r{:>3} %".format(progress
), end
="")
22 def find_cloud_instance(client
, instance_id
):
23 projects_list
= client
.get('/cloud/project/')
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
]
32 print("Instance not in list:")
33 for instance
in instances_list
:
34 print("{}: {}".format(instance
[1]["name"], instance
[1]["id"]))
36 return project_instance