diff --git a/cf_remote/main.py b/cf_remote/main.py index d97f016..503a580 100644 --- a/cf_remote/main.py +++ b/cf_remote/main.py @@ -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] @@ -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): @@ -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: