diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-16 19:14:29 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-03-16 20:13:46 +0100 |
commit | 69da835d04e741f4e85da3c473ba86c8801931fd (patch) | |
tree | 0cfb28cfd468a5b681f2b5af2b935c81d2221950 | |
parent | c15f2234474ff8a8266e26856702b3c561050667 (diff) | |
download | Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.gz Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.tar.zst Puppet-69da835d04e741f4e85da3c473ba86c8801931fd.zip |
Merge install scripts
-rwxr-xr-x | bin/install_script.sh (renamed from bin/install_script_ovh_vps_ssd.sh) | 78 | ||||
-rwxr-xr-x | bin/install_script_ovh_cloud_instance.sh | 114 | ||||
-rw-r--r-- | python/buy_ovh_vps_ssd.py (renamed from python/buy_vps_server.py) | 0 | ||||
-rw-r--r-- | python/get_initial_configuration_ovh_cloud_instance.py (renamed from python/get_initial_configuration_cloud_instance.py) | 15 | ||||
-rw-r--r-- | python/get_initial_configuration_ovh_vps_ssd.py (renamed from python/get_initial_configuration.py) | 0 | ||||
-rw-r--r-- | python/list_servers.py | 13 | ||||
-rw-r--r-- | python/ovh_helper.py | 17 | ||||
-rw-r--r-- | python/reboot_ovh_cloud_instance.py (renamed from python/reboot_cloud_instance.py) | 15 | ||||
-rw-r--r-- | python/reboot_ovh_vps_ssd.py (renamed from python/reboot_vps_server.py) | 0 | ||||
-rw-r--r-- | python/reinstall_ovh_cloud_instance.py (renamed from python/reinstall_cloud_instance.py) | 15 | ||||
-rw-r--r-- | python/reinstall_ovh_vps_ssd.py (renamed from python/reinstall_vps_server.py) | 0 | ||||
-rwxr-xr-x | scripts/ovh_cloud_instance/arch_host_script.sh | 2 | ||||
-rwxr-xr-x | scripts/send_and_run.tcl | 2 |
13 files changed, 92 insertions, 179 deletions
diff --git a/bin/install_script_ovh_vps_ssd.sh b/bin/install_script.sh index b5b0efb..bd7f38b 100755 --- a/bin/install_script_ovh_vps_ssd.sh +++ b/bin/install_script.sh | |||
@@ -2,39 +2,63 @@ | |||
2 | 2 | ||
3 | usage() { | 3 | usage() { |
4 | cat <<EOF | 4 | cat <<EOF |
5 | $0 [options] | 5 | $(basename $0) [options] |
6 | --help,-h This help | 6 | --help,-h This help |
7 | --vps vps_name Name of the vps | 7 | |
8 | --password password Password of the vps (only useful in case of no reboot) | 8 | One of the following options is necessary: |
9 | --instance-id id Id of the cloud instance | ||
10 | --vps-id id Id of the vps | ||
11 | |||
12 | Optional arguments: | ||
13 | --password password Password of the host (only useful in case of no reboot and vps) | ||
9 | --reinstall-first Start with reinstalling the vps | 14 | --reinstall-first Start with reinstalling the vps |
10 | --host-user user Use another user (default: root) | 15 | --host-user user Use another user than the default one |
11 | --no-reboot Don't reboot | 16 | --no-reboot Don't reboot |
12 | --no-reboot-start Don't reboot to rescue at the beginning | 17 | --no-reboot-start Don't reboot to rescue at the beginning |
13 | --no-reboot-end Don't reboot to normal at the end | 18 | --no-reboot-end Don't reboot to normal at the end |
14 | --git-branch Use another puppet branch (default: master) | 19 | --git-branch branch Use another puppet branch (default: master) |
15 | --environment Environment to use for the installl (default: production) | 20 | --environment env Environment to use for the install (default: production) |
16 | EOF | 21 | EOF |
17 | } | 22 | } |
18 | 23 | ||
19 | set -e | 24 | set -e |
20 | 25 | ||
21 | host_user=root | ||
22 | git_branch=master | 26 | git_branch=master |
23 | environment=production | 27 | environment=production |
28 | host_user="" | ||
29 | password="" | ||
30 | T="" | ||
24 | 31 | ||
25 | while [ -n "$1" ]; do | 32 | while [ -n "$1" ]; do |
26 | case "$1" in | 33 | case "$1" in |
27 | --vps) | 34 | --instance-id) |
28 | vps_name="$2" | 35 | host_id="$2" |
36 | if [ -z "$host_user" ]; then | ||
37 | host_user="arch" | ||
38 | fi | ||
39 | if [ -z "$password" ]; then | ||
40 | password="x" | ||
41 | fi | ||
42 | [ -n "$T" ] && usage && exit 1 | ||
43 | T="ovh_cloud_instance" | ||
29 | shift | 44 | shift |
30 | ;; | 45 | ;; |
31 | --reinstall-first) | 46 | --vps-id) |
32 | reinstall_first=1 | 47 | host_id="$2" |
48 | if [ -z "$host_user" ]; then | ||
49 | host_user="root" | ||
50 | fi | ||
51 | [ -n "$T" ] && usage && exit 1 | ||
52 | T="ovh_vps_ssd" | ||
53 | shift | ||
33 | ;; | 54 | ;; |
34 | --password) | 55 | --password) |
35 | password="$2" | 56 | password="$2" |
36 | shift | 57 | shift |
37 | ;; | 58 | ;; |
59 | --reinstall-first) | ||
60 | reinstall_first=1 | ||
61 | ;; | ||
38 | --host-user) | 62 | --host-user) |
39 | host_user="$2" | 63 | host_user="$2" |
40 | shift | 64 | shift |
@@ -65,24 +89,27 @@ while [ -n "$1" ]; do | |||
65 | shift | 89 | shift |
66 | done | 90 | done |
67 | 91 | ||
92 | if [ -z "$T" -o -z "$host_id" ]; then | ||
93 | usage | ||
94 | exit 1 | ||
95 | fi | ||
96 | |||
68 | DIRECTORY=$(cd `dirname $0` && pwd) | 97 | DIRECTORY=$(cd `dirname $0` && pwd) |
69 | PYTHON_DIRECTORY="$DIRECTORY/../python" | 98 | PYTHON_DIRECTORY="$DIRECTORY/../python" |
70 | SCRIPTS="$DIRECTORY/../scripts" | 99 | SCRIPTS="$DIRECTORY/../scripts" |
71 | 100 | ||
72 | if [ -z "$vps_name" ]; then | ||
73 | read -p "Nom du vps : " vps_name | ||
74 | fi | ||
75 | |||
76 | if [ -n "$reinstall_first" ]; then | 101 | if [ -n "$reinstall_first" ]; then |
77 | echo "Réinstallation du système" | 102 | echo "Réinstallation du système" |
78 | python $PYTHON_DIRECTORY/reinstall_vps_server.py --use-current "$vps_name" | 103 | python $PYTHON_DIRECTORY/reinstall_$T.py --use-current "$host_id" |
79 | 104 | ||
80 | read -p "Appuyer sur une touche quand le serveur est prêt" ready | 105 | read -p "Appuyer sur une touche quand le serveur est prêt" ready |
81 | fi | 106 | fi |
82 | 107 | ||
83 | if [ -z "$no_reboot" -a -z "$no_reboot_start" ]; then | 108 | if [ -z "$no_reboot" -a -z "$no_reboot_start" ]; then |
84 | echo "Patienter le temps du reboot" | 109 | echo "Patienter le temps du reboot" |
85 | python $PYTHON_DIRECTORY/reboot_vps_server.py --rescue "$vps_name" | 110 | python $PYTHON_DIRECTORY/reboot_$T.py --rescue "$host_id" |
111 | |||
112 | read -p "Appuyer sur une touche quand l'instance a redémarré" ready | ||
86 | fi | 113 | fi |
87 | 114 | ||
88 | if [ -z "$password" ]; then | 115 | if [ -z "$password" ]; then |
@@ -92,19 +119,24 @@ if [ -z "$password" ]; then | |||
92 | fi | 119 | fi |
93 | 120 | ||
94 | ARCH_DIR=`mktemp -d` | 121 | ARCH_DIR=`mktemp -d` |
95 | ARCH_HOST_SCRIPT="$SCRIPTS/ovh_vps_ssd/arch_host_script.sh" | 122 | ARCH_HOST_SCRIPT="$SCRIPTS/$T/arch_host_script.sh" |
96 | ARCH_CHROOT_SCRIPT="$SCRIPTS/ovh_vps_ssd/arch_chroot_script.sh" | 123 | if [ -f "$SCRIPTS/$T/arch_chroot_script.sh" ]; then |
124 | ARCH_CHROOT_SCRIPT="$SCRIPTS/$T/arch_chroot_script.sh" | ||
125 | else | ||
126 | ARCH_CHROOT_SCRIPT="" | ||
127 | fi | ||
97 | ARCH_INSTALL_SCRIPT="$SCRIPTS/arch_install_script.sh" | 128 | ARCH_INSTALL_SCRIPT="$SCRIPTS/arch_install_script.sh" |
98 | ARCH_HOST_PUPPET_CONFIGURATION_SCRIPT="$SCRIPTS/ovh_vps_ssd/arch_host_puppet_configuration_script.sh" | 129 | ARCH_HOST_PUPPET_CONFIGURATION_SCRIPT="$SCRIPTS/$T/arch_host_puppet_configuration_script.sh" |
99 | ARCH_PUPPET_CONFIGURATION_SCRIPT="$SCRIPTS/arch_puppet_configuration_script.sh" | 130 | ARCH_PUPPET_CONFIGURATION_SCRIPT="$SCRIPTS/arch_puppet_configuration_script.sh" |
100 | ARCH_PUPPET_INITIAL_CONFIGURATION="$ARCH_DIR/puppet_variables.json" | 131 | ARCH_PUPPET_INITIAL_CONFIGURATION="$ARCH_DIR/puppet_variables.json" |
101 | 132 | ||
102 | trap "rm -rf $ARCH_DIR" EXIT | 133 | trap "rm -rf $ARCH_DIR" EXIT |
103 | 134 | ||
104 | #### Base installation stage | 135 | #### Base installation stage |
105 | python $PYTHON_DIRECTORY/get_initial_configuration.py $vps_name > $ARCH_PUPPET_INITIAL_CONFIGURATION | 136 | python $PYTHON_DIRECTORY/get_initial_configuration_$T.py $host_id > $ARCH_PUPPET_INITIAL_CONFIGURATION |
137 | host_address=$(python $PYTHON_DIRECTORY/get_initial_configuration_$T.py $host_id | jq -r '.ips.v4.ipAddress') | ||
106 | 138 | ||
107 | dest="$host_user@$vps_name" | 139 | dest="$host_user@$host_address" |
108 | files="$ARCH_HOST_SCRIPT $ARCH_CHROOT_SCRIPT $ARCH_PUPPET_INITIAL_CONFIGURATION $ARCH_INSTALL_SCRIPT" | 140 | files="$ARCH_HOST_SCRIPT $ARCH_CHROOT_SCRIPT $ARCH_PUPPET_INITIAL_CONFIGURATION $ARCH_INSTALL_SCRIPT" |
109 | 141 | ||
110 | $SCRIPTS/send_and_run.tcl "$dest" "$password" "$git_branch" "$environment" $files | 142 | $SCRIPTS/send_and_run.tcl "$dest" "$password" "$git_branch" "$environment" $files |
@@ -119,5 +151,5 @@ $SCRIPTS/send_and_run.tcl "$dest" "$password" "$git_branch" "$environment" $file | |||
119 | ### Installation finished | 151 | ### Installation finished |
120 | if [ -z "$no_reboot" -a -z "$no_reboot_end" ]; then | 152 | if [ -z "$no_reboot" -a -z "$no_reboot_end" ]; then |
121 | echo "Rebooting" | 153 | echo "Rebooting" |
122 | python $PYTHON_DIRECTORY/reboot_vps_server.py --local "$vps_name" | 154 | python $PYTHON_DIRECTORY/reboot_$T.py --local "$host_id" |
123 | fi | 155 | fi |
diff --git a/bin/install_script_ovh_cloud_instance.sh b/bin/install_script_ovh_cloud_instance.sh deleted file mode 100755 index e1c8a54..0000000 --- a/bin/install_script_ovh_cloud_instance.sh +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | usage() { | ||
4 | cat <<EOF | ||
5 | $0 [options] | ||
6 | --help,-h This help | ||
7 | --instance-id id Id of the instance | ||
8 | --reinstall-first Start with reinstalling the vps | ||
9 | --host-user user Use another user (default: arch) | ||
10 | --no-reboot Don't reboot | ||
11 | --no-reboot-start Don't reboot to rescue at the beginning | ||
12 | --no-reboot-end Don't reboot to normal at the end | ||
13 | --git-branch Use another puppet branch (default: master) | ||
14 | --environment Environment to use for the installl (default: production) | ||
15 | EOF | ||
16 | } | ||
17 | |||
18 | set -e | ||
19 | |||
20 | host_user=arch | ||
21 | git_branch=master | ||
22 | environment=production | ||
23 | |||
24 | while [ -n "$1" ]; do | ||
25 | case "$1" in | ||
26 | --instance-id) | ||
27 | instance_id="$2" | ||
28 | shift | ||
29 | ;; | ||
30 | --reinstall-first) | ||
31 | reinstall_first=1 | ||
32 | ;; | ||
33 | --host-user) | ||
34 | host_user="$2" | ||
35 | shift | ||
36 | ;; | ||
37 | --no-reboot) | ||
38 | no_reboot=1 | ||
39 | ;; | ||
40 | --no-reboot-start) | ||
41 | no_reboot_start=1 | ||
42 | ;; | ||
43 | --no-reboot-end) | ||
44 | no_reboot_end=1 | ||
45 | ;; | ||
46 | --git-branch) | ||
47 | git_branch="$2" | ||
48 | shift | ||
49 | ;; | ||
50 | --environment) | ||
51 | environment="$2" | ||
52 | shift | ||
53 | ;; | ||
54 | --help|-h) | ||
55 | usage | ||
56 | exit 0 | ||
57 | ;; | ||
58 | esac | ||
59 | |||
60 | shift | ||
61 | done | ||
62 | |||
63 | DIRECTORY=$(cd `dirname $0` && pwd) | ||
64 | PYTHON_DIRECTORY="$DIRECTORY/../python" | ||
65 | SCRIPTS="$DIRECTORY/../scripts" | ||
66 | |||
67 | if [ -z "$instance_id" ]; then | ||
68 | read -p "Id de l'instance : " instance_id | ||
69 | fi | ||
70 | |||
71 | if [ -n "$reinstall_first" ]; then | ||
72 | echo "Réinstallation du système" | ||
73 | python $PYTHON_DIRECTORY/reinstall_cloud_instance.py --use-current "$instance_id" | ||
74 | |||
75 | read -p "Appuyer sur une touche quand le serveur est prêt" ready | ||
76 | fi | ||
77 | |||
78 | if [ -z "$no_reboot" -a -z "$no_reboot_start" ]; then | ||
79 | echo "Patienter le temps du reboot" | ||
80 | python $PYTHON_DIRECTORY/reboot_cloud_instance.py --rescue "$instance_id" | ||
81 | |||
82 | read -p "Appuyer sur une touche quand l'instance a redémarré" ready | ||
83 | fi | ||
84 | |||
85 | ARCH_DIR=`mktemp -d` | ||
86 | ARCH_HOST_SCRIPT="$SCRIPTS/ovh_cloud_instance/arch_host_script.sh" | ||
87 | ARCH_INSTALL_SCRIPT="$SCRIPTS/arch_install_script.sh" | ||
88 | ARCH_HOST_PUPPET_CONFIGURATION_SCRIPT="$SCRIPTS/ovh_cloud_instance/arch_host_puppet_configuration_script.sh" | ||
89 | ARCH_PUPPET_CONFIGURATION_SCRIPT="$SCRIPTS/arch_puppet_configuration_script.sh" | ||
90 | ARCH_PUPPET_INITIAL_CONFIGURATION="$ARCH_DIR/puppet_variables.json" | ||
91 | |||
92 | trap "rm -rf $ARCH_DIR" EXIT | ||
93 | |||
94 | #### Base installation stage | ||
95 | python $PYTHON_DIRECTORY/get_initial_configuration_cloud_instance.py $instance_id > $ARCH_PUPPET_INITIAL_CONFIGURATION | ||
96 | host_address=$(python $PYTHON_DIRECTORY/get_initial_configuration_cloud_instance.py $instance_id | jq -r '.ips.v4.ipAddress') | ||
97 | |||
98 | dest="$host_user@$host_address" | ||
99 | files="$ARCH_HOST_SCRIPT $ARCH_PUPPET_INITIAL_CONFIGURATION $ARCH_INSTALL_SCRIPT" | ||
100 | |||
101 | $SCRIPTS/send_and_run.tcl "$dest" "" "$git_branch" "$environment" $files | ||
102 | |||
103 | ### Role specific stage | ||
104 | read -p "Press key when LDAP is configured" i | ||
105 | |||
106 | files="$ARCH_HOST_PUPPET_CONFIGURATION_SCRIPT $ARCH_PUPPET_CONFIGURATION_SCRIPT" | ||
107 | |||
108 | $SCRIPTS/send_and_run.tcl "$dest" "" "$git_branch" "$environment" $files | ||
109 | |||
110 | ### Installation finished | ||
111 | if [ -z "$no_reboot" -a -z "$no_reboot_end" ]; then | ||
112 | echo "Rebooting" | ||
113 | python $PYTHON_DIRECTORY/reboot_cloud_instance.py --local "$instance_id" | ||
114 | fi | ||
diff --git a/python/buy_vps_server.py b/python/buy_ovh_vps_ssd.py index 44ae786..44ae786 100644 --- a/python/buy_vps_server.py +++ b/python/buy_ovh_vps_ssd.py | |||
diff --git a/python/get_initial_configuration_cloud_instance.py b/python/get_initial_configuration_ovh_cloud_instance.py index 4157716..844373c 100644 --- a/python/get_initial_configuration_cloud_instance.py +++ b/python/get_initial_configuration_ovh_cloud_instance.py | |||
@@ -6,6 +6,7 @@ except ImportError: | |||
6 | # In case it's installed globally | 6 | # In case it's installed globally |
7 | import ovh | 7 | import ovh |
8 | import sys | 8 | import sys |
9 | from ovh_helper import find_cloud_instance | ||
9 | 10 | ||
10 | infos = {} | 11 | infos = {} |
11 | 12 | ||
@@ -13,19 +14,7 @@ infos = {} | |||
13 | # See ovh/README.rst | 14 | # See ovh/README.rst |
14 | client = ovh.Client() | 15 | client = ovh.Client() |
15 | 16 | ||
16 | projects_list = client.get('/cloud/project/') | 17 | _, instance = find_cloud_instance(client, sys.argv[-1]) |
17 | if len(projects_list) > 1: | ||
18 | print("More than one project is not supported, taking the first one") | ||
19 | project = projects_list[0] | ||
20 | instances_list = client.get('/cloud/project/{}/instance'.format(project)) | ||
21 | instances = dict(map(lambda x: (x["id"], x), instances_list)) | ||
22 | if sys.argv[-1] in instances: | ||
23 | instance = instances[sys.argv[-1]] | ||
24 | else: | ||
25 | print("Instance not in list:") | ||
26 | for instance in instances_list: | ||
27 | print("{}: {}".format(instance["name"], instance["id"])) | ||
28 | sys.exit(1) | ||
29 | 18 | ||
30 | infos["ips"] = {} | 19 | infos["ips"] = {} |
31 | for ip_infos in instance["ipAddresses"]: | 20 | for ip_infos in instance["ipAddresses"]: |
diff --git a/python/get_initial_configuration.py b/python/get_initial_configuration_ovh_vps_ssd.py index 0c6f698..0c6f698 100644 --- a/python/get_initial_configuration.py +++ b/python/get_initial_configuration_ovh_vps_ssd.py | |||
diff --git a/python/list_servers.py b/python/list_servers.py index 9b8bc64..e7bd2af 100644 --- a/python/list_servers.py +++ b/python/list_servers.py | |||
@@ -6,7 +6,18 @@ except ImportError: | |||
6 | 6 | ||
7 | client = ovh.Client() | 7 | client = ovh.Client() |
8 | 8 | ||
9 | print("OVH cloud instances:") | ||
10 | projects_list = client.get('/cloud/project/') | ||
11 | for project_id in projects_list: | ||
12 | project = client.get('/cloud/project/{}'.format(project_id)) | ||
13 | print("\t{}:".format(project["description"])) | ||
14 | instances_list = client.get('/cloud/project/{}/instance'.format(project_id)) | ||
15 | for instance in instances_list: | ||
16 | print("\t\t{}: {}".format(instance["name"], instance["id"])) | ||
17 | |||
9 | vps_list = client.get('/vps/') | 18 | vps_list = client.get('/vps/') |
10 | 19 | ||
20 | print("OVH VPS SSD servers:") | ||
11 | for vps in vps_list: | 21 | for vps in vps_list: |
12 | print(vps) | 22 | print("\t{}".format(vps)) |
23 | |||
diff --git a/python/ovh_helper.py b/python/ovh_helper.py index a49a245..19834ae 100644 --- a/python/ovh_helper.py +++ b/python/ovh_helper.py | |||
@@ -1,4 +1,5 @@ | |||
1 | import time | 1 | import time |
2 | import sys | ||
2 | 3 | ||
3 | def show_progress(client, vps, task_type): | 4 | def show_progress(client, vps, task_type): |
4 | running_task_id = client.get("/vps/{}/tasks?type={}".format(vps, task_type))[0] | 5 | running_task_id = client.get("/vps/{}/tasks?type={}".format(vps, task_type))[0] |
@@ -17,3 +18,19 @@ def show_progress(client, vps, task_type): | |||
17 | time.sleep(3) | 18 | time.sleep(3) |
18 | 19 | ||
19 | print("\rFinished") | 20 | print("\rFinished") |
21 | |||
22 | def find_cloud_instance(client, instance_id): | ||
23 | projects_list = client.get('/cloud/project/') | ||
24 | instances_list = [] | ||
25 | for project in projects_list: | ||
26 | instances_list += list(map(lambda x: [project, x], | ||
27 | client.get('/cloud/project/{}/instance'.format(project)))) | ||
28 | instances = dict(map(lambda x: (x[1]["id"], x), instances_list)) | ||
29 | if instance_id in instances: | ||
30 | project_instance = instances[instance_id] | ||
31 | else: | ||
32 | print("Instance not in list:") | ||
33 | for instance in instances_list: | ||
34 | print("{}: {}".format(instance[1]["name"], instance[1]["id"])) | ||
35 | sys.exit(1) | ||
36 | return project_instance | ||
diff --git a/python/reboot_cloud_instance.py b/python/reboot_ovh_cloud_instance.py index b90f488..de20c07 100644 --- a/python/reboot_cloud_instance.py +++ b/python/reboot_ovh_cloud_instance.py | |||
@@ -6,24 +6,13 @@ except ImportError: | |||
6 | # In case it's installed globally | 6 | # In case it's installed globally |
7 | import ovh | 7 | import ovh |
8 | import sys | 8 | import sys |
9 | from ovh_helper import find_cloud_instance | ||
9 | 10 | ||
10 | # Credentials are stored in ~/.ovh.conf | 11 | # Credentials are stored in ~/.ovh.conf |
11 | # See ovh/README.rst | 12 | # See ovh/README.rst |
12 | client = ovh.Client() | 13 | client = ovh.Client() |
13 | 14 | ||
14 | projects_list = client.get('/cloud/project/') | 15 | project, instance = find_cloud_instance(client, sys.argv[-1]) |
15 | if len(projects_list) > 1: | ||
16 | print("More than one project is not supported, taking the first one") | ||
17 | project = projects_list[0] | ||
18 | instances_list = client.get('/cloud/project/{}/instance'.format(project)) | ||
19 | instances = dict(map(lambda x: (x["id"], x), instances_list)) | ||
20 | if sys.argv[-1] in instances: | ||
21 | instance = instances[sys.argv[-1]] | ||
22 | else: | ||
23 | print("Instance not in list:") | ||
24 | for instance in instances_list: | ||
25 | print("{}: {}".format(instance["name"], instance["id"])) | ||
26 | sys.exit(1) | ||
27 | 16 | ||
28 | if "--rescue" in sys.argv: | 17 | if "--rescue" in sys.argv: |
29 | netboot_mode="rescue" | 18 | netboot_mode="rescue" |
diff --git a/python/reboot_vps_server.py b/python/reboot_ovh_vps_ssd.py index 71c5227..71c5227 100644 --- a/python/reboot_vps_server.py +++ b/python/reboot_ovh_vps_ssd.py | |||
diff --git a/python/reinstall_cloud_instance.py b/python/reinstall_ovh_cloud_instance.py index c488fda..c0d2617 100644 --- a/python/reinstall_cloud_instance.py +++ b/python/reinstall_ovh_cloud_instance.py | |||
@@ -6,24 +6,13 @@ except ImportError: | |||
6 | # In case it's installed globally | 6 | # In case it's installed globally |
7 | import ovh | 7 | import ovh |
8 | import sys | 8 | import sys |
9 | from ovh_helper import find_cloud_instance | ||
9 | 10 | ||
10 | # Credentials are stored in ~/.ovh.conf | 11 | # Credentials are stored in ~/.ovh.conf |
11 | # See ovh/README.rst | 12 | # See ovh/README.rst |
12 | client = ovh.Client() | 13 | client = ovh.Client() |
13 | 14 | ||
14 | projects_list = client.get('/cloud/project/') | 15 | project, instance = find_cloud_instance(client, sys.argv[-1]) |
15 | if len(projects_list) > 1: | ||
16 | print("More than one project is not supported, taking the first one") | ||
17 | project = projects_list[0] | ||
18 | instances_list = client.get('/cloud/project/{}/instance'.format(project)) | ||
19 | instances = dict(map(lambda x: (x["id"], x), instances_list)) | ||
20 | if sys.argv[-1] in instances: | ||
21 | instance = instances[sys.argv[-1]] | ||
22 | else: | ||
23 | print("Instance not in list:") | ||
24 | for instance in instances_list: | ||
25 | print("{}: {}".format(instance["name"], instance["id"])) | ||
26 | sys.exit(1) | ||
27 | 16 | ||
28 | current_image = instance["imageId"] | 17 | current_image = instance["imageId"] |
29 | available_images = client.get('/cloud/project/{}/image'.format(project), | 18 | available_images = client.get('/cloud/project/{}/image'.format(project), |
diff --git a/python/reinstall_vps_server.py b/python/reinstall_ovh_vps_ssd.py index 9f535cc..9f535cc 100644 --- a/python/reinstall_vps_server.py +++ b/python/reinstall_ovh_vps_ssd.py | |||
diff --git a/scripts/ovh_cloud_instance/arch_host_script.sh b/scripts/ovh_cloud_instance/arch_host_script.sh index c188514..3408563 100755 --- a/scripts/ovh_cloud_instance/arch_host_script.sh +++ b/scripts/ovh_cloud_instance/arch_host_script.sh | |||
@@ -29,7 +29,7 @@ sudo mount "$DEVICE" /mnt | |||
29 | for i in /mnt/*; do | 29 | for i in /mnt/*; do |
30 | if [ "$i" = "/mnt/boot" ]; then | 30 | if [ "$i" = "/mnt/boot" ]; then |
31 | # keep /boot/grub | 31 | # keep /boot/grub |
32 | sudo rm -f $i/* | 32 | sudo rm -f $i/* || true |
33 | else | 33 | else |
34 | sudo rm -rf $i | 34 | sudo rm -rf $i |
35 | fi | 35 | fi |
diff --git a/scripts/send_and_run.tcl b/scripts/send_and_run.tcl index a087a2d..42fae62 100755 --- a/scripts/send_and_run.tcl +++ b/scripts/send_and_run.tcl | |||
@@ -6,7 +6,7 @@ set environment [lindex $argv 3] | |||
6 | set script [lindex $argv 4] | 6 | set script [lindex $argv 4] |
7 | set files [lrange $argv 4 end] | 7 | set files [lrange $argv 4 end] |
8 | 8 | ||
9 | if {$password == ""} { | 9 | if {$password == "x"} { |
10 | set ask_password 0 | 10 | set ask_password 0 |
11 | } else { | 11 | } else { |
12 | set ask_password 1 | 12 | set ask_password 1 |