]>
git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - buy_ovh_vps_ssd.py
44ae78627e1e8e5672e0b2a86944655fbd5dfbc7
1 # -*- encoding: utf-8 -*-
6 # In case it's installed globally
11 # Credentials are stored in ~/.ovh.conf
16 cart
= client
.post('/order/cart', ovhSubsidiary
="FR")
17 cart_id
= cart
["cartId"]
19 # Assign it to my user
20 client
.post('/order/cart/{}/assign'.format(cart_id
))
23 # client.get('/order/cart/{}/vps'.format(cart_id))
24 item
= client
.post('/order/cart/{}/vps'.format(cart_id
),
26 planCode
="vps_ssd_model1",
27 pricingMode
="default",
29 item_id
= item
["itemId"]
31 # Datacenter, OS, auto-renew
32 client
.post('/order/cart/{}/item/{}/configuration'.format(cart_id
, item_id
),
33 label
="vps_ssd_datacenter",
35 client
.post('/order/cart/{}/item/{}/configuration'.format(cart_id
, item_id
),
37 value
="linux--archlinux--64--en")
38 client
.post('/order/cart/{}/item/{}/configuration'.format(cart_id
, item_id
),
39 label
="AUTO_RENEW_VPS",
42 #summary = client.get('/order/cart/{}/summary'.format(cart_id))
43 #checkout = client.get('/order/cart/{}/checkout'.format(cart_id))
46 order
= client
.post('/order/cart/{}/checkout'.format(cart_id
),
47 waiveRetractationPeriod
=True)
48 order_id
= order
["orderId"]
51 payment_mean
= client
.get('/me/order/{}/availableRegisteredPaymentMean'.format(order_id
))[0]['paymentMean']
52 payment_mean_id
= client
.get('/me/paymentMean/{}'.format(payment_mean
))[0]
54 payment_mean_status
= client
.get('/me/paymentMean/{}/{}'.format(payment_mean
, payment_mean_id
))
56 if payment_mean_status
["state"] != "valid":
59 paid_order
= client
.post('/me/order/{}/payWithRegisteredPaymentMean'.format(order_id
),
60 paymentMean
=payment_mean
, paymentMeanId
=payment_mean_id
)
62 if 'paymentDate' in paid_order
: