示例#1
0
    def getEnabledComponentList(self, session: Session,
                                name: str) -> TortugaObjectList:
        """
        Get a list of enabled components from the db.

            Returns:
                node
            Throws:
                DbError
        """

        try:
            componentList = TortugaObjectList()

            for c in self._softwareProfilesDbHandler.getSoftwareProfile(
                    session, name).components:
                self.loadRelation(c, 'kit')

                componentList.append(Component.getFromDbDict(c.__dict__))

            return componentList
        except TortugaException:
            raise
        except Exception as ex:
            self._logger.exception(str(ex))
            raise
示例#2
0
    def getBestMatchComponent(self, session: Session, name, version, osInfo,
                              kitId):
        """
        Get component from the db.

            Returns:
                component
            Throws:
                ComponentNotFound
                DbError
        """

        try:
            dbComponent = self._componentsDbHandler.getBestMatchComponent(
                session, name, version, osInfo, kitId)

            self.loadRelations(
                dbComponent, {
                    'os': True,
                    'family': True,
                    'kit': True,
                    'os_components': True,
                    'osfamily_components': True,
                })

            return Component.getFromDbDict(dbComponent.__dict__)
        except TortugaException:
            raise
        except Exception as ex:
            self.getLogger().exception('%s' % ex)
            raise
示例#3
0
    def getComponent(self, session: Session, name: str, version: str,
                     osInfo: OsInfo,
                     optionDict: Optional[Union[dict, None]] = None) \
            -> Component:
        """
        Get component from the db.

            Returns:
                component
            Throws:
                ComponentNotFound
                DbError
        """
        try:
            dbComponent = self._componentsDbHandler.getComponentByOsInfo(
                session, name, version, osInfo)

            self.loadRelations(dbComponent, optionDict)

            return Component.getFromDbDict(dbComponent.__dict__)
        except TortugaException:
            raise
        except Exception as ex:
            self.getLogger().exception('%s' % ex)
            raise
示例#4
0
    def getEnabledComponentList(self, name):
        """
        Get a list of enabled components from the db.

            Returns:
                node
            Throws:
                DbError
        """

        session = DbManager().openSession()

        try:
            componentList = TortugaObjectList()

            for c in self._softwareProfilesDbHandler.getSoftwareProfile(
                    session, name).components:
                self.loadRelation(c, 'kit')

                componentList.append(Component.getFromDbDict(c.__dict__))

            return componentList
        except TortugaException as ex:
            raise
        except Exception as ex:
            self.getLogger().exception('%s' % ex)
            raise
        finally:
            DbManager().closeSession()
示例#5
0
    def getComponent(self, name, version, osInfo, optionDict=None):
        """
        Get component from the db.

            Returns:
                component
            Throws:
                ComponentNotFound
                DbError
        """

        session = DbManager().openSession()

        try:
            dbComponent = self._componentsDbHandler.getComponentByOsInfo(
                session, name, version, osInfo)

            self.loadRelations(dbComponent, optionDict or {})

            return Component.getFromDbDict(dbComponent.__dict__)
        except TortugaException as ex:
            raise
        except Exception as ex:
            self.getLogger().exception('%s' % ex)
            raise
        finally:
            DbManager().closeSession()
示例#6
0
    def __retrieveAllKitData(self, dbKit, kit):
        """
        Retrieve full kit data from the db.
        """

        for dbComponent in dbKit.components:
            # Force loading of OS/OS familyinfo
            self.loadRelations(dbComponent, {
                'os_components': True,
                'osfamily_components': True,
            })

            # Convert into component object
            c = Component.getFromDbDict(dbComponent.__dict__)

            # Associate component with kit
            kit.addComponent(c)

        kit.setSources(self.getTortugaObjectList(KitSource, dbKit.sources))

        return kit