Exemplo n.º 1
0
class EmVersionManager(object):
    '''
    Simplified version of versionmgr.py found in autooam.
    This class finds the tar ball file to be used in a db install.
    '''
    def __init__(self):
        '''
        Constructor.
        
        Ensure that package directory exists.
        '''
        self._basedir = common.props['cluster.emversionmgr.packages_base']

        if not os.path.exists(self._basedir):
            raise Exception("Package reference directory %s does not exist!" %
                            self._basedir)

        self._pkgfilenameparser = PkgFileNameParser()

    def retrieve(self, version, ptype):
        '''locates the specified package type.

        @param version - version to retrieve.
        @param ptype   - package type.  One of 'bin', 'deb', or 'rpm'
        Returns the relative path to the package tarball which is
        guaranteed to be located in /opt/infinidb/em/packages/database.
        
        Raises exceptions on failure to locate the specified package
        (or other misc. errors such as a bad type, etc.).
        '''
        if not ptype in ['binary']:  # presently only support binary
            raise Exception("Unsupported package type %s!" % ptype)

        # search for applicable pkg in self._basedir
        for p in os.listdir(self._basedir):
            mat = self._pkgfilenameparser.match(ptype, p)
            if mat and (self._pkgfilenameparser.get_pkg_version(p) == version):
                return p

        raise Exception("No %s package found in %s for version %s" %
                        (ptype, self._basedir, version))
Exemplo n.º 2
0
class EmVersionManager(object):
    """
    Simplified version of versionmgr.py found in autooam.
    This class finds the tar ball file to be used in a db install.
    """

    def __init__(self):
        """
        Constructor.
        
        Ensure that package directory exists.
        """
        self._basedir = common.props["cluster.emversionmgr.packages_base"]

        if not os.path.exists(self._basedir):
            raise Exception("Package reference directory %s does not exist!" % self._basedir)

        self._pkgfilenameparser = PkgFileNameParser()

    def retrieve(self, version, ptype):
        """locates the specified package type.

        @param version - version to retrieve.
        @param ptype   - package type.  One of 'bin', 'deb', or 'rpm'
        Returns the relative path to the package tarball which is
        guaranteed to be located in /opt/infinidb/em/packages/database.
        
        Raises exceptions on failure to locate the specified package
        (or other misc. errors such as a bad type, etc.).
        """
        if not ptype in ["binary"]:  # presently only support binary
            raise Exception("Unsupported package type %s!" % ptype)

        # search for applicable pkg in self._basedir
        for p in os.listdir(self._basedir):
            mat = self._pkgfilenameparser.match(ptype, p)
            if mat and (self._pkgfilenameparser.get_pkg_version(p) == version):
                return p

        raise Exception("No %s package found in %s for version %s" % (ptype, self._basedir, version))