]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blame_incremental - python/reboot_ovh_cloud_instance.py
Make mountpoints configurable
[perso/Immae/Projets/Puppet.git] / python / reboot_ovh_cloud_instance.py
... / ...
CommitLineData
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
9from ovh_helper import find_cloud_instance
10
11# Credentials are stored in ~/.ovh.conf
12# See ovh/README.rst
13client = ovh.Client()
14
15project, instance = find_cloud_instance(client, sys.argv[-1])
16
17if "--rescue" in sys.argv:
18 netboot_mode="rescue"
19elif "--local" in sys.argv:
20 netboot_mode="local"
21else:
22 netboot_mode=None
23
24if 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)
28else:
29 result = client.post("/cloud/project/{}/instance/{}/reboot".format(project, instance["id"]), type="soft")
30 print(result)
31
32# reboot normal:
33#result = client.post("/cloud/project/{}/instance/{}/reboot".format(project, instance["id"]), type="soft")