Пример #1
0
def resolve_hosts(string, single=False, private_ips=False):
    if is_file_string(string):
        ret = expand_list_from_file(string)
    elif is_in_cloud_state(string):
        ret = get_cloud_hosts(string, private_ips)
    else:
        ret = string.split(",")

    if single:
        if len(ret) != 1:
            user_error(
                "'{}' must contain exactly 1 hostname or IP".format(string))
        return ret[0]
    else:
        return ret
Пример #2
0
def resolve_hosts(string, single=False, private_ips=False):
    log.debug("resolving hosts from '{}'".format(string))
    if is_file_string(string):
        names = expand_list_from_file(string)
    else:
        names = string.split(",")

    ret = []

    for name in names:
        if is_in_cloud_state(name):
            hosts = get_cloud_hosts(name, private_ips)
            ret.extend(hosts)
            log.debug("found in cloud, adding '{}'".format(hosts))
        else:
            ret.append(name)

    if single:
        if len(ret) != 1:
            user_error("'{}' must contain exactly 1 hostname or IP".format(string))
        return ret[0]
    else:
        return ret
Пример #3
0
def file_or_comma_list(string):
    if is_file_string(string):
        return expand_list_from_file(string)
    return string.split(",")
Пример #4
0
def file_or_comma_list(string):
    if is_file_string(string):
        return expand_list_from_file(string)
    return string.split(",")