Skip to content

Commit

Permalink
Give a nicer error on image creation failures, refs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
jochumdev committed Mar 17, 2018
1 parent c556ff3 commit 909fe54
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions _modules/lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2783,9 +2783,13 @@ def image_from_simplestreams(server,
aliases = []

client = pylxd_client_get(remote_addr, cert, key, verify_cert)
image = client.images.create_from_simplestreams(
server, alias, public=public, auto_update=auto_update
)

try:
image = client.images.create_from_simplestreams(
server, alias, public=public, auto_update=auto_update
)
except pylxd.exceptions.LXDAPIException as e:
raise CommandExecutionError(six.text_type(e))

# Aliases support
for alias in aliases:
Expand Down Expand Up @@ -2860,9 +2864,13 @@ def image_from_url(url,
aliases = []

client = pylxd_client_get(remote_addr, cert, key, verify_cert)
image = client.images.create_from_url(
url, public=public, auto_update=auto_update
)

try:
image = client.images.create_from_url(
url, public=public, auto_update=auto_update
)
except pylxd.exceptions.LXDAPIException as e:
raise CommandExecutionError(six.text_type(e))

# Aliases support
for alias in aliases:
Expand Down Expand Up @@ -2942,7 +2950,11 @@ def image_from_file(filename,
data = fp.read()

client = pylxd_client_get(remote_addr, cert, key, verify_cert)
image = client.images.create(data, public=public, wait=True)

try:
image = client.images.create(data, public=public, wait=True)
except pylxd.exceptions.LXDAPIException as e:
raise CommandExecutionError(six.text_type(e))

# Aliases support
for alias in aliases:
Expand Down

0 comments on commit 909fe54

Please sign in to comment.