Пример #1
0
def main(args=sys.argv):

    if len(args) == 9:
        print("Starting the daemon ...")

        #Run as daemon
        #daemon.daemonize("cb-scheduled-xdcr.pid")

        url = args[1]
        user = args[2]
        password = args[3]
        source_bucket = args[4]
        target_bucket = args[5]
        target_cluster = args[6]
        start_time = args[7]
        interval = float(args[8])

        #Parse the date
        start_time_arr = parse_data_arg(start_time)

        #Make sure that XDCR is paused
        link_id = xdcrclient.link_id(url, user, password, source_bucket,
                                     target_bucket, target_cluster)
        xdcrclient.pause(url, user, password, link_id)

        #Prepare the job  parameters and schedule the job
        params = {
            "url": url,
            "user": user,
            "password": password,
            "source_bucket": source_bucket,
            "target_bucket": target_bucket,
            "target_cluster": target_cluster,
            "start_time_arr": start_time_arr,
            "interval": interval
        }

        print("Scheduling the job ...")
        print("params = " + str(params))

        jobscheduler.run(start_time_arr[0], start_time_arr[1],
                         start_time_arr[2], start_time_arr[3],
                         start_time_arr[4], interval, run_and_pause, params)

    else:
        usage()
def main(args = sys.argv):

    if len(args) == 9:
        print("Starting the daemon ...")

        #Run as daemon
        #daemon.daemonize("cb-scheduled-xdcr.pid")

        url = args[1]
        user = args[2]
        password = args[3]
        source_bucket = args[4]
        target_bucket = args[5]
        target_cluster = args[6]
        start_time = args[7]
        interval = float(args[8])

        #Parse the date
        start_time_arr = parse_data_arg(start_time)

        #Make sure that XDCR is paused
        link_id = xdcrclient.link_id(url, user, password, source_bucket,target_bucket,target_cluster)
        xdcrclient.pause(url,user,password,link_id)


        #Prepare the job  parameters and schedule the job
        params = { "url" : url, "user" : user, "password" : password, "source_bucket" : source_bucket,
                   "target_bucket" : target_bucket, "target_cluster" : target_cluster,
                   "start_time_arr" : start_time_arr, "interval" : interval }

        print("Scheduling the job ...")
        print("params = " + str(params))

        jobscheduler.run(start_time_arr[0],start_time_arr[1],start_time_arr[2],start_time_arr[3],start_time_arr[4],interval,run_and_pause,params)

    else:
        usage()
def test_run():
    print("Testing to run a job ...")
    params = {"msg" : "Hello world"}
    jobscheduler.run(2015, 8, 31, 16, 19, 120, hello, params)