Esempio n. 1
0
def getInformationFromListeners(client, procToPortDict, dbInstanceDict):
	shell = ShellUtils(client)
	env = oracle_shell_utils.getEnvConfigurator(shell)
	is_fully_discovered = 1
	for pid in procToPortDict.keys():
		processName = (procToPortDict[pid])[dbconnect_utils.PROCESSNAME_INDEX].lower()
		processPath = (procToPortDict[pid])[dbconnect_utils.PATH_INDEX]
		if re.search('tnslsnr', processName) or re.search('tnslistener', processName):
			logger.debug('Found listener with path "%s"' % processPath)
			env.setOracleHomeEnvVar(processPath)
			m = re.match(r"(.+)[\\\/]+tns.*", processPath)
			if m:
				output = shell.execCmd('%s/lsnrctl status' % m.group(1))
				if not(output and shell.getLastCmdReturnCode() == 0):
					is_fully_discovered = 0
#dbDict[sidFound] = ['oracle', tnslsnrPort, ipAddress, installPath, version, statusFlag]
				ip_port, service_instance, version = parseListenerOutput(output)
				for service, instance in service_instance:
					ip = None
					port = None
					if ip_port:
						ip, port = ip_port[0]
					details = dbInstanceDict.get(instance, [])
					if details:
						#instance already found previously
						if details[1] == dbconnect_utils.UNKNOWN:
							details[1] = port
						if details[2] == dbconnect_utils.UNKNOWN:
							details[2] = ip
						details[4] = version
						dbInstanceDict[instance] = details
					else:
						dbInstanceDict[instance] = ['oracle', port, ip, m.group(1), version, dbconnect_utils.UNKNOWN]
	return is_fully_discovered
Esempio n. 2
0
class ShellWithException(object):
    def __init__(self, client):
        self.__shell = ShellUtils(client)

    def __getattr__(self, name):
        return getattr(self.__shell, name)

    def execCmd(self, command, msg):
        output = self.__shell.execCmd(command).strip()
        if self.__shell.getLastCmdReturnCode() != 0 or not output:
            raise DiscoveryException(msg + (' (%s)' % command))
        return output
class ShellWithException(object):
    def __init__(self, client):
        self.__shell = ShellUtils(client)

    def __getattr__(self, name):
        return getattr(self.__shell, name)

    def execCmd(self, command, msg):
        output = self.__shell.execCmd(command).strip()
        if self.__shell.getLastCmdReturnCode() != 0 or not output:
            raise DiscoveryException(msg + (' (%s)' % command))
        return output