コード例 #1
0
 def _shell_exec_dvars(self, keys, variables):
     """shell execute dynvariables"""
     for k in list(keys):
         ret, out = shell(variables[k], debug=self.debug)
         if not ret:
             err = 'var \"{}: {}\" failed: {}'.format(k, variables[k], out)
             self.log.err(err)
             raise YamlException(err)
         if self.debug:
             self.log.dbg('\"{}\": {} -> {}'.format(k, variables[k], out))
         variables[k] = out
コード例 #2
0
 def _shell_exec_dvars(self, dic, keys=[]):
     """shell execute dynvariables in-place"""
     if not keys:
         keys = dic.keys()
     for k in keys:
         v = dic[k]
         ret, out = shell(v, debug=self._debug)
         if not ret:
             err = 'var \"{}: {}\" failed: {}'.format(k, v, out)
             self._log.err(err)
             raise YamlException(err)
         if self._debug:
             self._dbg('{}: `{}` -> {}'.format(k, v, out))
         dic[k] = out
コード例 #3
0
    def get_variables(self, profile, debug=False):
        """return the variables for this profile"""
        # get flat variables
        variables = self._get_variables(profile)

        # get interpreted variables
        dvariables = self._get_dynvariables(profile)

        # recursive resolve variables
        allvars = variables.copy()
        allvars.update(dvariables)
        var = self._rec_resolve_vars(allvars)

        # execute dynvariables
        for k in dvariables.keys():
            var[k] = shell(var[k])

        if debug:
            self.log.dbg('variables:')
            for k, v in var.items():
                self.log.dbg('\t\"{}\": {}'.format(k, v))

        return var