Merge lp:~roadmr/checkbox/897889-environ into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 1145
Proposed branch: lp:~roadmr/checkbox/897889-environ
Merge into: lp:checkbox
Diff against target: 71 lines (+17/-1)
3 files modified
debian/changelog (+3/-1)
jobs/wireless.txt.in (+4/-0)
plugins/backend_info.py (+10/-0)
To merge this branch: bzr merge lp:~roadmr/checkbox/897889-environ
Reviewer Review Type Date Requested Status
Brendan Donegan (community) Approve
Review via email: mp+85037@code.launchpad.net

Description of the change

OK, here's another stab at setting env variables for user: root jobs.

If environ: is specified in a job description, the specified environment variables will be taken from the frontend's environment and put in the backend's env prior to running the job.

I modified the wireless job files (the ones that prompted this madness) to use the new mechanism.

To test this, one could define a job like this:

plugin: shell
user: root
environ: WHATEVER
command: echo "the variable is $WHATEVER"
description: nothing really

put this on a whitelist or something and run:

WHATEVER="anything" checkbox-gtk -W my.whitelist

The test result should contain "the variable is anything" with the environ fix in place, and just "the variable is" without it.

The change is pretty much self-contained, doesn't really interact with any other code in checkbox, and can hopefully be easily backportable to any required branches.

To post a comment you must log in.
lp:~roadmr/checkbox/897889-environ updated
1146. By Daniel Manrique

Fixed borked indenting

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Yeah, we got it!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-12-07 21:25:59 +0000
3+++ debian/changelog 2011-12-08 22:34:26 +0000
4@@ -19,8 +19,10 @@
5 [Daniel Manrique]
6 * Update control files under debian/ to eliminate (most) lintian warnings
7 (LP: #352986)
8+ * Environment variables specified with environ: in a job description will be
9+ passed to the backend for it to add to its environment. (LP: #897889)
10
11- -- Daniel Manrique <daniel.manrique@canonical.com> Tue, 06 Dec 2011 16:31:47 -0500
12+ -- Daniel Manrique <daniel.manrique@canonical.com> Thu, 08 Dec 2011 16:43:28 -0500
13
14 checkbox (0.13) precise; urgency=low
15
16
17=== modified file 'jobs/wireless.txt.in'
18--- jobs/wireless.txt.in 2011-11-29 21:32:22 +0000
19+++ jobs/wireless.txt.in 2011-12-08 22:34:26 +0000
20@@ -23,6 +23,7 @@
21 name: wireless/wireless_connection_wpa_bg
22 requires: device.category == 'WIRELESS'
23 user: root
24+environ: WPA_BG_SSID WPA_BG_PSK
25 command: create_connection $WPA_BG_SSID --security=wpa --key=$WPA_BG_PSK && nmcli con up id $WPA_BG_SSID && internet_test
26 _description:
27 Tests that the systems wireless hardware can connect to a router using WPA
28@@ -32,6 +33,7 @@
29 name: wireless/wireless_connection_open_bg
30 requires: device.category == 'WIRELESS'
31 user: root
32+environ: OPEN_BG_SSID
33 command: create_connection $OPEN_BG_SSID && nmcli con up id $OPEN_BG_SSID && internet_test
34 _description:
35 Tests that the systems wireless hardware can connect to a router using no
36@@ -41,6 +43,7 @@
37 name: wireless/wireless_connection_wpa_n
38 requires: device.category == 'WIRELESS'
39 user: root
40+environ: WPA_N_SSID WPA_N_PSK
41 command: create_connection $WPA_N_SSID --security=wpa --key=$WPA_N_PSK && nmcli con up id $WPA_N_SSID && internet_test
42 _description:
43 Tests that the systems wireless hardware can connect to a router using WPA
44@@ -50,6 +53,7 @@
45 name: wireless/wireless_connection_open_n
46 requires: device.category == 'WIRELESS'
47 user: root
48+environ: OPEN_N_SSID
49 command: create_connection $OPEN_N_SSID && nmcli con up id $OPEN_N_SSID && internet_test
50 _description:
51 Tests that the systems wireless hardware can connect to a router using no
52
53=== modified file 'plugins/backend_info.py'
54--- plugins/backend_info.py 2011-07-15 13:33:45 +0000
55+++ plugins/backend_info.py 2011-12-08 22:34:26 +0000
56@@ -113,6 +113,16 @@
57
58 def message_exec(self, message):
59 if "user" in message:
60+ if "environ" in message:
61+ #Prepare variables to be "exported" from my environment
62+ #to the backend's.
63+ backend_environ=["%s=%s" % (key, os.environ[key])
64+ for key in message["environ"]
65+ if key in os.environ]
66+ message=dict(message) #so as to not wreck the
67+ #original message
68+ message["environ"]=backend_environ
69+
70 if (self.backend_is_alive and not self.ping_backend()):
71 self.backend_is_alive = False
72

Subscribers

People subscribed via source and target branches