Merge lp:~smoser/maas-images/trunk.centos-curtin-passthrough into lp:maas-images

Proposed by Scott Moser
Status: Merged
Merged at revision: 377
Proposed branch: lp:~smoser/maas-images/trunk.centos-curtin-passthrough
Merge into: lp:maas-images
Diff against target: 160 lines (+103/-2)
2 files modified
curtin/centos6/curtin-hooks.py (+52/-1)
curtin/centos7/curtin-hooks.py (+51/-1)
To merge this branch: bzr merge lp:~smoser/maas-images/trunk.centos-curtin-passthrough
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+328246@code.launchpad.net

Description of the change

Add support to CentOS 6 and 7 for network config and cloudconfig.

This adds the ability for the CentOS curthooks to make use of
the 'centos_apply_network_config' function of new curtin version.

Also adds the ability to handle 'cloudconfig' entries in curtin config
dictionary. It does this by utilizing 'write_files' from curtin.futil.

It also adds a short term legacy-curtin fallback for older curtin
import paths.

To post a comment you must log in.
378. By Scott Moser

fix calling of write_files from handle_cloudconfig

Revision history for this message
Lee Trager (ltrager) wrote :

Thanks for helping with the Curtin hooks. I have two fixes below. If Curtin trunk lands the final names before this we can just use the final names and drop the backwards compatibility.

review: Needs Fixing
Revision history for this message
Scott Moser (smoser) wrote :

I think we'll plan to merge the curtin updates in https://code.launchpad.net/~smoser/curtin/trunk.renames-for-centos/+merge/328250
and then drop the FIXME sections of this, providing no compatibility for curtin at revno 511-513.

379. By Scott Moser

drop support for curtin at versions 511-513.

Curtin at revno 514 now has the renamed import paths.
This breaks support for maas images using a curtin at
revisions 511-513 by dropping the FIXME fallback import paths.

380. By Scott Moser

do not name the import error as it was anot used

Revision history for this message
Scott Moser (smoser) wrote :

https://code.launchpad.net/~smoser/curtin/trunk.renames-for-centos/+merge/328250
is merged now.
and here i've removed the support for those older curtin revnos (511-513).

Revision history for this message
Lee Trager (ltrager) wrote :

LGTM, thanks again for the help!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'curtin/centos6/curtin-hooks.py'
--- curtin/centos6/curtin-hooks.py 2016-05-11 18:47:46 +0000
+++ curtin/centos6/curtin-hooks.py 2017-08-01 15:59:28 +0000
@@ -13,9 +13,28 @@
1313
14from curtin import (14from curtin import (
15 block,15 block,
16 config,
16 util,17 util,
17 )18 )
1819
20try:
21 from curtin import FEATURES as curtin_features
22except ImportError:
23 curtin_features = []
24
25write_files = None
26try:
27 from curtin.futil import write_files
28except ImportError:
29 pass
30
31centos_apply_network_config = None
32try:
33 if 'CENTOS_APPLY_NETWORK_CONFIG' in curtin_features:
34 from curtin.commands.curthooks import centos_apply_network_config
35except ImportError:
36 pass
37
19"""38"""
20CentOS 639CentOS 6
2140
@@ -309,6 +328,30 @@
309 })328 })
310329
311330
331def apply_networking(cfg, target, bootmac):
332 if 'network' in cfg and centos_apply_network_config:
333 centos_apply_network_config(cfg, target)
334 return
335
336 if 'network' in cfg:
337 sys.stderr.write("WARN: network configuration provided, but "
338 "no support for applying. Using basic config.")
339 write_network_config(target, bootmac)
340
341
342def handle_cloudconfig(cfg, target):
343 if not cfg.get('cloudconfig'):
344 return
345 if not write_files:
346 sys.stderr.write(
347 "WARN: Unable to handle 'cloudconfig' section in config."
348 "No 'write_files' found from curtin.\n")
349 return
350
351 base_dir = os.path.join(target, 'etc/cloud/cloud.cfg.d')
352 write_files(cfg['cloudconfig'], base_dir)
353
354
312def main():355def main():
313 state = util.load_command_environment()356 state = util.load_command_environment()
314 target = state['target']357 target = state['target']
@@ -335,7 +378,15 @@
335 grub_install(target, grub_root)378 grub_install(target, grub_root)
336379
337 set_autorelabel(target)380 set_autorelabel(target)
338 write_network_config(target, bootmac)381
382 if state.get('config'):
383 cfg = config.load_config(state['config'])
384 else:
385 cfg = {}
386
387 handle_cloudconfig(cfg, target)
388
389 apply_networking(cfg, target, bootmac)
339390
340391
341if __name__ == "__main__":392if __name__ == "__main__":
342393
=== modified file 'curtin/centos7/curtin-hooks.py'
--- curtin/centos7/curtin-hooks.py 2017-05-08 00:04:25 +0000
+++ curtin/centos7/curtin-hooks.py 2017-08-01 15:59:28 +0000
@@ -13,9 +13,27 @@
1313
14from curtin import (14from curtin import (
15 block,15 block,
16 config,
16 util,17 util,
17 )18 )
1819
20try:
21 from curtin import FEATURES as curtin_features
22except ImportError:
23 curtin_features = []
24
25write_files = None
26try:
27 from curtin.futil import write_files
28except ImportError:
29 pass
30
31centos_apply_network_config = None
32try:
33 if 'CENTOS_APPLY_NETWORK_CONFIG' in curtin_features:
34 from curtin.commands.curthooks import centos_apply_network_config
35except ImportError:
36 pass
1937
20"""38"""
21CentOS 739CentOS 7
@@ -299,6 +317,30 @@
299 })317 })
300318
301319
320def apply_networking(cfg, target, bootmac):
321 if 'network' in cfg and centos_apply_network_config:
322 centos_apply_network_config(cfg, target)
323 return
324
325 if 'network' in cfg:
326 sys.stderr.write("WARN: network configuration provided, but "
327 "no support for applying. Using basic config.")
328 write_network_config(target, bootmac)
329
330
331def handle_cloudconfig(cfg, target):
332 if not cfg.get('cloudconfig'):
333 return
334 if not write_files:
335 sys.stderr.write(
336 "WARN: Unable to handle 'cloudconfig' section in config."
337 "No 'write_files' found from curtin.\n")
338 return
339
340 base_dir = os.path.join(target, 'etc/cloud/cloud.cfg.d')
341 write_files(cfg['cloudconfig'], base_dir)
342
343
302def main():344def main():
303 state = util.load_command_environment()345 state = util.load_command_environment()
304 target = state['target']346 target = state['target']
@@ -330,7 +372,15 @@
330 grub2_install(target, dev)372 grub2_install(target, dev)
331373
332 set_autorelabel(target)374 set_autorelabel(target)
333 write_network_config(target, bootmac)375
376 if state.get('config'):
377 cfg = config.load_config(state['config'])
378 else:
379 cfg = {}
380
381 handle_cloudconfig(cfg, target)
382
383 apply_networking(cfg, target, bootmac)
334384
335385
336if __name__ == "__main__":386if __name__ == "__main__":

Subscribers

People subscribed via source and target branches