Merge lp:~shawn111/checkbox/image_info into lp:checkbox

Proposed by Shawn Wang
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 3798
Merged at revision: 3798
Proposed branch: lp:~shawn111/checkbox/image_info
Merge into: lp:checkbox
Diff against target: 556 lines (+453/-0)
10 files modified
providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu (+2/-0)
providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu (+2/-0)
providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist (+2/-0)
providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist (+2/-0)
providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist (+2/-0)
providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist (+2/-0)
providers/plainbox-provider-checkbox/bin/recovery_info (+389/-0)
providers/plainbox-provider-checkbox/jobs/info.txt.in (+48/-0)
providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist (+2/-0)
providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist (+2/-0)
To merge this branch: bzr merge lp:~shawn111/checkbox/image_info
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Sylvain Pineau (community) Needs Fixing
Review via email: mp+257761@code.launchpad.net

Description of the change

providers:checkbox: add jobs of recovery_info

jobs: dell_recovery_info_attachment, dell_bto_xml_attachment
put jobs into whitelists

Those information come from recovery partition.

To post a comment you must log in.
Revision history for this message
Shawn Wang (shawn111) wrote :

3732. is for buildstamp, it is related but not a new job

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

-1, please use python3. We don't accept new python2 code anymore as python2 is being removed from the Desktop images.

review: Needs Fixing
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Also, please squash fixes:

add foo
fix typo in foo
ohh more typo
pep 8 fyx to foo script
add bar

History like this is useless. Please rewrite the history (using git rebase -i) to look like this:

add foo
add bar

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

More inline comments below. Please ping me again after addressing all of the comments.

One more thing, to make it explicit: please define the version of Ubuntu that this script aims to support. This is important for things like udisks API and transition processes. Define your requirements and we'll see what to do about that.

Lastly. I'm somewhat tempted to move all of the DELL-specific stuff into a DELL provider though this can be done later.

Revision history for this message
Daniel Manrique (roadmr) wrote :

I replied to a couple of questions below and also made a suggestion on how to target this to Dell systems only. Note that the recovery_info stuff may be specific to Dell, but the buildstamp job is not, and it should be present on all OEM systems.

lp:~shawn111/checkbox/image_info updated
3741. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450052-barajas-provider-name/ by tarmac [r=zyga][bug=1450052][author=kissiel]"

3742. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450057-jobs-naming/ by tarmac [r=zyga][bug=1450057][author=kissiel]"

3743. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450048-categorise-qml-native-tests/ by tarmac [r=zyga][bug=1450048][author=kissiel]"

Revision history for this message
Shawn Wang (shawn111) wrote :

@Zyga,

I will rewrite by blkid to replace UDisks information.

lp:~shawn111/checkbox/image_info updated
3744. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450056/ by tarmac [r=zyga][bug=1450056][author=kissiel]"

3745. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/ci-systemd-compability/ by tarmac [r=zyga][bug=1450319][author=cypressyew]"

3746. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

3747. By Sylvain Pineau

"automatic merge of lp:~sylvain-pineau/checkbox/html_exporter_fixes/ by tarmac [r=sylvain-pineau][bug=][author=sylvain-pineau]"

3748. By Jeff Lane 

"automatic merge of lp:~bladernr/checkbox/revamp-network-test/ by tarmac [r=sylvain-pineau][bug=][author=bladernr]"

3749. By Sylvain Pineau

"Release_2015_Week19 [r=sylvain-pineau][bug=1331302,1341769,1347120,1382321,1383447,1387782,1387843,1388055,1388747,1389253,1399481,1400646,1403933,1406719,1410501,1428615,1451343][author=checkbox-dev]"

3750. By Sylvain Pineau

plainbox, version bump (0.22dev)

3751. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/fix-sru-cmd/ by tarmac [r=taihsiangho][bug=1450574][author=cypressyew]"

3752. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1451541-local-jobs-cdts/ by tarmac [r=sylvain-pineau][bug=1451541][author=kissiel]"

3753. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450050-naming/ by tarmac [r=zyga][bug=1450050][author=kissiel]"

3754. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450054-progress-bar/ by tarmac [r=zyga][bug=1450054][author=kissiel]"

3755. By Sylvain Pineau

"Release_2015_Week19 [r=sylvain-pineau][bug=1331302,1341769,1347120,1382321,1383447,1387782,1387843,1388055,1388747,1389253,1399481,1400646,1403933,1406719,1410501,1428615,1451343,1451541][author=checkbox-dev]"

3756. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450047-video-test-on-vivid/ by tarmac [r=zyga][bug=1450047][author=kissiel]"

3757. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450061-cbt-release-updates/ by tarmac [r=zyga][bug=1450061][author=kissiel]"

3758. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/checkbox-touch-release/ by tarmac [r=][bug=][author=kissiel]"

3759. By Daniel Manrique

"checkbox-support:parsers:submission: add modalias info to package elements
 [r=zyga][bug=][author=roadmr]"

3760. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/systemd-server/ by tarmac [r=sylvain-pineau][bug=1450319][author=cypressyew]"

3761. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1450165-autopilot-crash-on-header-actions/ by tarmac [r=zyga][bug=1450165][author=kissiel]"

3762. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1452782-report-export/ by tarmac [r=zyga][bug=1452782][author=kissiel]"

3763. By Sylvain Pineau

"Release_2015_Week19 [r=sylvain-pineau][bug=1331302,1341769,1347120,1382321,1383447,1387782,1387843,1388055,1388747,1389253,1399481,1400646,1403933,1406719,1410501,1428615,1451343,1451541][author=checkbox-dev]"

3764. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

3765. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/checkbox-touch-release/ by tarmac [r=kissiel][bug=][author=kissiel]"

3766. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/autopilot-fixes/ by tarmac [r=zyga][bug=][author=kissiel]"

3767. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1453070-print-header-name/ by tarmac [r=zyga][bug=][author=kissiel]"

3768. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/password-dialog/ by tarmac [r=zyga][bug=][author=kissiel]"

3769. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/haptics-test/ by tarmac [r=kissiel][bug=][author=zyga]"

3770. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1453067-steps-missing/ by tarmac [r=zyga][bug=1453067][author=kissiel]"

3771. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/status-fix/ by tarmac [r=zyga][bug=1453015][author=cypressyew]"

3772. By Daniel Manrique

"checkbox-support:parsers:submission: Add parsing of modprobe_attachment.

This includes the simple parser as well as the changes to
SubmissionParser and the TestRun class to actually invoke the subparser
when needed and gather the data. [r=zyga][bug=][author=roadmr]"

3773. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/fix-hibernate-test/ by tarmac [r=zyga][bug=1454524][author=cypressyew]"

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Looks really nice, just a few minor tweaks below. Please flake8 the whole file and try to add tests for the essential functions. Other than that, +1

lp:~shawn111/checkbox/image_info updated
3774. By Daniel Manrique

"checkbox-support:parsers:submission: Add parsing of kernel_cmdline_attachment.

This includes the kernel commandline parser as well as the changes to SubmissionParser and the TestRun class to actually invoke the subparser when needed and gather the data, data files and tests. [r=zyga][bug=1454577][author=roadmr]"

3775. By Daniel Manrique

"checkbox-support:parsers:submission: Add parsing of PCI subsystem ID.

This is simply obtaining the subsystem ID from the first device as output
by lspci -x (which we have in the lspci_standard_config_attachment). This is
used to uniquely identify some systems.

This includes the simple parser as well as the changes to SubmissionParser and
the TestRun class to actually invoke the subparser when needed and gather the
data.

Also includes unit tests for the parser, integration test for the
SubmissionParser with XML data file, and an entry point so the parser can be
invoked with plainbox dev parse. [r=zyga][bug=][author=roadmr]"

3776. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/generator-typo-fix/ by tarmac [r=zyga][bug=1454969][author=cypressyew]"

3777. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/fix-win32/ by tarmac [r=kissiel][bug=][author=zyga]"

3778. By Shawn Wang

"automatic merge of lp:~shawn111/checkbox/hexr-dkms/ by tarmac [r=zyga][bug=1454577][author=shawn111]"

3779. By Daniel Manrique

"providers: Fix dkms_info_attachment. Remove the device_package_info_attachment. [r=zyga][bug=1455197][author=roadmr]"

3780. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/new-pod-features/ by tarmac [r=kissiel][bug=][author=zyga]"

3781. By Sylvain Pineau

"automatic merge of lp:~sylvain-pineau/checkbox/fix-1450620/ by tarmac [r=zyga][bug=1450620][author=sylvain-pineau]"

3782. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/display-rename/ by tarmac [r=zyga][bug=1456022][author=cypressyew]"

3783. By Daniel Manrique

"automatic merge of lp:~roadmr/checkbox/dkms_info_subparser/ by tarmac [r=zyga][bug=][author=roadmr]"

3784. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/better-check-config/ by tarmac [r=sylvain-pineau][bug=][author=zyga]"

3785. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/fix-1456142/ by tarmac [r=sylvain-pineau,kissiel][bug=1456142][author=zyga]"

3786. By Sylvain Pineau

"automatic merge of lp:~sylvain-pineau/checkbox/fix-1456176/ by tarmac [r=zyga][bug=][author=sylvain-pineau]"

3787. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/xml-jinja/ by tarmac [r=zyga,sylvain-pineau][bug=][author=zyga]"

3788. By Launchpad Translations on behalf of checkbox-dev

Launchpad automatic translations update.

3789. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/add-before-s3-graphic-tests/ by tarmac [r=sylvain-pineau][bug=1456010][author=cypressyew]"

3790. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/14.04.3-testplan/ by tarmac [r=sylvain-pineau][bug=1454977][author=cypressyew]"

Revision history for this message
Shawn Wang (shawn111) wrote :

@Zyga,

I added some unittest and fix flake8 issues.
Thanks.

However, I didn't really do all the tests.
I bypassed some tests of stdout.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Hey.

There are some tools that can capture stdout for you. We have some in
plainbox and I believe there are tools like that now in python
standard library. Ping me on IRC if you want to discuss this further.
I'll check out the code later today.

On Tue, May 19, 2015 at 3:17 PM, Shawn Wang <email address hidden> wrote:
> @Zyga,
>
> I added some unittest and fix flake8 issues.
> Thanks.
>
> However, I didn't really do all the tests.
> I bypassed some tests of stdout.
> --
> https://code.launchpad.net/~shawn111/checkbox/image_info/+merge/257761
> You are reviewing the proposed merge of lp:~shawn111/checkbox/image_info into lp:checkbox.

lp:~shawn111/checkbox/image_info updated
3791. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/fix-1456560/ by tarmac [r=sylvain-pineau][bug=1456560][author=zyga]"

3792. By Daniel Manrique

"checkbox-support:parsers:submission: Adds modinfo_attachment parsing.

This includes the changes to the SubmissionParser and result class themselves, testing data file and "integration" tests, changes to the existing ModinfoParser and addition of new MultipleModinfoParser (with tests), and some PEP257 fixes to legacy code.
 [r=roadmr,zyga][bug=][author=roadmr]"

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Could you please also add the two new jobs to the following testplan units:

plainbox-provider-certification-client/units/client-cert-14-04-3.pxu
plainbox-provider-certification-client/units/client-cert-14-04.pxu

+1 minor inline typo

review: Needs Fixing
lp:~shawn111/checkbox/image_info updated
3793. By Po-Hsu Lin

"automatic merge of lp:~cypressyew/checkbox/add-tb-monitor-generator/ by tarmac [r=sylvain-pineau][bug=1456462][author=cypressyew]"

3794. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/fix-1455033-sensors-on-desktop/ by tarmac [r=zyga][bug=1455033][author=kissiel]"

3795. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/html-template-refresh/ by tarmac [r=sylvain-pineau][bug=][author=zyga]"

3796. By Sylvain Pineau

providers:certification-client: Fix a typo in the 14.04.3 testplan

audio/genereator_.* -> audio/generator_.*

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Hey

Have a look below:

- the root handling has to be fixed before landing this
- misc easy stuff as well (should take a second)

Testing:
 - please write tests for the blkid parser
 - collect blkid output from several systems, see if you're missing anything

Thanks

review: Needs Fixing
lp:~shawn111/checkbox/image_info updated
3797. By Shawn Wang

providers:checkbox: add recovery_info to provide image info

recovery_info is a guacamole Command.
use blkid to list partition information
provide
1. Show recovery version.
2. Check recovery type.
3. Print out the file in recovery partition

3798. By Shawn Wang

providers: Added the recovery_info_attachment to whitelists

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

There are a few minor things but I'll sort them out with a post-merge proposal

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu'
--- providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu 2015-05-20 06:58:13 +0000
+++ providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu 2015-05-20 10:15:25 +0000
@@ -418,6 +418,8 @@
418 sysctl_attachment418 sysctl_attachment
419 sysfs_attachment419 sysfs_attachment
420 udev_attachment420 udev_attachment
421 recovery_info_attachment
422 dell_bto_xml_attachment
421 lsmod_attachment423 lsmod_attachment
422 dkms_info_attachment424 dkms_info_attachment
423 acpi_sleep_attachment425 acpi_sleep_attachment
424426
=== modified file 'providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu'
--- providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu 2015-05-18 10:56:27 +0000
+++ providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu 2015-05-20 10:15:25 +0000
@@ -402,6 +402,8 @@
402 sysctl_attachment402 sysctl_attachment
403 sysfs_attachment403 sysfs_attachment
404 udev_attachment404 udev_attachment
405 recovery_info_attachment
406 dell_bto_xml_attachment
405 lsmod_attachment407 lsmod_attachment
406 acpi_sleep_attachment408 acpi_sleep_attachment
407 info/hdparm409 info/hdparm
408410
=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist'
--- providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist 2015-05-14 19:32:33 +0000
+++ providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist 2015-05-20 10:15:25 +0000
@@ -129,6 +129,8 @@
129sysctl_attachment129sysctl_attachment
130sysfs_attachment130sysfs_attachment
131udev_attachment131udev_attachment
132recovery_info_attachment
133dell_bto_xml_attachment
132lsmod_attachment134lsmod_attachment
133dkms_info_attachment135dkms_info_attachment
134acpi_sleep_attachment136acpi_sleep_attachment
135137
=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist'
--- providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist 2015-05-18 10:56:27 +0000
+++ providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist 2015-05-20 10:15:25 +0000
@@ -419,6 +419,8 @@
419sysctl_attachment419sysctl_attachment
420sysfs_attachment420sysfs_attachment
421udev_attachment421udev_attachment
422recovery_info_attachment
423dell_bto_xml_attachment
422lsmod_attachment424lsmod_attachment
423dkms_info_attachment425dkms_info_attachment
424acpi_sleep_attachment426acpi_sleep_attachment
425427
=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist'
--- providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist 2015-05-18 06:25:15 +0000
+++ providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist 2015-05-20 10:15:25 +0000
@@ -359,6 +359,8 @@
359sysctl_attachment359sysctl_attachment
360sysfs_attachment360sysfs_attachment
361udev_attachment361udev_attachment
362recovery_info_attachment
363dell_bto_xml_attachment
362lsmod_attachment364lsmod_attachment
363dkms_info_attachment365dkms_info_attachment
364acpi_sleep_attachment366acpi_sleep_attachment
365367
=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist'
--- providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist 2015-05-18 06:25:15 +0000
+++ providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist 2015-05-20 10:15:25 +0000
@@ -359,6 +359,8 @@
359sysctl_attachment359sysctl_attachment
360sysfs_attachment360sysfs_attachment
361udev_attachment361udev_attachment
362recovery_info_attachment
363dell_bto_xml_attachment
362lsmod_attachment364lsmod_attachment
363dkms_info_attachment365dkms_info_attachment
364acpi_sleep_attachment366acpi_sleep_attachment
365367
=== added file 'providers/plainbox-provider-checkbox/bin/recovery_info'
--- providers/plainbox-provider-checkbox/bin/recovery_info 1970-01-01 00:00:00 +0000
+++ providers/plainbox-provider-checkbox/bin/recovery_info 2015-05-20 10:15:25 +0000
@@ -0,0 +1,389 @@
1#!/usr/bin/env python3
2# Copyright 2015 Canonical Ltd.
3# Written by:
4# Shawn Wang <shawn.wang@canonical.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18"""Show the recovery partition information for the preinstalled OS."""
19
20import os
21import subprocess
22import sys
23import tempfile
24import unittest
25import xml.dom.minidom as minidom
26
27from guacamole import Command
28
29try:
30 from unittest import mock
31except ImportError:
32 from plainbox.vendor import mock
33
34RECOVERY_LABELS = {"HP_TOOLS": "HP",
35 "PQSERVICE": "UBUNTU",
36 "BACKUP": "TEST",
37 "INSTALL": "DELL",
38 "OS": "DELL",
39 "RECOVERY": "DELL"}
40
41RECOVERY_PACKAGES = ["dell-recovery", "ubuntu-recovery", "zip"]
42
43
44class MountedPartition(object):
45
46 """
47 Mount Manager to mount partition on tempdir.
48
49 e.g.
50 with MountedPartition("/dev/sda1") as tmp:
51 print("This is the mount point: {}".format(tmp))
52 do_stuff()
53 """
54
55 def __init__(self, part):
56 """
57 Prepare the mntdir point.
58
59 :param part: string of the partition device file, like /dev/sda2
60 """
61 self.part = part
62 self.mntdir = tempfile.mkdtemp()
63
64 def __enter__(self):
65 """
66 __enter__ method for python's with statement.
67
68 Mount the partition device to the mntdir.
69 """
70 cmd = ["mount", self.part, self.mntdir]
71 subprocess.check_output(cmd, universal_newlines=True)
72 return self.mntdir
73
74 def __exit__(self, type, value, traceback):
75 """
76 __exit__ method for python's with statement.
77
78 Unmount and remove the mntdir.
79 """
80 subprocess.check_output(["umount", self.mntdir],
81 universal_newlines=True)
82 os.rmdir(self.mntdir)
83
84
85class MountedPartitionTests(unittest.TestCase):
86
87 """Unittest of MountedPartition."""
88
89 @mock.patch('subprocess.check_output')
90 def test_with_of_MountedPartition(self, mock_subprocess_check_output):
91 """Test mount point."""
92 test_dir = ""
93 with MountedPartition("/dev/test") as tmp:
94 test_dir = tmp
95 self.assertTrue(os.path.exists(test_dir))
96 mock_subprocess_check_output.assert_has_calls(
97 [mock.call(['mount', '/dev/test', test_dir],
98 universal_newlines=True)])
99 self.assertFalse(os.path.exists(test_dir))
100 mock_subprocess_check_output.assert_has_calls(
101 [mock.call(['umount', test_dir],
102 universal_newlines=True)])
103
104
105class RecoveryVersion(Command):
106
107 """
108 subcommand of RecoveryInfo.
109
110 print out the version information.
111
112 image_version: xxx
113 bto_version: REV_xxx.iso (dell only)
114 """
115
116 def invoked(self, ctx):
117 """
118 Guacamole method called when the command is invoked.
119
120 /etc/buildstamp is a image information file,
121 it created by the oem image builder.
122
123 oilpalm Fri, 20 Jun 2014 04:02:07 +0000
124 somerville-trusty-amd64-20140620-0
125
126 If /etc/buildstamp exist, print out the second line (image iso name).
127
128 For Dell-recovery partition, /etc/buildstamp shows base image info.
129 If recovery_partition/bto.xml,
130 print out the bto_version (read from xml file).
131 """
132 if os.path.isfile("/etc/buildstamp"):
133 with open('/etc/buildstamp', 'rt', encoding='UTF-8') as stream:
134 data = stream.readlines()
135 print("image_version: {}".format(data[1].strip()))
136
137 with MountedPartition(ctx.recovery_partition) as mntdir:
138 fname = "{}/bto.xml".format(mntdir)
139 if os.path.isfile(fname):
140 o = minidom.parse("{}/bto.xml".format(mntdir))
141 bto_version = o.getElementsByTagName("iso")[0].firstChild.data
142 print("bto_version: {}".format(bto_version))
143
144
145class RecoveryFile(Command):
146
147 """
148 subcommand of RecoveryInfo.
149
150 print out the file in recovery partition.
151 """
152
153 def register_arguments(self, parser):
154 """
155 Guacamole method used by the argparse ingredient.
156
157 :param parser:
158 Argument parser (from :mod:`argparse`) specific to this command.
159 """
160 parser.add_argument('file', help='File name of print out the content')
161
162 def invoked(self, ctx):
163 """
164 Guacamole method used by the command ingredient.
165
166 :param ctx:
167 The guacamole context object. Context provides access to all
168 features of guacamole. The argparse ingredient adds the ``args``
169 attribute to it. That attribute contains the result of parsing
170 command line arguments.
171 :returns:
172 The return code of the command. Guacamole translates ``None`` to a
173 successful exit status (return code zero).
174 """
175 if ctx.args.file is None:
176 return 1
177 with MountedPartition(ctx.recovery_partition) as mntdir:
178 fname = "{}/{}".format(mntdir, ctx.args.file)
179 try:
180 with open(fname, 'rt', encoding='UTF-8') as f:
181 print(f.read())
182 except Exception as e:
183 sys.stderr.write(
184 "File({}) is not found, {}\n".format(ctx.args.file, e.msg))
185 return 1
186
187
188class RecoveryCheckType(Command):
189
190 """
191 subcommand of RecoveryInfo.
192
193 Check the recovery type if not matched return 1
194 """
195
196 def register_arguments(self, parser):
197 """
198 Guacamole method used by the argparse ingredient.
199
200 :param parser:
201 Argument parser (from :mod:`argparse`) specific to this command.
202 """
203 parser.add_argument('type',
204 help="""\
205Check current recovery type, like DELL.
206If current recovery type is DELL, return value is 0.
207If current recovery type is not DELL, return value is 1.
208""")
209
210 def invoked(self, ctx):
211 """
212 Guacamole method used by the command ingredient.
213
214 :param ctx:
215 The guacamole context object. Context provides access to all
216 features of guacamole. The argparse ingredient adds the ``args``
217 attribute to it. That attribute contains the result of parsing
218 command line arguments.
219 :returns:
220 The return code of the command. Guacamole translates ``None`` to a
221 successful exit status (return code zero).
222 """
223 if ctx.recovery_type != ctx.args.type.upper():
224 sys.stderr.write(
225 "{} and {}".format(ctx.recovery_type,
226 ctx.args.type.upper()))
227 sys.stderr.write(ctx.args.type.upper())
228 return 1
229
230
231class RecoveryInfo(Command):
232
233 """
234 RecoveryInfo command.
235
236 If system is not a preinstalled OS, the command return 1.
237 """
238
239 sub_commands = (
240 ('version', RecoveryVersion),
241 ('file', RecoveryFile),
242 ('checktype', RecoveryCheckType),
243 )
244
245 @staticmethod
246 def get_recovery_package():
247 """
248 Test with RECOVERY_PACKAGES.
249
250 to check recovery application is installed or not
251
252 :return:
253 string of package_version or None
254 """
255 for pkg in RECOVERY_PACKAGES:
256 output = subprocess.check_output(["apt-cache", "policy", pkg],
257 universal_newlines=True)
258 for line in output.split("\n"):
259 if line.startswith(" Installed:"):
260 ver = line.split(": ")[1]
261 return "{}_{}".format(pkg, ver.strip())
262 return None
263
264 @staticmethod
265 def get_recovery_partition():
266 """
267 Look for the recovery partition.
268
269 1. Check recovery package is installed or not.
270 2. Use blkid to get partition tables
271 3. Recovery partition type is ntfs or vfat
272 4. RECOVERY_LABELS to see if any partition match
273
274 :return:
275 (recovery_type, recovery_partition) or None
276 """
277 if RecoveryInfo.get_recovery_package() is None:
278 return None
279
280 output = subprocess.check_output(["blkid"], universal_newlines=True)
281 data = output.strip()
282
283 if data == "":
284 raise OSError("Please run by root. "
285 "Although blkid can runs without root, "
286 "it only works after root runs blkid.")
287
288 for section in data.split("\n"):
289 blk = {}
290 blk['dev'], line = section.split(': ')
291 line = line.strip() + " "
292
293 for part in line.split('" '):
294 item = part.split("=\"")
295 if item[0] == 'LABEL':
296 blk['label'] = item[1].upper()
297 if item[0] == 'TYPE':
298 blk['fs'] = item[1]
299 if 'label' not in blk:
300 continue
301
302 if not (blk['fs'] == "vfat" or
303 blk['fs'] == "ntfs"):
304 continue
305 for label in RECOVERY_LABELS:
306 if blk['label'] == label:
307 return (RECOVERY_LABELS[label], blk['dev'])
308 return None
309
310 def invoked(self, ctx):
311 """
312 Guacamole method used by the command ingredient.
313
314 :param ctx:
315 The guacamole context object. Context provides access to all
316 features of guacamole. The argparse ingredient adds the ``args``
317 attribute to it. That attribute contains the result of parsing
318 command line arguments.
319 :returns:
320 The return code of the command. Guacamole translates ``None`` to a
321 successful exit status (return code zero).
322 """
323 partition = RecoveryInfo.get_recovery_partition()
324
325 if partition is None:
326 sys.stderr.write("Recovery partition not found\n")
327 return 1
328
329 (recovery_type, recovery_partition) = partition
330 ctx.recovery_partition = recovery_partition
331 ctx.recovery_type = recovery_type
332
333
334class RecoveryInfoGuacamoleCommendTests(unittest.TestCase):
335
336 """Unittest of RecoveryInfo."""
337
338 @mock.patch('subprocess.check_output')
339 def testRecoveryInfo_get_recovery_package(self,
340 mock_subprocess_check_output):
341 """Unittest of RecoveryInfo.get_recovery_package()."""
342 mock_subprocess_check_output.return_value = """\
343dell-recovery:
344 Installed: 1.11
345 Candidate: 1.11
346 Version table:
347 1.11
348 500 https://archive/cesg-mirror/ test/public amd64 Packages
349"""
350 self.assertEqual(RecoveryInfo.get_recovery_package(),
351 "dell-recovery_1.11")
352
353 @mock.patch('__main__.RecoveryInfo.get_recovery_package')
354 @mock.patch('subprocess.check_output')
355 def testRecoveryInfo_get_recovery_partition(self,
356 mock_subprocess_check_output,
357 mock_get_recovery_package):
358 """Unittest of RecoveryInfo.get_recovery_partition()."""
359 mock_get_recovery_package.return_value = "dell-recovery_1.11"
360 mock_subprocess_check_output.return_value = """\
361/dev/sda1: LABEL="Test" UUID="xxxxx" TYPE="vfat" PARTUUID="00070b83-01"
362/dev/sda2: UUID="xxxxx" TYPE="vfat" PARTUUID="00070b83-02"
363/dev/sda3: LABEL="Recovery" UUID="xxxxx" TYPE="vfat" PARTUUID="00070b83-06"
364"""
365 self.assertEqual(RecoveryInfo.get_recovery_partition(),
366 ("DELL", "/dev/sda3"))
367
368 @mock.patch('__main__.RecoveryInfo.get_recovery_package')
369 @mock.patch('__main__.RecoveryInfo.get_recovery_partition')
370 def testRecoveryInfo_guacamole(self,
371 mock_get_recovery_partition,
372 mock_get_recovery_package):
373 """Unittest of command with argv."""
374 mock_get_recovery_partition.return_value = ("DELL", "/dev/sda3")
375 mock_get_recovery_package.return_value = "dell-recovery_1.11"
376
377 self.assertEqual(RecoveryInfo().main(argv=None, exit=False), 0)
378 self.assertEqual(
379 RecoveryInfo().main(argv=["checktype", "HP"], exit=False), 1)
380 self.assertEqual(
381 RecoveryInfo().main(argv=["checktype", "DELL"], exit=False), 0)
382
383
384if __name__ == '__main__':
385 if '--test' in sys.argv:
386 sys.argv.remove('--test')
387 unittest.main()
388 else:
389 RecoveryInfo().main()
0390
=== modified file 'providers/plainbox-provider-checkbox/jobs/info.txt.in'
--- providers/plainbox-provider-checkbox/jobs/info.txt.in 2015-05-14 19:32:33 +0000
+++ providers/plainbox-provider-checkbox/jobs/info.txt.in 2015-05-20 10:15:25 +0000
@@ -276,6 +276,54 @@
276_summary: Attach /etc/buildstamp276_summary: Attach /etc/buildstamp
277command: [ -s /etc/buildstamp ] && cat /etc/buildstamp277command: [ -s /etc/buildstamp ] && cat /etc/buildstamp
278278
279plugin: shell
280id: info/detect_recovery
281requires: package.name == 'dell-recovery' or package.name == 'ubuntu-recovery'
282user: root
283estimated_duration: 0.2
284_summary: Check existence of recovery partition
285_description: Check existence of recovery partition
286command: recovery_info --check-recovery-partition
287
288plugin: shell
289id: info/detect_dell_recovery
290depends: info/detect_recovery
291requires: package.name == 'dell-recovery'
292user: root
293estimated_duration: 0.2
294_summary: Check the recovery type is dell or not
295_description: Check the recovery type is dell or not
296command: recovery_info --check-recovery-type DELL
297
298plugin: attachment
299id: recovery_info_attachment
300depends: info/detect_recovery
301requires: package.name == 'dell-recovery' or package.name == 'ubuntu-recovery'
302user: root
303estimated_duration: 0.2
304_summary: Attach the recovery partition versions
305_description:
306 Attach the recovery partition version
307 image_version is the preinstalled OS image version
308 bto_version is only for dell_recovery
309 Example:
310 image_version: somerville-trusty-amd64-20140620-0
311 bto_version: A00_dell-bto-trusty-houston-15-A11-iso-20141203-0.iso
312command: recovery_info --show-version
313
314plugin: attachment
315id: dell_bto_xml_attachment
316depends: info/detect_dell_recovery
317requires: package.name == 'dell-recovery'
318estimated_duration: 0.5
319_summary: Attach the bto.xml in Dell recovery partition
320_description:
321 bto.xml is basically a Fish manifest
322 The information include:
323 - fish packages
324 - dell recovery stage 2 boot log
325command: recovery_info --readfile bto.xml
326
279plugin: attachment327plugin: attachment
280id: info/kvm_output328id: info/kvm_output
281estimated_duration: 0.1329estimated_duration: 0.1
282330
=== modified file 'providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist'
--- providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist 2015-05-14 19:32:33 +0000
+++ providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist 2015-05-20 10:15:25 +0000
@@ -25,6 +25,8 @@
25sysctl_attachment25sysctl_attachment
26sysfs_attachment26sysfs_attachment
27udev_attachment27udev_attachment
28recovery_info_attachment
29dell_bto_xml_attachment
28lsmod_attachment30lsmod_attachment
29dkms_info_attachment31dkms_info_attachment
30#Automated Test-verification Jobs32#Automated Test-verification Jobs
3133
=== modified file 'providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist'
--- providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist 2015-05-14 19:32:33 +0000
+++ providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist 2015-05-20 10:15:25 +0000
@@ -16,6 +16,8 @@
16dmi_attachment16dmi_attachment
17dmidecode_attachment17dmidecode_attachment
18kernel_cmdline_attachment18kernel_cmdline_attachment
19recovery_info_attachment
20dell_bto_xml_attachment
19lsmod_attachment21lsmod_attachment
20dkms_info_attachment22dkms_info_attachment
21lspci_attachment23lspci_attachment

Subscribers

People subscribed via source and target branches