Пример #1
0
    def get_class(self, resource_type, resource_name=None):
        if resource_type == "":
            msg = _('Resource "%s" has no type') % resource_name
            raise exception.InvalidResourceType(message=msg)
        elif resource_type is None:
            msg = _('Non-empty resource type is required '
                    'for resource "%s"') % resource_name
            raise exception.InvalidResourceType(message=msg)
        elif not isinstance(resource_type, six.string_types):
            msg = _('Resource "%s" type is not a string') % resource_name
            raise exception.InvalidResourceType(message=msg)

        info = self.get_resource_info(resource_type,
                                      resource_name=resource_name)
        if info is None:
            raise exception.ResourceTypeNotFound(type_name=resource_type)
        return info.get_class()
Пример #2
0
 def test_heat_exception(self):
     local = exception.InvalidResourceType(message='test')
     self.assertRaises(exception.InvalidResourceType,
                       self.parent_resource.raise_local_exception, local)