Example #1
0
    def iso(self, args):
        """validate the input and if no errors are found build an (unattended)
        installation ISO from a regular install ISO"""
        if not 'seed' in args:
            args.seed = ''
        if not 'config' in args:
            args.config = ''
        if not 'puppet' in args:
            args.puppet = []

        args, config = self._shared(args, 'iso')
        if args.release in config['isos']:
            iso_file = os.path.join(config['paths']['isos'], args.release)
            iso_file += '.iso'
        else:
            raise self.exception('"%s" is not a valid release' % args.release)

        if not os.path.isfile(iso_file):
            raise self.exception('"%s" is a valid release, but the installer '
                'ISO is not available (run "seedbank manage -i %s" to download '
                'the ISO)' % (args.release, args.release))

        if 'isofile' in args and args.isofile:
            iso_dst = os.path.abspath(args.isofile)
        else:
            iso_dst = os.path.join(os.getcwd(), '%s.iso' % args.fqdn)

        if os.path.isfile(iso_dst):
            logging.warning('"%s" already exists, will overwrite', iso_dst)

        build = iso.Build(config, iso_file, args.fqdn, iso_dst)
        build.prepare()

        if args.puppet:
            build.add_puppet_manifests(args.fqdn)

        template_cfg = settings.template(args.fqdn, args.overlay, args.config,
            args.variables)

        if args.overlay:
            overlay = pimp.Overlay(self.cfg, args.overlay, args.fqdn)
            overlay.prepare(template_cfg['seed'])
            permissions = pimp.OverlayPermissions(self.cfg)
            permissions.script(overlay.dst, args.overlay, '/target')

        seed = pimp.SeedPimp(template_cfg, 'iso')
        preseed = seed.pimp(args.seeds, args.overlay, args.puppet)
        build.add_preseed(preseed)
        distribution = args.release.split('-')[0]
        build.add_templates(distribution)
        if args.overlay:
            build.add_overlay(overlay.dst)
        build.non_free_firmware(args.release)
        build.rebuild_initrd()
        build.create()
        logging.info('ISO "%s" has been created', iso_dst)
        for hook in self.cfg['hooks_iso']['enable']:
            #hook = utils.apply_template(hook, self.pxe_variables)
            logging.info('found enable hook "%s"', hook)
            utils.run(hook, error=True)
Example #2
0
    def iso(self, args):
        """validate the input and if no errors are found build an (unattended)
        installation ISO from a regular install ISO"""
        if not "seed" in args:
            args.seed = ""
        if not "config" in args:
            args.config = ""
        if not "puppet" in args:
            args.puppet = []

        try:
            release = args.release.split("-")[1]
        except ValueError:
            raise self.exception('"%s" is not a valid release' % args.release)

        args, config = self._shared(args, release)

        if args.release in config["distributions"]["isos"]:
            iso_file = os.path.join(config["paths"]["isos"], args.release)
            iso_file += ".iso"
        else:
            raise self.exception('"%s" is not a valid release' % args.release)

        if not os.path.isfile(iso_file):
            raise self.exception(
                '"%s" is a valid release, but the installer '
                'ISO is not available (run "seedbank manage -i %s" to download '
                "the ISO)" % (args.release, args.release)
            )

        iso_dst = os.path.abspath(args.output)
        if os.path.isfile(iso_dst):
            logging.warning('"%s" already exists, will overwrite', iso_dst)

        build = iso.Build(config, iso_file, args.fqdn, iso_dst)
        build.prepare()

        if args.puppet:
            build.add_puppet_manifests(args.fqdn)

        template_cfg = settings.template(args.fqdn, args.overlay, args.config, args.variables)

        if args.overlay:
            overlay = pimp.Overlay(self.cfg, args.overlay, args.fqdn)
            overlay.prepare(template_cfg["seed"])
            permissions = pimp.OverlayPermissions(self.cfg)
            permissions.script(overlay.dst, args.overlay, "/target")

        seed = pimp.SeedPimp(template_cfg, "iso")
        preseed = seed.pimp(args.seeds, args.overlay, args.puppet)
        build.add_preseed(preseed)
        distribution = args.release.split("-")[0]
        build.add_templates(distribution)
        if args.overlay:
            build.add_overlay(overlay.dst)
        build.create()
Example #3
0
def seed(address):
    """return the generated preseed file"""
    pxe_vars = settings.pxe_variables(cfg, address)
    template_cfg = settings.template(pxe_vars['fqdn'], pxe_vars['overlay'],
        pxe_vars['config'], pxe_vars)
    seed = pimp.SeedPimp(template_cfg, 'pxe')
    try:
        result = seed.pimp(pxe_vars['seeds'], pxe_vars['overlay'],
            pxe_vars['puppet_manifests'])
    except KeyError as err:
        msg = 'key %s not found in the PXE variables' % err
        logging.error(msg)
        abort(400, msg)
    else:
        return result
Example #4
0
def seed(address):
    """return the generated preseed file"""
    pxe_vars = settings.pxe_variables(cfg, address)
    template_cfg = settings.template(pxe_vars['fqdn'], pxe_vars['overlay'],
                                     pxe_vars['config'], pxe_vars)
    seed = pimp.SeedPimp(template_cfg, 'pxe')
    try:
        result = seed.pimp(pxe_vars['seeds'], pxe_vars['overlay'],
                           pxe_vars['puppet_manifests'])
    except KeyError as err:
        msg = 'key %s not found in the PXE variables' % err
        logging.error(msg)
        abort(400, msg)
    else:
        return result
Example #5
0
    def iso(self, args):
        """validate the input and if no errors are found build an (unattended)
        installation ISO from a regular install ISO"""
        if not 'seed' in args:
            args.seed = ''
        if not 'config' in args:
            args.config = ''
        if not 'puppet' in args:
            args.puppet = []

        args, config = self._shared(args, 'iso')
        if args.release in config['isos']:
            iso_file = os.path.join(config['paths']['isos'], args.release)
            iso_file += '.iso'
        else:
            raise self.exception('"%s" is not a valid release' % args.release)

        if not os.path.isfile(iso_file):
            raise self.exception(
                '"%s" is a valid release, but the installer '
                'ISO is not available (run "seedbank manage -i %s" to download '
                'the ISO)' % (args.release, args.release))

        if 'isofile' in args and args.isofile:
            iso_dst = os.path.abspath(args.isofile)
        else:
            iso_dst = os.path.join(os.getcwd(), '%s.iso' % args.fqdn)

        if os.path.isfile(iso_dst):
            logging.warning('"%s" already exists, will overwrite', iso_dst)

        build = iso.Build(config, iso_file, args.fqdn, iso_dst)
        build.prepare()

        if args.puppet:
            build.add_puppet_manifests(args.fqdn)

        template_cfg = settings.template(args.fqdn, args.overlay, args.config,
                                         args.variables)

        if args.overlay:
            overlay = pimp.Overlay(self.cfg, args.overlay, args.fqdn)
            overlay.prepare(template_cfg['seed'])
            permissions = pimp.OverlayPermissions(self.cfg)
            permissions.script(overlay.dst, args.overlay, '/target')

        seed = pimp.SeedPimp(template_cfg, 'iso')
        preseed = seed.pimp(args.seeds, args.overlay, args.puppet)
        build.add_preseed(preseed)
        distribution = args.release.split('-')[0]
        build.add_templates(distribution)
        if args.overlay:
            build.add_overlay(overlay.dst)
        build.non_free_firmware(args.release)
        build.rebuild_initrd()
        build.create()
        logging.info('ISO "%s" has been created', iso_dst)
        for hook in self.cfg['hooks_iso']['enable']:
            #hook = utils.apply_template(hook, self.pxe_variables)
            logging.info('found enable hook "%s"', hook)
            utils.run(hook, error=True)