Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cf_remote/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def validate_command(command, args):
if command in ["sudo", "run"]:
if len(args.remote_command) != 1:
raise CFRExitError(
"cf-remote sude/run requires exactly 1 command (use quotes)"
"cf-remote sudo/run requires exactly 1 command (use quotes)"
)
args.remote_command = args.remote_command[0]

Expand Down Expand Up @@ -613,6 +613,17 @@ def get_cloud_hosts(name, bootstrap_ips=False):
return ret


def _get_cloud_group_names():
if not os.path.exists(paths.CLOUD_STATE_FPATH):
return []
state = read_json(paths.CLOUD_STATE_FPATH)
if not state:
return []
for key in state:
if key.startswith("@"):
return key[1:]


def resolve_hosts(string, single=False, bootstrap_ips=False):
log.debug("resolving hosts from '{}'".format(string))
if is_file_string(string):
Expand All @@ -628,6 +639,14 @@ def resolve_hosts(string, single=False, bootstrap_ips=False):
ret.extend(hosts)
log.debug("found in cloud, adding '{}'".format(hosts))
else:
if "." not in name and "@" not in name:
available = _get_cloud_group_names()
if available:
raise CFRUserError(
"'{}' not found in cloud state. Available groups: {}".format(
name, ", ".join(available)
)
)
ret.append(name)

if single:
Expand Down
Loading