def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() ipAddress = Framework.getDestinationAttribute('ip_address') credentialsId = Framework.getDestinationAttribute('credentialsId') hostId = Framework.getDestinationAttribute('hostId') hostOsh = ms_exchange_utils.restoreHostById(hostId) try: shellClient = Framework.createClient() client = PowerShellClient(shellClient, Framework) try: ExchangeServer = client.executeScenario("Exchange_Server_2007_Discovery.ps1") exchangeServerOsh = modeling.createExchangeServer(hostOsh, ipAddress, credentialsId, ExchangeServer.ExchangeSnapInVersion) exchangeServerOsh.setAttribute('guid', normalizeGuid(ExchangeServer.Guid)) exchangeServerOsh.setAttribute('fqdn', ExchangeServer.Fqdn) buildNumber = parseBuildNumber(ExchangeServer.AdminDisplayVersion) if buildNumber: exchangeServerOsh.setAttribute('build_number', buildNumber) #exchangeServerOsh.setAttribute('application_version_number', ExchangeServer.ExchangeSnapInVersion) versionNumber = parseExchangeVersion(ExchangeServer.AdminDisplayVersion) if versionNumber: exchangeServerOsh.setAttribute('application_version_number', exchange_version_mapping[versionNumber]) exchangeServerOsh.setAttribute('application_version', ExchangeServer.AdminDisplayVersion) exchangeServerOsh.setDateAttribute('creation_date', DATE_FORMAT.parse(ExchangeServer.WhenCreated)) OSHVResult.add(exchangeServerOsh) finally: client.close() except Exception, ex: logger.debugException('') strException = str(ex.getMessage()) errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() ipAddress = Framework.getDestinationAttribute('ip_address') credentialsId = Framework.getDestinationAttribute('credentialsId') hostId = Framework.getDestinationAttribute('hostId') hostOsh = ms_exchange_utils.restoreHostById(hostId) hostName = Framework.getDestinationAttribute('hostName') if not hostName or hostName == 'N/A': hostName = ms_exchange_utils.getHostNameFromWmi(Framework) if not hostName: errobj = errorobject.createError(errorcodes.FAILED_GETTING_INFORMATION_NO_PROTOCOL, ['host name'], 'Failed to obtain host name') logger.reportErrorObject(errobj) return props = Properties() props.put(AgentConstants.PROP_WMI_NAMESPACE, WMI_NAMESPACE) try: wmiClient = Framework.createClient(props) wmiAgent = WmiAgent(wmiClient, Framework) try: discoverExchangeServer(wmiAgent, ipAddress, credentialsId, OSHVResult, Framework, hostOsh, hostName) finally: wmiClient.close() except Exception, ex: message = ex.getMessage() if (re.search("Invalid\sclass", message)): message = 'Unable to get Exchange data from WMI' logger.debugException(message) errormessages.resolveAndReport(message, WMI_PROTOCOL, Framework)