providers:checkbox: Added manual card switching prompt test
providers:certification-client: Update whitelists to add card switching and tests for second card
Don't use ARMv7 qemu invocation on aarch64

There's no guarantee that a given aarch64 target actually supports ARMv7
instructions, and it probably isn't what we want to be testing anyway.
Rather, we probably want to test that aarch64 guests work on an aarch64
host.
Use userspace architecture string, not kernel uname

We shouldn't assume a kernel architecture maps to a given userspace
environment. We could be running in an armhf chroot on an aarch64 kernel,
for example. This probably isn't a practical issue for the KVM tests
since we probably wouldn't be certifying such setups, but it does
let us be more explicit about arch detection (vs. relying on regex
matching).
Use built-in uname function instead of exec'ing a binary

This also fixes an issue where we had an extra end-of-line character in the
-dtb parameter.
Rearchitect qemu commandline generation for easier porting

Generation of the qemu commandline is currently done with "if arm; else"
logic. This flow will require a lot of cut & pasting to add new
architectures, and the code will become more difficult to follow.

This changeset factors out the properties that are really different about
an architecture, and changes the logic in the qemu commandline generation
to react to those flags instead of to hardcoded assumptions about a given
architecture. Example properties include the type of disk the guest
emulates (sd vs. virtio), which qemu-system binary to use, etc. This should
let us add new architectures simply by adding a new config structure and
maximizing code reuse.

There are two key parts to this refactoring - the QEMU_ARCH_CONFIG
table that declares properties of an architecture, and the new
QemuRunner class that parses this data to generate the commandline.

My goal here is no functional change. The command we run should be
the same before and after this change. I tested this on two platforms
to verify:

AMD64
-----
Before this change:

DEBUG:root:Using params:qemu-system-x86_64 -machine accel=kvm:tcg -m 256 -net nic -net user,net=10.0.0.0/8,host=10.0.0.1,hostfwd=tcp::2222-:22 -drive file=trusty-server-cloudimg-i386-disk1.img,if=virtio -drive file=seed.iso,if=virtio -display none -nographic

After this change:

DEBUG:root:Using params:qemu-system-x86_64 -m 256 -display none -nographic -net nic -net user,net=10.0.0.0/8,host=10.0.0.1,hostfwd=tcp::2222-:22 -machine accel=kvm:tcg -drive file=trusty-server-cloudimg-i386-disk1.img,if=virtio -drive file=seed.iso,if=virtio

As you can see the arguments are identical, but reordered. The test successfully
boots and passes.

ARMHF
-----
Before this change:

DEBUG:root:Using params:qemu-system-arm -machine vexpress-a15 -cpu cortex-a15 -enable-kvm -m 256 -kernel /boot/vmlinuz -append "console=ttyAMA0 earlyprintk=serial root=/dev/mmcblk0 ro rootfstype=ext4" -serial stdio -dtb /lib/firmware/3.13.0-3-exynos5/device-tree/vexpress-v2p-ca15-tc1.dtb -initrd /boot/initrd.img -net nic -net user,net=10.0.0.0/8,host=10.0.0.1,hostfwd=tcp::2222-:22 -drive file=trusty-server-cloudimg-armhf.img,if=sd,cache=writeback -drive file=seed.iso,if=sd -display none -nographic

After this change:

DEBUG:root:Using params:qemu-system-arm -m 256 -display none -nographic -net nic -net user,net=10.0.0.0/8,host=10.0.0.1,hostfwd=tcp::2222-:22 -machine vexpress-a15 -cpu cortex-a15 -enable-kvm -serial stdio -kernel /boot/vmlinuz -initrd /boot/initrd.img -dtb /lib/firmware/3.13.0-3-exynos5/device-tree/vexpress-v2p-ca15-tc1.dtb -drive file=trusty-server-cloudimg-armhf.img,if=sd,cache=writeback -drive file=seed.iso,if=sd,cache=writeback -append "console=ttyAMA0 earlyprintk=serial ro rootfstype=ext4 root=/dev/mmcblk0"

You'll notice there is one change here - the seed.iso drive now has the
extra parameter "cache=writeback". This is due to the code consolidation
for adding new disks - every disk you add now has the same parameters.
I don't know of the reason we were using different cache settings before;
I'm assuming it is unintentional and that this change is OK.

The armhf fails in the same way it did before (my last fix got it booting,
but that's not sufficient for passing the test). I'll wait to fix armhf
and add arm64 support until after this groundwork is merged.
"Rearchitect the qemu commandline generation to simplify adding additional architecture support. [r=roadmr][bug=][author=dannf]"
providers:checkbox: Remove nonexisting dependency from some after-suspend jobs

These jobs were renamed and their names are variable, so we can't
express them in another job's depends: as that doesn't support
wildcards.

The easiest workaround at this point is to remove them from the
dependencies. THe consequence is that the affected jobs (after suspend)
will run even if their before-suspend counterpart failed. This doesn't
sound too critical though, as if they fail before suspend but pass after
suspend it may warrant a closer look.
"4f8aace providers:certification-client: Update whitelists to add card switching and tests for sec
17061d0 providers:checkbox: Added manual card switching prompt test


This should complete the hybrid graphics test suite, a simple manual test prompts the user to switch to the second card (if present), and after a restart the same set of tests run on card 1 should run on card 2.

 [r=apulido][bug=][author=roadmr]"
"providers:checkbox: Remove nonexisting dependency from some after-suspend jobs.
    
    These jobs were renamed and their names are variable, so we can't
    express them in another job's depends: as that doesn't support
    wildcards.
    
    The easiest workaround at this point is to remove them from the
    dependencies. THe consequence is that the affected jobs (after suspend)
    will run even if their before-suspend counterpart failed. This doesn't
    sound too critical though, as if they fail before suspend but pass after
    suspend it may warrant a closer look.
 [r=sylvain-pineau][bug=1314383][author=roadmr]"
plainbox:abc: add ISessionStateExporter interface

This is the same interface we de-facto implement already but now with
a public interface class for easier documentation access.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:exporter: fix PEP-8 issue

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:exporter: fix PEP-8 issue

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:exporter: make SessionStateExporterBase an ISessionStateExporter

We can drop the abstract dump() method because the docstring has moved
to the interface now.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session: add SessionStorage.id

This new property serves as a simple identifier for sessions.
It is derived from the random session directory name.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session: make SessionStorage.load_checkpoint() handle missing files

Previously the load_checkpoint() method would crash if the session file
does not exist. This can be the case before a first checkpoint is created.
In such cases we should simply treat that file as empty.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session: refactor _restore_SessionState_metadata()

This patch changes the API of
SessionResumeHelper{1,2,3}_restore_SessionState_metadata() so that
the first argument is a metadata object rather than a session object.

In addition, each of the 1-2-3 format versions implementations of that
method are moved to separate mix-in class MetaDataHelper{1,2,3}MixIn.
The existing SessionResumeHelper{1,2,3} clasess are all made to inherit
from the mix in.

This effectively allows the mix-in classes to be used by another
piece of code that wants to resume the meta-data object alone, without
having to resume the whole session.

Existing tests are adjusted to pass 'session.metadata' instead
of 'session', to compensate for the change.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session: create EnvelopeUnpackMixIn

This small patch creates a mix-in class with the unpack_envelope() method
out of the initial part of SessionResumeHelper.resume() so that the
envelope unpacking code can be shared with the upcoming session peek
code.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session: add SessionPeekHelper

This small class implements a peek(data) method and can peek at the
meta-data part of a session without having to restore a full session
(or handle any consistency issues the session may experience).

The new helper is added to objects importable from plainbox.impl.session

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:exporter: make the xlsx exporter resilient to missing data

This patch changes a number of resource['foo'] to resource.get('foo') as
we cannot rely on any of the resource records to have any particular
value.

Fixes: https://bugs.launchpad.net/plainbox/+bug/1314794

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>