コード例 #1
0
ファイル: rest.py プロジェクト: pathcl/seedBank
def puppet(manifest):
    """return the generated seedbank bootstrap init file"""
    file_name = os.path.join(cfg['paths']['templates'],
                             cfg['templates']['puppet_manifest'])
    result = utils.file_read(file_name)
    result = utils.apply_template(result, {'manifest': manifest}, file_name)
    return result
コード例 #2
0
ファイル: pxe.py プロジェクト: COOLSPOIL/seedBank
 def _gather_script(self):
     """get node information via a lookup script"""
     command = utils.apply_template(self.provider, self.values)
     command = command.split(' ')
     result = utils.run(command)
     if not result.retcode:
         return self._return(yaml.load(result.output))
コード例 #3
0
ファイル: pxe.py プロジェクト: pathcl/seedBank
 def _gather_script(self):
     """get node information via a lookup script"""
     command = utils.apply_template(self.provider, self.values)
     command = command.split(' ')
     result = utils.run(command)
     if not result.retcode:
         return self._return(yaml.load(result.output))
コード例 #4
0
ファイル: pxe.py プロジェクト: pathcl/seedBank
 def hook_enable(self):
     """apply PXE variables on the configured enable hook(s) and run the
     hook(s)"""
     for hook in cfg['hooks_pxe']['enable']:
         hook = utils.apply_template(hook, self.pxe_variables)
         logging.info('found enable hook "%s"', hook)
         utils.run(hook, error=True)
コード例 #5
0
ファイル: pxe.py プロジェクト: COOLSPOIL/seedBank
 def hook_enable(self):
     """apply PXE variables on the configured enable hook(s) and run the
     hook(s)"""
     for hook in cfg['hooks_pxe']['enable']:
         hook = utils.apply_template(hook, self.pxe_variables)
         logging.info('found enable hook "%s"', hook)
         utils.run(hook, error=True)
コード例 #6
0
ファイル: rest.py プロジェクト: bobcanthelpyou/seedBank
def puppet(manifest):
    """return the generated seedbank bootstrap init file"""
    file_name = os.path.join(cfg['paths']['templates'],
        cfg['templates']['puppet_manifest'])
    result = utils.file_read(file_name)
    result = utils.apply_template(result, {'manifest': manifest}, file_name)
    return result
コード例 #7
0
ファイル: pxe.py プロジェクト: pathcl/seedBank
 def _gather_http(self):
     """get internal nodes information via http ot https, delete the first line"""
     url = utils.apply_template(self.provider, self.values)
     result = utils.read_url(url)
     if result:
         del result[0]
     result = ''.join(result)
     return self._return(yaml.load(result))
コード例 #8
0
ファイル: pxe.py プロジェクト: COOLSPOIL/seedBank
 def _gather_http(self):
     """get internal nodes information via http ot https, delete the first line"""
     url = utils.apply_template(self.provider, self.values)
     result = utils.read_url(url)
     if result:
         del result[0]
     result = ''.join(result)
     return self._return(yaml.load(result))
コード例 #9
0
ファイル: rest.py プロジェクト: bobcanthelpyou/seedBank
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
コード例 #10
0
ファイル: rest.py プロジェクト: pathcl/seedBank
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
コード例 #11
0
ファイル: pimp.py プロジェクト: favoretti/seedBank
 def _merge_seeds(self, seeds, values):
     """merge the main seed file with the recipe(s) and additional seeds 
     return it as a string"""
     result = ''
     for seed in seeds:
         file_name = os.path.join(self.cfg['paths']['seeds'], seed + '.seed')
         logging.info('applying template values to "%s"', file_name)
         data = utils.file_read(file_name)
         result += utils.apply_template(data, values, file_name)
     return result
コード例 #12
0
 def _merge_seeds(self, seeds, values):
     """merge the main seed file with the recipe(s) and additional seeds
     return it as a string"""
     result = ''
     for seed in seeds:
         file_name = os.path.join(self.cfg['paths']['seeds'],
                                  seed + '.seed')
         logging.info('applying template values to "%s"', file_name)
         data = utils.file_read(file_name)
         result += utils.apply_template(data, values, file_name)
     return result
コード例 #13
0
ファイル: pxe.py プロジェクト: COOLSPOIL/seedBank
    def generate(self):
        """generate the pxe boot file"""
        self.pxe_variables.update({
            'config': self.config,
            'seeds': self.seeds,
            'seed_host': cfg['settings']['seed_host'],
            'seed_port': cfg['settings']['bottle_port'],
            'address': self.address,
            'overlay': self.overlay,
            'puppet_manifests': self.puppet,
            'host_name': self.host_name,
            'dns_domain': self.dns_domain,
            'fqdn': self.fqdn,
            'query': urllib.urlencode([('address', self.address)]),
            'date_generated': utils.date_time(),
            'date_disabled': '',
            'kernel': '%s/%s/%s' % ('seedbank', self.release, 'linux'),
            'initrd': '%s/%s/%s' % ('seedbank', self.release, 'initrd.gz')
        })

        if self.config:
            yaml_file = os.path.join(cfg['paths']['configs'], self.config)
            yaml_file = yaml_file + '.yaml'
            overrides = utils.yaml_read(yaml_file)
            if 'pxe' in overrides:
                cfg['pxe'].update(overrides['pxe'])
        values = cfg['pxe']
        self.pxe_variables.update(values)

        distribution = self.release.split('-')[0]
        file_name = cfg[distribution]['template_pxe']
        file_name = os.path.join(cfg['paths']['templates'], file_name)
        if not os.path.isfile(file_name):
            err = 'file "%s" does not exist (hint: check the templates '\
                'section in your settings)' % file_name
            raise utils.FatalException(err)

        pxe_variables_custom = []
        for variable in self.variables:
            key, value = variable
            pxe_variables_custom.append('# %s = %s' % (key, value))
            self.pxe_variables[key] = value
        pxe_variables_custom = '\n'.join(pxe_variables_custom)

        data = utils.file_read(file_name)
        data = utils.apply_template(data, self.pxe_variables, file_name)
        if pxe_variables_custom:
            data = re.sub(
                '(#\n# \*\*\* end - seedBank pxe variables \*\*\*)',
                pxe_variables_custom + '\n\\1', data)
        return data
コード例 #14
0
def commands_template(cmds, values):
    """apply values to a command template"""
    cmds = [utils.apply_template(cmd, values, cmd) for cmd in cmds]
    return cmds
コード例 #15
0
ファイル: pimp.py プロジェクト: favoretti/seedBank
def commands_template(cmds, values):
    """apply values to a command template"""
    cmds = [utils.apply_template(cmd, values, cmd) for cmd in cmds]
    return cmds
コード例 #16
0
ファイル: pxe.py プロジェクト: pathcl/seedBank
    def generate(self):
        """generate the pxe boot file"""
        self.pxe_variables.update({
            'config':
            self.config,
            'seeds':
            self.seeds,
            'seed_host':
            cfg['settings']['seed_host'],
            'seed_port':
            cfg['settings']['bottle_port'],
            'address':
            self.address,
            'overlay':
            self.overlay,
            'puppet_manifests':
            self.puppet,
            'host_name':
            self.host_name,
            'dns_domain':
            self.dns_domain,
            'fqdn':
            self.fqdn,
            'query':
            urllib.urlencode([('address', self.address)]),
            'date_generated':
            utils.date_time(),
            'date_disabled':
            '',
            'kernel':
            '%s/%s/%s' % ('seedbank', self.release, 'linux'),
            'initrd':
            '%s/%s/%s' % ('seedbank', self.release, 'initrd.gz')
        })

        if self.config:
            yaml_file = os.path.join(cfg['paths']['configs'], self.config)
            yaml_file = yaml_file + '.yaml'
            overrides = utils.yaml_read(yaml_file)
            if 'pxe' in overrides:
                cfg['pxe'].update(overrides['pxe'])
        values = cfg['pxe']
        self.pxe_variables.update(values)

        distribution = self.release.split('-')[0]
        file_name = cfg[distribution]['template_pxe']
        file_name = os.path.join(cfg['paths']['templates'], file_name)
        if not os.path.isfile(file_name):
            err = 'file "%s" does not exist (hint: check the templates '\
                'section in your settings)' % file_name
            raise utils.FatalException(err)

        pxe_variables_custom = []
        for variable in self.variables:
            key, value = variable
            pxe_variables_custom.append('# %s = %s' % (key, value))
            self.pxe_variables[key] = value
        pxe_variables_custom = '\n'.join(pxe_variables_custom)

        data = utils.file_read(file_name)
        data = utils.apply_template(data, self.pxe_variables, file_name)
        if pxe_variables_custom:
            data = re.sub('(#\n# \*\*\* end - seedBank pxe variables \*\*\*)',
                          pxe_variables_custom + '\n\\1', data)
        return data
コード例 #17
0
import utils

# utils.html_output()

# utils.apply_template()

import sys
print("This is argv:", sys.argv)
command = sys.argv[1]
if command == "build":
    utils.html_output()
    utils.apply_template()
elif command == "new":
    page_name = input("What is the page name?")
    new_page = 'content/' + page_name + '.html'
    open(new_page, "w+").write("Import new content")
else:
    print("Please specify ’build’ or ’new’")