Record server.id in server creation exception

If an error happens in the initial creation, no id is returned
to the server can't be cleaned up.

Change-Id: Ieb818dcf9ded062f016a3f96342f320dc203edd0
This commit is contained in:
Monty Taylor 2017-09-15 10:55:43 -06:00
parent 714dabcc33
commit 2c24e204a6
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
3 changed files with 16 additions and 2 deletions

View File

@ -0,0 +1,4 @@
---
features:
- server creation errors now include the server id in the
Exception to allow people to clean up.

View File

@ -54,6 +54,16 @@ class OpenStackCloudException(Exception):
return message return message
class OpenStackCloudCreateException(OpenStackCloudException):
def __init__(self, resource, resource_id, extra_data=None, **kwargs):
super(OpenStackCloudCreateException, self).__init__(
message="Error creating {resource}: {resource_id}".format(
resource=resource, resource_id=resource_id),
extra_data=extra_data, **kwargs)
self.resource_id = resource_id
class OpenStackCloudTimeout(OpenStackCloudException): class OpenStackCloudTimeout(OpenStackCloudException):
pass pass

View File

@ -6605,8 +6605,8 @@ class OpenStackCloud(
# going to do the wait loop below, this is a waste of a call # going to do the wait loop below, this is a waste of a call
server = self.get_server_by_id(server.id) server = self.get_server_by_id(server.id)
if server.status == 'ERROR': if server.status == 'ERROR':
raise OpenStackCloudException( raise OpenStackCloudCreationException(
"Error in creating the server.") resource='server', resource_id=server.id)
if wait: if wait:
server = self.wait_for_server( server = self.wait_for_server(