Example #1
0
    def getRepo(self, osInfo=None):
        """ Return repo given os info. """

        if not osInfo:
            osInfo = osUtility.getNativeOsInfo()

        osKey = '%s__%s__%s' % (osInfo.getName(), osInfo.getVersion(),
                                osInfo.getArch())

        return self._repoMap.get(osKey)
Example #2
0
def getOsInfo(osName=None, osVersion=None, osArch=None):
    if osName is not None:
        osConfigClass = getOsConfigClass(osName)

        osconfig = osConfigClass(osName, osVersion, osArch)
    else:
        nativeOsInfo = osUtility.getNativeOsInfo()

        osConfigClass = getOsConfigClass(nativeOsInfo.getName())

        osconfig = osConfigClass(nativeOsInfo.getName(),
                                 nativeOsInfo.getVersion(),
                                 nativeOsInfo.getArch())

    _osInfo = osInfo.OsInfo(osconfig.name, osconfig.vers, osconfig.arch)

    _osFamilyInfo = osFamilyInfo.OsFamilyInfo(
        osconfig.family, osconfig.familyvers, osconfig.arch)

    _osInfo.setOsFamilyInfo(_osFamilyInfo)

    return _osInfo
Example #3
0
    def __configure(self):
        """ Configure all repositories from the config file. """

        self._kitArchiveDir = self._cm.getKitDir()
        configFile = self._cm.getRepoConfigFile()

        if not os.path.exists(configFile):
            self._logger.debug('Repo configuration file [%s] not found' %
                               (configFile))
        else:
            self._logger.debug('Reading repo configuration file [%s]' %
                               (configFile))

        configParser = configparser.ConfigParser()
        configParser.read(configFile)

        try:
            osKeyList = configParser.sections()

            if osKeyList:
                self._logger.debug('Found OS sections [%s]' %
                                   (' '.join(osKeyList)))

            for osKey in osKeyList:
                self._logger.debug('Parsing OS section [%s]' % (osKey))

                osData = osKey.split('__')
                osName = osData[0]
                osVersion = osData[1]
                osArch = osData[2]
                osInfo = OsInfo(osName, osVersion, osArch)

                # Ignore all repos that weren't enabled
                bEnabled = True
                if configParser.has_option(osKey, 'enabled'):
                    value = configParser.get(osKey, 'enabled')
                    bEnabled = value.lower() == 'true'

                if not bEnabled:
                    self._logger.debug('Repo for [%s] is disabled' % (osInfo))

                    continue

                localPath = None
                if configParser.has_option(osKey, 'localPath'):
                    localPath = configParser.get(osKey, 'localPath', True)

                if not localPath:
                    localPath = self._repoRoot

                remoteUrl = None
                if configParser.has_option(osKey, 'remoteUrl'):
                    remoteUrl = configParser.get(osKey, 'remoteUrl', True)

                repo = self.__configureRepo(osInfo, localPath, remoteUrl)

                self._repoMap[osKey] = repo

            if not os.path.exists(self._kitArchiveDir):
                self._logger.debug('Creating kit archive directory [%s]' %
                                   (self._kitArchiveDir))

                os.makedirs(self._kitArchiveDir)

            osInfo = osUtility.getNativeOsInfo()

            repo = self.__configureRepo(osInfo, self._repoRoot)

            osKey = '%s__%s__%s' % (osInfo.getName(), osInfo.getVersion(),
                                    osInfo.getArch())

            # Configure repo for native os if there are no repos configured.
            if osKey not in self._repoMap:
                self._repoMap[osKey] = repo
        except ConfigurationError:
            raise
        except Exception as ex:
            raise ConfigurationError(exception=ex)