示例#1
0
    def config(self):
        self.nodetype = utils.to_list(self.nodetype)
        self.siteinfo = utils.to_list(self.siteinfo)

        if not self.nodetype or not self.siteinfo:
            raise exception.ConfigException(("Could not run YAIM: Bad "
                                             "nodetype or site-info."))

        with tempfile.NamedTemporaryFile("w+t",
                                         dir=config.CFG["yaim_path"],
                                         delete=True) as f:
            for si in self.siteinfo:
                f.write("source %s\n" % si)
            f.flush()

            api.info(("Creating temporary file '%s' with "
                      "content: %s" % (f.name, f.readlines())))

            # NOTE(orviz) Cannot use 'capture=True': execution gets
            # stalled (defunct)
            with context_managers.lcd(config.CFG["yaim_path"]):
                abort_exception_default = fabric_api.env.abort_exception
                fabric_api.env.abort_exception = exception.ConfigException
                try:
                    fabric_api.local("/opt/glite/yaim/bin/yaim -c -s %s -n %s"
                                     % (f.name, " -n ".join(self.nodetype)))
                except exception.ConfigException:
                    fabric_api.abort(api.fail(("YAIM execution failed. Check "
                                               "the logs at '/opt/glite/yaim/"
                                               "log/yaimlog'.")))
                api.info("YAIM configuration ran successfully.")
                fabric_api.env.abort_exception = abort_exception_default
示例#2
0
    def __init__(self,
                 manifest,
                 hiera_data=None,
                 module_from_puppetforge=[],
                 module_from_repository=[],
                 module_path=[]):
        """Runs Puppet configurations.

        :manifest: Main ".pp" with the configuration to be applied.
        :hiera_data: YAML file with hiera variables.
        :module_from_puppetforge: list of modules to be installed
                                  (from PuppetForge).
        :module_from_repository: module (repotype, repourl) tuples.
        :module_path: Extra Puppet module locations.
        """
        self.manifest = manifest
        self.hiera_data = hiera_data
        self.module_from_puppetforge = utils.to_list(module_from_puppetforge)
        self.module_from_repository = utils.to_list(module_from_repository)
        self.module_path = utils.to_list(module_path)
示例#3
0
 def _request(self, *args, **kwargs):
     step_methods = []
     if "qc_step" in kwargs.keys():
         for step in utils.to_list(kwargs["qc_step"]):
             try:
                 method = getattr(self, step.lower())
                 step_methods.append(method)
             except AttributeError:
                 api.info("Ignoring QC step '%s': not defined." % step)
                 continue
     return f(self, step_methods, *args, **kwargs)
示例#4
0
    def __init__(self, role, checkout="master", extra_vars=None, tags="all"):
        """Runs Ansible configurations.

        :role: Galaxy name or GitHub repository where the role is located.
        :checkout: Branch/tag/commit to checkout (see ansible-pull manpage).
        :extra_vars: Extra variables added to Ansible execution (usually
        filled in pre_config()).
        :tags: Run only tasks tagged with this value.
        """
        super(AnsibleConfig, self).__init__()
        self.role = role
        self.checkout = checkout
        self.extra_vars = extra_vars
        self.tags = utils.to_list(tags)
示例#5
0
    def __init__(self,
                 manifest,
                 module=[],
                 hiera_data=[],
                 extra_vars=None):
        """Runs Puppet configurations.

        :manifest: Main ".pp" with the configuration to be applied.
        :module: Name of a Forge module or git repository (Puppetfile format).
                 In can be a tuple, containing as a second item either the
                 Forge version or a Git repository valid reference (see
                 Puppetfile)
        :hiera_data: YAML file/s with hiera variables.
        """
        super(PuppetConfig, self).__init__()
        self.manifest = manifest
        self.module = utils.to_list(module)
        self.hiera_data = utils.to_list(hiera_data)
        self.hiera_data_dir = "/etc/puppet/hieradata"
        self.module_path = "/etc/puppet/modules"
        self.puppet_bin = "puppet"
        self.puppetfile = "etc/puppet/Puppetfile"
        self.params_files = []
        self.extra_vars = extra_vars