diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-10-06 00:24:55 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-10-06 00:24:55 +0200 |
commit | 4aa9e5f6b0c11f5e9e6bd762b1a9c1bb64ce41ad (patch) | |
tree | 9562aa88b6ec80783713452e5db2c3c9d68adef1 | |
parent | 3babc2c64aa406bb94caa8689c7e59fc3c1eb3c1 (diff) | |
download | Puppet-4aa9e5f6b0c11f5e9e6bd762b1a9c1bb64ce41ad.tar.gz Puppet-4aa9e5f6b0c11f5e9e6bd762b1a9c1bb64ce41ad.tar.zst Puppet-4aa9e5f6b0c11f5e9e6bd762b1a9c1bb64ce41ad.zip |
Add buy server script
-rw-r--r-- | python/buy_vps_server.py | 54 | ||||
-rw-r--r-- | python/reinstall_vps_server.py | 29 |
2 files changed, 54 insertions, 29 deletions
diff --git a/python/buy_vps_server.py b/python/buy_vps_server.py new file mode 100644 index 0000000..2803e32 --- /dev/null +++ b/python/buy_vps_server.py | |||
@@ -0,0 +1,54 @@ | |||
1 | # -*- encoding: utf-8 -*- | ||
2 | import json | ||
3 | try: | ||
4 | from ovh import ovh | ||
5 | except ImportError: | ||
6 | # In case it's installed globally | ||
7 | import ovh | ||
8 | import sys | ||
9 | import ovh_helper | ||
10 | |||
11 | # Credentials are stored in ~/.ovh.conf | ||
12 | # See ovh/README.rst | ||
13 | client = ovh.Client() | ||
14 | |||
15 | # Create a cart | ||
16 | cart = client.post('/order/cart', ovhSubsidiary="FR") | ||
17 | cart_id = cart["cartId"] | ||
18 | |||
19 | # Assign it to my user | ||
20 | client.post('/order/cart/{}/assign'.format(cart_id)) | ||
21 | |||
22 | # list of vps: | ||
23 | # client.get('/order/cart/{}/vps'.format(cart_id)) | ||
24 | item = client.post('/order/cart/{}/vps'.format(cart_id), | ||
25 | duration="P1M", | ||
26 | planCode="vps_ssd_model1", | ||
27 | pricingMode="default", | ||
28 | quantity=1) | ||
29 | item_id = item["itemId"] | ||
30 | |||
31 | # Datacenter, OS, auto-renew | ||
32 | client.post('/order/cart/{}/item/{}/configuration'.format(cart_id, item_id), | ||
33 | label="vps_ssd_datacenter", | ||
34 | value="gra") | ||
35 | client.post('/order/cart/{}/item/{}/configuration'.format(cart_id, item_id), | ||
36 | label="vps_ssd_os", | ||
37 | value="linux--archlinux--64--en") | ||
38 | client.post('/order/cart/{}/item/{}/configuration'.format(cart_id, item_id), | ||
39 | label="AUTO_RENEW_VPS", | ||
40 | value=False) | ||
41 | |||
42 | #summary = client.get('/order/cart/{}/summary'.format(cart_id)) | ||
43 | #checkout = client.get('/order/cart/{}/checkout'.format(cart_id)) | ||
44 | |||
45 | # Checkout | ||
46 | order = client.post('/order/cart/{}/checkout'.format(cart_id), | ||
47 | waiveRetractationPeriod=True) | ||
48 | order_id = order["orderId"] | ||
49 | print(order_id) | ||
50 | |||
51 | # Suite à tester : | ||
52 | # /me/order/{orderId}/availableRegisteredPaymentMean | ||
53 | # /me/paymentMean ? /me/order/{orderId}/debt/pay ? | ||
54 | |||
diff --git a/python/reinstall_vps_server.py b/python/reinstall_vps_server.py index 158ca23..9f535cc 100644 --- a/python/reinstall_vps_server.py +++ b/python/reinstall_vps_server.py | |||
@@ -51,35 +51,6 @@ else: | |||
51 | print("Chosen template not available. Chose among:") | 51 | print("Chosen template not available. Chose among:") |
52 | print_templates(client, vps, available_templates) | 52 | print_templates(client, vps, available_templates) |
53 | 53 | ||
54 | # Buy new: | ||
55 | # POST /order/cart | ||
56 | # ovhSubsidiary FR | ||
57 | # POST /order/cart/{cartId}/assign | ||
58 | # GET /vps/datacenter?country=FR | ||
59 | # Get list of vps: | ||
60 | # GET /order/cart/{cartId}/vps | ||
61 | # POST /order/cart/{cartId}/vps | ||
62 | # duration "P1M" | ||
63 | # planCode "vps_ssd_model1" | ||
64 | # pricingMode "default" | ||
65 | # quantity 1 | ||
66 | # POST /order/cart/{cartId}/item/{item}/configuration | ||
67 | # label: "vps_ssd_datacenter" | ||
68 | # value: "gra" | ||
69 | # POST /order/cart/{cartId}/item/{item}/configuration | ||
70 | # label: "vps_ssd_os" | ||
71 | # value: "linux--archlinux--64--en" | ||
72 | # POST /order/cart/{cartId}/item/{item}/configuration | ||
73 | # label: "AUTO_RENEW_VPS" | ||
74 | # value: false | ||
75 | # GET /order/cart/{carId}/summary | ||
76 | # GET /order/cart/{cartId}/checkout | ||
77 | # POST /order/cart/{cartId}/checkout | ||
78 | # waiveRetractationPeriod | ||
79 | # Suite à tester : | ||
80 | # /me/order/{orderId}/availableRegisteredPaymentMean | ||
81 | # /me/paymentMean ? /me/order/{orderId}/debt/pay ? | ||
82 | |||
83 | # Reboot in rescue: | 54 | # Reboot in rescue: |
84 | # PUT /vps/{serviceName} | 55 | # PUT /vps/{serviceName} |
85 | # netbootMode "rescue" / "local" | 56 | # netbootMode "rescue" / "local" |