Merge lp:~bzoltan/phablet-tools/different_nmcli_for_vivid into lp:phablet-tools

Proposed by Zoltan Balogh on 2015-02-02
Status: Merged
Approved by: Oliver Grawert on 2015-02-17
Approved revision: 338
Merged at revision: 334
Proposed branch: lp:~bzoltan/phablet-tools/different_nmcli_for_vivid
Merge into: lp:phablet-tools
Diff against target: 22 lines (+5/-6)
1 file modified
phablet-network (+5/-6)
To merge this branch: bzr merge lp:~bzoltan/phablet-tools/different_nmcli_for_vivid
Reviewer Review Type Date Requested Status
Brendan Donegan (community) Approve on 2015-02-10
Oliver Grawert Approve on 2015-02-10
Timo Jyrinki 2015-02-02 Approve on 2015-02-03
PS Jenkins bot continuous-integration Approve on 2015-02-03
Review via email: mp+248305@code.launchpad.net

Commit Message

Use different nmcli command on 15.04 than on 14.10 or 14.04

Description of the Change

Use different nmcli command on 15.04 than on 14.10 or 14.04

To post a comment you must log in.
Timo Jyrinki (timo-jyrinki) wrote :

Tested the new nmcli command on vivid and it seems to work fine. Much appreciated!

review: Approve
Brendan Donegan (brendan-donegan) wrote :

I would do 'wireless_adapter="$(nmcli -t -f device,type dev | egrep "wireless|wifi" | cut -d: -f1)"' before the case statement to reduce the amount of duplicated code. Also you *might* want to specify --active to nmcli connection show just to make sure we only ever use an active connection, but it's not essential since you grep for the adapter name and that only is shown on active connections.

Neither of these changes are essential, just suggestions

review: Needs Information
Brendan Donegan (brendan-donegan) wrote :

Actually now I think about it, there is one thing wrong here - the approach to choosing the command. Really the lsb_release output isn't what's relevant - it's the nmcli version. Check with cyphermox from which version the command changed and use the output of nmcli -v or dpkg -l to check the version.

review: Needs Fixing
Brendan Donegan (brendan-donegan) wrote :

> Actually now I think about it, there is one thing wrong here - the approach to
> choosing the command. Really the lsb_release output isn't what's relevant -
> it's the nmcli version. Check with cyphermox from which version the command
> changed and use the output of nmcli -v or dpkg -l to check the version.

e.g. if the lowest version with the change is 0.9.10 do:

dpkg --compare-versions $installed_version '>=' 0.9.10

Oliver Grawert (ogra) wrote :

there is a bunch of things wrong that needs some cleanup

you should only switch a variable based on the nmcli --version output:

ver=$(nmcli --version|sed 's/^.* //')

if $(dpkg --compare-versions ... )...

then keep the commands generic and just replace some version contents or command options that way ypur if/then becomes a lot cleaner and boils down to about 5 lines:

network_active_uuid="$(LC_ALL=C nmcli $nmcli_commands|grep $wireless_adapter| generric_post_processing)

wireless_adapter="$(nmcli -t -f device,type dev | egrep $wifitype | cut -d: -f1)"

Zoltan Balogh (bzoltan) wrote :

In utopic the nmcli is on 0.9.8.8 and in vivid is on 0.9.10.0

Oliver Grawert (ogra) wrote :

http://paste.ubuntu.com/10158481/ has a cleaned up version that should work (untested)

Oliver Grawert (ogra) :
review: Needs Fixing
Oliver Grawert (ogra) wrote :

and with brendans change (which i missed above):

http://paste.ubuntu.com/10158670/

Oliver Grawert (ogra) wrote :

cool, thanks for updating, looks very good now

review: Approve
Brendan Donegan (brendan-donegan) wrote :

Such cleaner, very approved

review: Approve
Leo Arias (elopio) wrote :

Why is this work in progress? seems everybody likes it, and we need it for the sanity suite automation. Can you please land it?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phablet-network'
2--- phablet-network 2014-09-23 17:55:51 +0000
3+++ phablet-network 2015-02-10 14:54:21 +0000
4@@ -96,13 +96,12 @@
5 NETWORK_MANAGER=/etc/NetworkManager/system-connections
6
7 find_active_network() {
8- wireless_adapter="$(nmcli -t -f device,type dev | egrep wireless | cut -d: -f1)"
9- if [ -z "$wireless_adapter" ]
10- then
11- echo "No wireless adapter found, exiting"
12- exit 1
13+ nmcli_cmd="-t -f name,uuid,devices con status"
14+ if $(dpkg --compare-versions "$(nmcli --version|sed 's/^.* //')" gt 0.9.8.8); then
15+ nmcli_cmd="-t -f name,uuid,device con show"
16 fi
17- network_active_uuid="$(LC_ALL=C nmcli -t -f name,uuid,devices,vpn con status | grep $wireless_adapter | egrep ':no$'| cut -d: -f2)"
18+ wireless_adapter="$(nmcli -t -f device,type dev | egrep "wireless|wifi" | cut -d: -f1)"
19+ network_active_uuid="$(LC_ALL=C nmcli $nmcli_cmd | grep $wireless_adapter | cut -d: -f2)"
20 if [ -z "$network_active_uuid" ]
21 then
22 echo "No active wifi network connection, exiting"

Subscribers

People subscribed via source and target branches