diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-19 16:21:00 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-19 16:21:00 +0100 |
commit | b60b98643a6da52c08ced89779964b722230a7db (patch) | |
tree | 0cfb28cfd468a5b681f2b5af2b935c81d2221950 /python/reboot_ovh_cloud_instance.py | |
parent | 985b53a258ee18eaca8d437ae532c232a6d19921 (diff) | |
parent | 69da835d04e741f4e85da3c473ba86c8801931fd (diff) | |
download | Puppet-b60b98643a6da52c08ced89779964b722230a7db.tar.gz Puppet-b60b98643a6da52c08ced89779964b722230a7db.tar.zst Puppet-b60b98643a6da52c08ced89779964b722230a7db.zip |
Merge branch 'split_scripts' into dev
Diffstat (limited to 'python/reboot_ovh_cloud_instance.py')
-rw-r--r-- | python/reboot_ovh_cloud_instance.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/python/reboot_ovh_cloud_instance.py b/python/reboot_ovh_cloud_instance.py new file mode 100644 index 0000000..de20c07 --- /dev/null +++ b/python/reboot_ovh_cloud_instance.py | |||
@@ -0,0 +1,28 @@ | |||
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 | from ovh_helper import find_cloud_instance | ||
10 | |||
11 | # Credentials are stored in ~/.ovh.conf | ||
12 | # See ovh/README.rst | ||
13 | client = ovh.Client() | ||
14 | |||
15 | project, instance = find_cloud_instance(client, sys.argv[-1]) | ||
16 | |||
17 | if "--rescue" in sys.argv: | ||
18 | netboot_mode="rescue" | ||
19 | elif "--local" in sys.argv: | ||
20 | netboot_mode="local" | ||
21 | else: | ||
22 | netboot_mode=None | ||
23 | |||
24 | if netboot_mode is not None: | ||
25 | result = client.post("/cloud/project/{}/instance/{}/rescueMode".format(project, | ||
26 | instance["id"]), imageId=instance["imageId"], rescue=(netboot_mode == "rescue")) | ||
27 | print(result) | ||
28 | |||