def node_pillar(node_name, **kwargs): ''' Returns pillar metadata for given node from reclass inventory. :param node_name: target minion ID CLI Examples: .. code-block:: bash salt-call reclass.node_pillar minion_id ''' defaults = find_and_read_configfile() pillar = ext_pillar(node_name, {}, defaults['storage_type'], defaults['inventory_base_uri']) output = {node_name: pillar} return output
def validate_pillar(node_name=None, **kwargs): ''' Validates whether the pillar of given node is in correct state. If node is not specified it validates pillars of all known nodes. Returns error message for every node with currupted metadata. :param node_name: target minion ID CLI Examples: .. code-block:: bash salt-call reclass.validate_pillar salt-call reclass.validate_pillar minion-id ''' if node_name is None: ret = {} nodes = node_list(**kwargs) for node_name, node in nodes.items(): ret.update(validate_pillar(node_name)) return ret else: defaults = find_and_read_configfile() meta = '' error = None try: pillar = ext_pillar(node_name, {}, defaults['storage_type'], defaults['inventory_base_uri']) except (ReclassException, Exception) as e: msg = "Validation failed in %s on %s" % (repr(e), node_name) LOG.error(msg) meta = {'Error': msg} s = str(type(e)) if 'yaml.scanner.ScannerError' in s: error = re.sub(r"\r?\n?$", "", repr(str(e)), 1) else: error = e.message if 'Error' in meta: ret = {node_name: error} else: ret = {node_name: ''} return ret