def Run_ds_job_on_windows(ds_node, ds_user, ds_pwd, job_name, job_stream_params, **kw): conf = ReadConfig() host_info = conf.Read_ds_conf(ds_node) cmd_path = conf.Read_DS_command_path() job_stream_parameter_list = conf.Read_job_stream_parameter_name_list() ########assign job stream to the driver job job_stream_count = len(job_stream_params) job_stream_appendix = '' for i in range(len(job_stream_parameter_list)): job_stream = ' -param ' + job_stream_parameter_list[ i] + '=' + '"' + job_stream_params[i] + '"' job_stream_appendix += job_stream #print(job_stream_appendix) ##########assign other input parameter to the driver job params_appendix = '' if len(kw) != 0: for key in kw: param = ' -param ' + key + '=' + '"' + kw[key] + '"' params_appendix += param #print(params_appendix) cmd_str = cmd_path + 'dsjob' + ' -domain ' + host_info['domain'] + ' -user ' + ds_user +' -password ' +ds_pwd \ +' -server ' + host_info['host'] +' -run -wait -mode NORMAL ' + job_stream_appendix + params_appendix \ +' ' + host_info['project'] +' '+job_name cmd_str += '\n' print("DataStage command: " + cmd_str.replace(ds_pwd, '********')) rs = os.popen(cmd=cmd_str, mode='r') print(rs.readlines()) return rs
def test_pre_action(ds_node, ds_user, ds_pwd): ''' define how to run the driver job, if the job is datastage sequence run below code ''' conf = ReadConfig() driver = conf.Read_test_run_driver() driver_type = driver['driver_type'] job_stream_param_name_list = conf.Read_job_stream_parameter_name_list() job_stream_count = len(job_stream_param_name_list) input_parameter = driver['input_parameter'] driver_sequence = driver['driver_job'] '''the job_stream_count will decide how many parallel job stream can run parallelly, that means how many job stream parameter should be assign to the driver sequence ''' if driver_type == 'DataStage': '''when the driver is dataStage assign necessary parameter to the driver job ''' job_stream_params = ['' for i in range(job_stream_count)] job_stream_list = get_dependency_job_list(driver_sequence) for i in range(len(job_stream_list)): param_index = i % job_stream_count job_stream_params[param_index] += job_stream_list[i] + ',' ''' generate other parameters ''' other_params = dict() if input_parameter != '': other_params_list = input_parameter.split(',') for param in other_params_list: other_params[param.split('=')[0]] = param.split('=')[1] print(other_params) ''' send the job_stream_params to the driver sequence to run, input other parameters if necessary ''' DS_Operation.Run_ds_job_on_windows(ds_node, ds_user, ds_pwd, driver_sequence, job_stream_params, **other_params) #''' if the driver is shell, should trigger the shell script with the necessary parameter ''' elif driver_type == 'Shell': pass else: pass