@@ -0,0 +1,2107 @@
+#!/usr/bin/env python%0A%0Aimport argparse%0Aimport ConfigParser%0Aimport httplib%0Aimport json%0Aimport time%0A%0Aparser = argparse.ArgumentParser()%0Aparser.add_argument(%22config%22)%0Aparser.add_argument(%22plans%22, nargs=%22*%22, help=%22query plans %22)%0Aargs = parser.parse_args()%0A%0Asleep_time = 1%0A%0A%0Adef execute(restURL):%0A    for idx, plan in enumerate(args.plans):%0A        # submit a query%0A        print %22submitting %7B%7D%22.format(plan)%0A        headers = %7B%0A            %22Content-type%22: %22application/JSON%22,%0A        %7D%0A        with open(plan, %22r%22) as myfile:%0A            data = myfile.read().replace('%5Cn', '')%0A        conn = httplib.HTTPConnection(restURL)%0A        conn.request(%22POST%22, %22/query%22, data, headers)%0A        response = conn.getresponse()%0A%0A        # raise an exception if something is going wrong%0A        if response.status != 202:%0A            raise Exception(%22 %7B%7D, %7B%7D, %7B%7D%22.format(response.status,%0A                            response.reason, response.read()))%0A%0A        queryStatus = json.load(response)%0A        if queryStatus%5B'status'%5D != 'ACCEPTED':%0A            raise Exception(%22Error in submitting %7B%7D%22.format(plan))%0A        queryId = queryStatus%5B'queryId'%5D%0A%0A        # wait until this query sucess%0A        while idx %3C len(args.plans)-1:%0A            time.sleep(sleep_time)%0A            conn = httplib.HTTPConnection(restURL)%0A            conn.request(%22GET%22, %22/query/query-%7B%7D%22.format(queryId), %22%22, headers)%0A            res = conn.getresponse()%0A            queryStatus = json.load(res)%0A            currentStatus = queryStatus%5B'status'%5D%0A            if(currentStatus == 'SUCCESS'):%0A                break%0A            elif (currentStatus != 'RUNNING'):%0A                raise Exception(%0A                    %22In submitting %7B%7D, error %7B%7D%22.format(plan, currentStatus))%0A%0A%0Adef getRestURL(configFilename):%0A    config = ConfigParser.RawConfigParser(allow_no_value=True)%0A    config.read(configFilename)%0A    master_ip = config.items('master')%5B0%5D%5B1%5D.split(':')%5B0%5D%0A    rest_port = config.get('deployment', 'rest_port')%0A    return %22%7B%7D:%7B%7D%22.format(master_ip, rest_port)%0A%0A%0Aif __name__ == '__main__':%0A    print args.plans%0A    execute(getRestURL(args.config))%0A

add sequential execute script