blob: 1e88c8943142c78a4767d2d2c68108d893bd4db2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# -*- encoding: utf-8 -*-
import json
try:
from ovh import ovh
except ImportError:
# In case it's installed globally
import ovh
import sys
from ovh_helper import find_cloud_instance
# Credentials are stored in ~/.ovh.conf
# See ovh/README.rst
client = ovh.Client()
project, instance = find_cloud_instance(client, sys.argv[-1])
if "--rescue" in sys.argv:
netboot_mode="rescue"
elif "--local" in sys.argv:
netboot_mode="local"
else:
netboot_mode=None
if netboot_mode is not None:
result = client.post("/cloud/project/{}/instance/{}/rescueMode".format(project,
instance["id"]), imageId=instance["imageId"], rescue=(netboot_mode == "rescue"))
print(result)
else:
result = client.post("/cloud/project/{}/instance/{}/reboot".format(project, instance["id"]), type="soft")
print(result)
# reboot normal:
#result = client.post("/cloud/project/{}/instance/{}/reboot".format(project, instance["id"]), type="soft")
|