]>
Commit | Line | Data |
---|---|---|
df0c42af IB |
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 | |
69da835d | 9 | from ovh_helper import find_cloud_instance |
df0c42af IB |
10 | |
11 | # Credentials are stored in ~/.ovh.conf | |
12 | # See ovh/README.rst | |
13 | client = ovh.Client() | |
14 | ||
69da835d | 15 | project, instance = find_cloud_instance(client, sys.argv[-1]) |
df0c42af IB |
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) | |
5feedbb4 IB |
28 | else: |
29 | result = client.post("/cloud/project/{}/instance/{}/reboot".format(project, instance["id"]), type="soft") | |
30 | print(result) | |
df0c42af | 31 | |
71084626 IB |
32 | # reboot normal: |
33 | #result = client.post("/cloud/project/{}/instance/{}/reboot".format(project, instance["id"]), type="soft") |