Skip to content

Commit

Permalink
Merge pull request #84 from mineralsfree/ENT-11138
Browse files Browse the repository at this point in the history
ENT-11134: improve the error message format
  • Loading branch information
olehermanse authored Mar 19, 2024
2 parents 4f188b2 + d103740 commit 82de565
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cf_remote/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def spawn(
spawned_cb=print_progress_dot,
)
except ValueError as e:
print("Failed to spawn VMs with following error:\n" + str(e))
print("\nError: Failed to spawn VMs - " + str(e))
return 1
print("DONE")

Expand Down
10 changes: 4 additions & 6 deletions cf_remote/spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,24 +308,22 @@ def spawn_vm_in_aws(
size=None,
role=None,
):
if platform not in aws_platforms:
raise ValueError("Platform '%s' does not exist. (Available platforms: %s)" % (platform,
", ".join(cloud_data.aws_platforms.keys())))
try:
driver = get_cloud_driver(Providers.AWS, aws_creds, region)
existing_vms = driver.list_nodes()
except InvalidCredsError as error:
raise ValueError(
"Invalid credentials, check cloud_config.json file, details: \n"
+ str(error)
)
"Invalid credentials, check cloud_config.json (%s.)" % str(error)[1:-1])
if name is None:
name = _get_unused_name(
[vm.name for vm in existing_vms], platform, _NAME_RANDOM_PART_LENGTH
)
else:
if any(vm.state in (0, "running") and vm.name == name for vm in existing_vms):
raise ValueError("VM with the name '%s' already exists" % name)
if not platform in aws_platforms:
raise ValueError("Platform '%s' does not exist.\nList of available platforms:\n%s" % (platform,
"\n".join(cloud_data.aws_platforms.keys())))
aws_platform = aws_platforms[platform]
size = size or aws_platform.get("xlsize") or aws_platform["size"]
user = aws_platform.get("user")
Expand Down

0 comments on commit 82de565

Please sign in to comment.