X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=python%2Freinstall_ovh_cloud_instance.py;fp=python%2Freinstall_cloud_instance.py;h=c0d26174821bf7e0bb4a13b86371b55a2d85765d;hb=69da835d04e741f4e85da3c473ba86c8801931fd;hp=c488fda23f4de2d3e408f14a476a492e46821bc8;hpb=c15f2234474ff8a8266e26856702b3c561050667;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/python/reinstall_cloud_instance.py b/python/reinstall_ovh_cloud_instance.py similarity index 71% rename from python/reinstall_cloud_instance.py rename to python/reinstall_ovh_cloud_instance.py index c488fda..c0d2617 100644 --- a/python/reinstall_cloud_instance.py +++ b/python/reinstall_ovh_cloud_instance.py @@ -6,24 +6,13 @@ except ImportError: # In case it's installed globally import ovh import sys +from ovh_helper import find_cloud_instance # Credentials are stored in ~/.ovh.conf # See ovh/README.rst client = ovh.Client() -projects_list = client.get('/cloud/project/') -if len(projects_list) > 1: - print("More than one project is not supported, taking the first one") -project = projects_list[0] -instances_list = client.get('/cloud/project/{}/instance'.format(project)) -instances = dict(map(lambda x: (x["id"], x), instances_list)) -if sys.argv[-1] in instances: - instance = instances[sys.argv[-1]] -else: - print("Instance not in list:") - for instance in instances_list: - print("{}: {}".format(instance["name"], instance["id"])) - sys.exit(1) +project, instance = find_cloud_instance(client, sys.argv[-1]) current_image = instance["imageId"] available_images = client.get('/cloud/project/{}/image'.format(project),