From 0fba3a76bd85ddde23cd442b9e0bc16612dc3f8a Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 4 Feb 2019 15:49:09 +0100 Subject: Ovh reboot --- ovh_reboot.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ovh_reboot.py (limited to 'ovh_reboot.py') diff --git a/ovh_reboot.py b/ovh_reboot.py new file mode 100644 index 0000000..5ee3fff --- /dev/null +++ b/ovh_reboot.py @@ -0,0 +1,43 @@ +''' +First, install the latest release of Python wrapper: $ pip install ovh +''' + +import json +import ovh + +def main(): + """ Software to reboot a VPS from OVH using the OVH API + Intend to be used as an example + """ + # Instanciate an OVH Client. + # You can generate new credentials with full access to your account on + # the token creation page + with open("~/.ovh_auth", "r") as f_file: + auth = f_file.read().strip().split(';') + client = ovh.Client( + endpoint=auth[0], # Endpoint of API OVH Europe + application_key=auth[1], # Application Key + application_secret=auth[2], # Application Secret + consumer_key=auth[3], # Consumer Key + ) + + result = client.get('/vps') + print(json.dumps(result, indent=4)) + + ## ache.one + result = client.post('/vps/vps446497.ovh.net/reboot') + print(json.dumps(result, indent=4)) + + ## mail.ache.one + #result = client.post('/vps/vps514854.ovh.net/reboot') + #print(json.dumps(result, indent=4)) + + ## Useless test about task percentage + #result = client.get('/vps/vps446497.ovh.net/tasks', + # type='rebootVm', # Filter the value of type property (=) (type: vps.TaskTypeEnum) + #) + #print(json.dumps(result, indent=4)) + + +if __name__ == '__main__': + main() -- cgit v1.2.3