示例#1
0
    def get(cls, resource, service=None, feature=None, **kwargs):
        """
        Look up a model instance for this resource based on its build info

        Either feature or service must be specified, but not both.

        :param resource: The resource for which we are looking up a model.
        :param service: The lumberjack service, if there is a single service
            that the model represents.  Either this or `feature` must
            be specified, but not both.
        :param feature: The feature (which may be a grouping of lumberjack
            services or a legacy non-lumberjack area) that the model
            represents.  Either this or `service` must be specified,
            but not both.

        :return: An instance of the appropriate model class.

        :raises steelscript.common.factory.FactoryLookupError: if no model can
            be found.
        :raises ImportError: if a module was found but failed to import
            properly.  Other errors that Python may raise while importing
            a module may also be raised out of this method.
        """
        # TODO: Read the build_info from the resource.  Right now 'None'
        # just means 'use the latest'.
        build_info = None

        model_callable = factory.get_by_standard_fwk_layout(
            build_info=build_info,
            module_name='model',
            service=service,
            feature=feature,
            check=_check_model,
            first_fail=True)
        return model_callable(resource, **kwargs)
示例#2
0
    def get(cls, resource, service=None, feature=None, **kwargs):
        """
        Look up a model instance for this resource based on its build info

        Either feature or service must be specified, but not both.

        :param resource: The resource for which we are looking up a model.
        :param service: The lumberjack service, if there is a single service
            that the model represents.  Either this or `feature` must
            be specified, but not both.
        :param feature: The feature (which may be a grouping of lumberjack
            services or a legacy non-lumberjack area) that the model
            represents.  Either this or `service` must be specified,
            but not both.

        :return: An instance of the appropriate model class.

        :raises steelscript.common.factory.FactoryLookupError: if no model can
            be found.
        :raises ImportError: if a module was found but failed to import
            properly.  Other errors that Python may raise while importing
            a module may also be raised out of this method.
        """
        # TODO: Read the build_info from the resource.  Right now 'None'
        # just means 'use the latest'.
        build_info = None

        model_callable = factory.get_by_standard_fwk_layout(
            build_info=build_info,
            module_name='model',
            service=service,
            feature=feature,
            check=_check_model,
            first_fail=True)
        return model_callable(resource, **kwargs)
示例#3
0
    def get(cls, resource, service=None, feature=None, **kwargs):
        """
        Look up an action instance for this resource based on its build info

        The location is further specified by the given service or feature.
        Either feature or service must be specified, but not both.

        :param resource: The resource for which we are looking up an action.
        :param service: The REST service, if there is a single service that
            the action represents.  Either this or `feature` must
            be specified, but not both.
        :param feature: The feature (which may be a grouping of REST services
            or a legacy non-REST area) that the action represents.  Either
            this or `service` must be specified, but not both.

        :return: An instance of the appropriate action class.

        :raises ValueError: if the version lookup returns data that this method
            does not understand.
        :raises pq_runtime.factory.FactoryLookupError: if no action can
            be found.
        :raises ImportError: if a module was found but failed to import
            properly.  Other errors that Python may raise while importing
            a module may also be raised out of this method.
        """
        # TODO: Read the build_info from the resource.  Right now 'None'
        # just means 'use the latest'.
        build_info = None

        action_callable = factory.get_by_standard_fwk_layout(
            build_info=build_info,
            module_name='action',
            service=service,
            feature=feature,
            check=_check_action,
            first_fail=True)
        return action_callable(resource,
                               service=service,
                               feature=feature,
                               **kwargs)
示例#4
0
    def get(cls, resource, service=None, feature=None, **kwargs):
        """
        Look up an action instance for this resource based on its build info

        The location is further specified by the given service or feature.
        Either feature or service must be specified, but not both.

        :param resource: The resource for which we are looking up an action.
        :param service: The REST service, if there is a single service that
            the action represents.  Either this or `feature` must
            be specified, but not both.
        :param feature: The feature (which may be a grouping of REST services
            or a legacy non-REST area) that the action represents.  Either
            this or `service` must be specified, but not both.

        :return: An instance of the appropriate action class.

        :raises ValueError: if the version lookup returns data that this method
            does not understand.
        :raises pq_runtime.factory.FactoryLookupError: if no action can
            be found.
        :raises ImportError: if a module was found but failed to import
            properly.  Other errors that Python may raise while importing
            a module may also be raised out of this method.
        """
        # TODO: Read the build_info from the resource.  Right now 'None'
        # just means 'use the latest'.
        build_info = None

        action_callable = factory.get_by_standard_fwk_layout(
            build_info=build_info,
            module_name='action',
            service=service,
            feature=feature,
            check=_check_action,
            first_fail=True)
        return action_callable(resource, service=service, feature=feature,
                               **kwargs)
示例#5
0
    def _get_ui_delegatee(self, class_hint, module_name=None):
        # Factory lookup to get all the delegatee classes (REST/CLI/Web)
        if module_name is None:
            # The UI classes share the same module as the delegator class, so
            # use self.__module__ to default the module name.
            module_name = self.__module__.split('.')[-1]

        check_class = lambda c: type(c) is type and c.__name__ == class_hint
        check_class.__doc__ = 'class name is "%s"' % class_hint

        # TODO: Read the build_info from the resource.  Right now 'None'
        # just means 'use the latest'.
        build_info = None

        ui_class = factory.get_by_standard_fwk_layout(
            build_info=build_info,
            module_name=module_name,
            service=self._service,
            feature=self._feature,
            check=check_class)
        return ui_class(resource=self._resource,
                        service=self._service,
                        feature=self._feature)