Merge lp:~terceiro/lava-deployment-tool/fix-1056428 into lp:~linaro-validation/lava-deployment-tool/trunk

Proposed by Antonio Terceiro
Status: Merged
Merged at revision: 209
Proposed branch: lp:~terceiro/lava-deployment-tool/fix-1056428
Merge into: lp:~linaro-validation/lava-deployment-tool/trunk
Diff against target: 36 lines (+11/-2)
1 file modified
lava-deployment-tool (+11/-2)
To merge this branch: bzr merge lp:~terceiro/lava-deployment-tool/fix-1056428
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+127030@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

+ if [ -z "$LAVA_SERVER_IP" ]; then
+ # try the IP associated with the default gateway
+ LAVA_SERVER_IP=$(ip route | awk '{ if ($1 == "default") { print($3) } }')
+ fi

Doesn't this return the IP of the gateway? ie, my "ip route" returns:

 default via 192.168.0.1 dev eth0 proto static

the idea is pretty good though. just print $5, which would give you "eth0". and then you can pull the ip address via ifconfig $iface

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Antonio Terceiro <email address hidden> writes:

> Antonio Terceiro has proposed merging lp:~terceiro/lava-deployment-tool/fix-1056428 into lp:lava-deployment-tool.
>
> Requested reviews:
> Linaro Validation Team (linaro-validation)
> Related bugs:
> Bug #1056428 in LAVA Deployment Tool: "non-interactive mode leaves broken dispatcher configuration"
> https://bugs.launchpad.net/lava-deployment-tool/+bug/1056428
>
> For more details, see:
> https://code.launchpad.net/~terceiro/lava-deployment-tool/fix-1056428/+merge/127030
>
> fix for bug #1056428
>
> https://bugs.launchpad.net/lava-deployment-tool/+bug/1056428
> --
> https://code.launchpad.net/~terceiro/lava-deployment-tool/fix-1056428/+merge/127030
> You are subscribed to branch lp:lava-deployment-tool.
> === modified file 'lava-deployment-tool'
> --- lava-deployment-tool 2012-09-14 21:11:54 +0000
> +++ lava-deployment-tool 2012-09-28 17:18:20 +0000
> @@ -740,7 +740,7 @@
> wizard_config_app() {
> _read_input "Enable the scheduler in this instance (yes/no)? [yes] " LAVA_SCHEDULER_ENABLED yes
>
> - _read_input "Do you want to configure the lava-dispatcher (yes/no)? [no] " LAVA_DISPATCHER_CONFIG no
> + _read_input "Do you want to configure the lava-dispatcher (yes/no)? [yes] " LAVA_DISPATCHER_CONFIG yes

I haven't checked this (sorry) but you need to be a bit careful here.
The way the dispatcher auto-configuration was done was a bit peculiar
and we've had bugs where upgrading an instance has overwritten the
dispatcher config with an autogenerated one. Can you check that this
change doesn't make this happen?

> if [ $LAVA_DISPATCHER_CONFIG = yes ]; then
> config_lava_dispatcher
> @@ -761,6 +761,11 @@
>
> ifconfig | grep 'Ethernet\|inet addr'
>
> + if [ -z "$LAVA_SERVER_IP" ]; then
> + # try the IP associated with the default gateway
> + LAVA_SERVER_IP=$(ip route | awk '{ if ($1 == "default") { print($3) } }')
> + fi

As Andy says, this isn't quite right.

Cheers,
mwh

Revision history for this message
Antonio Terceiro (terceiro) wrote :

Andy Doan escreveu:
> + if [ -z "$LAVA_SERVER_IP" ]; then
> + # try the IP associated with the default gateway
> + LAVA_SERVER_IP=$(ip route | awk '{ if ($1 == "default") { print($3) } }')
> + fi
>
> Doesn't this return the IP of the gateway? ie, my "ip route" returns:
>
> default via 192.168.0.1 dev eth0 proto static
>
> the idea is pretty good though. just print $5, which would give you
> "eth0". and then you can pull the ip address via ifconfig $iface

Yes, I didn't pay enough attention to the output - thanks for spotting.
I already have the code for getting the correct IP address!

--
Antonio Terceiro
Software Engineer - Linaro
http://www.linaro.org

Revision history for this message
Antonio Terceiro (terceiro) wrote :

Michael Hudson-Doyle escreveu:
> Antonio Terceiro <email address hidden> writes:
> > === modified file 'lava-deployment-tool'
> > --- lava-deployment-tool 2012-09-14 21:11:54 +0000
> > +++ lava-deployment-tool 2012-09-28 17:18:20 +0000
> > @@ -740,7 +740,7 @@
> > wizard_config_app() {
> > _read_input "Enable the scheduler in this instance (yes/no)? [yes] " LAVA_SCHEDULER_ENABLED yes
> >
> > - _read_input "Do you want to configure the lava-dispatcher (yes/no)? [no] " LAVA_DISPATCHER_CONFIG no
> > + _read_input "Do you want to configure the lava-dispatcher (yes/no)? [yes] " LAVA_DISPATCHER_CONFIG yes
>
> I haven't checked this (sorry) but you need to be a bit careful here.
> The way the dispatcher auto-configuration was done was a bit peculiar
> and we've had bugs where upgrading an instance has overwritten the
> dispatcher config with an autogenerated one. Can you check that this
> change doesn't make this happen?

Just tested this, and the upgrade did not touch the configuration.

The gen_lava_dispatcher_config function (also called during upgrade)
will not overwrite an existing configuration file.

--
Antonio Terceiro
Software Engineer - Linaro
http://www.linaro.org

210. By Antonio Terceiro

correct way of guessing the "best" IP address

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 2012-09-14 21:11:54 +0000
3+++ lava-deployment-tool 2012-10-01 23:46:23 +0000
4@@ -740,7 +740,7 @@
5 wizard_config_app() {
6 _read_input "Enable the scheduler in this instance (yes/no)? [yes] " LAVA_SCHEDULER_ENABLED yes
7
8- _read_input "Do you want to configure the lava-dispatcher (yes/no)? [no] " LAVA_DISPATCHER_CONFIG no
9+ _read_input "Do you want to configure the lava-dispatcher (yes/no)? [yes] " LAVA_DISPATCHER_CONFIG yes
10
11 if [ $LAVA_DISPATCHER_CONFIG = yes ]; then
12 config_lava_dispatcher
13@@ -761,6 +761,12 @@
14
15 ifconfig | grep 'Ethernet\|inet addr'
16
17+ if [ -z "$LAVA_SERVER_IP" ]; then
18+ # try the IP associated with the default gateway
19+ local iface=$(ip route | awk '{ if ($1 == "default") { print($5) } }')
20+ LAVA_SERVER_IP=$(ip addr show "$iface" | awk '{ if ($1 == "inet") { gsub("/.*", "", $2); print($2) } }')
21+ fi
22+
23 while true; do
24
25 _read_input "Please enter the IP address: " LAVA_SERVER_IP
26@@ -769,7 +775,10 @@
27 echo "The IP address is '$LAVA_SERVER_IP'"
28 break
29 else
30- echo "Incorrect IP address"
31+ echo "$LAVA_SERVER_IP is not a valid IP address."
32+ if [ "$LAVA_NON_INTERACTIVE" = "yes" ]; then
33+ exit 1
34+ fi
35 fi
36 done
37

Subscribers

People subscribed via source and target branches