Beispiel #1
0
def discoverITS(client, installpath, WEBSERVER_ID, OSHVResult):

    shellUtils = ShellUtils(client)

    webserverOSH = modeling.createOshByCmdbIdString('webserver', WEBSERVER_ID)

    sapitsOSH = ObjectStateHolder('sap_its_wgate')
    sapitsOSH.setAttribute('data_name', 'ITS_' + client.getIpAddress())
    sapitsOSH.setContainer(webserverOSH)
    OSHVResult.add(sapitsOSH)

    mapInstanceNameToAgate = getAgates(shellUtils, installpath, sapitsOSH, OSHVResult)

    filePath = installpath + '\\config\\ItsRegistryALL.xml'
    data = shellUtils.safecat(filePath)

    logger.debug('got ItsRegistryALL file')
    # data = stripNtcmdHeaders(data)
    if data == None or error(data):
        logger.error('No data found')
    else:
        builder = SAXBuilder(0)
        doc = builder.build(StringReader(data))
        root = doc.getRootElement()
        keyElem = getElementByAttrValue(root, 'key', 'name', 'AGate')
        instancesRoot = getElementByAttrValue(keyElem, 'key', 'name', 'Instances')
        instances = instancesRoot.getChildren('value')
        it = instances.iterator()
        while it.hasNext():
            instance = it.next()
            name = instance.getText()
            agates = mapInstanceNameToAgate.get(name)
            if agates != None and agates.isEmpty() == 0:
                servers(name, installpath, sapitsOSH, agates, shellUtils, OSHVResult)
def discoverConfigFile(siebelRootDir, appServerOSH, client, version,
                       OSHVResult):
    shellUtils = ShellUtils(client)
    relativePaths = ['']
    protocolType = client.getClientType()
    if protocolType == ClientsConsts.NTCMD_PROTOCOL_NAME:
        relativePaths = ['\\bin\\ENU\\', '\\bin\\']
    else:
        relativePaths = ['/bin/enu/', '/bin/ENU/', '/bin/']

    found = 0
    for relativePath in relativePaths:
        path = siebelRootDir + relativePath + 'siebel.cfg'
        try:
            data = shellUtils.safecat(path)
            if not error(data, protocolType):
                found = 1
                break
        except:
            pass
    if found == 0:
        logger.error('Failed getting configuration file')
        return

    if version != None and version != '' and (version[0] == '6'
                                              or version.find('7.8') == 0):
        updateMissingAttributes(data, appServerOSH, OSHVResult)

    lastUpdateTime = file_ver_lib.getFileLastModificationTime(shellUtils, path)

    configfile = modeling.createConfigurationDocumentOSH(
        'siebel.cfg', '', data, appServerOSH, modeling.MIME_TEXT_PLAIN,
        lastUpdateTime, "Configuration file of siebel application server")
    logger.debug('found siebel config file:')
    OSHVResult.add(configfile)
def discoverConfigFile(siebelRootDir,appServerOSH,client,version,OSHVResult):
	shellUtils = ShellUtils(client)
	relativePaths = ['']
	protocolType = client.getClientType()
	if protocolType == ClientsConsts.NTCMD_PROTOCOL_NAME:
		relativePaths = ['\\bin\\ENU\\','\\bin\\']
	else:
		relativePaths = ['/bin/enu/','/bin/ENU/','/bin/']

	found = 0
	for relativePath in relativePaths:
		path = siebelRootDir + relativePath + 'siebel.cfg'
		try:
			data = shellUtils.safecat(path)
			if not error(data,protocolType):
				found = 1
				break
		except:
			pass
	if  found==0:
		logger.error('Failed getting configuration file')
		return

	if version != None and version != '' and (version[0] == '6' or version.find('7.8') == 0):
		updateMissingAttributes(data,appServerOSH,OSHVResult)

	lastUpdateTime = file_ver_lib.getFileLastModificationTime(shellUtils, path)

	configfile = modeling.createConfigurationDocumentOSH('siebel.cfg', '', data, appServerOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, "Configuration file of siebel application server")	
	logger.debug('found siebel config file:')
	OSHVResult.add(configfile)
Beispiel #4
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
Beispiel #5
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
Beispiel #7
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    logger.info('Starting HACMP Applications')
    hostIP = Framework.getDestinationAttribute('ip_address')
    logger.debug('Host IP: ', hostIP)
    cluster = Framework.getDestinationAttribute('cluster')
    hostOS = Framework.getDestinationAttribute('host_os')
    hostOS = hostOS or 'NA'
    protocolName = Framework.getDestinationAttribute('Protocol')
    hostId = Framework.getDestinationAttribute('hostId')
    ##  Get Parameter Section
    cldisp_command = Framework.getParameter('cldisp_command') or 'cldisp'
    cllsif_command = Framework.getParameter('cllsif_command') or 'cllsif'

    try:
        client = Framework.createClient()
        shell = ShellUtils(client)
        #   If we get  good client connection , run the client commands to get the Application information for the cluster
        HostOSH = modeling.createOshByCmdbIdString('host', hostId)
        ClusterOSH = getclusterOSH(cluster)
        appDictionary = getapplicationInfo(shell, cldisp_command, Framework)
        resourceDictionary = getresourceinfo(shell, cllsif_command)
        OSHVResult.addAll(
            createserviceapplicationOSH(shell, appDictionary,
                                        resourceDictionary, HostOSH,
                                        ClusterOSH, Framework))
        client.close()
    except JavaException, ex:
        strException = ex.getMessage()
        logger.debugException('')
        errormessages.resolveAndReport(strException, protocolName, Framework)
def DiscoveryMain(Framework):

	# Create our dynamic SSH credential entry	
	sshCredOSH = ObjectStateHolder('sshprotocol')
	sshCredOSH.setStringAttribute('sshprotocol_authmode','password')
	sshCredOSH.setStringAttribute('protocol_username','root')

	# Enter a real password here instead of <YOUR PASSWORD HERE> string
	sshCredOSH.setBytesAttribute('protocol_password', '<YOUR PASSWORD HERE>')
	
	# List of required attributes to create SQL credential:
	# protocol name - sqlprotocol
	# protocol_port (integer)
	# sqlprotocol_dbname (string) - for use with  db2
	# sqlprotocol_dbsid (string) - for use with oracle, MicrosoftSQLServerNTLM, 
	# sqlprotocol_dbtype (db_types) - can be one of the following: 
	# 	MicrosoftSQLServer, db2, Sybase, oracle, MicrosoftSQLServerNTLM
	
	# List of required attributes to create NTCMD credential:
	# protocol name - ntadminprotocol
	# ntadminprotocol_ntdomain (string) - Windows Domain name

	credentialId = Framework.createDynamicCredential(sshCredOSH)


	# Use our Dynamic credential in order to connect to the remote machine
	client = Framework.createClient(credentialId)
	
	# Create shellUtils
	shellUtils = ShellUtils(client)
	
	# Execute some command
	shellUtils.execCmd('uname -a')


	# Explicitly Release all our used resources
	shellUtils.closeClient()
	Framework.releaseDynamicCredential(credentialId)
Beispiel #9
0
def discoverITS(client, installpath, WEBSERVER_ID, OSHVResult):

    shellUtils = ShellUtils(client)

    webserverOSH = modeling.createOshByCmdbIdString('webserver', WEBSERVER_ID)

    sapitsOSH = ObjectStateHolder('sap_its_wgate')
    sapitsOSH.setAttribute('data_name', 'ITS_' + client.getIpAddress())
    sapitsOSH.setContainer(webserverOSH)
    OSHVResult.add(sapitsOSH)

    mapInstanceNameToAgate = getAgates(shellUtils, installpath, sapitsOSH,
                                       OSHVResult)

    filePath = installpath + '\\config\\ItsRegistryALL.xml'
    data = shellUtils.safecat(filePath)

    logger.debug('got ItsRegistryALL file')
    # data = stripNtcmdHeaders(data)
    if data == None or error(data):
        logger.error('No data found')
    else:
        builder = SAXBuilder(0)
        doc = builder.build(StringReader(data))
        root = doc.getRootElement()
        keyElem = getElementByAttrValue(root, 'key', 'name', 'AGate')
        instancesRoot = getElementByAttrValue(keyElem, 'key', 'name',
                                              'Instances')
        instances = instancesRoot.getChildren('value')
        it = instances.iterator()
        while it.hasNext():
            instance = it.next()
            name = instance.getText()
            agates = mapInstanceNameToAgate.get(name)
            if agates != None and agates.isEmpty() == 0:
                servers(name, installpath, sapitsOSH, agates, shellUtils,
                        OSHVResult)
Beispiel #10
0
def DiscoveryMain(Framework):

    logger.info('Starting HACMP Topology')
    OSHVResult = ObjectStateHolderVector()

    # Get Destination Attribute Section

    hostIP = Framework.getDestinationAttribute('ip_address')
    hostOS = Framework.getDestinationAttribute('host_os')
    hostOS = hostOS or 'NA'
    hostCmdbId = Framework.getDestinationAttribute('hostId')

    physicalHostOsh = modeling.createOshByCmdbId('host', hostCmdbId)
    #  Get Parameter Section

    AIX_ClusterPackageName = Framework.getParameter(
        'AIX_ClusterPackageName') or 'cluster.license'
    cldisp_command = Framework.getParameter('cldisp_command') or 'cldisp'

    try:
        client = Framework.createClient()
        shell = ShellUtils(client)

        # We got a good client connection , determine if HACMP is installed
        # If we find HACMP then build a Cluster and Clustered Servers (Nodes) with storage and interfaces

        version = getClusterVersion(shell, hostOS, AIX_ClusterPackageName)
        if version is None:
            logger.warnException('')
            Framework.reportWarning("No HACMP package found")
        else:
            logger.info(concatenate('HACMP package version: ', version))
            hostOSH = createHostOSH(hostIP)
            OSHVResult.addAll(
                CreateCluster(shell, version, hostOSH, hostIP, cldisp_command,
                              Framework))
            OSHVResult.addAll(createstorage(shell, physicalHostOsh))
            OSHVResult.addAll(
                createinterfaces(shell, physicalHostOsh, Framework))
            client.close()
    except JavaException, ex:
        strException = ex.getMessage()
        logger.debugException('')
        Framework.reportError("Protocol Failure, Unable to connect to client")
Beispiel #11
0
def DiscoveryMain(Framework):
    protocol = Framework.getDestinationAttribute('Protocol')
    protocolName = errormessages.protocolNames.get(protocol) or protocol
    hostId = Framework.getDestinationAttribute('hostId')
    reportHostName = Framework.getParameter('reportHostNameAsVmName')

    vector = ObjectStateHolderVector()
    try:
        client = Framework.createClient()
        try:
            shell = ShellUtils(client)

            if isIvmSystem(shell):
                vector.addAll(
                    discoverIvmTopology(shell, hostId, reportHostName))
            else:
                Framework.reportWarning(
                    "The destination host is not a part of HP IVM system")
        finally:
            client.close()
    except JavaException, ex:
        strException = ex.getMessage()
        logger.debugException('')
        errormessages.resolveAndReport(strException, protocolName, Framework)
def DiscoveryMain(Framework):

    # Create our dynamic SSH credential entry
    sshCredOSH = ObjectStateHolder('sshprotocol')
    sshCredOSH.setStringAttribute('sshprotocol_authmode', 'password')
    sshCredOSH.setStringAttribute('protocol_username', 'root')

    # Enter a real password here instead of <YOUR PASSWORD HERE> string
    sshCredOSH.setBytesAttribute('protocol_password', '<YOUR PASSWORD HERE>')

    # List of required attributes to create SQL credential:
    # protocol name - sqlprotocol
    # protocol_port (integer)
    # sqlprotocol_dbname (string) - for use with  db2
    # sqlprotocol_dbsid (string) - for use with oracle, MicrosoftSQLServerNTLM,
    # sqlprotocol_dbtype (db_types) - can be one of the following:
    # 	MicrosoftSQLServer, db2, Sybase, oracle, MicrosoftSQLServerNTLM

    # List of required attributes to create NTCMD credential:
    # protocol name - ntadminprotocol
    # ntadminprotocol_ntdomain (string) - Windows Domain name

    credentialId = Framework.createDynamicCredential(sshCredOSH)

    # Use our Dynamic credential in order to connect to the remote machine
    client = Framework.createClient(credentialId)

    # Create shellUtils
    shellUtils = ShellUtils(client)

    # Execute some command
    shellUtils.execCmd('uname -a')

    # Explicitly Release all our used resources
    shellUtils.closeClient()
    Framework.releaseDynamicCredential(credentialId)
Beispiel #13
0
 def __init__(self, client):
     self.__shell = ShellUtils(client)
 def __init__(self, client):
     self.__shell = ShellUtils(client)
Beispiel #15
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    cmclconfig_path = getParameter(Framework, 'cmclconfig_path',
                                   '/etc/cmcluster/')
    cmclconfig_files_pattern = getParameter(Framework, 'cmclconfig_file',
                                            'ascii')

    client = None
    try:
        try:
            client = Framework.createClient()
            shell = ShellUtils(client)

            clusterDiscoverer = ServiceGuardClusterDiscoverer(shell)
            cluster = clusterDiscoverer.discover()

            if cluster.packages:
                # in case any running packages were discovered,
                # try to discover package mount points, ips and networks
                # which do not appear in cmview command output
                addPkgInfoDiscoverer = AdditionalPackageResourcesDiscoverer(
                    shell)
                packageNameToPackageMap = addPkgInfoDiscoverer.discover(
                    cmclconfig_path, cluster)
                #merging data into the stored packages DO
                for package in cluster.packages:
                    addPackage = packageNameToPackageMap.get(package.name)
                    if addPackage:
                        package.mountPoints = addPackage.mountPoints
                        package.additionalIpList = addPackage.additionalIpList
                        package.ipNetworkList = addPackage.ipNetworkList

            endpointReporter = netutils.EndpointReporter(
                netutils.ServiceEndpointBuilder())
            quorumServerReporter = service_guard.QuorumServerReporter(
                service_guard.QuorumServerBuilder(), endpointReporter)
            vector = Reporter(quorumServerReporter).report(cluster)
            OSHVResult.addAll(vector)

            softwareInformationList = []
            for discoverer in (OracleDiscoverer(shell),
                               OracleIasDiscoverer(shell)):
                try:
                    softwareInformationList.extend(discoverer.discover())
                except:
                    logger.debugException('')

            if softwareInformationList:
                relationsBuilder = PackageToRunningSoftwareTopologyBuilder(
                    cluster)
                OSHVResult.addAll(
                    relationsBuilder.build(softwareInformationList))

            if cluster.osh != None:
                discoverConfigFiles(Framework, cluster.osh, shell,
                                    cmclconfig_path, cmclconfig_files_pattern,
                                    OSHVResult)
            else:
                errobj = errorobject.createError(
                    errorcodes.SERVICE_GUARD_CLUSTER_NOT_FOUND, None,
                    'Service Guard Cluster not found in discovery')
                logger.reportWarningObject(errobj)
        except:
            msg = sys.exc_info()[1]
            strmsg = '%s' % msg
            if (strmsg.lower().find('timeout') > -1):
                errobj = errorobject.createError(
                    errorcodes.CONNECTION_TIMEOUT_NO_PROTOCOL, None,
                    'Connection timed out')
                logger.reportErrorObject(errobj)
                logger.debugException('Connection timed out')
            else:
                errobj = errormessages.resolveError(strmsg, 'shell')
                logger.reportErrorObject(errobj)
                logger.errorException(strmsg)

    finally:
        if client != None:
            client.close()
    return OSHVResult