def _isDestFull(dest): r'Checks whether all required attributes present for discovery' return (dest.targetHost and sap.isCorrectSapInstanceNumber(dest.instNr) # check for substitution variable and dest.targetHost.find('%') == -1 # check for route string and dest.targetHost.find('/') == -1)
def updateInstanceNumber(self, instanceOsh, number): r'@types: ObjectStateHolder, str -> ObjectStateHolder' if not instanceOsh: raise ValueError("Instance OSH is not specified") if not (number and sap.isCorrectSapInstanceNumber(number)): raise ValueError("Instance number is not correct") instanceOsh.setAttribute('number', number) return instanceOsh
def composeGatewayServerPort(inst_nr): '''Compose gateway insecure port using patter 33xx based on instance number @types: str -> int >>> composeGatewayServerPort("00") 3300 >>> composeGatewayServerPort("91") 3391 ''' if not sap.isCorrectSapInstanceNumber(inst_nr): raise ValueError("Specified instance number '%s' is not correct" % inst_nr) return int("33%s" % inst_nr)
def _parseJavaScsDetails(doc): ''' Find Java SCS information in profiles SCS details must be always present in Java and Double Stack @types: IniDocument -> tuple[str?, str?] @raise ValueError: Instance number is not valid @return: instance information in such order: hostname, number ''' hostname = doc.get('j2ee/scs/host') number = doc.get('j2ee/scs/system') if not sap.isCorrectSapInstanceNumber(number): raise ValueError("Instance number is not valid") return (hostname, number)
def _parseServerNameWithSpaces(name): ''' Parse name of format <hostname> <SID> <NR> @return: tuple of isScs (False), NR, SID, hostname, nodeServerId as None or None if doesn't match expected format ''' tokens = name.split() if len(tokens) == 3: hostname, sid, nr = tokens if (sap.isCorrectSystemName(sid) and sap.isCorrectSapInstanceNumber(nr)): return False, hostname, sid, nr, None
def parseSystemAndInstanceDetails(value): '''Parse string string of format <SAPLOCALHOST>_<SAPSYSTEMNAME>_<SAPSYSTEM> @types: str -> tuple[sap.System, str, str] @return: Tuple of SAP System, hostname and instance number respectively ''' if not value: raise ValueError("Value to parse is not specified") tokens = value.rsplit('_', 2) if len(tokens) != 3: raise ValueError("Value is not of supported format") hostname, sid, number = tokens if not sap.isCorrectSapInstanceNumber(number): raise ValueError("Instance number is not valid") return sap.System(sid), hostname, number