Example #1
0
    def __storeMeta(self, containerName, nfsMount, cowdir, unionMount, lzcopydir):
        mdfile = utils.getContainerMDFile(containerName)
        volMap = {}
        newVol = {}
        newVol["nfs"] = nfsMount
        newVol["cow"] = cowdir
        newVol["union"] = unionMount
        newVol["lazy"] = lzcopydir

        if os.path.exists(mdfile):
            volMap = pickle.load( open( mdfile, "rb" ))            
        volMap[unionMount] = newVol
        pickle.dump( volMap, open( mdfile, "wb" ) )
Example #2
0
    def failoverVolumes(self, containerId):
        mdfile = utils.getContainerMDFile(containerId)
        rc = codes.SUCCESS
        volMap = {}
        if os.path.exists(mdfile):
            volMap = pickle.load( open( mdfile, "rb" ))            
        
        for unionMout, mountMap in volMap.items():
            logging.debug("Starting failover for volume: %s"%(unionMout))
            #1. unmount the aufs directory
            logging.debug("Un-mounting aufs mount point : %s"%(unionMout))
            
            cmd = UNMOUNT_CMD.substitute(MOUNT = str(unionMout))
            rc = self.__exec(cmd)
            if rc == codes.SUCCESS:
                logging.debug("aufs mount point unmounted successfully: %s"%(unionMout))
            else:
                return rc

            #2. delete aufs mount directory
            umdir = unionMout.rstrip('/')
            cmd = "rm -rf %s"%(umdir)
            rc = self.__exec(cmd)
            if rc == codes.SUCCESS:
                logging.debug("aufs mount point deleted successfully %s"%(unionMout))
            else:
                return rc

            #3. rename lazy directory to mount point
            lazycopyDir = volMap[unionMout]["lazy"].rstrip("/")
            os.rename(lazycopyDir, umdir)

            logging.debug("lazycopy directory renamed from %s to %s"%(lazycopyDir, umdir))
            #4. hard-link from cow to unin mount directory
            cmd = COPY_WITH_HARDLINKS.substitute(SRC = volMap[unionMout]["cow"], TARGET = unionMout)
            rc = self.__exec(cmd)
            if rc  == codes.SUCCESS:
                logging.debug("Data files hard-linked successfully")
            else:
                return rc

            #5. unmount nfs
            cmd = UNMOUNT_CMD.substitute(MOUNT = volMap[unionMout]["nfs"])
            self.__exec(cmd)

            return rc