Example #1
0
def main():
    print('Tiandi Workflow')
    metadataClient = conductor.MetadataClient('http://10.60.38.173:18080/api')
    workflowClient = conductor.WorkflowClient('http://10.60.38.173:18080/api')

    tasks = metadataClient.getAllTaskDefs()

    with open("mockJson/mockTask.json", 'r') as load_mockTask:
        taskJsonObj = json.load(load_mockTask)
        print(taskJsonObj)
        for (k, v) in taskJsonObj.items():
            print(k)
            print(v)
            registerTask(metadataClient, v)

    # ----- tiandi demo for unregisterTask -----
    # for (k, v) in taskJsonObj.items():
    #     for item in v:
    #         unregisterTask(metadataClient,item['name'])

    with open("mockJson/mockMetadata.json", 'r') as load_mockMetadata:
        metadataJsonArr = json.load(load_mockMetadata)
        for item in metadataJsonArr:
            try:
                metadataClient.createWorkflowDef(item)
            except Exception as err:
                print(err)
            workflowClient.startWorkflow(item['name'],
                                         {'inputString': 'xietiandi666'})
Example #2
0
def main():
    if (len(sys.argv) < 3):
        print "Usage - python conductor server_url command parameters..."
        return None

    wfc = conductor.WorkflowClient(sys.argv[1])
    command = sys.argv[2]
    if command == 'start':
        if len(sys.argv) < 5:
            print 'python conductor server_url start workflow_name input_json [version] [correlationId]'
            return None
        wfName = sys.argv[3]
        input = json.loads(sys.argv[4])
        workflowId = wfc.startWorkflow(wfName, input, 1, None)
        print workflowId
        return workflowId
    elif command == 'get':
        if len(sys.argv) < 4:
            print 'python conductor server_url get workflow_id'
            return None
        wfId = sys.argv[3]
        wfjson = wfc.getWorkflow(wfId)
        print json.dumps(wfjson, indent=True, separators=(',', ': '))
        return wfjson
    elif command == 'terminate':
        if len(sys.argv) < 4:
            print 'python conductor server_url terminate workflow_id'
            return None
        wfId = sys.argv[3]
        wfjson = wfc.terminateWorkflow(wfId)
        print 'OK'
        return wfId
Example #3
0
 def __init__(self, serverAddr):
     self._serverAddr = serverAddr + '/api'
     self._metaDataClient = conductor.MetadataClient(self._serverAddr)
     self._workflowClient = conductor.WorkflowClient(self._serverAddr)
     self._tasksDefined = False
     self._workflowDefined = False
     self._workflowName = ""
Example #4
0
 def start_wf(self, wfName, inputjson, wf_server_path):
     wf_client = conductor.WorkflowClient(wf_server_path)
     wf_client.startWorkflow(wfName = wfName, inputjson = inputjson)
     print("--Finish invoking workflow %s" % wfName)
Example #5
0
 def get_wf(self, wfId):
     wf_client = conductor.WorkflowClient(self.wf_server_path)
     return wf_client.getWorkflow(wfId, includeTasks=False)
Example #6
0
 def start_wf(self, wfName, inputjson):
     wf_client = conductor.WorkflowClient(self.wf_server_path)
     wf_id = wf_client.startWorkflow(wfName=wfName, inputjson=inputjson)
     #        print("Finish invoking workflow %s" % wfName)
     return wf_id
def get_wf(wfId):
    wf_client = conductor.WorkflowClient(WF_SERVER_PATH)
    return wf_client.getWorkflow(wfId, includeTasks=False)
def start_wf(wfName, inputjson):
    wf_client = conductor.WorkflowClient(WF_SERVER_PATH)
    wf_client.startWorkflow(wfName=wfName, inputjson=inputjson)
    print("Finish invoking workflow %s" % wfName)