Add functionality to dump/restore current wifi connection

Bug #1359622 reported by Martin Pitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
phablet-tools (Ubuntu)
Fix Released
Wishlist
Martin Pitt

Bug Description

For running tests on the device it should be reset to a known pristine state before each test, to avoid tests influencing each other. For that, autopkgtest's adb setup script currently saves the network connections, resets to factory state, and restores the network connections:

    echo "Performing factory reset, this will take a minute..." >&2

    # save current network connections
    local network_tar=$(mktemp)
    adb $ADBOPTS shell tar cPpf /run/netconf.tar /etc/NetworkManager/system-connections
    adb $ADBOPTS pull /run/netconf.tar $network_tar

    # reset to factory state
    adb $ADBOPTS shell 'echo format data > /cache/recovery/ubuntu_command'
    adb $ADBOPTS reboot recovery
    adb $ADBOPTS wait-for-device

    # restore network connections
    adb $ADBOPTS push $network_tar /run/netconf.tar
    adb $ADBOPTS shell 'tar xPpf /run/netconf.tar && rm /run/netconf.tar'

Doing that is a lot faster than having to re-flash the device from scratch every time. It allows us to manually set up a device once (i. e. pick network and type passphrase), and then just use it noninteractively.

It would be good to move this to phablet-tools, which is a more appropriate place as it contains all the other phone specific knowledge.

Related branches

Revision history for this message
Martin Pitt (pitti) wrote :

Should this become a new phablet-factory-reset tool, or be integrated into phablet-config, or something else?

Changed in phablet-tools (Ubuntu):
importance: Undecided → Wishlist
description: updated
description: updated
Revision history for this message
Oliver Grawert (ogra) wrote :

why do you need to save the network connections here ?
in all other test environments in the lab we simply use phablet-network with a file the provisioning server provides for a local WLAN setup. do you expect the network to change between tests ?

apart from the netwroking bit i don't see why this script wouldn't work right away even in the new world order ...

Revision history for this message
Martin Pitt (pitti) wrote :

> why do you need to save the network connections here ?

Because we want to use the exact same testing tool in CI and for local developers. For the latter case it's much more convenient to re-use an already configured network on the phone than requiring the developer to create a network config file locally and supply that to phablet-config (or adt-run). After all, the phone already knows its network connections, so it can just save/restore them.

Revision history for this message
Martin Pitt (pitti) wrote :

Discussed with Oli on IRC: In order to keep this flexible, we'll add three things:

  - phablet-config save-network # could default to /run/$serial-netconf.tar, and get an option for file name
  - phablet-config restore-network # dito
  - phablet-config factory-reset

Developers would seldomly call this manually (they'd usually run tests through adt-run or phablet-test-run), and it's more flexible for scripts.

If at some point we want a factory-reset --keep-network, this is then trivial to implement, as the code is already in phablet-config.

Changed in phablet-tools (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
status: New → Triaged
Revision history for this message
Martin Pitt (pitti) wrote :

> phablet-config restore-network # dito

scratch that, that's just phablet-network :-)

Revision history for this message
Martin Pitt (pitti) wrote :

Building blocks for reading network connection and password:

gdbus call --system -d org.freedesktop.NetworkManager -o /org/freedesktop/NetworkManager/ActiveConnection/0 -m org.freedesktop.DBus.Properties.Get 'org.freedesktop.NetworkManager.Connection.Active' Connection
(<objectpath '/org/freedesktop/NetworkManager/Settings/1'>,)

gdbus call --system -d org.freedesktop.NetworkManager -o /org/freedesktop/NetworkManager/Settings/1 -m org.freedesktop.NetworkManager.Settings.Connection.GetSettings
({'802-11-wireless': {'security': <'802-11-wireless-security'>, 'ssid': <[byte 0x70, 0x69, 0x74, 0x74, 0x69, 0x6e, 0x65, 0x74, 0x20, 0x35, 0x20, 0x47, 0x48, 0x7a]>, 'mode': <'infrastructure'>, 'mac-address': <[byte 0xa4, 0x4e, 0x31, 0x84, 0x8d, 0x2c]>, 'seen-bssids': <['1C:C6:3C:34:08:C1']>}, 'connection': {'id': <'pittinet 5 GHz'>, 'uuid': <'61143bb3-6f77-4b6e-9787-e69b32a5ffc3'>, 'timestamp': <uint64 1408618144>, 'type': <'802-11-wireless'>}, 'ipv4': {'addresses': <@aau []>, 'dns': <@au []>, 'method': <'auto'>, 'routes': <@aau []>}, '802-11-wireless-security': {'auth-alg': <'open'>, 'key-mgmt': <'wpa-psk'>}, 'ipv6': {'addresses': <@a(ayuay) []>, 'dns': <@aay []>, 'method': <'auto'>, 'routes': <@a(ayuayu) []>}},)

gdbus call --system -d org.freedesktop.NetworkManager -o /org/freedesktop/NetworkManager/Settings/1 -m org.freedesktop.NetworkManager.Settings.Connection.GetSecrets 802-11-wireless-security
({'802-11-wireless-security': {'psk': <'s3kr1t'>}},)

Call for factory-reset (as user):
gdbus call --system -d com.canonical.SystemImage -o /Service -m com.canonical.SystemImage.FactoryReset
(note that system-image-cli --factory-reset needs root, it's not going through D-BUS)

Revision history for this message
Martin Pitt (pitti) wrote :

Thinking about it again, factory reset is so simple that it's not really worth the hassle of wrapping this in phablet-tools. Scripts can use the gdbus call, and users can call sudo system-image-cli or the button in system-settings. Retitling accordingly.

summary: - Add functionality to reset device to factory state with keeping network
- connections
+ Add functionality to dump/restore current wifi connection
Changed in phablet-tools (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package phablet-tools - 1.1+14.10.20140919-0ubuntu1

---------------
phablet-tools (1.1+14.10.20140919-0ubuntu1) utopic; urgency=low

  [ Martin Pitt ]
  * phablet-config: Add "network" group for saving/restoring current
    wifi connection. (LP: #1359622)

  [ Oliver Grawert ]
  * phablet-network: support network files with spaces in their filename
    (LP: #1367180), make finding the active UUID not break on non-
    english locale settings, quieten down glib noise from nmcli on the
    device (LP: #1367180)
 -- Ubuntu daily release <email address hidden> Fri, 19 Sep 2014 17:36:15 +0000

Changed in phablet-tools (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.