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
1=== modified file 'providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu'
2--- providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu 2015-05-20 06:58:13 +0000
3+++ providers/plainbox-provider-certification-client/units/client-cert-14-04-3.pxu 2015-05-20 10:15:25 +0000
4@@ -418,6 +418,8 @@
5 sysctl_attachment
6 sysfs_attachment
7 udev_attachment
8+ recovery_info_attachment
9+ dell_bto_xml_attachment
10 lsmod_attachment
11 dkms_info_attachment
12 acpi_sleep_attachment
13
14=== modified file 'providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu'
15--- providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu 2015-05-18 10:56:27 +0000
16+++ providers/plainbox-provider-certification-client/units/client-cert-14-04.pxu 2015-05-20 10:15:25 +0000
17@@ -402,6 +402,8 @@
18 sysctl_attachment
19 sysfs_attachment
20 udev_attachment
21+ recovery_info_attachment
22+ dell_bto_xml_attachment
23 lsmod_attachment
24 acpi_sleep_attachment
25 info/hdparm
26
27=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist'
28--- providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist 2015-05-14 19:32:33 +0000
29+++ providers/plainbox-provider-certification-client/whitelists/client-cert-regression.whitelist 2015-05-20 10:15:25 +0000
30@@ -129,6 +129,8 @@
31 sysctl_attachment
32 sysfs_attachment
33 udev_attachment
34+recovery_info_attachment
35+dell_bto_xml_attachment
36 lsmod_attachment
37 dkms_info_attachment
38 acpi_sleep_attachment
39
40=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist'
41--- providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist 2015-05-18 10:56:27 +0000
42+++ providers/plainbox-provider-certification-client/whitelists/client-cert.whitelist 2015-05-20 10:15:25 +0000
43@@ -419,6 +419,8 @@
44 sysctl_attachment
45 sysfs_attachment
46 udev_attachment
47+recovery_info_attachment
48+dell_bto_xml_attachment
49 lsmod_attachment
50 dkms_info_attachment
51 acpi_sleep_attachment
52
53=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist'
54--- providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist 2015-05-18 06:25:15 +0000
55+++ providers/plainbox-provider-certification-client/whitelists/client-selftest-14-04.whitelist 2015-05-20 10:15:25 +0000
56@@ -359,6 +359,8 @@
57 sysctl_attachment
58 sysfs_attachment
59 udev_attachment
60+recovery_info_attachment
61+dell_bto_xml_attachment
62 lsmod_attachment
63 dkms_info_attachment
64 acpi_sleep_attachment
65
66=== modified file 'providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist'
67--- providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist 2015-05-18 06:25:15 +0000
68+++ providers/plainbox-provider-certification-client/whitelists/client-selftest.whitelist 2015-05-20 10:15:25 +0000
69@@ -359,6 +359,8 @@
70 sysctl_attachment
71 sysfs_attachment
72 udev_attachment
73+recovery_info_attachment
74+dell_bto_xml_attachment
75 lsmod_attachment
76 dkms_info_attachment
77 acpi_sleep_attachment
78
79=== added file 'providers/plainbox-provider-checkbox/bin/recovery_info'
80--- providers/plainbox-provider-checkbox/bin/recovery_info 1970-01-01 00:00:00 +0000
81+++ providers/plainbox-provider-checkbox/bin/recovery_info 2015-05-20 10:15:25 +0000
82@@ -0,0 +1,389 @@
83+#!/usr/bin/env python3
84+# Copyright 2015 Canonical Ltd.
85+# Written by:
86+# Shawn Wang <shawn.wang@canonical.com>
87+#
88+# This program is free software: you can redistribute it and/or modify
89+# it under the terms of the GNU General Public License version 3,
90+# as published by the Free Software Foundation.
91+#
92+# This program is distributed in the hope that it will be useful,
93+# but WITHOUT ANY WARRANTY; without even the implied warranty of
94+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95+# GNU General Public License for more details.
96+#
97+# You should have received a copy of the GNU General Public License
98+# along with this program. If not, see <http://www.gnu.org/licenses/>.
99+
100+"""Show the recovery partition information for the preinstalled OS."""
101+
102+import os
103+import subprocess
104+import sys
105+import tempfile
106+import unittest
107+import xml.dom.minidom as minidom
108+
109+from guacamole import Command
110+
111+try:
112+ from unittest import mock
113+except ImportError:
114+ from plainbox.vendor import mock
115+
116+RECOVERY_LABELS = {"HP_TOOLS": "HP",
117+ "PQSERVICE": "UBUNTU",
118+ "BACKUP": "TEST",
119+ "INSTALL": "DELL",
120+ "OS": "DELL",
121+ "RECOVERY": "DELL"}
122+
123+RECOVERY_PACKAGES = ["dell-recovery", "ubuntu-recovery", "zip"]
124+
125+
126+class MountedPartition(object):
127+
128+ """
129+ Mount Manager to mount partition on tempdir.
130+
131+ e.g.
132+ with MountedPartition("/dev/sda1") as tmp:
133+ print("This is the mount point: {}".format(tmp))
134+ do_stuff()
135+ """
136+
137+ def __init__(self, part):
138+ """
139+ Prepare the mntdir point.
140+
141+ :param part: string of the partition device file, like /dev/sda2
142+ """
143+ self.part = part
144+ self.mntdir = tempfile.mkdtemp()
145+
146+ def __enter__(self):
147+ """
148+ __enter__ method for python's with statement.
149+
150+ Mount the partition device to the mntdir.
151+ """
152+ cmd = ["mount", self.part, self.mntdir]
153+ subprocess.check_output(cmd, universal_newlines=True)
154+ return self.mntdir
155+
156+ def __exit__(self, type, value, traceback):
157+ """
158+ __exit__ method for python's with statement.
159+
160+ Unmount and remove the mntdir.
161+ """
162+ subprocess.check_output(["umount", self.mntdir],
163+ universal_newlines=True)
164+ os.rmdir(self.mntdir)
165+
166+
167+class MountedPartitionTests(unittest.TestCase):
168+
169+ """Unittest of MountedPartition."""
170+
171+ @mock.patch('subprocess.check_output')
172+ def test_with_of_MountedPartition(self, mock_subprocess_check_output):
173+ """Test mount point."""
174+ test_dir = ""
175+ with MountedPartition("/dev/test") as tmp:
176+ test_dir = tmp
177+ self.assertTrue(os.path.exists(test_dir))
178+ mock_subprocess_check_output.assert_has_calls(
179+ [mock.call(['mount', '/dev/test', test_dir],
180+ universal_newlines=True)])
181+ self.assertFalse(os.path.exists(test_dir))
182+ mock_subprocess_check_output.assert_has_calls(
183+ [mock.call(['umount', test_dir],
184+ universal_newlines=True)])
185+
186+
187+class RecoveryVersion(Command):
188+
189+ """
190+ subcommand of RecoveryInfo.
191+
192+ print out the version information.
193+
194+ image_version: xxx
195+ bto_version: REV_xxx.iso (dell only)
196+ """
197+
198+ def invoked(self, ctx):
199+ """
200+ Guacamole method called when the command is invoked.
201+
202+ /etc/buildstamp is a image information file,
203+ it created by the oem image builder.
204+
205+ oilpalm Fri, 20 Jun 2014 04:02:07 +0000
206+ somerville-trusty-amd64-20140620-0
207+
208+ If /etc/buildstamp exist, print out the second line (image iso name).
209+
210+ For Dell-recovery partition, /etc/buildstamp shows base image info.
211+ If recovery_partition/bto.xml,
212+ print out the bto_version (read from xml file).
213+ """
214+ if os.path.isfile("/etc/buildstamp"):
215+ with open('/etc/buildstamp', 'rt', encoding='UTF-8') as stream:
216+ data = stream.readlines()
217+ print("image_version: {}".format(data[1].strip()))
218+
219+ with MountedPartition(ctx.recovery_partition) as mntdir:
220+ fname = "{}/bto.xml".format(mntdir)
221+ if os.path.isfile(fname):
222+ o = minidom.parse("{}/bto.xml".format(mntdir))
223+ bto_version = o.getElementsByTagName("iso")[0].firstChild.data
224+ print("bto_version: {}".format(bto_version))
225+
226+
227+class RecoveryFile(Command):
228+
229+ """
230+ subcommand of RecoveryInfo.
231+
232+ print out the file in recovery partition.
233+ """
234+
235+ def register_arguments(self, parser):
236+ """
237+ Guacamole method used by the argparse ingredient.
238+
239+ :param parser:
240+ Argument parser (from :mod:`argparse`) specific to this command.
241+ """
242+ parser.add_argument('file', help='File name of print out the content')
243+
244+ def invoked(self, ctx):
245+ """
246+ Guacamole method used by the command ingredient.
247+
248+ :param ctx:
249+ The guacamole context object. Context provides access to all
250+ features of guacamole. The argparse ingredient adds the ``args``
251+ attribute to it. That attribute contains the result of parsing
252+ command line arguments.
253+ :returns:
254+ The return code of the command. Guacamole translates ``None`` to a
255+ successful exit status (return code zero).
256+ """
257+ if ctx.args.file is None:
258+ return 1
259+ with MountedPartition(ctx.recovery_partition) as mntdir:
260+ fname = "{}/{}".format(mntdir, ctx.args.file)
261+ try:
262+ with open(fname, 'rt', encoding='UTF-8') as f:
263+ print(f.read())
264+ except Exception as e:
265+ sys.stderr.write(
266+ "File({}) is not found, {}\n".format(ctx.args.file, e.msg))
267+ return 1
268+
269+
270+class RecoveryCheckType(Command):
271+
272+ """
273+ subcommand of RecoveryInfo.
274+
275+ Check the recovery type if not matched return 1
276+ """
277+
278+ def register_arguments(self, parser):
279+ """
280+ Guacamole method used by the argparse ingredient.
281+
282+ :param parser:
283+ Argument parser (from :mod:`argparse`) specific to this command.
284+ """
285+ parser.add_argument('type',
286+ help="""\
287+Check current recovery type, like DELL.
288+If current recovery type is DELL, return value is 0.
289+If current recovery type is not DELL, return value is 1.
290+""")
291+
292+ def invoked(self, ctx):
293+ """
294+ Guacamole method used by the command ingredient.
295+
296+ :param ctx:
297+ The guacamole context object. Context provides access to all
298+ features of guacamole. The argparse ingredient adds the ``args``
299+ attribute to it. That attribute contains the result of parsing
300+ command line arguments.
301+ :returns:
302+ The return code of the command. Guacamole translates ``None`` to a
303+ successful exit status (return code zero).
304+ """
305+ if ctx.recovery_type != ctx.args.type.upper():
306+ sys.stderr.write(
307+ "{} and {}".format(ctx.recovery_type,
308+ ctx.args.type.upper()))
309+ sys.stderr.write(ctx.args.type.upper())
310+ return 1
311+
312+
313+class RecoveryInfo(Command):
314+
315+ """
316+ RecoveryInfo command.
317+
318+ If system is not a preinstalled OS, the command return 1.
319+ """
320+
321+ sub_commands = (
322+ ('version', RecoveryVersion),
323+ ('file', RecoveryFile),
324+ ('checktype', RecoveryCheckType),
325+ )
326+
327+ @staticmethod
328+ def get_recovery_package():
329+ """
330+ Test with RECOVERY_PACKAGES.
331+
332+ to check recovery application is installed or not
333+
334+ :return:
335+ string of package_version or None
336+ """
337+ for pkg in RECOVERY_PACKAGES:
338+ output = subprocess.check_output(["apt-cache", "policy", pkg],
339+ universal_newlines=True)
340+ for line in output.split("\n"):
341+ if line.startswith(" Installed:"):
342+ ver = line.split(": ")[1]
343+ return "{}_{}".format(pkg, ver.strip())
344+ return None
345+
346+ @staticmethod
347+ def get_recovery_partition():
348+ """
349+ Look for the recovery partition.
350+
351+ 1. Check recovery package is installed or not.
352+ 2. Use blkid to get partition tables
353+ 3. Recovery partition type is ntfs or vfat
354+ 4. RECOVERY_LABELS to see if any partition match
355+
356+ :return:
357+ (recovery_type, recovery_partition) or None
358+ """
359+ if RecoveryInfo.get_recovery_package() is None:
360+ return None
361+
362+ output = subprocess.check_output(["blkid"], universal_newlines=True)
363+ data = output.strip()
364+
365+ if data == "":
366+ raise OSError("Please run by root. "
367+ "Although blkid can runs without root, "
368+ "it only works after root runs blkid.")
369+
370+ for section in data.split("\n"):
371+ blk = {}
372+ blk['dev'], line = section.split(': ')
373+ line = line.strip() + " "
374+
375+ for part in line.split('" '):
376+ item = part.split("=\"")
377+ if item[0] == 'LABEL':
378+ blk['label'] = item[1].upper()
379+ if item[0] == 'TYPE':
380+ blk['fs'] = item[1]
381+ if 'label' not in blk:
382+ continue
383+
384+ if not (blk['fs'] == "vfat" or
385+ blk['fs'] == "ntfs"):
386+ continue
387+ for label in RECOVERY_LABELS:
388+ if blk['label'] == label:
389+ return (RECOVERY_LABELS[label], blk['dev'])
390+ return None
391+
392+ def invoked(self, ctx):
393+ """
394+ Guacamole method used by the command ingredient.
395+
396+ :param ctx:
397+ The guacamole context object. Context provides access to all
398+ features of guacamole. The argparse ingredient adds the ``args``
399+ attribute to it. That attribute contains the result of parsing
400+ command line arguments.
401+ :returns:
402+ The return code of the command. Guacamole translates ``None`` to a
403+ successful exit status (return code zero).
404+ """
405+ partition = RecoveryInfo.get_recovery_partition()
406+
407+ if partition is None:
408+ sys.stderr.write("Recovery partition not found\n")
409+ return 1
410+
411+ (recovery_type, recovery_partition) = partition
412+ ctx.recovery_partition = recovery_partition
413+ ctx.recovery_type = recovery_type
414+
415+
416+class RecoveryInfoGuacamoleCommendTests(unittest.TestCase):
417+
418+ """Unittest of RecoveryInfo."""
419+
420+ @mock.patch('subprocess.check_output')
421+ def testRecoveryInfo_get_recovery_package(self,
422+ mock_subprocess_check_output):
423+ """Unittest of RecoveryInfo.get_recovery_package()."""
424+ mock_subprocess_check_output.return_value = """\
425+dell-recovery:
426+ Installed: 1.11
427+ Candidate: 1.11
428+ Version table:
429+ 1.11
430+ 500 https://archive/cesg-mirror/ test/public amd64 Packages
431+"""
432+ self.assertEqual(RecoveryInfo.get_recovery_package(),
433+ "dell-recovery_1.11")
434+
435+ @mock.patch('__main__.RecoveryInfo.get_recovery_package')
436+ @mock.patch('subprocess.check_output')
437+ def testRecoveryInfo_get_recovery_partition(self,
438+ mock_subprocess_check_output,
439+ mock_get_recovery_package):
440+ """Unittest of RecoveryInfo.get_recovery_partition()."""
441+ mock_get_recovery_package.return_value = "dell-recovery_1.11"
442+ mock_subprocess_check_output.return_value = """\
443+/dev/sda1: LABEL="Test" UUID="xxxxx" TYPE="vfat" PARTUUID="00070b83-01"
444+/dev/sda2: UUID="xxxxx" TYPE="vfat" PARTUUID="00070b83-02"
445+/dev/sda3: LABEL="Recovery" UUID="xxxxx" TYPE="vfat" PARTUUID="00070b83-06"
446+"""
447+ self.assertEqual(RecoveryInfo.get_recovery_partition(),
448+ ("DELL", "/dev/sda3"))
449+
450+ @mock.patch('__main__.RecoveryInfo.get_recovery_package')
451+ @mock.patch('__main__.RecoveryInfo.get_recovery_partition')
452+ def testRecoveryInfo_guacamole(self,
453+ mock_get_recovery_partition,
454+ mock_get_recovery_package):
455+ """Unittest of command with argv."""
456+ mock_get_recovery_partition.return_value = ("DELL", "/dev/sda3")
457+ mock_get_recovery_package.return_value = "dell-recovery_1.11"
458+
459+ self.assertEqual(RecoveryInfo().main(argv=None, exit=False), 0)
460+ self.assertEqual(
461+ RecoveryInfo().main(argv=["checktype", "HP"], exit=False), 1)
462+ self.assertEqual(
463+ RecoveryInfo().main(argv=["checktype", "DELL"], exit=False), 0)
464+
465+
466+if __name__ == '__main__':
467+ if '--test' in sys.argv:
468+ sys.argv.remove('--test')
469+ unittest.main()
470+ else:
471+ RecoveryInfo().main()
472
473=== modified file 'providers/plainbox-provider-checkbox/jobs/info.txt.in'
474--- providers/plainbox-provider-checkbox/jobs/info.txt.in 2015-05-14 19:32:33 +0000
475+++ providers/plainbox-provider-checkbox/jobs/info.txt.in 2015-05-20 10:15:25 +0000
476@@ -276,6 +276,54 @@
477 _summary: Attach /etc/buildstamp
478 command: [ -s /etc/buildstamp ] && cat /etc/buildstamp
479
480+plugin: shell
481+id: info/detect_recovery
482+requires: package.name == 'dell-recovery' or package.name == 'ubuntu-recovery'
483+user: root
484+estimated_duration: 0.2
485+_summary: Check existence of recovery partition
486+_description: Check existence of recovery partition
487+command: recovery_info --check-recovery-partition
488+
489+plugin: shell
490+id: info/detect_dell_recovery
491+depends: info/detect_recovery
492+requires: package.name == 'dell-recovery'
493+user: root
494+estimated_duration: 0.2
495+_summary: Check the recovery type is dell or not
496+_description: Check the recovery type is dell or not
497+command: recovery_info --check-recovery-type DELL
498+
499+plugin: attachment
500+id: recovery_info_attachment
501+depends: info/detect_recovery
502+requires: package.name == 'dell-recovery' or package.name == 'ubuntu-recovery'
503+user: root
504+estimated_duration: 0.2
505+_summary: Attach the recovery partition versions
506+_description:
507+ Attach the recovery partition version
508+ image_version is the preinstalled OS image version
509+ bto_version is only for dell_recovery
510+ Example:
511+ image_version: somerville-trusty-amd64-20140620-0
512+ bto_version: A00_dell-bto-trusty-houston-15-A11-iso-20141203-0.iso
513+command: recovery_info --show-version
514+
515+plugin: attachment
516+id: dell_bto_xml_attachment
517+depends: info/detect_dell_recovery
518+requires: package.name == 'dell-recovery'
519+estimated_duration: 0.5
520+_summary: Attach the bto.xml in Dell recovery partition
521+_description:
522+ bto.xml is basically a Fish manifest
523+ The information include:
524+ - fish packages
525+ - dell recovery stage 2 boot log
526+command: recovery_info --readfile bto.xml
527+
528 plugin: attachment
529 id: info/kvm_output
530 estimated_duration: 0.1
531
532=== modified file 'providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist'
533--- providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist 2015-05-14 19:32:33 +0000
534+++ providers/plainbox-provider-checkbox/whitelists/autotesting.whitelist 2015-05-20 10:15:25 +0000
535@@ -25,6 +25,8 @@
536 sysctl_attachment
537 sysfs_attachment
538 udev_attachment
539+recovery_info_attachment
540+dell_bto_xml_attachment
541 lsmod_attachment
542 dkms_info_attachment
543 #Automated Test-verification Jobs
544
545=== modified file 'providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist'
546--- providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist 2015-05-14 19:32:33 +0000
547+++ providers/plainbox-provider-checkbox/whitelists/hwsubmit.whitelist 2015-05-20 10:15:25 +0000
548@@ -16,6 +16,8 @@
549 dmi_attachment
550 dmidecode_attachment
551 kernel_cmdline_attachment
552+recovery_info_attachment
553+dell_bto_xml_attachment
554 lsmod_attachment
555 dkms_info_attachment
556 lspci_attachment

Subscribers

People subscribed via source and target branches