Merge lp:~ltrager/maas-images/centos_storage_curthooks into lp:maas-images

Proposed by Lee Trager on 2018-08-17
Status: Merged
Merged at revision: 408
Proposed branch: lp:~ltrager/maas-images/centos_storage_curthooks
Merge into: lp:maas-images
Diff against target: 164 lines (+56/-40)
2 files modified
conf/centos.yaml (+10/-3)
curtin/centos7/curtin-hooks.py (+46/-37)
To merge this branch: bzr merge lp:~ltrager/maas-images/centos_storage_curthooks
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) 2018-08-17 Approve on 2018-08-23
Review via email: mp+353351@code.launchpad.net

Commit message

Update CentOS 7 curthooks to use internal Curtin storage support.

Curtin now supports deploying custom storage on CentOS 7+. Hooks are no
longer required for CentOS but they are still included for backwards
compatibility. If CentOS is deployed with MAAS 2.5+ and a supported version of Curtin the hooks will simply call back into Curtin to configure storage.
If an older version of MAAS or Curtin is used the old hooks will still run.

Description of the change

Stream with updated CentOS 7 image: http://162.213.35.187/centos-storage/

Testing:
I tested in the CI and configured a BIOS and UEFI machine with 2 disk to have a btrfs filesystem for / on LVM on top of a RAID 1 over 2 disks

MAAS-2.4.1 + curtin-18.1-17-gae48e86f-0ubuntu1~18.04.1(stable) - Flat layout
MAAS-2.4.1 + curtin+centos-storage - Flat layout
MAAS-master + curtin-18.1-17-gae48e86f-0ubuntu1~18.04.1 - Flat layout
MAAS-master + curtin+centos-storage - Custom storage layout deployed!

* curtin+centos-storage - https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/349075

To post a comment you must log in.
Ryan Harper (raharper) :
Lee Trager (ltrager) wrote :

Thanks for the review. I've updated to use the real package name as discussed on IRC. I was also able to confirm custom storage deployment works :)

414. By Lee Trager on 2018-08-23

Cleanup package order

Andres Rodriguez (andreserl) wrote :

Question inline.

review: Needs Information
Lee Trager (ltrager) wrote :

We're not supporting custom storage on CentOS 6 so its Curtin hooks remain the same. grub2-efi-x64 is only added to the list of packages added to the CentOS 7 image.

Andres Rodriguez (andreserl) wrote :

lgtm! But this should land if and only if the hooks are exactly like those in maas-image-builder

review: Approve
Lee Trager (ltrager) wrote :

Yes they are exactly the same

$ diff -u maas-images/centos_storage_curthooks/curtin/centos7/ maas-image-builder/contrib/centos/centos7/curtin/
$

415. By Lee Trager on 2018-08-29

Don't include grub2-efi-x64

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'conf/centos.yaml'
--- conf/centos.yaml 2018-08-16 19:38:27 +0000
+++ conf/centos.yaml 2018-08-29 01:11:32 +0000
@@ -17,6 +17,7 @@
17 # cloud-init depends on packages from EPEL17 # cloud-init depends on packages from EPEL
18 - epel-release18 - epel-release
19 - bash-completion19 - bash-completion
20 - linux-firmware
20 # XXX ltrager 2017-07-28 - COPR doesn't provide a URL to the latest21 # XXX ltrager 2017-07-28 - COPR doesn't provide a URL to the latest
21 # package build. Instead it expects you to first add the repo which22 # package build. Instead it expects you to first add the repo which
22 # is what is included in this package.23 # is what is included in this package.
@@ -28,11 +29,16 @@
28 # Without it cloud-init will try to install it which will not work in29 # Without it cloud-init will try to install it which will not work in
29 # isolated environments.30 # isolated environments.
30 - bridge-utils31 - bridge-utils
31 - linux-firmware
32 - grub2-efi-modules
33 - efibootmgr
34 # Tools needed to allow custom storage to be deployed without32 # Tools needed to allow custom storage to be deployed without
35 # accessing the Internet.33 # accessing the Internet.
34 # grub2-efi-x64 contains the signed bootloader which currently does not
35 # chainboot - RHBZ #1623296
36 # - grub2-efi-x64
37 # - shim-x64
38 # RHBZ #1101352
39 - grub2-efi-x64-modules
40 - grub2-tools
41 - efibootmgr
36 - dosfstools42 - dosfstools
37 - lvm243 - lvm2
38 - mdadm44 - mdadm
@@ -57,6 +63,7 @@
57 - bridge-utils63 - bridge-utils
58 # Tools needed to allow custom storage to be deployed without64 # Tools needed to allow custom storage to be deployed without
59 # accessing the Internet.65 # accessing the Internet.
66 - efibootmgr
60 - btrfs-progs67 - btrfs-progs
61 - dosfstools68 - dosfstools
62 - lvm269 - lvm2
6370
=== modified file 'curtin/centos7/curtin-hooks.py'
--- curtin/centos7/curtin-hooks.py 2017-08-02 19:10:25 +0000
+++ curtin/centos7/curtin-hooks.py 2018-08-29 01:11:32 +0000
@@ -7,6 +7,7 @@
7 )7 )
88
9import codecs9import codecs
10import importlib
10import os11import os
11import re12import re
12import sys13import sys
@@ -14,41 +15,37 @@
14from curtin import (15from curtin import (
15 block,16 block,
16 config,17 config,
18 log,
17 util,19 util,
18 )20 )
1921
20try:22
21 from curtin import FEATURES as curtin_features23def try_import(path, unavailable=None, condition=True):
22except ImportError:24 """Import path (module.submodule.attribute) and return it.
23 curtin_features = []25 return unavailable if
2426 - condition is not true
25write_files = None27 - import fails
26try:28 - attribute does not exist in module."""
27 from curtin.futil import write_files29 if not condition:
28except ImportError:30 return unavailable
29 pass31 modname, _, attrname = path.rpartition(".")
3032 try:
31centos_apply_network_config = None33 mod = importlib.import_module(modname)
32try:34 imported = getattr(mod, attrname, None)
33 if 'CENTOS_APPLY_NETWORK_CONFIG' in curtin_features:35 except ImportError:
34 from curtin.commands.curthooks import centos_apply_network_config36 imported = None
35except ImportError:37 return imported if imported else unavailable
36 pass38
3739
38"""40curtin_features = try_import("curtin.FEATURES", [])
39CentOS 741write_files = try_import("curtin.futil.write_files")
4042centos_apply_network_config = try_import(
41Currently Support:43 "curtin.commands.curthooks.centos_apply_network_config",
4244 condition='CENTOS_APPLY_NETWORK_CONFIG' in curtin_features)
43- Legacy boot45centos_curthooks = try_import(
44- UEFI boot46 "curtin.commands.curthooks.builtin_curthooks",
45- DHCP of BOOTIF47 condition='CENTOS_CURTHOOK_SUPPORT' in curtin_features)
4648
47Not Supported:
48
49- Multiple network configration
50- IPv6
51"""
5249
53FSTAB_PREPEND = """\50FSTAB_PREPEND = """\
54#51#
@@ -342,6 +339,10 @@
342339
343340
344def main():341def main():
342 # Enable logging to stdout for curtin functions
343 verbosity = int(os.environ.get("CURTIN_VERBOSITY", 1))
344 log.basicConfig(stream=sys.stdout, verbosity=verbosity)
345
345 state = util.load_command_environment()346 state = util.load_command_environment()
346 target = state['target']347 target = state['target']
347 if target is None:348 if target is None:
@@ -360,6 +361,19 @@
360 print("Unable to find block device for: %s" % target)361 print("Unable to find block device for: %s" % target)
361 sys.exit(1)362 sys.exit(1)
362363
364 if state.get('config'):
365 cfg = config.load_config(state['config'])
366 else:
367 cfg = {}
368
369 # Run builtin hooks if curtin has the feature and maas sent storage cfg
370 if centos_curthooks and cfg.get('storage'):
371 # centos_curthooks will complete successfully or raise an exception.
372 # Not handling the exception here means we will exit this program with
373 # a non-zero value
374 centos_curthooks(cfg, target, state)
375 return
376
363 write_fstab(target, fstab)377 write_fstab(target, fstab)
364378
365 update_grub_default(379 update_grub_default(
@@ -373,11 +387,6 @@
373387
374 set_autorelabel(target)388 set_autorelabel(target)
375389
376 if state.get('config'):
377 cfg = config.load_config(state['config'])
378 else:
379 cfg = {}
380
381 handle_cloudconfig(cfg, target)390 handle_cloudconfig(cfg, target)
382391
383 apply_networking(cfg, target, bootmac)392 apply_networking(cfg, target, bootmac)

Subscribers

People subscribed via source and target branches