Merge lp:~terceiro/lava-deployment-tool/missing-install_devmode-function into lp:~linaro-validation/lava-deployment-tool/trunk

Proposed by Antonio Terceiro
Status: Merged
Merge reported by: Antonio Terceiro
Merged at revision: not available
Proposed branch: lp:~terceiro/lava-deployment-tool/missing-install_devmode-function
Merge into: lp:~linaro-validation/lava-deployment-tool/trunk
Diff against target: 199 lines (+75/-44)
1 file modified
lava-deployment-tool (+75/-44)
To merge this branch: bzr merge lp:~terceiro/lava-deployment-tool/missing-install_devmode-function
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Review via email: mp+183002@code.launchpad.net

Description of the change

Add missing function. It does not need to do anything, just be there to be called.

To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

Looks good.
Approve +1.

review: Approve
249. By Antonio Terceiro

Forbid removing instances in non-interactive mode

250. By Antonio Terceiro

Fix indentation

251. By Antonio Terceiro

Allow removing instance in non-interactive mode with --force

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava-deployment-tool'
2--- lava-deployment-tool 2013-08-29 23:10:35 +0000
3+++ lava-deployment-tool 2013-09-02 18:06:05 +0000
4@@ -42,6 +42,9 @@
5 LAVA_NON_INTERACTIVE=no
6 LAVA_DB_CUSTOMPWD=no
7
8+# force destructive actions, specially in non-interactive mode
9+LAVA_FORCE=no
10+
11 os_check() {
12 case `lsb_release -i -s` in
13 Ubuntu)
14@@ -351,6 +354,10 @@
15 return 1 # another loop please
16 }
17
18+install_devmode() {
19+ true
20+}
21+
22 defaults_user() {
23 if [ $LAVA_DEV_MODE = "yes" ]; then
24 export LAVA_SYS_USER=$(whoami)
25@@ -447,50 +454,50 @@
26 _ssh_install() {
27 sshdir=$(eval echo ~$LAVA_SYS_USER)/.ssh
28 if [ "$LAVA_INSTALL_STEPS" = "$LAVA_WORKER_STEPS" ]
29- then
30- # we are configuring a worker
31- if [ ! -d $sshdir ]
32- then
33- echo "SSH directory (${sshdir}) not found, creating it"
34- sudo mkdir -p $sshdir
35- sudo chown $LAVA_SYS_USER $sshdir
36- fi
37+ then
38+ # we are configuring a worker
39+ if [ ! -d $sshdir ]
40+ then
41+ echo "SSH directory (${sshdir}) not found, creating it"
42+ sudo mkdir -p $sshdir
43+ sudo chown $LAVA_SYS_USER $sshdir
44+ fi
45
46- if [ ! -f $sshdir/id_rsa ]
47- then
48- echo "Creating RSA ssh key for user $LAVA_SYS_USER"
49- sudo -u $LAVA_SYS_USER ssh-keygen -C "ssh key used by LAVA for sshfs" -f $sshdir/id_rsa -t rsa -N ""
50- fi
51+ if [ ! -f $sshdir/id_rsa ]
52+ then
53+ echo "Creating RSA ssh key for user $LAVA_SYS_USER"
54+ sudo -u $LAVA_SYS_USER ssh-keygen -C "ssh key used by LAVA for sshfs" -f $sshdir/id_rsa -t rsa -N ""
55+ fi
56
57 # we don't want anything under media since this will get mounted
58 sudo rm -rf $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/*
59 else
60- ### we are configuring a master
61- # Setup the ssh directories in case you want to point workers at this master
62- if [ ! -d $sshdir ]
63- then
64- echo "Creating SSH directory (${sshdir}) as it didn't exist"
65- sudo mkdir -p $sshdir
66- sudo chown -R $LAVA_SYS_USER:$LAVA_SYS_USER $sshdir
67- sudo chmod 700 $sshdir
68- fi
69-
70- if [ ! -f $sshdir/authorized_keys ]
71- then
72- echo "Creating an authorized_keys file, as it didn't exist"
73- sudo touch $sshdir/authorized_keys
74- sudo chown $LAVA_SYS_USER:$LAVA_SYS_USER $sshdir/authorized_keys
75- sudo chmod 600 $sshdir/authorized_keys
76- fi
77-
78- # this file will allow worker nodes to check if the directory is
79- # properly mounted or not
80- sudo touch $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/.mounted
81-
82- # ensure lava-logs and job-output is group writeable for new sshfs workers
83- sudo chmod g+w $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/lava-logs
84- sudo chmod g+w $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/job-output
85- fi
86+ ### we are configuring a master
87+ # Setup the ssh directories in case you want to point workers at this master
88+ if [ ! -d $sshdir ]
89+ then
90+ echo "Creating SSH directory (${sshdir}) as it didn't exist"
91+ sudo mkdir -p $sshdir
92+ sudo chown -R $LAVA_SYS_USER:$LAVA_SYS_USER $sshdir
93+ sudo chmod 700 $sshdir
94+ fi
95+
96+ if [ ! -f $sshdir/authorized_keys ]
97+ then
98+ echo "Creating an authorized_keys file, as it didn't exist"
99+ sudo touch $sshdir/authorized_keys
100+ sudo chown $LAVA_SYS_USER:$LAVA_SYS_USER $sshdir/authorized_keys
101+ sudo chmod 600 $sshdir/authorized_keys
102+ fi
103+
104+ # this file will allow worker nodes to check if the directory is
105+ # properly mounted or not
106+ sudo touch $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/.mounted
107+
108+ # ensure lava-logs and job-output is group writeable for new sshfs workers
109+ sudo chmod g+w $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/lava-logs
110+ sudo chmod g+w $LAVA_PREFIX/$LAVA_INSTANCE/var/lib/lava-server/media/job-output
111+ fi
112 }
113
114 install_fs() {
115@@ -806,7 +813,7 @@
116 done
117 for hbafile in `find /etc/postgresql -name pg_hba.conf`
118 do
119- echo "host all all 0.0.0.0/0 trust" | sudo tee -a $hbafile > /dev/null
120+ echo "host all all 0.0.0.0/0 trust" | sudo tee -a $hbafile > /dev/null
121 done
122 sudo /etc/init.d/postgresql restart
123 }
124@@ -1226,7 +1233,7 @@
125 migrate --noinput || die "Failed to run database migrations"
126 set +x
127
128- echo "Starting instance again..."
129+ echo "Starting instance again..."
130 set -x
131 sudo start lava-instance LAVA_INSTANCE=$LAVA_INSTANCE
132 set +x
133@@ -1686,6 +1693,19 @@
134 cmd_remove() {
135 LAVA_INSTANCE=${1:-dev}
136
137+ local destroy=""
138+ if [ "$LAVA_NON_INTERACTIVE" = yes ]; then
139+ if [ "$LAVA_FORCE" = no ]; then
140+ echo
141+ echo "For safety reasons we do not allow removing an instance"
142+ echo "in non-interactive mode. Try again without -n/--non-interactive"
143+ echo "(or use --force)"
144+ exit 1
145+ else
146+ destroy="DESTROY"
147+ fi
148+ fi
149+
150 _banner
151
152 # Sanity checking, ensure that instance exists
153@@ -1711,8 +1731,11 @@
154 echo "We will remove everything in $LAVA_PREFIX/$LAVA_INSTANCE"
155 echo "We will remove the apache site $LAVA_INSTANCE.conf"
156 echo
157- _read_input "Type DESTROY to continue: " RESPONSE
158- test "$RESPONSE" = 'DESTROY' || return
159+ _read_input "Type DESTROY to continue: " RESPONSE "$destroy"
160+ if test "$RESPONSE" != 'DESTROY'; then
161+ echo "Instance removal aborted."
162+ exit 1
163+ fi
164
165 logger "Removing LAVA instance $LAVA_INSTANCE"
166
167@@ -2166,6 +2189,10 @@
168 Runs non-interactively. Default answers for all questions
169 will be assumed.
170
171+-f, --force
172+ Forces potentially destructive actions to be performed, even in
173+ non-interactive mode.
174+
175 See the README file for instructions
176 END_OF_USAGE
177 }
178@@ -2194,9 +2221,10 @@
179 fi
180
181 options="
182- -o nd
183+ -o ndf
184 --long non-interactive
185 --long developer-mode
186+ --long force
187 "
188 TEMP="$(getopt --name ${__FILE_NAME__} $options -- "$@")"
189 getopt_status=$?
190@@ -2215,6 +2243,9 @@
191 --developer-mode|-d)
192 LAVA_DEV_MODE=yes
193 ;;
194+ --force|-f)
195+ LAVA_FORCE=yes
196+ ;;
197 --)
198 break;;
199 esac

Subscribers

People subscribed via source and target branches