Beispiel #1
0
    def pxe(self, args):
        """process the pxe command"""
        args, config = self._shared(args, "pxe")
        release = args.release

        path = os.path.join(config["paths"]["tftpboot"], "seedbank", release)
        if not os.path.isdir(path):
            if release in config["netboots"]:
                err = '"%s" is not available, run "seedbank manage -n %s" to ' "download and prepare the release" % (
                    release,
                    release,
                )
            else:
                err = '"%s" is not a valid release, run "seedbank list -n" to ' "list valid releases " % release
            raise self.exception(err)

        if args.macaddress:
            if len(args.macaddress) == 12:
                pass
            elif not re.match("([a-fA-F0-9]{2}[:|\-]?){6}", args.macaddress):
                err = '"%s" is not a valid MAC address' % args.macaddress
                raise self.exception(err)
            args.address = utils.format_address(args.macaddress)
        else:
            ip_address = utils.resolve_ip_address(args.fqdn)
            args.address = utils.ip_to_hex(ip_address)

        pxe_linux = pxe.GeneratePxe(args)
        pxe_linux.state_remove()
        pxe_linux.write(pxe_linux.generate())
        pxe_linux.hook_enable()

        logging.info('"%s" will be installed with "%s" after the next PXE boot', args.fqdn, args.release)
Beispiel #2
0
    def pxe(self, args):
        """process the pxe command"""
        args, config = self._shared(args, 'pxe')
        release = args.release

        path = os.path.join(config['paths']['tftpboot'], 'seedbank', release)
        if not os.path.isdir(path):
            if release in config['netboots']:
                err = '"%s" is not available, run "seedbank manage -n %s" to '\
                    'download and prepare the release' % (release, release)
            else:
                err = '"%s" is not a valid release, run "seedbank list -n" to '\
                    'list valid releases ' % release
            raise self.exception(err)

        if args.macaddress:
            if len(args.macaddress) == 12:
                pass
            elif not re.match('([a-fA-F0-9]{2}[:|\-]?){6}', args.macaddress):
                err = '"%s" is not a valid MAC address' % args.macaddress
                raise self.exception(err)
            args.address = utils.format_address(args.macaddress)
        else:
            ip_address = utils.resolve_ip_address(args.fqdn)
            args.address = utils.ip_to_hex(ip_address)

        pxe_linux = pxe.GeneratePxe(args)
        pxe_linux.state_remove()
        pxe_linux.write(pxe_linux.generate())
        pxe_linux.hook_enable()

        logging.info(
            '"%s" will be installed with "%s" after the next PXE boot',
            args.fqdn, args.release)
Beispiel #3
0
    def pxe(self, args):
        """process the pxe command"""
        try:
            _, release, _ = args.release.split("-")
        except:
            err = (
                '"%s" is an unknown release (first run "seedbank '
                'manage -n <release>" to download and prepare the '
                'release, run "seedbank list -n" to list available '
                "releases" % args.release
            )
            raise self.exception(err)

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

        path = os.path.join(config["paths"]["tftpboot"], "seedbank", args.release)
        if not os.path.isdir(path):
            if release in config["distributions"]["netboots"]:
                err = (
                    '"%s" is not available, run "seedbank manage -n "%s" to '
                    "download an prepare the release" % args.release
                )
            raise self.exception(err)

        if args.macaddress:
            if len(args.macaddress) == 12:
                pass
            elif not re.match("([a-fA-F0-9]{2}[:|\-]?){6}", args.macaddress):
                err = '"%s" is not a valid MAC address' % args.macaddress
                raise self.exception(err)
            args.address = utils.format_address(args.macaddress)
        else:
            ip_address = utils.resolve_ip_address(args.fqdn)
            args.address = utils.ip_to_hex(ip_address)

        pxe_linux = pxe.GeneratePxe(args)
        pxe_linux.state_remove()
        pxe_linux.write(pxe_linux.generate())
        pxe_linux.hook_enable()