示例#1
0
    def startReplication(self, containerId, volumeId, nodeId, cargoServer, payload):
        payloadJson = json.loads(payload)
        srchost = payloadJson["srchost"]
        volume = payloadJson["volume"]
        volcnt = payloadJson["volcnt"]
        mondir = utils.getCOWDir(containerId, volcnt)
        lzcopydir = utils.getLazyCopyDir(containerId, volcnt)        
        nfsdir = utils.getNFSMountDir(containerId, volcnt)

        cmd = START_LAZY_COPY_CMD.substitute(PWD = os.getcwd(), MON_DIR = mondir, NFS_DIR = nfsdir, SRC_DIR = volume, \
            DEST_DIR = lzcopydir, SRC_HOST = srchost, CONTAINER = containerId,\
            CARGO_SERVER = cargoServer, VOLUMEID = volumeId, AGENTID = nodeId)
       
        svcName = utils.createReplSvc(containerId, volumeId, cmd)
        rc, output = utils.startSvc(svcName)
        if rc != codes.SUCCESS :
            logging.error("Error starting replication service %s: %s"%(svcName, output))
        else:
            logging.debug("Replication service %s started successfully"%(svcName))
        
        return rc
示例#2
0
    def prepareTargetFS(self, config):
        containerName = config["container"]
        sourceHost = config["sourceHost"]
        exportPath = config["exportPath"]
       	volcnt = config["volcnt"]
	 
        #nfsMount = "{home}/nfs_{name}_{cnt}".format(home=CARGO_VOL_DIR,name = containerName, cnt = volcnt)
        #cowdir = "{home}/cow_{name}_{cnt}".format(home=CARGO_VOL_DIR,name = containerName, cnt = volcnt)
        #unionMount = "{home}/union_{name}_{cnt}".format(home=CARGO_VOL_DIR,name = containerName, cnt = volcnt)
        #lzcopydir = "{home}/lzcopy_{name}_{cnt}".format(home=CARGO_VOL_DIR,name = containerName, cnt = volcnt)
        nfsMount = utils.getNFSMountDir(containerName, volcnt)
        cowdir = utils.getCOWDir(containerName, volcnt)
        unionMount = utils.getUnionMountDir(containerName, volcnt)
        lzcopydir = utils.getLazyCopyDir(containerName, volcnt)

        #unionMount = exportPath
        nfsexport = "{host}:{path}".format(host=sourceHost, path = exportPath)

        if self.__nfs_import(nfsexport, nfsMount) == codes.SUCCESS:
                if self.__merge_fs(nfsMount, cowdir, unionMount) == codes.SUCCESS:
                    self.__storeMeta(containerName, nfsMount, cowdir, unionMount, lzcopydir)
                    return codes.SUCCESS

        return codes.FAILED
示例#3
0
    def startReplication(self, containerId, volumeId, nodeId, cargoServer,
                         payload):
        payloadJson = json.loads(payload)
        srchost = payloadJson["srchost"]
        volume = payloadJson["volume"]
        volcnt = payloadJson["volcnt"]
        mondir = utils.getCOWDir(containerId, volcnt)
        lzcopydir = utils.getLazyCopyDir(containerId, volcnt)
        nfsdir = utils.getNFSMountDir(containerId, volcnt)

        cmd = START_LAZY_COPY_CMD.substitute(PWD = os.getcwd(), MON_DIR = mondir, NFS_DIR = nfsdir, SRC_DIR = volume, \
            DEST_DIR = lzcopydir, SRC_HOST = srchost, CONTAINER = containerId,\
            CARGO_SERVER = cargoServer, VOLUMEID = volumeId, AGENTID = nodeId)

        svcName = utils.createReplSvc(containerId, volumeId, cmd)
        rc, output = utils.startSvc(svcName)
        if rc != codes.SUCCESS:
            logging.error("Error starting replication service %s: %s" %
                          (svcName, output))
        else:
            logging.debug("Replication service %s started successfully" %
                          (svcName))

        return rc