Merge lp:~milner/landscape-client/add-more-preseeding-goodness into lp:~landscape/landscape-client/trunk
- add-more-preseeding-goodness
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Kevin McDermott | ||||
Approved revision: | 379 | ||||
Merged at revision: | 386 | ||||
Proposed branch: | lp:~milner/landscape-client/add-more-preseeding-goodness | ||||
Merge into: | lp:~landscape/landscape-client/trunk | ||||
Diff against target: |
425 lines (+255/-19) 7 files modified
debian/landscape-client.config (+14/-0) debian/landscape-client.postinst (+30/-5) debian/landscape-client.templates (+47/-0) debian/po/templates.pot (+99/-4) landscape/broker/config.py (+1/-1) landscape/configuration.py (+10/-9) landscape/tests/test_configuration.py (+54/-0) |
||||
To merge this branch: | bzr merge lp:~milner/landscape-client/add-more-preseeding-goodness | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kevin McDermott (community) | Approve | ||
Thomas Herve (community) | Approve | ||
Review via email: mp+78578@code.launchpad.net |
Commit message
Description of the change
- Adds more variables to debconf to allow them to be pre-seeded.
- Fixes to landscape-config to respect the --no-start command line flag
- 375. By Mike Milner
-
Removed the low-priority debconf questions so they don't get asked during a
dpk-reconfigure. They will only be accesible using preseed or
debconf-set-selections.
Thomas Herve (therve) wrote : | # |
Sorry, forget what I said about otp.
- 376. By Mike Milner
-
Merged from trunk.
- 377. By Mike Milner
-
Fixed failing tests.
- 378. By Mike Milner
-
Fix lint issues.
Mike Milner (milner) wrote : | # |
> [1] I have several test failures, related to your config file changes most
> likely.
Fixed - sorry I missed these!
Thomas Herve (therve) wrote : | # |
[3]
+ args = ["--silent", "--no-start"]
+ args += ["--computer-
+ args += ["--account-name", ""]
+ args += ["--registratio
+ args += ["--url", "https:/
+ args += ["--exchange-
+ args += ["--urgent-
+ args += ["--ping-url", "http://
+ args += ["--ping-interval", "30"]
+ args += ["--http-proxy", ""]
+ args += ["--https-proxy", ""]
+ args += ["--otp", ""]
+ args += ["--tags", ""]
Can you create the list "normally" instead?
+ args = ["--silent", "--no-start",
+ "--computer-title", "", ...
+1!
- 379. By Mike Milner
-
Fixed list formatting.
Mike Milner (milner) wrote : | # |
> [3]
> + args = ["--silent", "--no-start"]
> + args += ["--computer-
> + args += ["--account-name", ""]
> + args += ["--registratio
> + args += ["--url", "https:/
> + args += ["--exchange-
> + args += ["--urgent-
> + args += ["--ping-url", "http://
> + args += ["--ping-interval", "30"]
> + args += ["--http-proxy", ""]
> + args += ["--https-proxy", ""]
> + args += ["--otp", ""]
> + args += ["--tags", ""]
>
> Can you create the list "normally" instead?
>
> + args = ["--silent", "--no-start",
> + "--computer-title", "", ...
Fixed!
Kevin McDermott (bigkevmcd) wrote : | # |
Looks good, +1
Preview Diff
1 | === modified file 'debian/landscape-client.config' |
2 | --- debian/landscape-client.config 2011-10-04 11:33:05 +0000 |
3 | +++ debian/landscape-client.config 2011-10-24 17:41:25 +0000 |
4 | @@ -21,7 +21,14 @@ |
5 | ACCOUNT_NAME=$(get_var_from_file "account_name" "$CONFIGFILE") |
6 | REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE") |
7 | URL=$(get_var_from_file "url" "$CONFIGFILE") |
8 | + EXCHANGE_INTERVAL=$(get_var_from_file "exchange_interval" "$CONFIGFILE") |
9 | + URGENT_EXCHANGE_INTERVAL=$(get_var_from_file "urgent_exchange_interval" "$CONFIGFILE") |
10 | PING_URL=$(get_var_from_file "ping_url" "$CONFIG_FILE") |
11 | + PING_INTERVAL=$(get_var_from_file "ping_interval" "$CONFIGFILE") |
12 | + HTTP_PROXY=$(get_var_from_file "http_proxy" "$CONFIGFILE") |
13 | + HTTPS_PROXY=$(get_var_from_file "https_proxy" "$CONFIGFILE") |
14 | + OTP=$(get_var_from_file "otp" "$CONFIGFILE") |
15 | + TAGS=$(get_var_from_file "tags" "$CONFIG_FILE") |
16 | |
17 | # Store values from config file into |
18 | # debconf db. |
19 | @@ -30,7 +37,14 @@ |
20 | db_set $PACKAGE/account_name $ACCOUNT_NAME |
21 | db_set $PACKAGE/registration_password $REGISTRATION_PASSWORD |
22 | db_set $PACKAGE/url $URL |
23 | + db_set $PACKAGE/exchange_interval $EXCHANGE_INTERVAL |
24 | + db_set $PACKAGE/urgent_exchange_interval $URGENT_EXCHANGE_INTERVAL |
25 | db_set $PACKAGE/ping_url $PING_URL |
26 | + db_set $PACKAGE/ping_interval $PING_INTERVAL |
27 | + db_set $PACKAGE/http_proxy $HTTP_PROXY |
28 | + db_set $PACKAGE/https_proxy $HTTPS_PROXY |
29 | + db_set $PACKAGE/otp $OTP |
30 | + db_set $PACKAGE/tags $TAGS |
31 | fi |
32 | |
33 | # Ask questions. |
34 | |
35 | === modified file 'debian/landscape-client.postinst' |
36 | --- debian/landscape-client.postinst 2011-10-03 14:09:48 +0000 |
37 | +++ debian/landscape-client.postinst 2011-10-24 17:41:25 +0000 |
38 | @@ -37,26 +37,51 @@ |
39 | REGISTRATION_PASSWORD="${RET}" |
40 | db_get $PACKAGE/url |
41 | URL="${RET}" |
42 | + db_get $PACKAGE/exchange_interval |
43 | + EXCHANGE_INTERVAL="${RET}" |
44 | + db_get $PACKAGE/urgent_exchange_interval |
45 | + URGENT_EXCHANGE_INTERVAL="${RET}" |
46 | db_get $PACKAGE/ping_url |
47 | PING_URL="${RET}" |
48 | + db_get $PACKAGE/ping_interval |
49 | + PING_INTERVAL="${RET}" |
50 | + db_get $PACKAGE/http_proxy |
51 | + HTTP_PROXY="${RET}" |
52 | + db_get $PACKAGE/https_proxy |
53 | + HTTPS_PROXY="${RET}" |
54 | + db_get $PACKAGE/otp |
55 | + OTP="${RET}" |
56 | + db_get $PACKAGE/tags |
57 | + TAGS="${RET}" |
58 | |
59 | # Create new configuration, with private mode |
60 | TEMPFILE=$(mktemp -p /etc/landscape) |
61 | cat > $TEMPFILE <<END |
62 | [client] |
63 | log_level = info |
64 | -url = ${URL} |
65 | -ping_url = ${PING_URL} |
66 | data_path = /var/lib/landscape/client |
67 | END |
68 | chown landscape $TEMPFILE |
69 | mv $TEMPFILE $CONFIG_FILE |
70 | |
71 | + # Configure landscape |
72 | + landscape-config --silent --no-start \ |
73 | + --computer-title "$COMPUTER_TITLE" \ |
74 | + --account-name "$ACCOUNT_NAME" \ |
75 | + --registration-password "$REGISTRATION_PASSWORD" \ |
76 | + --url "$URL" \ |
77 | + --exchange-interval "$EXCHANGE_INTERVAL" \ |
78 | + --urgent-exchange-interval "$URGENT_EXCHANGE_INTERVAL" \ |
79 | + --ping-url "$PING_URL" \ |
80 | + --ping-interval "$PING_INTERVAL" \ |
81 | + --http-proxy "$HTTP_PROXY" \ |
82 | + --https-proxy "$HTTPS_PROXY" \ |
83 | + --otp "$OTP" \ |
84 | + --tags "$TAGS" |
85 | + |
86 | # If we got the needed information, actually do the registration. |
87 | if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then |
88 | - landscape-config --silent --ok-no-register -a "$ACCOUNT_NAME" \ |
89 | - -p "$REGISTRATION_PASSWORD" \ |
90 | - -t "$COMPUTER_TITLE" |
91 | + landscape-config --silent --ok-no-register |
92 | fi |
93 | else |
94 | # Fix non-private permissions |
95 | |
96 | === modified file 'debian/landscape-client.templates' |
97 | --- debian/landscape-client.templates 2011-10-11 19:38:46 +0000 |
98 | +++ debian/landscape-client.templates 2011-10-24 17:41:25 +0000 |
99 | @@ -23,12 +23,59 @@ |
100 | _Description: Landscape Server URL: |
101 | The server URL to connect to. |
102 | |
103 | +Template: landscape-client/exchange_interval |
104 | +Type: string |
105 | +Default: 900 |
106 | +_Description: Message Exchange Interval: |
107 | + Interval, in seconds, between normal message exchanges with the Landscape |
108 | + server. |
109 | + |
110 | +Template: landscape-client/urgent_exchange_interval |
111 | +Type: string |
112 | +Default: 60 |
113 | +_Description: Urgent Message Exchange Interval: |
114 | + Interval, in seconds, between urgent message exchanges with the Landscape |
115 | + server. |
116 | + |
117 | Template: landscape-client/ping_url |
118 | Type: string |
119 | Default: http://landscape.canonical.com/ping |
120 | _Description: Landscape PingServer URL: |
121 | The URL to perform lightweight exchange initiation with. |
122 | |
123 | +Template: landscape-client/ping_interval |
124 | +Type: string |
125 | +Default: 30 |
126 | +_Description: Ping Interval: |
127 | + Interval, in seconds, between client ping exchanges with the Landscape server. |
128 | + |
129 | +Template: landscape-client/http_proxy |
130 | +Type: string |
131 | +Default: |
132 | +_Description: HTTP proxy (blank for none): |
133 | + The URL of the HTTP proxy, if one is needed. |
134 | + |
135 | +Template: landscape-client/https_proxy |
136 | +Type: string |
137 | +Default: |
138 | +_Description: HTTPS proxy (blank for none): |
139 | + The URL of the HTTPS proxy, if one is needed. |
140 | + |
141 | +Template: landscape-client/otp |
142 | +Type: string |
143 | +Default: |
144 | +_Description: The OTP to use in initial configuration: |
145 | + The OneTimePassword to use for initial registration with the Landscape server. |
146 | + This is only required for Cloud or Preseeded installs. |
147 | + |
148 | +Template: landscape-client/tags |
149 | +Type: string |
150 | +Default: |
151 | +_Description: Initial tags for first registration |
152 | + Comma separated list of tags which will be assigned to this computer on its |
153 | + first registration. Once the machine is registered, these tags can only be |
154 | + changed using the Landscape server. |
155 | + |
156 | Template: landscape-client/register_system |
157 | Type: boolean |
158 | Default: false |
159 | |
160 | === modified file 'debian/po/templates.pot' |
161 | --- debian/po/templates.pot 2011-09-30 16:09:07 +0000 |
162 | +++ debian/po/templates.pot 2011-10-24 17:41:25 +0000 |
163 | @@ -8,7 +8,7 @@ |
164 | msgstr "" |
165 | "Project-Id-Version: PACKAGE VERSION\n" |
166 | "Report-Msgid-Bugs-To: landscape-client@packages.debian.org\n" |
167 | -"POT-Creation-Date: 2011-09-30 11:01-0300\n" |
168 | +"POT-Creation-Date: 2011-10-06 10:12-0300\n" |
169 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
170 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
171 | "Language-Team: LANGUAGE <LL@li.org>\n" |
172 | @@ -74,24 +74,119 @@ |
173 | #. Type: string |
174 | #. Description |
175 | #: ../landscape-client.templates:5001 |
176 | +msgid "Message Exchange Interval:" |
177 | +msgstr "" |
178 | + |
179 | +#. Type: string |
180 | +#. Description |
181 | +#: ../landscape-client.templates:5001 |
182 | +msgid "" |
183 | +"Interval, in seconds, between normal message exchanges with the Landscape " |
184 | +"server." |
185 | +msgstr "" |
186 | + |
187 | +#. Type: string |
188 | +#. Description |
189 | +#: ../landscape-client.templates:6001 |
190 | +msgid "Urgent Message Exchange Interval:" |
191 | +msgstr "" |
192 | + |
193 | +#. Type: string |
194 | +#. Description |
195 | +#: ../landscape-client.templates:6001 |
196 | +msgid "" |
197 | +"Interval, in seconds, between urgent message exchanges with the Landscape " |
198 | +"server." |
199 | +msgstr "" |
200 | + |
201 | +#. Type: string |
202 | +#. Description |
203 | +#: ../landscape-client.templates:7001 |
204 | msgid "Landscape PingServer URL:" |
205 | msgstr "" |
206 | |
207 | #. Type: string |
208 | #. Description |
209 | -#: ../landscape-client.templates:5001 |
210 | +#: ../landscape-client.templates:7001 |
211 | msgid "The URL to perform lightweight exchange initiation with." |
212 | msgstr "" |
213 | |
214 | +#. Type: string |
215 | +#. Description |
216 | +#: ../landscape-client.templates:8001 |
217 | +msgid "Ping Interval:" |
218 | +msgstr "" |
219 | + |
220 | +#. Type: string |
221 | +#. Description |
222 | +#: ../landscape-client.templates:8001 |
223 | +msgid "" |
224 | +"Interval, in seconds, between client ping exchanges with the Landscape " |
225 | +"server." |
226 | +msgstr "" |
227 | + |
228 | +#. Type: string |
229 | +#. Description |
230 | +#: ../landscape-client.templates:9001 |
231 | +msgid "HTTP proxy (blank for none):" |
232 | +msgstr "" |
233 | + |
234 | +#. Type: string |
235 | +#. Description |
236 | +#: ../landscape-client.templates:9001 |
237 | +msgid "The URL of the HTTP proxy, if one is needed." |
238 | +msgstr "" |
239 | + |
240 | +#. Type: string |
241 | +#. Description |
242 | +#: ../landscape-client.templates:10001 |
243 | +msgid "HTTPS proxy (blank for none):" |
244 | +msgstr "" |
245 | + |
246 | +#. Type: string |
247 | +#. Description |
248 | +#: ../landscape-client.templates:10001 |
249 | +msgid "The URL of the HTTPS proxy, if one is needed." |
250 | +msgstr "" |
251 | + |
252 | +#. Type: string |
253 | +#. Description |
254 | +#: ../landscape-client.templates:11001 |
255 | +msgid "The OTP to use in initial configuration:" |
256 | +msgstr "" |
257 | + |
258 | +#. Type: string |
259 | +#. Description |
260 | +#: ../landscape-client.templates:11001 |
261 | +msgid "" |
262 | +"The OneTimePassword to use for initial registration with the Landscape " |
263 | +"server. This is only required for Cloud or Preseeded installs." |
264 | +msgstr "" |
265 | + |
266 | +#. Type: string |
267 | +#. Description |
268 | +#: ../landscape-client.templates:12001 |
269 | +msgid "Initial tags for first registration" |
270 | +msgstr "" |
271 | + |
272 | +#. Type: string |
273 | +#. Description |
274 | +#: ../landscape-client.templates:12001 |
275 | +msgid "" |
276 | +"Comma separated list of tags which will be assigned to this computer on its " |
277 | +"first registration. Once the machine is registered, these tags can only be " |
278 | +"changed using the Landscape server." |
279 | +msgstr "" |
280 | + |
281 | #. Type: boolean |
282 | #. Description |
283 | -#: ../landscape-client.templates:6001 |
284 | +#: ../landscape-client.templates:13001 |
285 | msgid "Register this system with the Landscape server?" |
286 | msgstr "" |
287 | |
288 | #. Type: boolean |
289 | #. Description |
290 | -#: ../landscape-client.templates:6001 |
291 | +#: ../landscape-client.templates:13001 |
292 | msgid "" |
293 | "Register this system with a preexisting Landscape account. Please\n" |
294 | " go to http://landscape.canonical.com if you need a Landscape account." |
295 | |
296 | === modified file 'landscape/broker/config.py' |
297 | --- landscape/broker/config.py 2011-08-19 15:47:27 +0000 |
298 | +++ landscape/broker/config.py 2011-10-24 17:41:25 +0000 |
299 | @@ -79,7 +79,7 @@ |
300 | help="The URL of the HTTPS proxy, if one is needed.") |
301 | parser.add_option("--cloud", action="store_true", |
302 | help="Set this if your computer is in an EC2 cloud.") |
303 | - parser.add_option("--otp", |
304 | + parser.add_option("--otp", default="", |
305 | help="The OTP to use in cloud configuration.") |
306 | parser.add_option("--tags", |
307 | help="Comma separated list of tag names to be sent " |
308 | |
309 | === modified file 'landscape/configuration.py' |
310 | --- landscape/configuration.py 2011-01-12 17:05:48 +0000 |
311 | +++ landscape/configuration.py 2011-10-24 17:41:25 +0000 |
312 | @@ -378,7 +378,7 @@ |
313 | if self._get_invalid_tags(self.config.tags): |
314 | self.show_help("Tag names may only contain alphanumeric " |
315 | "characters.") |
316 | - self.config.tags = None # Reset for the next prompt |
317 | + self.config.tags = None # Reset for the next prompt |
318 | else: |
319 | break |
320 | |
321 | @@ -439,11 +439,12 @@ |
322 | if config.https_proxy is None and os.environ.get("https_proxy"): |
323 | config.https_proxy = os.environ["https_proxy"] |
324 | |
325 | - if config.silent: |
326 | + if config.silent and not config.no_start: |
327 | if not config.get("otp") and (not config.get("account_name") or not |
328 | config.get("computer_title")): |
329 | raise ConfigurationError("An account name and computer title are " |
330 | "required.") |
331 | + if config.silent: |
332 | if config.get("script_users"): |
333 | invalid_users = get_invalid_users(config.get("script_users")) |
334 | if invalid_users: |
335 | @@ -622,7 +623,6 @@ |
336 | print_text(str(error), error=True) |
337 | sys.exit(1) |
338 | |
339 | - |
340 | # Disable startup on boot and stop the client, if one is running. |
341 | if config.disable: |
342 | stop_client_and_disable_init_script() |
343 | @@ -636,10 +636,11 @@ |
344 | sys.exit("Aborting Landscape configuration") |
345 | |
346 | # Attempt to register the client. |
347 | - if config.silent: |
348 | - register(config) |
349 | - else: |
350 | - answer = raw_input("\nRequest a new registration for " |
351 | - "this computer now? (Y/n): ") |
352 | - if not answer.upper().startswith("N"): |
353 | + if not config.no_start: |
354 | + if config.silent: |
355 | register(config) |
356 | + else: |
357 | + answer = raw_input("\nRequest a new registration for " |
358 | + "this computer now? (Y/n): ") |
359 | + if not answer.upper().startswith("N"): |
360 | + register(config) |
361 | |
362 | === modified file 'landscape/tests/test_configuration.py' |
363 | --- landscape/tests/test_configuration.py 2011-07-05 05:09:11 +0000 |
364 | +++ landscape/tests/test_configuration.py 2011-10-24 17:41:25 +0000 |
365 | @@ -720,6 +720,60 @@ |
366 | account_name = account |
367 | """ % config.data_path) |
368 | |
369 | + def test_silent_setup_no_register(self): |
370 | + """ |
371 | + Called with command line options to write a config file but no |
372 | + registration or validation of parameters is attempted. |
373 | + """ |
374 | + # Make sure no sysvconfig modifications are attempted |
375 | + self.mocker.patch(SysVConfig) |
376 | + self.mocker.replay() |
377 | + |
378 | + config = self.get_config(["--silent", "--no-start"]) |
379 | + setup(config) |
380 | + self.assertEqual(self.get_content(config), """\ |
381 | +[client] |
382 | +url = https://landscape.canonical.com/message-system |
383 | +data_path = %s |
384 | +""" % config.data_path) |
385 | + |
386 | + def test_silent_setup_no_register_with_default_preseed_params(self): |
387 | + """ |
388 | + Make sure that the configuration can be used to write the |
389 | + configuration file after a fresh install. |
390 | + """ |
391 | + # Make sure no sysvconfig modifications are attempted |
392 | + self.mocker.patch(SysVConfig) |
393 | + self.mocker.replay() |
394 | + |
395 | + args = ["--silent", "--no-start", |
396 | + "--computer-title", "", |
397 | + "--account-name", "", |
398 | + "--registration-password", "", |
399 | + "--url", "https://landscape.canonical.com/message-system", |
400 | + "--exchange-interval", "900", |
401 | + "--urgent-exchange-interval", "60", |
402 | + "--ping-url", "http://landscape.canonical.com/ping", |
403 | + "--ping-interval", "30", |
404 | + "--http-proxy", "", |
405 | + "--https-proxy", "", |
406 | + "--otp", "", |
407 | + "--tags", ""] |
408 | + config = self.get_config(args) |
409 | + setup(config) |
410 | + self.assertEqual(self.get_content(config), |
411 | + "[client]\n" |
412 | + "http_proxy = \n" |
413 | + "tags = \n" |
414 | + "data_path = %s\n" |
415 | + "registration_password = \n" |
416 | + "account_name = \n" |
417 | + "url = https://landscape.canonical.com/message-system\n" |
418 | + "computer_title = \n" |
419 | + "https_proxy = \n" |
420 | + "ping_url = http://landscape.canonical.com/ping\n" |
421 | + % config.data_path) |
422 | + |
423 | def test_silent_setup_without_computer_title(self): |
424 | """A computer title is required.""" |
425 | sysvconfig_mock = self.mocker.patch(SysVConfig) |
[1] I have several test failures, related to your config file changes most likely.
[2] You should remove the otp option. This is something internal, not meant to be used by preseed.