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/reboot_cloud_instance.py | |
parent | c15f2234474ff8a8266e26856702b3c561050667 (diff) | |
download | Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.gz Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.zst Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.zip |
Merge install scripts
Diffstat (limited to 'python/reboot_cloud_instance.py')
-rw-r--r-- | python/reboot_cloud_instance.py | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/python/reboot_cloud_instance.py b/python/reboot_cloud_instance.py deleted file mode 100644 index b90f488..0000000 --- a/python/reboot_cloud_instance.py +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | # -*- encoding: utf-8 -*- | ||
2 | import json | ||
3 | try: | ||
4 | from ovh import ovh | ||
5 | except ImportError: | ||
6 | # In case it's installed globally | ||
7 | import ovh | ||
8 | import sys | ||
9 | |||
10 | # Credentials are stored in ~/.ovh.conf | ||
11 | # See ovh/README.rst | ||
12 | client = ovh.Client() | ||
13 | |||
14 | projects_list = client.get('/cloud/project/') | ||
15 | if len(projects_list) > 1: | ||
16 | print("More than one project is not supported, taking the first one") | ||
17 | project = projects_list[0] | ||
18 | instances_list = client.get('/cloud/project/{}/instance'.format(project)) | ||
19 | instances = dict(map(lambda x: (x["id"], x), instances_list)) | ||
20 | if sys.argv[-1] in instances: | ||
21 | instance = instances[sys.argv[-1]] | ||
22 | else: | ||
23 | print("Instance not in list:") | ||
24 | for instance in instances_list: | ||
25 | print("{}: {}".format(instance["name"], instance["id"])) | ||
26 | sys.exit(1) | ||
27 | |||
28 | if "--rescue" in sys.argv: | ||
29 | netboot_mode="rescue" | ||
30 | elif "--local" in sys.argv: | ||
31 | netboot_mode="local" | ||
32 | else: | ||
33 | netboot_mode=None | ||
34 | |||
35 | if netboot_mode is not None: | ||
36 | result = client.post("/cloud/project/{}/instance/{}/rescueMode".format(project, | ||
37 | instance["id"]), imageId=instance["imageId"], rescue=(netboot_mode == "rescue")) | ||
38 | print(result) | ||
39 | |||