Esempio n. 1
0
    def DSLoadLibrary(self, api_lib_file):
        """
        api_lib_file - full path to DataStage API library
            vmdsapi.dll on windows
            or
            libvmdsapi.so on *nix

        PATH on windows should include directory where file 'vmdsapi.dll' is located
        in most cases, in the '../IBM/InformationServer/Clients/Classic/'

        LD_LIBRARY_PATH on *nix should include directory where file 'libvmdsapi.so' and its dependencies are located
        in most cases, in the '../IBM/InformationServer/Server/DSEngine/lib/'
        """

        if not os.path.exists(api_lib_file) or not os.path.isfile(
                api_lib_file):
            return None, DSAPIERROR.create_error(
                "DSLoadLibrary",
                "Path to {} doesn't exist".format(api_lib_file))

        try:
            self.__api = ctypes.CDLL(api_lib_file)
        except OSError as e:
            return None, DSAPIERROR.create_error(
                "DSLoadLibrary", "Can't load the library: {}".format(str(e)))

        return True, None
Esempio n. 2
0
    def DSGetJobInfo(self, handleJob, infoType):
        self.__api.DSGetJobInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int,
            ctypes.POINTER(DSJOBINFO)
        ]
        self.__api.DSGetJobInfo.restype = ctypes.c_int

        jobInfo = DSJOBINFO()
        res = self.__api.DSGetJobInfo(handleJob, infoType,
                                      ctypes.pointer(jobInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetJobInfo",
                                                 self.DSGetLastError())
        else:
            if infoType == self.DSJ_JOBSTATUS:
                return jobInfo.info.jobStatus, None
            if infoType == self.DSJ_JOBNAME:
                return jobInfo.info.jobName, None
            if infoType == self.DSJ_JOBCONTROLLER:
                return jobInfo.info.jobController, None
            if infoType == self.DSJ_JOBSTARTTIMESTAMP:
                return jobInfo.info.jobStartTime, None
            if infoType == self.DSJ_JOBWAVENO:
                return jobInfo.info.jobWaveNumber, None
            if infoType == self.DSJ_PARAMLIST:
                return convert_char_p_to_list(jobInfo.info.paramList), None
            if infoType == self.DSJ_STAGELIST:
                return convert_char_p_to_list(jobInfo.info.stageList), None
            if infoType == self.DSJ_USERSTATUS:
                return jobInfo.info.userStatus, None
            if infoType == self.DSJ_JOBCONTROL:
                return jobInfo.info.jobControl, None
            if infoType == self.DSJ_JOBPID:
                return jobInfo.info.jobPid, None
            if infoType == self.DSJ_JOBLASTTIMESTAMP:
                return jobInfo.info.jobLastTime, None
            if infoType == self.DSJ_JOBINVOCATIONS:
                return convert_char_p_to_list(
                    jobInfo.info.jobInvocations), None
            if infoType == self.DSJ_JOBINTERIMSTATUS:
                return jobInfo.info.jobInterimStatus, None
            if infoType == self.DSJ_JOBINVOCATIONID:
                return jobInfo.info.jobInvocationId, None
            if infoType == self.DSJ_JOBDESC:
                return jobInfo.info.jobDesc, None
            if infoType == self.DSJ_STAGELIST2:
                return convert_char_p_to_list(jobInfo.info.stageList2), None
            if infoType == self.DSJ_JOBELAPSED:
                return jobInfo.info.jobElapsed, None
            if infoType == self.DSJ_JOBDMISERVICE:
                return jobInfo.info.jobDMIService, None
            if infoType == self.DSJ_JOBMULTIINVOKABLE:
                return jobInfo.info.jobMultiInvokable, None
            if infoType == self.DSJ_JOBFULLDESC:
                return jobInfo.info.jobFullDesc, None
            if infoType == self.DSJ_JOBRESTARTABLE:
                return jobInfo.info.jobRestartable, None
            else:
                return '', None
Esempio n. 3
0
    def DSGetReposInfo(self,
                       handleProj,
                       objectType,
                       infoType,
                       searchCriteria,
                       startingCategory,
                       subcategories=1):
        self.__api.DSGetReposInfo.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_int, ctypes.c_int,
            ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int,
            ctypes.POINTER(DSREPOSINFO)
        ]
        self.__api.DSGetReposInfo.restype = ctypes.c_int

        reposInfo = DSREPOSINFO()
        res = self.__api.DSGetReposInfo(handleProj, objectType, infoType,
                                        encode_string(searchCriteria),
                                        encode_string(startingCategory),
                                        subcategories,
                                        ctypes.pointer(reposInfo))

        if res > 0:
            return reposInfo.info.jobs.contents, None
        if res == 0:
            return None, None

        return None, DSAPIERROR.create_error("DSGetReposInfo",
                                             self.DSGetLastError())
Esempio n. 4
0
    def DSGetProjectInfo(self, handleProj, infoType):
        self.__api.DSGetProjectInfo.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_int,
            ctypes.POINTER(DSPROJECTINFO)
        ]
        self.__api.DSGetProjectInfo.restype = ctypes.c_int

        projInfo = DSPROJECTINFO()
        res = self.__api.DSGetProjectInfo(handleProj, infoType,
                                          ctypes.pointer(projInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetProjectInfo",
                                                 self.DSGetLastError())

        if infoType == self.DSJ_JOBLIST:
            return convert_char_p_to_list(projInfo.info.jobList), None
        if infoType == self.DSJ_PROJECTNAME:
            return projInfo.info.projectName, None
        if infoType == self.DSJ_HOSTNAME:
            return projInfo.info.projectPath, None
        if infoType == self.DSJ_INSTALLTAG:
            return projInfo.info.hostName, None
        if infoType == self.DSJ_TCPPORT:
            return projInfo.info.installTag, None
        if infoType == self.DSJ_PROJECTPATH:
            return projInfo.info.tcpPort, None
        else:
            return '', None
Esempio n. 5
0
    def DSGetProjectList(self):
        self.__api.DSGetProjectList.argtypes = []
        self.__api.DSGetProjectList.restype = ctypes.POINTER(ctypes.c_char)

        projectList = self.__api.DSGetProjectList()

        if not projectList:
            return None, DSAPIERROR.create_error("DSGetProjectList",
                                                 self.DSGetLastError())
        else:
            return convert_char_p_to_list(projectList), None
Esempio n. 6
0
    def DSGetWLMEnabled(self):
        self.__api.DSGetWLMEnabled.argtypes = []
        self.__api.DSGetWLMEnabled.restype = ctypes.c_int

        wlmEnabled = self.__api.DSGetWLMEnabled()

        if not wlmEnabled:
            return None, DSAPIERROR.create_error("DSGetWLMEnabled",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 7
0
    def DSWaitForJob(self, handleJob):
        self.__api.DSWaitForJob.argtypes = [ctypes.POINTER(DSJOB)]
        self.__api.DSWaitForJob.restype = ctypes.c_int

        res = self.__api.DSWaitForJob(handleJob)

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSWaitForJob",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 8
0
    def DSCloseProject(self, handleProj):
        self.__api.DSCloseProject.argtypes = [ctypes.POINTER(DSPROJECT)]
        self.__api.DSCloseProject.restype = ctypes.c_int

        res = self.__api.DSCloseProject(handleProj)
        self.__handleProj = None

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSCloseProject",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 9
0
    def DSOpenProject(self, projectName):
        self.__api.DSOpenProjectEx.argtypes = [ctypes.c_int, ctypes.c_char_p]
        self.__api.DSOpenProjectEx.restype = ctypes.POINTER(DSPROJECT)

        handleProj = self.__api.DSOpenProjectEx(self.DSAPI_VERSION,
                                                encode_string(projectName))

        if not handleProj:
            return None, DSAPIERROR.create_error("DSOpenProject",
                                                 self.DSGetLastError())
        else:
            self.__handleProj = handleProj
            return handleProj, None
Esempio n. 10
0
    def DSSetDisableJobHandler(self, handleJob, value):
        self.__api.DSSetDisableJobHandler.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int
        ]
        self.__api.DSSetDisableJobHandler.restype = ctypes.c_int

        res = self.__api.DSSetDisableJobHandler(handleJob, value)

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetDisableJobHandler",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 11
0
    def DSSetGenerateOpMetaData(self, handleJob, value):
        self.__api.DSSetGenerateOpMetaData.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int
        ]
        self.__api.DSSetGenerateOpMetaData.restype = ctypes.c_int

        res = self.__api.DSSetGenerateOpMetaData(handleJob, value)

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetGenerateOpMetaData",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 12
0
    def DSDeleteEnvVar(self, handleProj, envVarName):
        self.__api.DSDeleteEnvVar.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p
        ]
        self.__api.DSDeleteEnvVar.restype = ctypes.c_int

        res = self.__api.DSDeleteEnvVar(handleProj, encode_string(envVarName))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSDeleteEnvVar",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 13
0
    def DSSetJobLimit(self, handleJob, limitType, limitValue):
        self.__api.DSSetJobLimit.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int, ctypes.c_int
        ]
        self.__api.DSSetJobLimit.restype = ctypes.c_int

        res = self.__api.DSSetJobLimit(handleJob, limitType, limitValue)

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetJobLimit",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 14
0
    def DSSetJobQueue(self, handleJob, queueName):
        self.__api.DSSetJobQueue.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p
        ]
        self.__api.DSSetJobQueue.restype = ctypes.c_int

        res = self.__api.DSSetJobQueue(handleJob, queueName)

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetJobQueue",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 15
0
    def DSGetNewestLogId(self, handleJob, eventType):
        self.__api.DSGetNewestLogId.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int
        ]
        self.__api.DSGetNewestLogId.restype = ctypes.c_int

        lastLogId = self.__api.DSGetNewestLogId(handleJob, eventType)

        if lastLogId == -1:
            return None, DSAPIERROR.create_error("DSGetNewestLogId",
                                                 self.DSGetLastError())
        else:
            return lastLogId, None
Esempio n. 16
0
    def DSSetDisableProjectHandler(self, handleProj, value):
        # Does function work incorrectly due to bad definition in dsapi.h?
        self.__api.DSSetDisableProjectHandler.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_int
        ]
        self.__api.DSSetDisableProjectHandler.restype = ctypes.c_int

        res = self.__api.DSSetDisableProjectHandler(handleProj, value)

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetDisableProjectHandler",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 17
0
    def DSGetStageInfo(self, handleJob, stageName, infoType):
        self.__api.DSGetStageInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p, ctypes.c_int,
            ctypes.POINTER(DSSTAGEINFO)
        ]
        self.__api.DSGetStageInfo.restype = ctypes.c_int

        stageInfo = DSSTAGEINFO()
        res = self.__api.DSGetStageInfo(handleJob, encode_string(stageName),
                                        infoType, ctypes.pointer(stageInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetStageInfo",
                                                 self.DSGetLastError())
        else:
            if infoType == self.DSJ_LINKLIST:
                return convert_char_p_to_list(stageInfo.info.linkList), None
            if infoType == self.DSJ_STAGELASTERR:
                return stageInfo.info.lastError, None
            if infoType == self.DSJ_STAGENAME:
                return stageInfo.info.stageName, None
            if infoType == self.DSJ_STAGETYPE:
                return stageInfo.info.typeName, None
            if infoType == self.DSJ_STAGEINROWNUM:
                return stageInfo.info.inRowNum, None
            if infoType == self.DSJ_VARLIST:
                return convert_char_p_to_list(stageInfo.info.varList), None
            if infoType == self.DSJ_STAGESTARTTIMESTAMP:
                return stageInfo.info.stageStartTime, None
            if infoType == self.DSJ_STAGEENDTIMESTAMP:
                return stageInfo.info.stageEndTime, None
            if infoType == self.DSJ_STAGEDESC:
                return stageInfo.info.stageDesc, None
            if infoType == self.DSJ_STAGEINST:
                return convert_char_p_to_list(stageInfo.info.instList), None
            if infoType == self.DSJ_STAGECPU:
                return convert_char_p_to_list(stageInfo.info.cpuList), None
            if infoType == self.DSJ_LINKTYPES:
                return convert_char_p_to_list(stageInfo.info.linkTypes), None
            if infoType == self.DSJ_STAGEELAPSED:
                return stageInfo.info.stageElapsed, None
            if infoType == self.DSJ_STAGEPID:
                return convert_char_p_to_list(stageInfo.info.pidList), None
            if infoType == self.DSJ_STAGESTATUS:
                return stageInfo.info.stageStatus, None
            if infoType == self.DSJ_CUSTINFOLIST:
                return convert_char_p_to_list(
                    stageInfo.info.custInfoList), None
            else:
                return '', None
Esempio n. 18
0
    def DSOpenJob(self, handleProj, jobName):
        self.__api.DSOpenJob.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p
        ]
        self.__api.DSOpenJob.restype = ctypes.POINTER(DSJOB)

        handleJob = self.__api.DSOpenJob(
            handleProj, ctypes.c_char_p(encode_string(jobName)))

        if not handleJob:
            return None, DSAPIERROR.create_error("DSOpenJob",
                                                 self.DSGetLastError())
        else:
            self.__handleJob = handleJob
            return handleJob, None
Esempio n. 19
0
    def DSSetParam(self, handleJob, paramName, param):
        self.__api.DSSetParam.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p,
            ctypes.POINTER(DSPARAM)
        ]
        self.__api.DSSetParam.restype = ctypes.c_int

        res = self.__api.DSSetParam(handleJob, encode_string(paramName),
                                    ctypes.pointer(param))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetParam",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 20
0
    def DSSetProjectProperty(self, handleProj, property, value):
        self.__api.DSSetProjectProperty.argtypes = [
            ctypes.POINTER(DSPROJECT), ctypes.c_char_p, ctypes.c_char_p
        ]
        self.__api.DSSetProjectProperty.restype = ctypes.c_int

        res = self.__api.DSSetProjectProperty(handleProj,
                                              encode_string(property),
                                              encode_string(value))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSSetProjectProperty",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 21
0
    def DSLogEvent(self, handleJob, eventType, message):
        self.__api.DSLogEvent.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int, ctypes.c_char_p,
            ctypes.c_char_p
        ]
        self.__api.DSLogEvent.restype = ctypes.c_int

        res = self.__api.DSLogEvent(handleJob, eventType, encode_string(''),
                                    encode_string(message))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSLogEvent",
                                                 self.DSGetLastError())
        else:
            return 0, None
Esempio n. 22
0
    def DSFindNextLogEntry(self, handleJob):
        self.__api.DSFindNextLogEntry.argtypes = [
            ctypes.POINTER(DSJOB),
            ctypes.POINTER(DSLOGEVENT)
        ]
        self.__api.DSFindNextLogEntry.restype = ctypes.c_int

        logEvent = DSLOGEVENT()
        res = self.__api.DSFindNextLogEntry(handleJob,
                                            ctypes.pointer(logEvent))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSFindNextLogEntry",
                                                 self.DSGetLastError())
        else:
            return logEvent, None
Esempio n. 23
0
    def DSGetLogEntry(self, handleJob, eventId):
        self.__api.DSGetLogEntry.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_int,
            ctypes.POINTER(DSLOGDETAIL)
        ]
        self.__api.DSGetLogEntry.restype = ctypes.c_int

        logDetail = DSLOGDETAIL()
        res = self.__api.DSGetLogEntry(handleJob, eventId,
                                       ctypes.pointer(logDetail))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetLogEntry",
                                                 self.DSGetLastError())
        else:
            return logDetail, None
Esempio n. 24
0
    def DSGetParamInfo(self, handleJob, paramName):
        self.__api.DSGetParamInfo.argtypes = [
            ctypes.POINTER(DSJOB), ctypes.c_char_p,
            ctypes.POINTER(DSPARAMINFO)
        ]
        self.__api.DSGetParamInfo.restype = ctypes.c_int

        paramInfo = DSPARAMINFO()
        res = self.__api.DSGetParamInfo(handleJob, encode_string(paramName),
                                        ctypes.pointer(paramInfo))

        if res != DSAPIERROR.DSJE_NOERROR:
            return None, DSAPIERROR.create_error("DSGetParamInfo",
                                                 self.DSGetLastError())
        else:
            return paramInfo, None