diff --git a/releasenotes/notes/server-create-error-id-66c698c7e633fb8b.yaml b/releasenotes/notes/server-create-error-id-66c698c7e633fb8b.yaml new file mode 100644 index 000000000..673c7dcb8 --- /dev/null +++ b/releasenotes/notes/server-create-error-id-66c698c7e633fb8b.yaml @@ -0,0 +1,4 @@ +--- +features: + - server creation errors now include the server id in the + Exception to allow people to clean up. diff --git a/shade/exc.py b/shade/exc.py index 3d29af490..cda469f9c 100644 --- a/shade/exc.py +++ b/shade/exc.py @@ -54,6 +54,16 @@ class OpenStackCloudException(Exception): 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): pass diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 7727dddd6..781a06efd 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -6605,8 +6605,8 @@ class OpenStackCloud( # going to do the wait loop below, this is a waste of a call server = self.get_server_by_id(server.id) if server.status == 'ERROR': - raise OpenStackCloudException( - "Error in creating the server.") + raise OpenStackCloudCreationException( + resource='server', resource_id=server.id) if wait: server = self.wait_for_server(