示例#1
0
def pillar_format(ret, keys, value):
    '''
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
    '''
    # skip it
    if value is None:
        return ret
    # if wrapped in quotes, drop them
    if value[0] == value[-1] == '"':
        pillar_value = value[1:-1]
    # if we have a list, reformat into a list
    if value[0] == '-' and value[1] == ' ':
        array_data = value.split('\n')
        # drop the '- ' on each element
        pillar_value = [elem[2:] for elem in array_data]
    # leave it be
    else:
        pillar_value = value
    keyvalue = keys.pop()
    pil = {keyvalue: pillar_value}
    keys.reverse()
    for k in keys:
        pil = {k: pil}

    return dict_merge(ret, pil)
示例#2
0
def pillar_format(ret, keys, value):
    '''
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
    '''
    if value is None:
        return ret
    if value[0] == value[-1] == '"':
        pillar_value = value[1:-1]
    else:
        array_data = value.split('\n')
        pillar_value = array_data[0] if len(array_data) == 1 else array_data
    keyvalue = keys.pop()
    pil = {keyvalue: pillar_value}
    keys.reverse()
    for k in keys:
        pil = {k: pil}

    return dict_merge(ret, pil)
示例#3
0
def pillar_format(ret, keys, value):
    '''
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
    '''
    if value is None:
        return ret
    if value[0] == value[-1] == '"':
        pillar_value = value[1:-1]
    else:
        array_data = value.split('\n')
        pillar_value = array_data[0] if len(array_data) == 1 else array_data
    keyvalue = keys.pop()
    pil = {keyvalue: pillar_value}
    keys.reverse()
    for k in keys:
        pil = {k: pil}

    return dict_merge(ret, pil)
示例#4
0
def pillar_format(ret, keys, value):
    '''
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
    '''
    # if value is empty in Consul then it's None here - skip it
    if value is None:
        return ret

    # If value is not None then it's a string
    # Use YAML to parse the data
    # YAML strips whitespaces unless they're surrounded by quotes
    pillar_value = yaml.load(value, Loader=SaltYamlSafeLoader)

    keyvalue = keys.pop()
    pil = {keyvalue: pillar_value}
    keys.reverse()
    for k in keys:
        pil = {k: pil}

    return dict_merge(ret, pil)
示例#5
0
def pillar_format(ret, keys, value):
    '''
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
    '''
    # if value is empty in Consul then it's None here - skip it
    if value is None:
        return ret

    # If value is not None then it's a string
    # Use YAML to parse the data
    # YAML strips whitespaces unless they're surrounded by quotes
    pillar_value = yaml.load(value)

    keyvalue = keys.pop()
    pil = {keyvalue: pillar_value}
    keys.reverse()
    for k in keys:
        pil = {k: pil}

    return dict_merge(ret, pil)
示例#6
0
def pillar_format(ret, keys, value, expand_keys):
    """
    Perform data formatting to be used as pillar data and
    merge it with the current pillar data
    """
    # if value is empty in Consul then it's None here - skip it
    if value is None:
        return ret

    # If value is not None then it's a string
    # YAML strips whitespaces unless they're surrounded by quotes
    # If expand_keys is true, deserialize the YAML data
    if expand_keys:
        pillar_value = salt.utils.yaml.safe_load(value)
    else:
        pillar_value = value

    keyvalue = keys.pop()
    pil = {keyvalue: pillar_value}
    keys.reverse()
    for k in keys:
        pil = {k: pil}

    return dict_merge(ret, pil)