diff options
author | ache <ache@ache.one> | 2019-02-04 15:49:09 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2019-02-04 15:49:09 +0100 |
commit | 0fba3a76bd85ddde23cd442b9e0bc16612dc3f8a (patch) | |
tree | 73753bb69a942d278fa589041c3c1f33a27995e6 /ovh_reboot.py | |
parent | Merge tethapp and autoDHCP (diff) |
Ovh reboot
Diffstat (limited to 'ovh_reboot.py')
-rw-r--r-- | ovh_reboot.py | 43 |
1 files changed, 43 insertions, 0 deletions
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() |