aboutsummaryrefslogtreecommitdiff
path: root/python/reboot_ovh_vps_ssd.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-16 19:14:29 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-16 20:13:46 +0100
commit69da835d04e741f4e85da3c473ba86c8801931fd (patch)
tree0cfb28cfd468a5b681f2b5af2b935c81d2221950 /python/reboot_ovh_vps_ssd.py
parentc15f2234474ff8a8266e26856702b3c561050667 (diff)
downloadPuppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.gz
Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.zst
Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.zip
Merge install scripts
Diffstat (limited to 'python/reboot_ovh_vps_ssd.py')
-rw-r--r--python/reboot_ovh_vps_ssd.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/python/reboot_ovh_vps_ssd.py b/python/reboot_ovh_vps_ssd.py
new file mode 100644
index 0000000..71c5227
--- /dev/null
+++ b/python/reboot_ovh_vps_ssd.py
@@ -0,0 +1,40 @@
1# -*- encoding: utf-8 -*-
2import json
3try:
4 from ovh import ovh
5except ImportError:
6 # In case it's installed globally
7 import ovh
8import sys
9import ovh_helper
10
11# Credentials are stored in ~/.ovh.conf
12# See ovh/README.rst
13client = ovh.Client()
14
15vps_list = client.get('/vps/')
16if sys.argv[-1] in vps_list:
17 vps = sys.argv[-1]
18else:
19 print("VPS not in list:")
20 for vps in vps_list:
21 print(vps)
22 sys.exit(1)
23
24if "--rescue" in sys.argv:
25 netboot_mode="rescue"
26elif "--local" in sys.argv:
27 netboot_mode="local"
28else:
29 netboot_mode=None
30
31current_state=client.get("/vps/{}".format(vps))["netbootMode"]
32
33if netboot_mode is None or current_state == netboot_mode:
34 client.post("/vps/{}/reboot".format(vps))
35 task_type="rebootVm"
36else:
37 client.put("/vps/{}".format(vps), netbootMode=netboot_mode)
38 task_type="setNetboot"
39
40ovh_helper.show_progress(client, vps, task_type)