]>
git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - python/reinstall_vps_server.py
1 # -*- encoding: utf-8 -*-
7 # Credentials are stored in ~/.ovh.conf
11 vps_list
= client
.get('/vps/')
12 if sys
.argv
[-1] in vps_list
:
15 print("VPS not in list:")
20 current_distribution
= client
.get('/vps/{}/distribution'.format(vps
))
22 available_templates
= client
.get('/vps/{}/templates'.format(vps
))
24 def print_templates(client
, vps
, available_templates
):
25 for tid
in available_templates
:
26 template
= client
.get('/vps/{}/templates/{}'.format(vps
, tid
))
27 print("{}: {}".format(template
["id"], template
["distribution"]))
30 if "--get-state" in sys
.argv
:
31 print(client
.get('/vps/{}'.format(vps
))["state"])
32 elif "--use-current" in sys
.argv
:
33 if current_distribution
['id'] in available_templates
:
34 print("Current template still available, using it")
35 result
= client
.post('/vps/{}/reinstall'.format(vps
), templateId
=current_distribution
['id'])
37 ovh_helper
.show_progress(client
, vps
, "reinstallVm")
39 print("Current template no more available. Chose among:")
40 print_templates(client
, vps
, available_templates
)
41 elif sys
.argv
[-1] in available_templates
:
42 print("Chosen template available, using it")
43 result
= client
.post('/vps/{}/reinstall'.format(vps
), templateId
=int(sys
.argv
[-1]))
45 ovh_helper
.show_progress(client
, vps
, "reinstallVm")
47 print("Chosen template not available. Chose among:")
48 print_templates(client
, vps
, available_templates
)
53 # POST /order/cart/{cartId}/assign
54 # GET /vps/datacenter?country=FR
56 # GET /order/cart/{cartId}/vps
57 # POST /order/cart/{cartId}/vps
59 # planCode "vps_ssd_model1"
60 # pricingMode "default"
62 # POST /order/cart/{cartId}/item/{item}/configuration
63 # label: "vps_ssd_datacenter"
65 # POST /order/cart/{cartId}/item/{item}/configuration
67 # value: "linux--archlinux--64--en"
68 # POST /order/cart/{cartId}/item/{item}/configuration
69 # label: "AUTO_RENEW_VPS"
71 # GET /order/cart/{carId}/summary
72 # GET /order/cart/{cartId}/checkout
73 # POST /order/cart/{cartId}/checkout
74 # waiveRetractationPeriod
76 # /me/paymentMean ? /me/order/{orderId}/debt/pay ?
79 # PUT /vps/{serviceName}
80 # netbootMode "rescue" / "local"