def check_setup(self, storage, ksdata, instClass): """ Check storage to make sure the selected VG has a thinpool and it is named docker-pool :param storage: Blivet storage object :param ksdata: Kickstart data object :param instClass: Anaconda installclass object If there is an error, raise the appropriate Kickstart error. """ if self.addon.vgname not in (vg.name for vg in storage.vgs): raise KickstartParseError(formatErrorMsg(0, msg=_("%%addon com_redhat_docker is missing VG named %s")) % self.addon.vgname) # Make sure the VG has a docker-pool LV if self.addon.vgname+"-docker-pool" not in (lv.name for lv in storage.lvs): raise KickstartParseError(formatErrorMsg(0, msg=_("%%addon com_redhat_docker is missing a LV named docker-pool")))
def handle_header(self, lineno, args): """ Handle the kickstart addon header :param lineno: Line number :param args: arguments from %addon line """ # This gets called after __init__, very early in the installation. op = KSOptionParser() op.add_option("--vgname", required=True, help="Name of the VG that contains a thinpool named docker-pool") op.add_option("--fstype", required=True, help="Type of filesystem to use for docker to use with docker-pool") op.add_option("--save-args", action="store_true", default=False, help="Save all extra args to the OPTIONS variable in /etc/sysconfig/docker") (opts, extra) = op.parse_args(args=args, lineno=lineno) fmt = blivet.formats.getFormat(opts.fstype) if not fmt or fmt.type is None: raise KickstartValueError(formatErrorMsg(lineno, msg=_("%%addon com_redhat_docker fstype of %s is invalid.")) % opts.fstype) self.vgname = opts.vgname self.fstype = opts.fstype self.enabled = True self.extra_args = extra self.save_args = opts.save_args
def check_setup(self, storage, ksdata, instClass): """ Check to make sure /var/lib/docker is on a BTRFS filesystem""" for path in ["/var/lib/docker", "/var/lib", "/var", "/"]: device = storage.mountpoints.get(path) if isinstance(device, BTRFSDevice): log.debug("com_redhat_docker found BTRFS at %s", path) return raise KickstartParseError(formatErrorMsg(0, msg=_("%%addon com_redhat_docker /var/lib/docker is not on a BTRFS volume")))
def setup(self, storage, ksdata, instClass): """ Setup the addon :param storage: Blivet storage object :param ksdata: Kickstart data object :param instClass: Anaconda installclass object """ # This gets called after entering progress hub, just before installation and device partitioning. if "docker" not in ksdata.packages.packageList: raise KickstartValueError(formatErrorMsg(0, msg=_("%%package section is missing docker"))) # Check storage to make sure the selected VG has a thinpool and it is named docker-pool? if self.vgname not in (vg.name for vg in storage.vgs): raise KickstartValueError(formatErrorMsg(0, msg=_("%%addon com_redhat_docker is missing VG named %s")) % self.vgname) # Make sure the VG has a docker-pool LV if self.vgname+"-docker-pool" not in (lv.name for lv in storage.lvs): raise KickstartValueError(formatErrorMsg(0, msg=_("%%addon com_redhat_docker is missing a LV named docker-pool")))
def handle_header(self, lineno, args): """ Handle the kickstart addon header :param lineno: Line number :param args: arguments from %addon line """ # This gets called after __init__, very early in the installation. op = KSOptionParser() op.add_option("--vgname", help="Name of the VG that contains a thinpool named docker-pool") op.add_option("--fstype", help="Type of filesystem for docker to use with the docker-pool") op.add_option("--overlay", action="store_true", help="Use the overlay driver") op.add_option("--btrfs", action="store_true", help="Use the BTRFS driver") op.add_option("--save-args", action="store_true", default=False, help="Save all extra args to the OPTIONS variable in /etc/sysconfig/docker") (opts, extra) = op.parse_args(args=args, lineno=lineno) if sum(1 for v in [opts.overlay, opts.btrfs, opts.vgname] if bool(v)) != 1: raise KickstartParseError(formatErrorMsg(lineno, msg=_("%%addon com_redhat_docker must choose one of --overlay, --btrfs, or --vgname"))) self.enabled = True self.extra_args = extra self.save_args = opts.save_args if opts.overlay: self.storage = OverlayStorage(self) elif opts.btrfs: self.storage = BTRFSStorage(self) elif opts.vgname: fmt = blivet.formats.get_format(opts.fstype) if not fmt or fmt.type is None: raise KickstartParseError(formatErrorMsg(lineno, msg=_("%%addon com_redhat_docker fstype of %s is invalid.")) % opts.fstype) self.vgname = opts.vgname self.fstype = opts.fstype self.storage = LVMStorage(self)
def setup(self, storage, ksdata, instClass): """ Setup the addon :param storage: Blivet storage object :param ksdata: Kickstart data object :param instClass: Anaconda installclass object """ # This gets called after entering progress hub, just before installation and device partitioning. if not self.enabled: return if "docker" not in ksdata.packages.packageList: raise KickstartValueError(formatErrorMsg(0, msg=_("%%package section is missing docker"))) self.storage.check_setup(storage, ksdata, instClass)