Add OVH authentication
This commit is contained in:
parent
9d721349c4
commit
f6cdae0158
17
vm.py
17
vm.py
@ -25,6 +25,8 @@ import socket
|
||||
import jinja2
|
||||
import libvirt
|
||||
import ovhtool
|
||||
import ovh
|
||||
import ovh.exceptions
|
||||
|
||||
config = {
|
||||
'vg': '/dev/vg',
|
||||
@ -240,6 +242,21 @@ def main(gargv):
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
exit(main(sys.argv[1:]))
|
||||
except ovh.exceptions.InvalidCredential:
|
||||
req = ovh.Client().request_consumerkey([
|
||||
{'method': 'GET', 'path': '/ip'},
|
||||
{'method': 'GET', 'path': '/dedicated/server'},
|
||||
{'method': 'GET', 'path': '/dedicated/server/*/virtualMac'},
|
||||
{'method': 'GET', 'path': '/dedicated/server/*/virtualMac/*/virtualAddress'},
|
||||
|
||||
{'method': 'POST', 'path': '/dedicated/server/*/virtualMac'},
|
||||
])
|
||||
|
||||
print('********\n\tNo valid OVH consumer_key, click this URL:\n\t'
|
||||
'{0.validationUrl}\n\tand copy this consumer_key to ovh.conf: '
|
||||
'{0.consumerKey}\n********'.format(req), file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
except CommandException as exc:
|
||||
print(exc, file=sys.stderr)
|
||||
exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user