Пример #1
0
    def get_schema(cls, resource_name, operation):
        """Returns the schema for an operation

        :param resource_name: Operation for which resource need
        to be validated.
        :type operation: `six.text_type`

        :param operation: Operation for which params need
        to be validated.
        :type operation: `six.text_type`

        :returns: Operation's schema
        :rtype: dict

        :raises: `errors.InvalidResource` if the resource
        does not exist and `errors.InvalidOperation` if the operation
        does not exist
        """
        try:
            resource_schemas = cls.schema[resource_name]
        except KeyError:
            # TODO(tonytan4ever): gettext support
            msg = _('{0} is not a valid resource name').format(resource_name)
            raise errors.InvalidResourceName(msg)

        try:
            return resource_schemas[operation]
        except KeyError:
            # TODO(tonytan4ever): gettext support
            msg = _('{0} is not a valid operation for resource: {1}').format(
                operation,
                resource_name)
            raise errors.InvalidOperation(msg)
Пример #2
0
    def _wrapper():
        atexit.register(_enable_echo, True)
        _enable_echo(True)

        try:
            conf = cfg.CONF
            log.register_options(conf)
            log.setup(conf, 'poppy')
            func()
        except KeyboardInterrupt:
            LOG.info(_(u'Terminating'))
        except Exception as ex:
            _fail(1, ex)
Пример #3
0
    def _wrapper():
        atexit.register(_enable_echo, True)
        _enable_echo(True)

        try:
            conf = cfg.CONF
            log.register_options(conf)
            log.setup(conf, 'poppy')
            func()
        except KeyboardInterrupt:
            LOG.info(_(u'Terminating'))
        except Exception as ex:
            _fail(1, ex)