diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-09-17 19:05:41 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-09-18 00:22:19 +0200 |
commit | 248bd83ed797f6e0f385e72a56aa7bafdf23d490 (patch) | |
tree | 29cd0d69b73b34d6d12ebe354be9d1d616983e3f /python | |
parent | 503e4cf5c54e3fe4b802038e8917341c4ce803e5 (diff) | |
download | Puppet-248bd83ed797f6e0f385e72a56aa7bafdf23d490.tar.gz Puppet-248bd83ed797f6e0f385e72a56aa7bafdf23d490.tar.zst Puppet-248bd83ed797f6e0f385e72a56aa7bafdf23d490.zip |
Enhance install script, and add ip6 address
Diffstat (limited to 'python')
-rw-r--r-- | python/get_initial_configuration.py | 37 | ||||
-rw-r--r-- | python/reboot_vps_server.py | 6 |
2 files changed, 42 insertions, 1 deletions
diff --git a/python/get_initial_configuration.py b/python/get_initial_configuration.py new file mode 100644 index 0000000..0c6f698 --- /dev/null +++ b/python/get_initial_configuration.py | |||
@@ -0,0 +1,37 @@ | |||
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 | |||
10 | infos = {} | ||
11 | |||
12 | # Credentials are stored in ~/.ovh.conf | ||
13 | # See ovh/README.rst | ||
14 | client = ovh.Client() | ||
15 | |||
16 | vps_list = client.get('/vps/') | ||
17 | if sys.argv[-1] in vps_list: | ||
18 | vps = sys.argv[-1] | ||
19 | else: | ||
20 | print("VPS not in list:") | ||
21 | for vps in vps_list: | ||
22 | print(vps) | ||
23 | sys.exit(1) | ||
24 | |||
25 | ips = client.get('/vps/{}/ips'.format(vps)) | ||
26 | |||
27 | infos["ips"] = {} | ||
28 | for ip in ips: | ||
29 | ip_infos = client.get('/vps/{}/ips/{}'.format(vps, ip)) | ||
30 | |||
31 | if ip_infos["version"] == "v4": | ||
32 | infos["ips"]["v4"] = ip_infos | ||
33 | else: | ||
34 | infos["ips"]["v6"] = ip_infos | ||
35 | infos["ips"]["v6"]["mask"] = 128 | ||
36 | |||
37 | print(json.dumps(infos)) | ||
diff --git a/python/reboot_vps_server.py b/python/reboot_vps_server.py index 7ea301a..71c5227 100644 --- a/python/reboot_vps_server.py +++ b/python/reboot_vps_server.py | |||
@@ -1,6 +1,10 @@ | |||
1 | # -*- encoding: utf-8 -*- | 1 | # -*- encoding: utf-8 -*- |
2 | import json | 2 | import json |
3 | from ovh import ovh | 3 | try: |
4 | from ovh import ovh | ||
5 | except ImportError: | ||
6 | # In case it's installed globally | ||
7 | import ovh | ||
4 | import sys | 8 | import sys |
5 | import ovh_helper | 9 | import ovh_helper |
6 | 10 | ||