'InvalidTenant',
'StackNotFound',
'ResourceNotFound',
+ 'ResourceNotAvailable',
'StackExists',
)
'ValueError': client_error,
'StackNotFound': exc.HTTPNotFound,
'ResourceNotFound': exc.HTTPNotFound,
+ 'ResourceNotAvailable': exc.HTTPNotFound,
'InvalidTenant': exc.HTTPForbidden,
'StackExists': exc.HTTPConflict,
}
class ResourceNotFound(OpenstackException):
message = _("The Resource (%(resource_name)s) could not be found "
"in Stack %(stack_name)s.")
+
+
+class ResourceNotAvailable(OpenstackException):
+ message = _("The Resource (%(resource_name)s) is not available.")
def __set__(self, resource, metadata):
'''Update the metadata for the owning resource.'''
if resource.id is None:
- raise AttributeError("Resource has not yet been created")
+ raise exception.ResourceNotAvailable(resource_name=resource.name)
rs = db_api.resource_get(resource.stack.context, resource.id)
rs.update_and_save({'rsrc_metadata': metadata})
resource = stack[resource_name]
if resource.id is None:
- raise AttributeError('Resource not created')
+ raise exception.ResourceNotAvailable(resource_name=resource_name)
return api.format_stack_resource(stack[resource_name])
# License for the specific language governing permissions and limitations
# under the License.
+from heat.common import exception
+
class Timestamp(object):
'''
def __set__(self, obj, timestamp):
'''Update the timestamp for the given object.'''
if obj.id is None:
- raise AttributeError("%s has not yet been created" % str(obj))
+ raise exception.ResourceNotAvailable(resource_name=obj.name)
o = self.db_fetch(obj.context, obj.id)
o.update_and_save({self.attribute: timestamp})
resource_name=res_name)
self.m.VerifyAll()
+ def test_show_uncreated_resource(self):
+ res_name = 'WikiDatabase'
+ stack_identity = identifier.HeatIdentifier(self.tenant,
+ 'wordpress', '1')
+ res_identity = identifier.ResourceIdentifier(resource_name=res_name,
+ **stack_identity)
+
+ req = self._get(res_identity._tenant_path())
+
+ self.m.StubOutWithMock(rpc, 'call')
+ rpc.call(req.context, self.topic,
+ {'method': 'describe_stack_resource',
+ 'args': {'stack_identity': stack_identity,
+ 'resource_name': res_name},
+ 'version': self.api_version},
+ None).AndRaise(rpc_common.RemoteError("ResourceNotAvailable"))
+ self.m.ReplayAll()
+
+ self.assertRaises(webob.exc.HTTPNotFound,
+ self.controller.show,
+ req, tenant_id=self.tenant,
+ stack_name=stack_identity.stack_name,
+ stack_id=stack_identity.stack_id,
+ resource_name=res_name)
+ self.m.VerifyAll()
+
def test_metadata_show(self):
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,