def createAllPackageMapping(self): self._packageMapping.clear() connection = self._testClient.getConnection() result = None menuUtil = VistAMenuUtil(duz=1) # set duz as 1 menuUtil.gotoFileManPrintFileEntryMenu(self._testClient) # print file entry connection.send("9.4\r") # Package file with fileman #9.4 connection.expect("SORT BY:") connection.send("\r") connection.expect("START WITH") connection.send("\r") connection.expect("FIRST PRINT FIELD:") connection.send(".01\r") # fileman field# .01 is NAME connection.expect("THEN PRINT FIELD:") connection.send("1\r") # fileman field# 1 is the PREFIX connection.expect("THEN PRINT FIELD:") connection.send("\r") connection.expect("PACKAGE LIST//") connection.send("\r") connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("Select OPTION: ") self.__parseAllPackages__(connection.before) menuUtil.exitFileManMenu(self._testClient, waitOption=False)
def getInstallationStatus(self, installName): connection = self._testClient.getConnection() result = -1 # default is not installed menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManInquireFileEntryMenu(self._testClient) connection.send("9.7\r") # Package file with fileman #9.7 connection.expect("Select INSTALL NAME:") connection.send("%s\r" % installName) while True: index = connection.expect(["Select INSTALL NAME: ", "ANOTHER ONE: ", "CHOOSE 1-[0-9]+: "]) if index == 0: connection.send("\r") break elif index == 1: txtToSearch = connection.before.replace("\r\n","") logger.debug(txtToSearch) result = indexOfInstallStatus(txtToSearch) connection.send("^\r") break # handle if the install has multiple install status elif index == 2: linesToSearch = connection.before.split("\r\n") for line in linesToSearch: # only care the the first line line = line.strip("\r\n ") if not re.search("^1 ", line): continue result = indexOfInstallStatus(line) break connection.send("^\r") continue menuUtil.exitFileManMenu(self._testClient) return result
def addPackagePatchHistory(packageName, version, seqNo, patchNo, vistAClient, inputDuz): logger.info("Adding %s, %s, %s, %s to Package Patch history" % (packageName, version, seqNo, patchNo)) connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManEditEnterEntryMenu(vistAClient) connection.send("9.4\r") # package file connection.expect("EDIT WHICH FIELD: ") connection.send("VERSION\r") connection.expect("EDIT WHICH VERSION SUB-FIELD: ") connection.send("PATCH APPLICATION HISTORY\r") connection.expect("EDIT WHICH PATCH APPLICATION HISTORY SUB-FIELD: ") connection.send("ALL\r") connection.expect("THEN EDIT VERSION SUB-FIELD: ") connection.send("\r") connection.expect("THEN EDIT FIELD: ") connection.send("\r") connection.expect("Select PACKAGE NAME: ") connection.send("%s\r" % packageName) connection.expect("Select VERSION: %s//" % version) connection.send("\r") connection.expect("Select PATCH APPLICATION HISTORY: ") connection.send("%s SEQ #%s\r" % (patchNo, seqNo)) connection.expect("Are you adding .*\? No//") connection.send("YES\r") connection.expect("DATE APPLIED: ") connection.send("T\r") connection.expect("APPLIED BY: ") connection.send("`%s\r" % inputDuz) connection.expect("DESCRIPTION:") connection.send("\r") connection.expect("Select PATCH APPLICATION HISTORY: ") connection.send("\r") connection.expect("Select PACKAGE NAME: ") connection.send("\r") menuUtil.exitFileManMenu(vistAClient)
def preInstallationWork(self, vistATestClient, **kargs): """ ignore the multi-build patch for now """ if self._multiBuildList is not None: return globalFiles = self.__getGlobalFileList__() if globalFiles is None or len(globalFiles) == 0: return globalImport = VistAGlobalImport() for glbFile in globalFiles: logger.info("Import global file %s" % (glbFile)) fileSize = os.path.getsize(glbFile) importTimeout = DEFAULT_GLOBAL_IMPORT_TIMEOUT importTimeout += int(old_div(fileSize, GLOBAL_IMPORT_BYTE_PER_SEC)) globalImport.importGlobal(vistATestClient, glbFile, timeout=importTimeout) """ Requires the installer account to have the ZTMQ security key""" menuUtil = VistAMenuUtil(duz=17) menuUtil.gotoSystemMenu(vistAClient) connection.send("Allocation of Security\r") connection.expect("Allocate key") connection.send("ZTMQ\r\r") connection.expect("Holder of key") connection.send(" \r\r") connection.expect("Do you wish to proceed") connection.send("Y\r")
def preInstallationWork(self, vistATestClient, **kargs): """ ignore the multi-build patch for now """ if self._multiBuildList is not None: return globalFiles = self.__getGlobalFileList__() if globalFiles is None or len(globalFiles) == 0: return globalImport = VistAGlobalImport() for glbFile in globalFiles: logger.info("Import global file %s" % (glbFile)) fileSize = os.path.getsize(glbFile) importTimeout = DEFAULT_GLOBAL_IMPORT_TIMEOUT importTimeout += int(fileSize/GLOBAL_IMPORT_BYTE_PER_SEC) globalImport.importGlobal(vistATestClient, glbFile, timeout=importTimeout) """ Requires the installer account to have the ZTMQ security key""" menuUtil = VistAMenuUtil(duz=17) menuUtil.gotoSystemMenu(vistAClient) connection.send("Allocation of Security\r") connection.expect("Allocate key") connection.send("ZTMQ\r\r") connection.expect("Holder of key") connection.send(" \r\r") connection.expect("Do you wish to proceed") connection.send("Y\r")
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) connection = vistATestClient.getConnection() connection.send('S ^PS(56,1961,0)="MAGNESIUM/ZALCITABINE (DIDEOXYCYTIDINE,ddC)^255^3150^2^1^10624"\r') connection.expect(vistATestClient.getPrompt()) connection.send('S ^PS(56,531,0)="LOMEFLOXACIN/MAGNESIUM^3183^255^2^1^28817^3141031"\r') connection.expect(vistATestClient.getPrompt()) connection.send('S ^PS(56,513,0)="ENOXACIN/MAGNESIUM^2779^255^2^1^37112^3141031"\r') menuUtil.gotoKidsMainMenu(vistATestClient)
def getAllPatchInstalledAfterByTime(self, dateTime): """ This will search install file to find out all patches installed after specific time """ connection = self._testClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManSearchFileEntryMenu(self._testClient) connection.send("9.7\r") # INSTALL file # connection.expect("-A- SEARCH FOR INSTALL FIELD: ") connection.send("17\r") # field # for INSTALL COMPLETE TIME connection.expect("-A- CONDITION: ") connection.send("GREATER THAN\r") connection.expect("-A- GREATER THAN DATE: ") connection.send("%s\r" % dateTime) connection.expect("-B- SEARCH FOR INSTALL FIELD: ") connection.send("\r") connection.expect("IF: A// ") connection.send("\r") connection.expect("STORE RESULTS OF SEARCH IN TEMPLATE: ") connection.send("\r") connection.expect([re.compile("SORT BY: ", re.I), re.compile("SORT BY: NAME// ", re.I)]) connection.send("17\r") # sort by INSTALL COMPLETE TIME connection.expect([re.compile("START WITH INSTALL COMPLETE TIME: ", re.I), re.compile("START WITH INSTALL COMPLETE TIME: FIRST// ",re.I)]) connection.send("\r") connection.expect(re.compile("WITHIN INSTALL COMPLETE TIME, SORT BY: ", re.I)) connection.send("\r") connection.expect(re.compile("FIRST PRINT FIELD: ", re.I)) connection.send("NAME\r") connection.expect(re.compile("THEN PRINT FIELD: ", re.I)) connection.send("17\r") connection.expect(re.compile("THEN PRINT FIELD: ", re.I)) connection.send("\r") connection.expect(re.compile("Heading \(S/C\): INSTALL SEARCH// ", re.I)) connection.send("\r") # use default heading connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("[0-9]+ MATCH(ES)? FOUND\.") result = connection.before.split("\r\n") output = [] resultStart = False DATETIME_INDENT = 52 for line in result: line = line.strip() if len(line) == 0: continue if resultStart: output.append((line[:DATETIME_INDENT].rstrip(), parsePatchInstallDatetime(line[DATETIME_INDENT:]))) continue if re.search('^-+$',line): resultStart = True menuUtil.exitFileManMenu(self._testClient) return output
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) connection = vistATestClient.getConnection() connection.send("D STOP^ZTMKU\r") connection.expect("Are you sure") connection.send("Y\r") connection.expect("Should active") connection.send("Y\r") connection.expect("Should active") connection.send("Y\r") time.sleep(30) menuUtil.gotoKidsMainMenu(vistATestClient)
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) connection = vistATestClient.getConnection() connection.send("D STOP^ZTMKU\r") connection.expect("Are you sure") connection.send("Y\r") connection.expect("Should active") connection.send("Y\r") connection.expect("Should active") connection.send("Y\r") time.sleep(30) menuUtil.gotoKidsMainMenu(vistATestClient)
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) connection = vistATestClient.getConnection() connection.send( 'S ^PS(56,1961,0)="MAGNESIUM/ZALCITABINE (DIDEOXYCYTIDINE,ddC)^255^3150^2^1^10624"\r' ) connection.expect(vistATestClient.getPrompt()) connection.send( 'S ^PS(56,531,0)="LOMEFLOXACIN/MAGNESIUM^3183^255^2^1^28817^3141031"\r' ) connection.expect(vistATestClient.getPrompt()) connection.send( 'S ^PS(56,513,0)="ENOXACIN/MAGNESIUM^2779^255^2^1^37112^3141031"\r' ) menuUtil.gotoKidsMainMenu(vistATestClient)
def stopTaskman(self, vistAClient, shutdownSubMgrs=True, shutdownActJobs=True): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) connection.send('D GROUP^ZTMKU("SSUB(NODE)")\n') vistAClient.waitForPrompt() connection.send('D GROUP^ZTMKU("SMAN(NODE)")\n') # menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) # connection.send("Stop Task Manager\r") # connection.expect("Are you sure you want to stop TaskMan\? ") # connection.send("YES\r") # connection.expect("Should active submanagers shut down after finishing their current tasks\? ") # if shutdownSubMgrs: # connection.send("YES\r") # else: # connection.send("NO\r") # connection.expect("Should active jobs be signaled to stop\? ") # if shutdownActJobs: # connection.send("YES\r") # else: # connection.send("NO\r") # menuUtil.exitTaskmanMgrUtilMenu(vistAClient) logger.info("Wait 30 seconds for Taskman to stop") time.sleep(30)
def getPersonNameByDuz(inputDuz, vistAClient): logger.info ("inputDuz is %s" % inputDuz) """ user Kernel User API """ connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoSystemMenu(vistAClient) connection.send('Prog\r') connection.expect('Select Programmer Options') connection.send('^\r') menuUtil.exitSystemMenu(vistAClient) vistAClient.waitForPrompt() connection.send('W $$NAME^XUSER(%s)\r' % inputDuz) connection.expect('\)') # get rid of the echo vistAClient.waitForPrompt() result = connection.before.strip(' \r\n') connection.send('\r') return result
def getInstallationStatus(self, installName): connection = self._testClient.getConnection() result = -1 # default is not installed if not self.isPatchInstalled(installName): menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManSearchFileEntryMenu(self._testClient) connection.send("9.7\r") # Package file with fileman #9.7 connection.expect("SEARCH FOR") connection.send("NAME\r") connection.expect("CONDITION:") connection.send("EQUALS\r") connection.expect("EQUALS") connection.send("%s\r" % installName) connection.expect("SEARCH FOR") connection.send("\r") connection.expect("IF:") connection.send("\r") connection.expect("IN TEMPLATE") connection.send("\r") connection.expect(re.compile("SORT BY: ", re.I)) connection.send("\r") connection.expect("Start with") connection.send("\r") connection.expect("First Print") connection.send("STATUS\r") connection.expect("Then Print") connection.send("\r") connection.expect("Heading") connection.send("\r") connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("Select OPTION: ") linesToSearch = connection.before.split("\r\n") for line in linesToSearch: # only care the the first line line = line.strip("\r\n ") tmpResult = indexOfInstallStatus(line) if tmpResult > result: result=tmpResult connection.send("?\r") menuUtil.exitFileManMenu(self._testClient) return result else: return 3
def stopTaskman(self, vistAClient, shutdownSubMgrs=True, shutdownActJobs=True): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("Stop Task Manager\r") connection.expect("Are you sure you want to stop TaskMan\? ") connection.send("YES\r") connection.expect("Should active submanagers shut down after finishing their current tasks\? ") if shutdownSubMgrs: connection.send("YES\r") else: connection.send("NO\r") connection.expect("Should active jobs be signaled to stop\? ") if shutdownActJobs: connection.send("YES\r") else: connection.send("NO\r") menuUtil.exitTaskmanMgrUtilMenu(vistAClient) logger.info("Wait 30 seconds for Taskman to stop") time.sleep(30)
def getInstallationStatus(self, installName): connection = self._testClient.getConnection() result = -1 # default is not installed menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManInquireFileEntryMenu(self._testClient) connection.send("9.7\r") # Package file with fileman #9.7 connection.expect("Select INSTALL NAME:") connection.send("%s\r" % installName) while True: index = connection.expect([ "Select INSTALL NAME: ", re.compile("ANOTHER ONE: ", re.I), "CHOOSE 1-[0-9]+: " ]) if index == 0: connection.send("\r") break elif index == 1: txtToSearch = connection.before.replace("\r\n", "") logger.debug(txtToSearch) result = indexOfInstallStatus(txtToSearch) connection.send("^\r") break # handle if the install has multiple install status elif index == 2: linesToSearch = connection.before.split("\r\n") for line in linesToSearch: # only care the the first line line = line.strip("\r\n ") if not re.search("^1 ", line): continue result = indexOfInstallStatus(line) break connection.send("^\r") continue menuUtil.exitFileManMenu(self._testClient) return result
def verifyTaskmanSiteParameter(self, vistAClient, autoFix=True): retValue = True connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) boxVolPair = getBoxVolPair(vistAClient) logger.debug("Box:Vol Pair is [%s] " % boxVolPair) menuUtil.gotoTaskmanEditParamMenu(vistAClient) connection.send("Site Parameters Edit\r") connection.expect("Select TASKMAN SITE PARAMETERS BOX-VOLUME PAIR: ") connection.send("?\r") connection.expect("Answer with TASKMAN SITE PARAMETERS BOX-VOLUME PAIR.*?:") connection.expect("You may enter a new TASKMAN SITE PARAMETERS") curBoxVol = connection.before.strip(' \r\n') curBoxVol = [x.strip(' ') for x in curBoxVol.split('\r\n')] logger.debug("Box:Vol Pair is [%s] " % curBoxVol) if boxVolPair not in curBoxVol : logger.error("taskman site parameter mismatch, current:[%s], correct:[%s]" % (curBoxVol, boxVolPair)) if autoFix: self.__fixTaskmanSiteParameter__(connection, curBoxVol[0], boxVolPair) else: retValue = False connection.expect("Select TASKMAN SITE PARAMETERS BOX-VOLUME PAIR: ") connection.send('\r') menuUtil.exitTaskmanEditParamMenu(vistAClient) return retValue
def createAllPackageMapping(self): self._packageMapping.clear() connection = self._testClient.getConnection() result = None menuUtil = VistAMenuUtil(duz=1) # set duz as 1 menuUtil.gotoFileManPrintFileEntryMenu(self._testClient) # print file entry connection.send("9.4\r") # Package file with fileman #9.4 connection.expect("SORT BY:") connection.send("\r") connection.expect("START WITH") connection.send("\r") connection.expect("FIRST PRINT FIELD:") connection.send(".01\r") # fileman field# .01 is NAME connection.expect("THEN PRINT FIELD:") connection.send("1\r") # fileman field# 1 is the PREFIX connection.expect("THEN PRINT FIELD:") connection.send("\r") connection.expect("PACKAGE LIST//") connection.send("\r") connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("Select OPTION: ") self.__parseAllPackages__(connection.lastconnection) menuUtil.exitFileManMenu(self._testClient, waitOption=False)
def getPackagePatchHistory(self, packageName, namespace): if not self._packageMapping: self.createAllPackageMapping() connection = self._testClient.getConnection() result = None menuUtil = VistAMenuUtil(duz=1) # set duz as 1 menuUtil.gotoKidsUtilMenu(self._testClient) connection.send("Display\r") connection.expect("Select PACKAGE NAME:") connection.send("%s\r" % packageName) while True: index = connection.expect(["Select VERSION: [0-9.]+\/\/", "Select VERSION: ", "Select Utilities ", "CHOOSE [0-9]+-[0-9]+"]) if index == 3: outchoice = findChoiceNumber(connection.before, packageName, namespace) if outchoice: connection.send("%s\r" % outchoice) else: # no match connection.send("\r") continue if index == 0 or index == 1: if index == 0: connection.send("\r") else: connection.send("1.0\r") connection.expect("Do you want to see the Descriptions\?") connection.send("\r") connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("Select Utilities ") result = parseKIDSPatchHistory(connection.before, packageName, namespace) break else: break menuUtil.exitKidsUtilMenu(self._testClient) self._packagePatchHist[packageName] = result return result
def preInstallationWork(self, vistATestClient, **kargs): """ ignore the multi-build patch for now """ if self._multiBuildList is not None: return """ Requires the installer account to have the ZTMQ security key""" menuUtil = VistAMenuUtil(duz=17) menuUtil.gotoFileManEditEnterEntryMenu(vistATestClient) connection = vistATestClient.getConnection() connection.send("LABORATORY TEST\r") connection.expect("EDIT WHICH FIELD") connection.send("\r") connection.expect("Select LABORATORY TEST NAME") connection.send("VBEC PATIENT REFLEX TEST\r") index = connection.expect(["Are you adding", "NAME"]) if index == 0: connection.send("Y\r") connection.expect("LABORATORY TEST SUBSCRIPT") connection.send("WORKLOAD\r") connection.expect("LABORATORY TEST HIGHEST URGENCY ALLOWED") connection.send("ROUTINE\r") connection.expect("LABORATORY TEST PRINT NAME") connection.send("VBEC PATIENT REFLEX\r") connection.expect("LABORATORY TEST DATA NAME") connection.send("\r") connection.expect("TEST COST") connection.send("\r") connection.expect("Select SYNONYM") connection.send("\r") connection.expect("TYPE") connection.send("NEITHER\r") connection.send("^\r\r") menuUtil.exitFileManMenu(vistATestClient)
def stopTaskman(self, vistAClient, shutdownSubMgrs=True, shutdownActJobs=True): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("Stop Task Manager\r") connection.expect("Are you sure you want to stop TaskMan\? ") connection.send("YES\r") connection.expect( "Should active submanagers shut down after finishing their current tasks\? " ) if shutdownSubMgrs: connection.send("YES\r") else: connection.send("NO\r") connection.expect("Should active jobs be signaled to stop\? ") if shutdownActJobs: connection.send("YES\r") else: connection.send("NO\r") menuUtil.exitTaskmanMgrUtilMenu(vistAClient) logger.info("Wait 30 seconds for Taskman to stop") time.sleep(30)
def inhibitLogons(testClient, flag=True): from VistAMenuUtil import VistAMenuUtil from VistATaskmanUtil import getBoxVolPair volumeSet = getBoxVolPair(testClient).split(':')[0] menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManEditEnterEntryMenu(testClient) conn = testClient.getConnection() conn.send('14.5\r') # 14.5 is the VOLUME SET File conn.expect('EDIT WHICH FIELD: ') conn.send('1\r') # field Inhibit Logons? conn.expect('THEN EDIT FIELD: ') conn.send('\r') conn.expect('Select VOLUME SET: ') conn.send('%s\r' % volumeSet) conn.expect('INHIBIT LOGONS\?: ') if flag: conn.send('YES\r') else: conn.send('NO\r') conn.expect('Select VOLUME SET: ') conn.send('\r') menuUtil.exitFileManMenu(testClient)
def removeTaskmanFromWait(self, vistAClient): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("Remove Taskman from WAIT State\r") menuUtil.exitTaskmanMgrUtilMenu(vistAClient) logger.info("Wait 10 seconds for Taskman to start") time.sleep(10)
def getAllPatchInstalledAfterByTime(self, dateTime): """ This will search install file to find out all patches installed after specific time """ connection = self._testClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManSearchFileEntryMenu(self._testClient) connection.send("9.7\r") # INSTALL file # connection.expect("-A- SEARCH FOR INSTALL FIELD: ") connection.send("17\r") # field # for INSTALL COMPLETE TIME connection.expect("-A- CONDITION: ") connection.send("GREATER THAN\r") connection.expect("-A- GREATER THAN DATE: ") connection.send("%s\r" % dateTime) connection.expect("-B- SEARCH FOR INSTALL FIELD: ") connection.send("\r") connection.expect("IF: A// ") connection.send("\r") connection.expect("STORE RESULTS OF SEARCH IN TEMPLATE: ") connection.send("\r") connection.expect(["SORT BY: ", "SORT BY: NAME// "]) connection.send("17\r") # sort by INSTALL COMPLETE TIME connection.expect([ "START WITH INSTALL COMPLETE TIME: ", "START WITH INSTALL COMPLETE TIME: FIRST// " ]) connection.send("\r") connection.expect("WITHIN INSTALL COMPLETE TIME, SORT BY: ") connection.send("\r") connection.expect("FIRST PRINT FIELD: ") connection.send("NAME\r") connection.expect("THEN PRINT FIELD: ") connection.send("17\r") connection.expect("THEN PRINT FIELD: ") connection.send("\r") connection.expect("Heading \(S/C\): INSTALL SEARCH// ") connection.send("\r") # use default heading connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("[0-9]+ MATCH(ES)? FOUND\.") result = connection.lastconnection.split("\r\n") output = [] resultStart = False DATETIME_INDENT = 52 for line in result: line = line.strip() if len(line) == 0: continue if resultStart: output.append( (line[:DATETIME_INDENT].rstrip(), parsePatchInstallDatetime(line[DATETIME_INDENT:]))) continue if re.search('^-+$', line): resultStart = True menuUtil.exitFileManMenu(self._testClient) return output
def getTaskmanStatus(self, vistAClient): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("MTM\r") # Monitor Taskman curStatus = self.__getTaskmanStatus__(connection) connection.send("^\r") menuUtil.exitTaskmanMgrUtilMenu(vistAClient) return curStatus
def stopHL7BackgroundFiler(self, vistAClient): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoHL7FilerLinkMgrMenu(vistAClient) connection.send("Stop All Messaging Background Processes\r") connection.expect("Okay to shut down all Links and Filers\? ") connection.send("Yes\r") menuUtil.exitHL7FilerLinkMgrMenu(vistAClient) logger.info("Wait 30 seconds for HL7 backgroud filer to stop") time.sleep(30)
def stopMailManBackgroundFiler(self, vistAClient): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoMailmanLocalDeliveryMgrMenu(vistAClient) connection.send("STOP background filer\r") connection.expect("Are you sure you want the Background Filers to stop delivering mail\? ") connection.send("YES\r") menuUtil.exitMailmanLocalDeliveryMgrMenu(vistAClient) logger.info("Wait 30 seconds for Mailman backgroud filer to stop") time.sleep(30)
def placeTaskmanToWait(self, vistAClient, shutdownSubMgrs=True): connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("Place Taskman in a WAIT State\r") connection.expect("Should active submanagers shut down after finishing their current tasks\? ") if shutdownSubMgrs: connection.send("YES\r") else: connection.send("NO\r") menuUtil.exitTaskmanMgrUtilMenu(vistAClient) logger.info("Wait 10 seconds for Taskman to wait state") time.sleep(10)
def getPersonNameByDuz(inputDuz, vistAClient): logger.info("inputDuz is %s" % inputDuz) """ user Kernel User API """ connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoSystemMenu(vistAClient) connection.send('Prog\r') connection.expect('Select Programmer Options') connection.send('^\r') menuUtil.exitSystemMenu(vistAClient) vistAClient.waitForPrompt() connection.send('W $$NAME^XUSER(%s)\r' % inputDuz) connection.expect('\)') # get rid of the echo vistAClient.waitForPrompt() result = connection.before.strip(' \r\n') connection.send('\r') return result
def getInstallationStatus(self, installName): connection = self._testClient.getConnection() result = -1 # default is not installed if not self.isPatchInstalled(installName): menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManSearchFileEntryMenu(self._testClient) connection.send("9.7\r") # Package file with fileman #9.7 connection.expect("SEARCH FOR") connection.send("NAME\r") connection.expect("CONDITION:") connection.send("EQUALS\r") connection.expect("EQUALS") connection.send("%s\r" % installName) connection.expect("SEARCH FOR") connection.send("\r") connection.expect("IF:") connection.send("\r") connection.expect("IN TEMPLATE") connection.send("\r") connection.expect("SORT BY: ") connection.send("\r") connection.expect("Start with") connection.send("\r") connection.expect("First Print") connection.send("STATUS\r") connection.expect("Then Print") connection.send("\r") connection.expect("Heading") connection.send("\r") connection.expect("DEVICE:") connection.send(";132;99999\r") connection.expect("Select OPTION: ") linesToSearch = connection.lastconnection.split("\r\n") for line in linesToSearch: # only care the the first line line = line.strip("\r\n ") tmpResult = indexOfInstallStatus(line) if tmpResult > result: result = tmpResult connection.send("?\r") menuUtil.exitFileManMenu(self._testClient) return result else: return 3
def startTaskman(self, vistAClient, waitToCurrent=True): self.verifyTaskmanSiteParameter(vistAClient) connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("Restart Task Manager\r") index = connection.expect(["ARE YOU SURE YOU WANT TO RESTART ANOTHER TASKMAN\?", "ARE YOU SURE YOU WANT TO RESTART TASKMAN\?"]) if index == 0: connection.send("NO\r") elif index == 1: connection.send("YES\r") connection.expect("Restarting...TaskMan restarted\!") menuUtil.exitTaskmanMgrUtilMenu(vistAClient) curStatus = self.getTaskmanStatus(vistAClient) if self.isTaskmanInWaitState(curStatus): self.removeTaskmanFromWait(vistAClient) if waitToCurrent: if not self.isTaskmanRunningCurrent(curStatus): self.waitTaskmanToCurrent(vistAClient)
def waitTaskmanToCurrent(self, vistAClient, timeOut=120): DEFAULT_POLL_INTERVAL = 1 # 1 seconds MaxRetry = timeOut/DEFAULT_POLL_INTERVAL startRetry = 0 connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoTaskmanMgrUtilMenu(vistAClient) connection.send("MTM\r") # Monitor Taskman while startRetry < MaxRetry: curStatus = self.__getTaskmanStatus__(connection) if self.isTaskmanRunningCurrent(curStatus): break; else: startRetry += 1 time.sleep(DEFAULT_POLL_INTERVAL) connection.send("\r") if startRetry >= MaxRetry: logger.error("Time out while waiting Taskman to Current") connection.send("^\r") menuUtil.exitTaskmanMgrUtilMenu(vistAClient)
def inhibitLogons(testClient, flag=True): from VistAMenuUtil import VistAMenuUtil from VistATaskmanUtil import getBoxVolPair volumeSet = getBoxVolPair(testClient).split(':')[0] menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManEditEnterEntryMenu(testClient) conn = testClient.getConnection() conn.send('14.5\r') # 14.5 is the VOLUME SET File conn.expect('EDIT WHICH FIELD: ') conn.send('1\r') # field Inhibit Logons? conn.expect('THEN EDIT FIELD: ') conn.send('\r') conn.expect('Select VOLUME SET: ') conn.send('%s\r' % volumeSet) conn.expect('INHIBIT LOGONS\?: ') if flag: conn.send('YES\r') else: conn.send('NO\r') conn.expect('Select VOLUME SET: ') conn.send('\r') menuUtil.exitFileManMenu(testClient)
def addPackagePatchHistory(packageName, version, seqNo, patchNo, vistAClient, inputDuz): logger.info("Adding %s, %s, %s, %s to Package Patch history" % (packageName, version, seqNo, patchNo)) appliedUser = getPersonNameByDuz(inputDuz, vistAClient) connection = vistAClient.getConnection() menuUtil = VistAMenuUtil(duz=1) menuUtil.gotoFileManEditEnterEntryMenu(vistAClient) connection.send("9.4\r") # package file connection.expect("EDIT WHICH FIELD: ") connection.send("VERSION\r") connection.expect("EDIT WHICH VERSION SUB-FIELD: ") connection.send("PATCH APPLICATION HISTORY\r") connection.expect("EDIT WHICH PATCH APPLICATION HISTORY SUB-FIELD: ") connection.send("ALL\r") connection.expect("THEN EDIT VERSION SUB-FIELD: ") connection.send("\r") connection.expect("THEN EDIT FIELD: ") connection.send("\r") connection.expect("Select PACKAGE NAME: ") connection.send("%s\r" % packageName) connection.expect("Select VERSION: %s//" % version) connection.send("\r") connection.expect("Select PATCH APPLICATION HISTORY: ") connection.send("%s SEQ #%s\r" % (patchNo, seqNo)) connection.expect("Are you adding .*\? No//") connection.send("YES\r") connection.expect("DATE APPLIED: ") connection.send("T\r") connection.expect("APPLIED BY: ") connection.send("%s\r" % appliedUser) connection.expect("DESCRIPTION:") connection.send("\r") connection.expect("Select PATCH APPLICATION HISTORY: ") connection.send("\r") connection.expect("Select PACKAGE NAME: ") connection.send("\r") menuUtil.exitFileManMenu(vistAClient)
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) menuUtil.gotoKidsMainMenu(vistATestClient)
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) taskmanUtil = VistATaskmanUtil() taskmanUtil.stopTaskman(vistATestClient) menuUtil.gotoKidsMainMenu(vistATestClient)
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) menuUtil.gotoKidsMainMenu(vistATestClient)
def __gotoKIDSMainMenu__(self, vistATestClient): menuUtil = VistAMenuUtil(self._duz) taskmanUtil = VistATaskmanUtil() taskmanUtil.stopTaskman(vistATestClient) menuUtil.gotoKidsMainMenu(vistATestClient)
def getPackagePatchHistory(self, packageName, namespace, version=None): if not self._packageMapping: self.createAllPackageMapping() connection = self._testClient.getConnection() result = None menuUtil = VistAMenuUtil(duz=1) # set duz as 1 menuUtil.gotoKidsUtilMenu(self._testClient) connection.send("Display\r") connection.expect("Select PACKAGE NAME:") connection.send("%s\r" % packageName) while True: index = connection.expect([ "Select VERSION: [0-9.VvTtPp]+\/\/", "Select VERSION: ", "Select Utilities ", "CHOOSE [0-9]+-[0-9]+" ]) if index == 3: outchoice = findChoiceNumber(connection.lastconnection, packageName, namespace) if outchoice: connection.send("%s\r" % outchoice) else: # no match connection.send("\r") continue if index == 0 or index == 1: if index == 0: if version: connection.send("%s\r" % version) else: connection.send("\r") else: connection.send("1.0\r") """ handle the case that same version could also have different history, like test version T1, T2 or V1, V2, or package does not have a version information (old system) """ while True: idx = connection.expect([ "Do you want to see the Descriptions\?", "CHOOSE [0-9]+-[0-9]+", "Select VERSION: ", "DEVICE:" ]) if idx == 0: connection.send("\r") continue elif idx == 1: connection.send("1\r") # always use the latest one continue elif idx == 2: connection.send('^\r') break elif idx == 3: connection.send(";132;99999\r") break connection.expect("Select Utilities ") result = parsePackagePatchHistory(connection.lastconnection, packageName, namespace, version) break else: break menuUtil.exitKidsUtilMenu(self._testClient) if not result: return result assert result.version # ignore the non-floating version try: curVer = float(result.version) except ValueError as ve: return None if packageName not in self._packagePatchHist: self._packagePatchHist[packageName] = dict() verDict = self._packagePatchHist[packageName] curVer = float(result.version) if curVer in verDict: logger.info("already has hist for ver:%s, package:%s" % (result.version, packageName)) self._packagePatchHist[packageName][curVer] = result return result
def getPackagePatchHistory(self, packageName, namespace, version=None): if not self._packageMapping: self.createAllPackageMapping() connection = self._testClient.getConnection() result = None menuUtil = VistAMenuUtil(duz=1) # set duz as 1 menuUtil.gotoKidsUtilMenu(self._testClient) connection.send("Display\r") connection.expect("Select PACKAGE NAME:") connection.send("%s\r" % packageName) while True: index = connection.expect(["Select VERSION: [0-9.VvTtPp]+\/\/", "Select VERSION: ", "Select Utilities ", "CHOOSE [0-9]+-[0-9]+"]) if index == 3: outchoice = findChoiceNumber(connection.before, packageName, namespace) if outchoice: connection.send("%s\r" % outchoice) else: # no match connection.send("\r") continue if index == 0 or index == 1: if index == 0: if version: connection.send("%s\r" % version) else: connection.send("\r") else: connection.send("1.0\r") """ handle the case that same version could also have different history, like test version T1, T2 or V1, V2, or package does not have a version information (old system) """ while True: idx = connection.expect(["Do you want to see the Descriptions\?", "CHOOSE [0-9]+-[0-9]+", "Select VERSION: ", "DEVICE:"]) if idx == 0: connection.send("\r") continue elif idx == 1: connection.send("1\r") # always use the latest one continue elif idx == 2: connection.send('^\r') break elif idx ==3 : connection.send(";132;99999\r") break connection.expect("Select Utilities ") result = parsePackagePatchHistory(connection.before, packageName, namespace, version) break else: break menuUtil.exitKidsUtilMenu(self._testClient) if not result: return result assert result.version # ignore the non-floating version try: curVer = float(result.version) except ValueError as ve: return None if packageName not in self._packagePatchHist: self._packagePatchHist[packageName] = dict() verDict = self._packagePatchHist[packageName] curVer = float(result.version) if curVer in verDict: logger.info("already has hist for ver:%s, package:%s" % (result.version, packageName)) self._packagePatchHist[packageName][curVer] = result return result