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
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
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
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()
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()
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