def status(address, msg): """write a file with custom status""" pxe_vars = settings.pxe_variables(cfg, address) logging.info('setting state to "%s"', msg) file_name = '%s_%s.state' % (pxe_vars['fqdn'], msg) file_name = os.path.join(cfg['paths']['status'], file_name) utils.file_write(file_name, msg)
def rclocal(address): """return the rc.local file""" pxe_vars = settings.pxe_variables(cfg, address) file_name = os.path.join(cfg['paths']['templates'], cfg['templates']['rc_local']) result = utils.file_read(file_name) result = utils.apply_template(result, pxe_vars, file_name) return result
def overlay(address): """apply templates to a file overlay and return it a gzipped tar archive""" pxe_vars = settings.pxe_variables(cfg, address) overlay = pimp.Overlay(cfg, pxe_vars['overlay'], pxe_vars['fqdn']) overlay.prepare(pxe_vars) permissions = pimp.OverlayPermissions(cfg) permissions.script(overlay.dst, pxe_vars['overlay'], '/target') result = utils.tar_gz_directory(overlay.dst) return result
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
def install(address): """write installation started to the log""" pxe_vars = settings.pxe_variables(cfg, address) msg = '%(fqdn)s - installation started' % pxe_vars logging.info(msg) return msg