示例#1
0
    def get_software_profiles_with_component(
            self,
            session: Session,
            kit_name: str,
            component_name: str,
            *,
            kit_version: Optional[str] = None) -> List[SoftwareProfile]:         \
            # pylint: disable=no-self-use
        """
        Return list of software profiles with component enabled.

        Raises:
            ResourceNotFound
        """

        try:
            q = session.query(Component).join(Kit)

            if kit_version:
                q = q.filter(
                    and_(Kit.name == kit_name, Kit.version == kit_version))
            else:
                q = q.filter(Kit.name == kit_name)

            return q.filter(
                Component.name == component_name).one().softwareprofiles
        except NoResultFound:
            raise ResourceNotFound(
                f'Component [{component_name}] (from kit [{kit_name}]) not'
                ' found')
示例#2
0
def getResourceAdapterClass(adapter_name):
    for adapter in find_resource_adapters():
        if adapter.__adaptername__ == adapter_name:
            return adapter

    raise ResourceNotFound(
        'Unable to find resource adapter [{0}]'.format(adapter_name))
def get_resourceadapter_class(adapter_name: str):
    """
    Gets the resource adapter class for the given resource adapter name.

    :param adapter_name:      the name of the resource adapter
    :return ResourceAdatper:  a resource adapter class
    :raises ResourceNotFound:

    """
    for adapter in find_resourceadapters():
        if adapter.__adaptername__ == adapter_name:
            return adapter

    raise ResourceNotFound(
        'Unable to find resource adapter [{0}]'.format(adapter_name))
示例#4
0
    def instanceCacheGet(self, nodeName):
        self.getLogger().debug('instanceCacheGet(nodeName=[%s])' % (nodeName))

        cfg = self.instanceCacheRefresh()

        if not cfg.has_section(nodeName):
            raise ResourceNotFound(
                'No instance cache entry for [{0}]'.format(nodeName))

        # Read entire section into a dict
        result = {}

        for key, value in cfg.items(nodeName):
            result[key] = value

        return result
    def get(self, session: Session, resadapter_name: str, name: str) \
            -> ResourceAdapterConfig:
        """
        Returns resource adapter configuration

        Raises:
            ResourceNotFound
            ResourceAdapterNotFound
        """

        self.getLogger().debug(
            'ResourceAdapterConfigDbHandler.get(resadapter_name=[{}],'
            ' name=[{}]'.format(resadapter_name, name))

        try:
            return session.query(ResourceAdapterConfig).join(
                ResourceAdapter).filter(
                    and_(ResourceAdapter.name == resadapter_name,
                         ResourceAdapterConfig.name == name)).one()
        except NoResultFound:
            raise ResourceNotFound(
                'Resource adapter configuration [{1}] does not exist for'
                ' resource adapter [{0}]'.format(resadapter_name, name))
示例#6
0
 def __raise_not_found_exception(self, resadapter_name, name):
     raise ResourceNotFound(
         'Resource adapter configuration [{1}] does not exist for'
         ' resource adapter [{0}]'.format(resadapter_name, name))