def discoverReplication(self, mysqlOsh): """ Tries to find config variables related to mysql replication @param ObjectStateHolder mysqlOsh mysql osh @return list list of OSHs """ masterHostIp = self.getProperty('master-host') if not masterHostIp: return if not netutils.isValidIp(masterHostIp): try: resolver = netutils.DnsResolverByShell(self.shell) masterHostIp = resolver.resolveIpsByHostname(masterHostIp)[0] except netutils.ResolveException: logger.warn('Failed to resolve Master Host into IP') return masterPort = self.getProperty('master-port') mysqlReplicationOsh = ObjectStateHolder('mysql_replication') mysqlReplicationOsh.setAttribute('data_name', 'MySQL Replication') mysqlReplicationOsh.setContainer(mysqlOsh) self.setAttribute(mysqlReplicationOsh, 'master_user', self.REPL_ARGS_MAPPING) self.setAttribute(mysqlReplicationOsh, 'master_connect_retry', self.REPL_ARGS_MAPPING) masterHostOsh = modeling.createHostOSH(masterHostIp) serviceAddressOsh = modeling.createServiceAddressOsh(masterHostOsh, masterHostIp, masterPort, modeling.SERVICEADDRESS_TYPE_TCP) clientServerLink = modeling.createLinkOSH('client_server', mysqlReplicationOsh, serviceAddressOsh) clientServerLink.setStringAttribute('clientserver_protocol', 'TCP') clientServerLink.setLongAttribute('clientserver_destport', int(masterPort)) # masterMysqlOsh = modeling.createDatabaseOSH('mysql', 'MySQL. Port ' + masterPort, masterPort, masterHostIp, masterHostOsh) # useLink = modeling.createLinkOSH('use', masterHostOsh, serviceAddressOsh) return [masterHostOsh, serviceAddressOsh, clientServerLink, mysqlReplicationOsh]
class Cluster: '''Data Object represents Service Guard Cluster ''' def __init__(self, name, version, ipAddress, propertiesFileContent, quorumServer=None): r'@types: str, str, str, str, QuorumServer' self.name = name self.version = version self.propertiesFileContent = propertiesFileContent self.ipAddress = ipAddress self.osh = None self.nodes = [] self.packages = [] self.quorumServer = quorumServer def build(self): ''' Creates serviceguardcluster OSH @returns: instance of serviceguardcluster OSH ''' if self.name: self.osh = ObjectStateHolder('serviceguardcluster') self.osh.setAttribute('data_name', self.name) modeling.setAppSystemVendor(self.osh) if self.version: self.osh.setStringAttribute('version', self.version) return self.osh
def report(self, region_osh, event_osh=None): vector = ObjectStateHolderVector() osh = ObjectStateHolder('host_node') osh.setAttribute('name', self.name) logger.debug("self.id:", self.id) vector.add(osh) if self.ips: for ip in self.ips: ip_osh = modeling.createIpOSH(str(ip)) vector.add(ip_osh) vector.add(modeling.createLinkOSH('contained', osh, ip_osh)) if self.image: imageOsh, image_vector = self.image.report(region_osh) vector.addAll(image_vector) vector.add(modeling.createLinkOSH('dependency', osh, imageOsh)) if self.hypervisorHostName: hypervisorOsh, hypervisor_vector = Hypervisor(self.hypervisorHostName).report(region_osh) vector.addAll(hypervisor_vector) vector.add(modeling.createLinkOSH('execution_environment', hypervisorOsh, osh)) if self.flavor: flavorOsh, flavor_vector = self.flavor.report(region_osh) vector.addAll(flavor_vector) vector.add(modeling.createLinkOSH('dependency', osh, flavorOsh)) if event_osh: vector.add(modeling.createLinkOSH('dependency', osh, event_osh)) return osh, vector
def DiscoveryMain(Framework): credentialsId = Framework.getDestinationAttribute('credentialsId') OSHVResult = ObjectStateHolderVector() matchers = SiebelAgent.SIEBEL_DEFAULT_ENTERPRISE_MATCHERS ip = Framework.getDestinationAttribute('ip_address') port = Framework.getDestinationAttribute('port') if port == 'NA': port = None try: client = None try: client = siebel_common.createClient(Framework, ip, matchers, credentialsId, port) username = client.getUserName() enterprise = client.getEnterprise() siteOSH = ObjectStateHolder('siebel_site') siteOSH.setAttribute('data_name', enterprise) siteOSH.setAttribute('gateway_address', ip) modeling.setAppSystemVendor(siteOSH) start_srvrmgr_discovery(client, ip, username, enterprise, siteOSH, Framework, OSHVResult) finally: if client is not None: client.close() except Exception, ex: strException = str(ex.getMessage()) errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework) logger.debugException('')
def buildLogin(self, login): if not login: raise ValueError('DB User is not specified') osh = ObjectStateHolder('dbuser') if login.getName(): osh.setAttribute('data_name', login.getName()) return osh
def report(self, container): vector = ObjectStateHolderVector() zone_osh = ObjectStateHolder('openstack_zone') zone_osh.setStringAttribute('name', self.name) zone_osh.setContainer(container) vector.add(zone_osh) return zone_osh, vector
def build_layer2_connection(layer2_connection): ''' Build Layer 2 connection topology. @type param: SNMP_CDP_LLDP.Laer2Connwction -> OSHV ''' oshv = ObjectStateHolderVector() (local_device_osh, local_device_ip_address_osh, local_device_interface_osh, local_device_member_ip_osh) = build_network_device(layer2_connection.local_device) (remote_device_osh, remote_device_ip_address_osh, remote_device_interface_osh, remote_device_member_ip_osh) = build_network_device(layer2_connection.remote_device) if local_device_osh and local_device_interface_osh and remote_device_osh and remote_device_interface_osh: layer2_osh = ObjectStateHolder('layer2_connection') layer2_osh.setAttribute('layer2_connection_id',str(hash(layer2_connection.local_device.address_id + layer2_connection.remote_device.address_id))) layer2_member_local_interface_osh = modeling.createLinkOSH('member', layer2_osh, local_device_interface_osh) layer2_member_remote_interface_osh = modeling.createLinkOSH('member', layer2_osh, remote_device_interface_osh) oshv.add(local_device_osh) oshv.add(local_device_interface_osh) if (local_device_ip_address_osh): oshv.add(local_device_ip_address_osh) oshv.add(local_device_member_ip_osh) oshv.add(remote_device_osh) oshv.add(remote_device_interface_osh) if (remote_device_ip_address_osh): oshv.add(remote_device_ip_address_osh) oshv.add(remote_device_member_ip_osh) oshv.add(layer2_osh) oshv.add(layer2_member_local_interface_osh) oshv.add(layer2_member_remote_interface_osh) return oshv
def _buildWorkProcess(name, numberOfWorkingProcesses): '@types: str, digit -> osh' osh = ObjectStateHolder("sap_work_process") osh.setAttribute("data_name", name) if str(numberOfWorkingProcesses).isdigit(): osh.setAttribute("number_wp", int(numberOfWorkingProcesses)) return osh
def buildHanaSoftware(self, software): r'@types: Software -> ObjectStateHolder' assert software osh = ObjectStateHolder("running_software") osh.setStringAttribute('name', software.name) self.updateDiscoveredProductName(osh, software.name) return osh
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() credentialsId = Framework.getDestinationAttribute('credentialsId') ip_address = Framework.getDestinationAttribute('ip_address') url = Framework.getDestinationAttribute('name') version = Framework.getDestinationAttribute('version') query_chunk_size = Framework.getParameter('query_chunk_size') organization = Framework.getParameter('organization') logger.debug('UDDI_Registry started query_chunk_size', query_chunk_size, ' organization:', organization, ' credentialsId', credentialsId) properties = Properties() properties.setProperty(UDDIAgent.CHUNK_SIZE,str(query_chunk_size)) properties.setProperty('ORGANIZATION',str(organization)) properties.setProperty('uddi_version', version) try: uddiAgent = Framework.getAgent(AgentConstants.UDDI_AGENT, ip_address, credentialsId, properties) registryOSH = ObjectStateHolder('uddiregistry') registryOSH.setAttribute('name', url) registryOSH.setAttribute('version', int(version)) OSHVResult.add(registryOSH) logger.debug('Do Uddi Explore url:', url) doUddiExplore(uddiAgent, registryOSH, OSHVResult) except MissingSdkJarException, ex: logger.debugException(ex.getMessage()) Framework.reportError("UDDI SDK jars are missed. Refer documentation for details")
def getCICSRegions(ls, subsystemOSH): regiondict = {} str_name = 'name' if UCMDB_VERSION < 9: str_name = 'data_name' vector = ObjectStateHolderVector() # Get the active jobs running on the lpar # Look for the program name , if it is DFHSIP then we have found an active CICS job # The job name is the CICS region output = ls.evSysInfoCmd(_CMD_F_ALL_JOBS,'40') if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: if isNotNull(line): splitline = line.split('|') if len(splitline) == 10: if splitline[9] == 'DFHSIP': region = splitline[0].strip() #logger.debug ('Found region ===> ',region) cicsRegionOSH = ObjectStateHolder('cics_region') cicsRegionOSH.setAttribute(str_name, region) cicsRegionOSH.setContainer(subsystemOSH) addInfoOnRegions(ls, cicsRegionOSH) if not(regiondict.has_key(region)): regiondict[region] = cicsRegionOSH vector.add(cicsRegionOSH) return vector, regiondict
def addsoftwaretoclusterOSH(ClusterOSH, myVec, primarynode_ip, primarynode_name, secondarynode_ip, secondarynode_name, serviceOSH): if primarynode_ip and primarynode_name: PrimaryhostOSH = gethostOSH(primarynode_ip, primarynode_name) priclusterSoftwareOSH = ObjectStateHolder('failoverclustersoftware') priclusterSoftwareOSH.setAttribute('data_name', 'HACMP Cluster Software') priclusterSoftwareOSH.setContainer(PrimaryhostOSH) myVec.add(PrimaryhostOSH) myVec.add(priclusterSoftwareOSH) memberOSH = modeling.createLinkOSH('member', ClusterOSH, priclusterSoftwareOSH) myVec.add(memberOSH) runOSH = modeling.createLinkOSH('run', priclusterSoftwareOSH, serviceOSH) myVec.add(runOSH) potrunOSH = modeling.createLinkOSH('potentially_run', priclusterSoftwareOSH, serviceOSH) myVec.add(potrunOSH) if secondarynode_ip and secondarynode_name: SecondaryhostOSH = gethostOSH(secondarynode_ip, secondarynode_name) secclusterSoftwareOSH = ObjectStateHolder('failoverclustersoftware') secclusterSoftwareOSH.setAttribute('data_name', 'HACMP Cluster Software') secclusterSoftwareOSH.setContainer(SecondaryhostOSH) myVec.add(SecondaryhostOSH) myVec.add(secclusterSoftwareOSH) memberOSH = modeling.createLinkOSH('member', ClusterOSH, secclusterSoftwareOSH) myVec.add(memberOSH) potrunOSH = modeling.createLinkOSH('potentially_run', secclusterSoftwareOSH, serviceOSH) myVec.add(potrunOSH) myVec.add(ClusterOSH) containedOSH = modeling.createLinkOSH('contained', ClusterOSH, serviceOSH) myVec.add(containedOSH) return myVec
def buildHostByHostname(self, hostname): r'@types: str -> ObjectStateHolder[node]' if not (hostname and hostname.strip()): raise ValueError("Hostname is not specified or empty") osh = ObjectStateHolder('node') osh.setStringAttribute('name', hostname) return osh
def build(self): osh = ObjectStateHolder('host_node') osh.setAttribute('host_key', self.hostId) osh.setBoolAttribute('host_iscomplete', 1) setAttribute(osh, 'name', self.__hostname) setAttribute(osh, 'primary_dns_name', self.__fqdn) return osh
def createTransportPathObjects(cluster, hostOshByName, resultsVector, framework): for tPath in cluster.transportPaths: sourceInterfaceResult = createTransportInterfaceObject(tPath.fromNode, tPath.fromInterface, cluster, hostOshByName) targetInterfaceResult = createTransportInterfaceObject(tPath.toNode, tPath.toInterface, cluster, hostOshByName) if sourceInterfaceResult and targetInterfaceResult: (sourceInterfaceOsh, sourceAdapter) = sourceInterfaceResult (targetInterfaceOsh, targetAdapter) = targetInterfaceResult resultsVector.add(sourceInterfaceOsh) resultsVector.add(targetInterfaceOsh) versionAsDouble = logger.Version().getVersion(framework) if versionAsDouble >= 9: layer2Osh = ObjectStateHolder('layer2_connection') linkId = "%s:%s" % (sourceAdapter.mac, targetAdapter.mac) linkId = str(hash(linkId)) layer2Osh.setAttribute('layer2_connection_id', linkId) sourceMemberLink = modeling.createLinkOSH('member', layer2Osh, sourceInterfaceOsh) targetMemberLink = modeling.createLinkOSH('member', layer2Osh, targetInterfaceOsh) resultsVector.add(layer2Osh) resultsVector.add(sourceMemberLink) resultsVector.add(targetMemberLink) else: layer2Link = modeling.createLinkOSH('layertwo', sourceInterfaceOsh, targetInterfaceOsh) resultsVector.add(layer2Link)
def discoverContentRules(self): contentRuleQueryBuilder = SnmpQueryBuilder(CNT_OID_OFFSET) contentRuleQueryBuilder.addQueryElement(2, 'cnt_name') contentRuleQueryBuilder.addQueryElement(4, 'ipserver_address') contentRuleQueryBuilder.addQueryElement(5, 'ipport_type') contentRuleQueryBuilder.addQueryElement(6, 'ipport_number') contentRuleQueryBuilder.addQueryElement(68, 'ip_range') snmpRowElements = self.snmpAgent.getSnmpData(contentRuleQueryBuilder) for snmpRowElement in snmpRowElements: virtualServer = modeling.createHostOSH(snmpRowElement.ipserver_address, 'clusteredservice') virtualServerHostKey = virtualServer.getAttributeValue('host_key') virtualServer.setAttribute('data_name', virtualServerHostKey) self.OSHVResult.add(modeling.createLinkOSH('owner', self.css, virtualServer)) self.OSHVResult.add(virtualServer) resourcePool = ObjectStateHolder('loadbalancecluster') resourcePool.setStringAttribute('data_name', snmpRowElement.cnt_name) self.OSHVResult.add(modeling.createLinkOSH('contained', resourcePool, virtualServer)) self.OSHVResult.add(resourcePool) self.resourcePools[snmpRowElement.cnt_name] = resourcePool serviceAddress = modeling.createServiceAddressOsh(virtualServer, snmpRowElement.ipserver_address, snmpRowElement.ipport_number, CNT_PROTOCOL_MAP[snmpRowElement.ipport_type]) serviceAddress.setContainer(virtualServer) self.OSHVResult.add(serviceAddress) # KB specific: fix of port translations self.resourcePoolsToServiceAddress[snmpRowElement.cnt_name] = serviceAddress for i in range(int(snmpRowElement.ip_range)): #TODO: Add all IPs from range pass
def getPublishersFromDistributor(self,oshv,distributor, distributorDatabaseName,sqlServerId): #check if i am a distributor first rs = self.connection.doCall('exec sp_helpdistpublisher') publishers = HashMap() sqlServers = HashMap() while(rs.next()): publisherName = rs.getString('name') publisher = ObjectStateHolder('sqlserverpublisher') sqlServer = self.createSqlServer(publisherName,oshv,sqlServerId) publisher.setContainer(sqlServer) publisher.setAttribute(Queries.DATA_NAME,publisherName) publishers.put(publisherName,publisher) sqlServers.put(publisherName,sqlServer) oshv.add(sqlServer) oshv.add(publisher) oshv.add(modeling.createLinkOSH('dblink',publisher,distributor)) #add the dblink between the distributor and the publisher rs.close() if(publishers.size() == 0): return #for each publisher get the published dbs workingDatabase = self.connection.getWorkingDatabase() self.connection.setWorkingDatabase(distributorDatabaseName) itr = publishers.keySet().iterator() while (itr.hasNext()): publisherName = itr.next() publisher = publishers.get(publisherName) sqlServer = sqlServers.get(publisherName) self.getPublications(publisherName,sqlServer,publisher,oshv,sqlServerId) self.connection.setWorkingDatabase(workingDatabase)
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 build_network_device(device): ''' Build Layer 2 connection end. @type param: NetworkDevice -> OSH ''' device_osh = None device_ip_address_osh = None device_interface_osh = None device_member_ip = None if device.ucmdb_id: device_osh = modeling.createOshByCmdbIdString('node', device.ucmdb_id) if device.mac_address: if not device_osh: device_osh = modeling.createCompleteHostOSH('node', device.mac_address) device_interface_osh = modeling.createInterfaceOSH(device.mac_address, device_osh) if device.ip_address: if not device_osh: device_osh = modeling.createHostOSH(device.ip_address) device_ip_address_osh = modeling.createIpOSH(device.ip_address) device_member_ip = modeling.createLinkOSH('contained', device_osh, device_ip_address_osh) if device.port: if device_interface_osh: device_interface_osh.setAttribute('interface_name', device.port) elif device_osh: device_interface_osh = ObjectStateHolder('interface') device_interface_osh.setContainer(device_osh) device_interface_osh.setAttribute('interface_name', device.port) return device_osh, device_ip_address_osh, device_interface_osh, device_member_ip
def build(self): lbcOsh = ObjectStateHolder('loadbalancecluster') lbcOsh.setStringAttribute('name', self.vServer.name) containment_link = modeling.createLinkOSH('containment', lbcOsh, self.crgOsh) membershipLink = modeling.createLinkOSH('membership', lbcOsh, self.netscaler_software_osh) self.osh = lbcOsh return self.newVector(lbcOsh, containment_link, membershipLink)
def fillOshDict(self, processor, attrDefs): """ Sets OSHs attributes and stores them in the inner dictionaries. SheetProcessor, {str: AttrTypeDef} -> None """ sheetName = processor.getSheetName() for rowNum in xrange(1, processor.getLastRowNum()+1): osh = ObjectStateHolder(sheetName) reference = self.getOshKey(sheetName, rowNum) compositeKey = None for colNum in xrange(processor.getLastColNum(0)): attrName = processor.getCellValueAt(0, colNum) if not attrName: logger.debug('Column doesn\'t have the header representing an attribute name') continue if attrName.startswith(self.__COMMENT_START) or attrName == 'root_container': continue try: attrValue = processor.getCellValueAt(rowNum, colNum) if attrValue and ((type(attrValue) == type(' ')) or (type(attrValue) == type(u' '))): attrValue = attrValue.strip() if attrValue or self.set_empty_value: self.classModelUtils.setCiAttribute(osh, attrName, attrValue, attrDefs[attrName].attrType) #TODO: this part is left for backward compatibility #this code allows to refer CIs by composition of key attributes #but without class name and should be deprecated #@see: resolveOsh method if attrDefs[attrName].isId: if compositeKey: if type(attrValue) in [type(u''), type('')]: compositeKey += self.__KEY_DELIMITER + attrValue else: compositeKey += self.__KEY_DELIMITER + str(attrValue) else: compositeKey = attrValue except Exception, e: logger.debugException(reference) logger.reportWarning(e.args[0]) if osh.getAttributeAll().size() == 0: continue #prepare references to object in view like 'key1|key2|key3' -> OSH if compositeKey: if self.oshByCompositeKeys.has_key(compositeKey): logger.reportWarning('Object references are overlapped. Not all relations can be assigned') logger.warn("%s %i: Object reference '%s' is overlapped. It won't be accessible. " % (sheetName, rowNum, compositeKey)) self.oshByCompositeKeysCount[compositeKey] = self.oshByCompositeKeysCount[compositeKey] + 1 self.oshByCompositeKeys[compositeKey] = osh else: self.oshByCompositeKeys[compositeKey] = osh self.oshByCompositeKeysCount[compositeKey] = 1 #prepare object reference in form 'sheetName rowNumber' to uniquely identify OSH if self.keysToOsh.has_key(reference): raise Exception, 'This can only happen if references map was modified outside' else: self.keysToOsh[reference] = osh
def buildDatabase(self, database): if not database: raise ValueError('Database is not specified') osh = ObjectStateHolder('sybasedb') osh.setAttribute('data_name', database.getName()) if database.getCreateDate(): osh.setAttribute('createdate', database.getCreateDate()) return osh
def buildJmsStore(self, store): r'''@types: jms.DataStorage -> ObjectStateHolder ''' jmsdatastoreOSH = ObjectStateHolder('jmsdatastore') jmsdatastoreOSH.setAttribute('name', store.getName()) if store.getObjectName(): jmsdatastoreOSH.setAttribute('j2eemanagedobject_objectname', store.getObjectName()) return jmsdatastoreOSH
def buildDevice(self, device): if not device: raise ValueError('DB Device is not specified') osh = ObjectStateHolder('sybase_device') osh.setAttribute('data_name', device.getName()) osh.setAttribute('resource_path', device.getPhysicalName()) osh.setAttribute('dbdatafile_fileid', device.getDeviceId()) return osh
def buildTrexSystem(self, sapSystem): r'@types: sap.System -> ObjectStateHolder[sap_trex_system]' if not sapSystem: raise ValueError("SAP System is not specified") osh = ObjectStateHolder('sap_trex_system') osh.setStringAttribute('name', sapSystem.getName()) osh.setStringAttribute('vendor', sap.VENDOR) return osh
def __createAS400AgentOSH(self, ip_address): ''' @types str->ObjectStateHolder ''' as400Osh = ObjectStateHolder('as400') as400Osh.setAttribute('application_ip', ip_address) as400Osh.setAttribute('data_name', 'as400') return as400Osh
def buildSapSystem(self, system): r'@types: sap.System -> ObjectStateHolder' osh = ObjectStateHolder("sap_system") osh = self.updateSystemType(osh, system.type) osh.setAttribute("data_name", system.getName()) self.updateUuid(osh, system.uuid) modeling.setAppSystemVendor(osh) return osh
def reportVcloudUri(self, cloud, vcloudRootOsh, vector): if cloud.urlString: uriOsh = ObjectStateHolder('uri_endpoint') uriOsh.setStringAttribute('uri', cloud.urlString) vector.add(uriOsh) usageLink = modeling.createLinkOSH('usage', vcloudRootOsh, uriOsh) vector.add(usageLink)
def build(self, vcloud): if vcloud is None: raise ValueError("vcloud is None") vcloudOsh = ObjectStateHolder('vmware_vcloud') if vcloud.companyName: vcloudOsh.setStringAttribute('name', vcloud.companyName) return vcloudOsh
def visitAwsEbs(self, ebs): r'@types: aws_store.Ebs -> ObjectStateHolder' osh = ObjectStateHolder('logical_volume') osh.setAttribute('logical_volume_global_id', ebs.getId()) if ebs.sizeInMb and ebs.sizeInMb.value() is not None: size = Double.valueOf(ebs.sizeInMb.value()) osh.setAttribute('logicalvolume_size', size) return osh
def visitEc2AmiInstanceConfig(self, ec2AmiInstanceConfig): r'@types: ec2.Ami.Instance -> ObjectStateHolder' ami = ec2AmiInstanceConfig.ami instance = ec2AmiInstanceConfig.instance osh = ObjectStateHolder('amazon_ec2_config') osh.setStringAttribute('name', ami.getName()) osh.setStringAttribute('ami_visibility', str(ami.getVisibility())) osh.setStringAttribute('description', ami.description) osh.setStringAttribute('type', instance.type) osh.setStringAttribute('ami_id', ami.getId()) index = instance.launchIndex if index and index.value() is not None: osh.setAttribute('ami_launch_index', index.value()) if instance.getKeyPairName(): osh.setAttribute('key_pair_name', instance.getKeyPairName()) return osh
def StepMain(Framework): logger.debug('Start dependency mapping') # get result from workflow state workflowState = Framework.getWorkflowState() searchResult = workflowState.getProperty( DependenciesDiscoveryConsts.DEPENDENCIES_DISCOVERY_RESULT) oshv = ObjectStateHolderVector() dependencyCount = 0 if searchResult: providerServiceOsh = None providerDeployable = searchResult.getProviderDeployable() if providerDeployable: providerServiceOsh = providerDeployable.getDeployable() if providerServiceOsh: logger.debug( 'The search result does not contain a provider object, generate one from destination data instead' ) triggerId = Framework.getCurrentDestination().getId() providerType = Framework.getDestinationAttribute('PROVIDERTYPE') providerServiceOsh = ObjectStateHolder( providerType, CmdbObjectID.Factory.restoreObjectID(triggerId)) moreProviderOshs = createOtherProviderOshsIfNeed(Framework) for index in range(0, searchResult.size()): deployable = searchResult.get(index) deployableOsh = deployable.getDeployable() if providerServiceOsh.compareTo(deployableOsh): dependencyNames = [] references = [] for dependency in deployable.getDependencies(): dependencyName = dependency.getDependencyName() variables = dependency.getExportVariables() logger.debug('%s export variables found by dependency %s' % (variables.size(), dependencyName)) dependencyNames.append(dependencyName) for var in variables: varName = var.getName() values = var.getValues() logger.debug('Variable %s:%s' % (varName, values)) if varName.lower() == REFERENCES: references += list(values) reference = references and ','.join(references) logger.debug( 'Found %s link from %s(%s) to %s(%s) by dependency [%s] with reference %s' % (CONSUMER_PROVIDER_LINK_TYPE, deployableOsh.getObjectClass(), deployableOsh.getCmdbId(), providerServiceOsh.getObjectClass(), providerServiceOsh.getCmdbId(), '/'.join(dependencyNames), reference)) consumerProviderLink = modeling.createLinkOSH( CONSUMER_PROVIDER_LINK_TYPE, deployableOsh, providerServiceOsh) if reference: consumerProviderLink.setAttribute(REFERENCES, reference) oshv.add(consumerProviderLink) dependencyCount += 1 for otherProviderOsh in moreProviderOshs: oshv.add( modeling.createLinkOSH(CONSUMER_PROVIDER_LINK_TYPE, deployableOsh, otherProviderOsh)) else: logger.debug('Ignore self link found on %s(%s)' % (deployableOsh.getObjectClass(), deployableOsh.getCmdbId())) logger.debug('%s consumer-provider link(s) found' % dependencyCount) if dependencyCount: Framework.sendObjects(oshv) Framework.flushObjects() logger.debug("Finished sending results")
for importWsdldName in importWsdldNames: importData = netutils.doHttpGet(wsdl_url).strip() importWsdldNameToData[importWsdldName] = importData services = defintion.getServices().values() for service in services: serviceName = service.getQName().getLocalPart() namespaceURI = service.getQName().getNamespaceURI() targetNamespace = defintion.getTargetNamespace() if wsdl_url == None and namespaceURI != None: wsdl_url = namespaceURI + '?WSDL' wsOSH = ObjectStateHolder('webservice') wsOSH.setAttribute('data_name', targetNamespace) wsOSH.setAttribute('service_name', serviceName) if wsdl_url: wsOSH.setAttribute('wsdl_url', wsdl_url) OSHVResult.add(wsOSH) if wsdl_url_data: configFileName = "%s.xml" % serviceName cfOSH = modeling.createConfigurationDocumentOSH( configFileName, wsdl_url, wsdl_url_data, wsOSH, modeling.MIME_TEXT_XML, None, "This document holds the content of the WSDL file") OSHVResult.add(cfOSH) # Add import CFs
def discover_vlans(self): bridge_mac_address = self.get_bridge_mac_address() vlan_table_res = self.snmp_client.executeQuery( self.VLAN_TABLE_MIB) #@@CMD_PERMISION snmp protocol execution vlan_table = vlan_table_res.asTable() if len(vlan_table) == 0: raise NoVlansException, "No VLANs Configured on the device." vlan_ports_map = self.get_ports() for i in range(len(vlan_table)): oshv_result = ObjectStateHolderVector() vlan_oid = vlan_table[i][0] vlan_name = vlan_table[i][1] vlan_number = vlan_oid[vlan_oid.find('.') + 1:] port_list = vlan_ports_map.get(vlan_number) bridge_osh = None if not port_list: logger.warn( 'Skipping VLAN %s since it has no ports assigned.' % vlan_number) continue vlan_osh = ObjectStateHolder('vlan') vlan_osh.setContainer(self.host_osh) modeling.setVlanIdAttribute(vlan_osh, vlan_number) vlan_osh.setAttribute('data_name', vlan_name) if bridge_mac_address: vlan_osh.setAttribute('vlan_bridgemac', bridge_mac_address) bridge_osh = ObjectStateHolder('bridge') bridge_osh.setContainer(self.host_osh) bridge_osh.setAttribute('bridge_basemacaddr', bridge_mac_address) oshv_result.add(bridge_osh) depend_link = modeling.createLinkOSH('depend', vlan_osh, bridge_osh) oshv_result.add(depend_link) oshv_result.add(vlan_osh) for port in port_list: port_osh = ObjectStateHolder('port') port_osh.setContainer(self.host_osh) modeling.setPhysicalPortNumber(port_osh, port) oshv_result.add(port_osh) member_link = modeling.createLinkOSH('membership', vlan_osh, port_osh) oshv_result.add(member_link) if bridge_osh: contains_link = modeling.createLinkOSH( 'contains', bridge_osh, port_osh) oshv_result.add(contains_link) self.framework.sendObjects(oshv_result) self.framework.flushObjects() logger.debug( 'Vlan %s successfully discovered. Result vector contains %d objects.' % (vlan_name, oshv_result.size())) if self.snmp_client: self.snmp_client.close()
def applications(client, systemOSH, databasesOSH, OSHVResult, schemaName=None, viewSchemaName=None): #query information about Oracle Applications products at your site mapIdToOSH = HashMap() objs = __assocWithSchemaName( ['FND_PRODUCT_INSTALLATIONS', 'FND_APPLICATION_VL'], schemaName, viewSchemaName) resultSet = client.executeQuery( 'SELECT * FROM %s P,%s V WHERE V.APPLICATION_ID = P.APPLICATION_ID' % objs) #@@CMD_PERMISION sql protocol execution while resultSet.next(): id = resultSet.getString(1) version = resultSet.getString(8) status = resultSet.getString(9) tablespace = resultSet.getString(11) indexTablespace = resultSet.getString(12) tempTablespace = resultSet.getString(13) sizing = resultSet.getString(14) patchSet = resultSet.getString(17) shortName = resultSet.getString(20) basePath = resultSet.getString(26) description = resultSet.getString(27) if patchSet == None: patchSet = '' if logger.isDebugEnabled(): logger.debug('-------------------------------------------------') logger.debug('id = ', id) logger.debug('version = ', version) logger.debug('status = ', status) logger.debug('tablespace = ', tablespace) logger.debug('indexTablespace = ', indexTablespace) logger.debug('tempTablespace = ', tempTablespace) logger.debug('sizing = ', sizing) logger.debug('patchSet = ', patchSet) logger.debug('shortName = ', shortName) logger.debug('basepath = ', basePath) logger.debug('description = ', description) logger.debug('-------------------------------------------------') appOSH = ObjectStateHolder('oracleapplication') appOSH.setAttribute('data_name', id) if version != None: appOSH.setAttribute('oracleapplication_version', version) appOSH.setAttribute('oracleapplication_status', getStatusString(status)) if tablespace != None: appOSH.setAttribute('oracleapplication_tablespace', tablespace) if indexTablespace != None: appOSH.setAttribute('oracleapplication_indextablespace', indexTablespace) if tempTablespace != None: appOSH.setAttribute('oracleapplication_temptablespace', tempTablespace) if sizing != None: appOSH.setAttribute('oracleapplication_sizing', int(sizing)) if patchSet != None: appOSH.setAttribute('oracleapplication_patchset', patchSet) if shortName != None: appOSH.setAttribute('oracleapplication_shortname', shortName) if basePath != None: appOSH.setAttribute('oracleapplication_basepath', basePath) if description != None: appOSH.setAttribute('oracleapplication_description', description) appOSH.setContainer(systemOSH) OSHVResult.add(appOSH) mapIdToOSH.put(id, appOSH) if databasesOSH != None: linkTablespace(appOSH, databasesOSH, tablespace, OSHVResult) linkTablespace(appOSH, databasesOSH, indexTablespace, OSHVResult) linkTablespace(appOSH, databasesOSH, tempTablespace, OSHVResult) # build application dependencies resultSet.close() objs = __assocWithSchemaName(['FND_PRODUCT_DEPENDENCIES'], schemaName, viewSchemaName) resultSet = client.executeQuery( 'SELECT APPLICATION_ID,REQUIRED_APPLICATION_ID FROM %s' % objs) #@@CMD_PERMISION sql protocol execution while resultSet.next(): id = resultSet.getString(1) requiredId = resultSet.getString(2) appOSH = mapIdToOSH.get(id) requiredAppOSH = mapIdToOSH.get(requiredId) if appOSH != None and requiredAppOSH != None: dependOSH = modeling.createLinkOSH('depend', appOSH, requiredAppOSH) OSHVResult.add(dependOSH) else: logger.debug('Applications for ids [', id, '] and/or [', requiredId, '] are not found') resultSet.close() return mapIdToOSH
def createIoSlotOsh(ioSlot, managedSystemOsh): """ Creates the I/O Slot Object State Holder @param ioSlot: the discovered IO Slot @type ioSlot: instance of the IoSlot Data Object @param managedSystemOsh: the discovered Managed System the Hypervisor is runnig on @type managedSystemOsh: instance of the IBM PSeries Frame Object State Holder @return: Object State Holder for I/O Slot CI """ if ioSlot and managedSystemOsh and ioSlot.drcName: ioSlotOsh = ObjectStateHolder('ioslot') ioSlotOsh.setContainer(managedSystemOsh) ioSlotOsh.setStringAttribute("data_name", ioSlot.name) if ioSlot.normalizedDrcName: ioSlotOsh.setStringAttribute("drc_name", ioSlot.normalizedDrcName) else: ioSlotOsh.setStringAttribute("drc_name", ioSlot.drcName) if ioSlot.busId: ioSlotOsh.setStringAttribute("bus_id", ioSlot.busId) if ioSlot.physLocOnBus: ioSlotOsh.setStringAttribute("phys_loc", ioSlot.physLoc) if ioSlot.pciRevId: ioSlotOsh.setStringAttribute("pci_revision_id", ioSlot.pciRevId) if ioSlot.busGrouping: ioSlotOsh.setStringAttribute("bus_grouping", ioSlot.busGrouping) if ioSlot.pciDeviceId: ioSlotOsh.setStringAttribute("pci_device_id", ioSlot.pciDeviceId) if ioSlot.physLoc: ioSlotOsh.setStringAttribute("unit_phys_loc", ioSlot.physLoc) if ioSlot.parentDrcIndex: ioSlotOsh.setStringAttribute("parent_slot_drc_index", ioSlot.parentDrcIndex) if ioSlot.drcIndex: ioSlotOsh.setStringAttribute("drc_index", ioSlot.drcIndex) if ioSlot.subSlotVendorId: ioSlotOsh.setStringAttribute("pci_subs_vendor_id", ioSlot.subSlotVendorId) if ioSlot.pciClass: ioSlotOsh.setStringAttribute("pci_class", ioSlot.pciClass) if ioSlot.ioPoolId: ioSlotOsh.setStringAttribute("slot_io_pool_id", ioSlot.ioPoolId) if ioSlot.vendorId: ioSlotOsh.setStringAttribute("pci_vendor_id", ioSlot.vendorId) if ioSlot.featureCodes: ioSlotOsh.setStringAttribute("feature_codes", ioSlot.featureCodes) if ioSlot.subslotDeviceId: ioSlotOsh.setStringAttribute("pci_subs_device_id", ioSlot.subslotDeviceId) return ioSlotOsh
def osh_createEviewOsh(localshell, zOsOsh, appPath, confFolder, file, nodeName, eviewVersion, defaultIp): # Create EView agent OSH --------------------------------------------------- logger.debug('Creating EView object') eviewOSH = ObjectStateHolder('eview') if _CMDB_CLASS_MODEL.version() >= 9: eviewOSH.setAttribute('name', nodeName) eviewOSH.setAttribute('discovered_product_name', nodeName) eviewOSH.setAttribute('version', eviewVersion) else: eviewOSH.setAttribute('data_name', nodeName) eviewOSH.setAttribute('application_version', eviewVersion) eviewOSH.setAttribute('application_path', appPath) eviewOSH.setAttribute('application_ip', defaultIp) eviewOSH.setAttribute('vendor', 'EView Technology Inc.') eviewOSH.setAttribute('eview_agent_type', 'z/OS') fileContents = localshell.safecat('%s%s' % (confFolder, file)) address, port = eview_lib.getEviewAgentAddress(localshell, fileContents) if eview_lib.isNotNull(address): eviewOSH.setAttribute('application_ip', address) if eview_lib.isNotNull(port) and eview_lib.isnumeric(port): eviewOSH.setIntegerAttribute('application_port', int(port)) eviewOSH.setContainer(zOsOsh) return eviewOSH
def build(self, installedSoftware): ''' @types: InstalledSoftware -> OSH ''' softwareOSH = ObjectStateHolder('installed_software') softwareOSH.setAttribute('data_name', installedSoftware.name) if installedSoftware.path: softwareOSH.setAttribute('software_installpath', installedSoftware.path) if installedSoftware.version: softwareOSH.setAttribute('software_version', installedSoftware.version) if installedSoftware.vendor: softwareOSH.setAttribute('software_vendor', installedSoftware.vendor) if installedSoftware.productId: softwareOSH.setAttribute('software_productid', installedSoftware.productId) if installedSoftware.productCode: softwareOSH.setAttribute('software_productcode', installedSoftware.productCode) if installedSoftware.installationDateAsDate: softwareOSH.setAttribute('installation_date', installedSoftware.installationDateAsDate) if installedSoftware.installDate: softwareOSH.setAttribute('software_data', installedSoftware.installDate) if installedSoftware.softwareType: softwareOSH.setAttribute('software_type', installedSoftware.softwareType) if installedSoftware.description: softwareOSH.setAttribute('data_description', installedSoftware.description.strip()) return softwareOSH
def build(self, containerOsh): 'host osh -> list(Cpu)' for cpu in self.getCpus(): osh = ObjectStateHolder('cpu') osh.setContainer(containerOsh) osh.setAttribute('cpu_cid', cpu.id) cpu.vendor and osh.setAttribute('cpu_vendor', cpu.vendor) if cpu.speedInMhz(): osh.setLongAttribute("cpu_clock_speed", cpu.speedInMhz()) if cpu.name: osh.setAttribute('data_name', cpu.name) if cpu.coresCount(): osh.setIntegerAttribute('core_number', cpu.coresCount()) if cpu.description: osh.setAttribute('data_description', cpu.description) cpu.osh = osh
def DiscoveryMain(Framework): properties = Properties() vector = ObjectStateHolderVector() properties.setProperty('timeoutDiscover', Framework.getParameter('timeoutDiscover')) properties.setProperty('retryDiscover', Framework.getParameter('retryDiscover')) properties.setProperty('pingProtocol', Framework.getParameter('pingProtocol')) properties.setProperty('threadPoolSize', Framework.getParameter('threadPoolSize')) ip = Framework.getDestinationAttribute('ip_address') domainName = Framework.getDestinationAttribute('domain_name') id = Framework.getTriggerCIData('id') ports = getUDAAvailablePorts(Framework) try: client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME, properties) try: range_uda_status = {} range_result = pingIPsInRange(Framework, client, ip, ports) range_uda_status.update(range_result) for x in range_uda_status.values(): logger.debug(x) #build the udaStatus context = UdaState.Builder(x.ip).computerName( x.computerName ).alive(x.alive).portAlive(x.portAlive).isDDMI( x.isDDMI).isNative(x.isNative).isWin(x.isWin).osType( x.osType).agentVersion( str(x.agentVersion) + ('-fips' if x.isFIPSEnabled else '')).UDUniqueId( x.UDUniqueId).build() #save UdaStatusService.getInstance().saveUdaStatus(context) if Framework.getParameter('isCreateUDA') == 'true': if x.UDUniqueId: hostOsh = modeling.createHostOSH(x.ip) hostOsh.setStringAttribute( InventoryUtils.ATTR_UD_UNIQUE_ID, x.UDUniqueId) uda = ObjectStateHolder('uda') uda.setStringAttribute('application_ip', x.ip) uda.setStringAttribute('application_ip_domain', domainName) uda.setStringAttribute('discovered_product_name', 'uda') uda.setStringAttribute('version', str(x.agentVersion)) uda.setContainer(hostOsh) vector.add(hostOsh) vector.add(uda) finally: client.close() except: msg = logger.prepareJythonStackTrace('') errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework) return vector
class MsMqQueue: def __init__(self, msMqManagerOsh, queueName=None, queueTransactionType=None, queueIsPrivateType=None, queueStorageLimit=None, queueJuornalEnabled=None, queueJournalStorageLimit=None): self.queueName = queueName self.queueTransactionType = queueTransactionType self.queueIsPrivateType = queueIsPrivateType self.queueStorageLimit = queueStorageLimit self.queueJuornalEnabled = queueJuornalEnabled self.queueJournalStorageLimit = queueJournalStorageLimit self.msMqManagerOsh = msMqManagerOsh self.queueOsh = None def setName(self, name): self.queueName = name def setTransactionType(self, transactionType): self.queueTransactionType = transactionType def setIsPrivateQueueType(self, isPrivateType): self.queueIsPrivateType = isPrivateType def setStorageLimit(self, storageLimit): try: self.queueStorageLimit = long(storageLimit) except: logger.warn( 'Message Storage Limit exceeds long capacity. Setting to zero') self.queueStorageLimit = 0 def setJournalEnabled(self, isEnabled): self.queueJuornalEnabled = isEnabled def setJournalStorageLimit(self, limit): try: self.queueJournalStorageLimit = long(limit) except: logger.warn( 'Message Journal Storage Limit exceeds long capacity. Setting to zero' ) self.queueJournalStorageLimit = 0 def buildOsh(self): if self.queueName and self.msMqManagerOsh: self.queueOsh = ObjectStateHolder('msmqqueue') self.queueOsh.setAttribute('data_name', self.queueName) queueType = '' if self.queueIsPrivateType is not None: self.queueOsh.setAttribute( 'queue_type', QUEUE_TYPE.get(self.queueIsPrivateType)) if self.queueTransactionType: self.queueOsh.setBoolAttribute("istransactional", self.queueTransactionType) if self.queueStorageLimit: self.queueOsh.setLongAttribute('message_storage_limit', self.queueStorageLimit) if self.queueJuornalEnabled: self.queueOsh.setBoolAttribute('journal_enabled', int(self.queueJuornalEnabled)) if self.queueJournalStorageLimit: self.queueOsh.setLongAttribute('journal_storage_limit', self.queueJournalStorageLimit) self.queueOsh.setContainer(self.msMqManagerOsh) def getOsh(self): return self.queueOsh def addResultsToVector(self, resultsVector): self.buildOsh() if self.queueOsh: resultsVector.add(self.queueOsh)
class MsMqTrigger: def __init__(self, queueObj, triggerName, triggerGuid, remoteQueueObj=None, triggerIsEnabled=None, triggerMsgProcessType=None, isSerialized=None): self.triggerName = triggerName self.triggerIsEnabled = triggerIsEnabled self.triggerMsgProcessType = triggerMsgProcessType self.triggerGuid = triggerGuid self.queueObj = queueObj self.remoteQueueObj = remoteQueueObj self.isSerialized = isSerialized self.queueOsh = None self.ruleGuidsList = [] self.triggerOsh = None def setTriggerGuid(self, triggerGuid): self.triggerGuid = triggerGuid def setIsEnabled(self, triggerIsEnabled): try: self.triggerIsEnabled = int(triggerIsEnabled, 16) except: logger.warn('Failed to convert isEnabled attribute.') self.triggerIsEnabled = None def setIsSerialized(self, isSerialized): if isSerialized: self.isSerialized = int(isSerialized) def setMsgProcessType(self, triggerMsgProcessType): try: self.triggerMsgProcessType = int(triggerMsgProcessType, 16) except: logger.warn('Failed to convert message processing type') self.triggerMsgProcessType = None def setRuleGuidsList(self, ruleGuidsList): self.ruleGuidsList = ruleGuidsList def build(self): if self.queueObj: self.queueOsh = self.queueObj.getOsh() if self.remoteQueueObj: self.queueOsh = self.remoteQueueObj.getOsh() if self.queueOsh and self.triggerName and self.triggerGuid: self.triggerOsh = ObjectStateHolder('msmqtrigger') self.triggerOsh.setAttribute('data_name', self.triggerName) self.triggerOsh.setAttribute('triggerid', self.triggerGuid) if self.triggerIsEnabled: self.triggerOsh.setBoolAttribute('enabled', self.triggerIsEnabled) if self.triggerMsgProcessType: process_type = TRIGGER_PROCESSING_TYPE.get( self.triggerMsgProcessType) if process_type: self.triggerOsh.setAttribute('message_processing_type', process_type) if self.isSerialized is not None: self.triggerOsh.setBoolAttribute('isserialized', self.isSerialized) self.triggerOsh.setContainer(self.queueOsh) else: logger.warn('Failed reporting trigger.') def addResultsToVector(self, resultsVector, rulesDict): if self.remoteQueueObj: self.remoteQueueObj.addResultsToVector(resultsVector) self.build() if self.triggerOsh: resultsVector.add(self.triggerOsh) for ruleGuid in self.ruleGuidsList: ruleObj = rulesDict.get(ruleGuid.lower()) if ruleObj: ruleOsh = ruleObj.getOsh() resultsVector.add( modeling.createLinkOSH('use', self.triggerOsh, ruleOsh))
def services(client, mapAppIdToOSH, hostToServerOSH, nameToHostOSH, systemOSH, OSHVResult, schemaName=None, viewSchemaName=None): mapManagerToOSH = HashMap() mapServiceToOSH = HashMap() #we have no way for now to obtain processes names, and pid is not interesting for us #so we don't want to create processes (and can't, since process name is key_attribute) #mapProcessIDToOSH = getProcesses(client,nameToHostOSH, OSHVResult) mapProcessIDToOSH = HashMap() objs = __assocWithSchemaName( ['FND_CONCURRENT_QUEUES_VL', 'FND_CP_SERVICES_VL'], schemaName, viewSchemaName) resultSet = client.executeQuery( 'SELECT Q.CONCURRENT_QUEUE_ID,Q.APPLICATION_ID,Q.CONCURRENT_QUEUE_NAME,Q.MAX_PROCESSES,Q.RUNNING_PROCESSES,Q.TARGET_NODE,Q.USER_CONCURRENT_QUEUE_NAME,Q.DESCRIPTION,S.SERVICE_NAME,S.DESCRIPTION FROM %s Q, %s S WHERE Q.MANAGER_TYPE = S.SERVICE_ID' % objs) #@@CMD_PERMISION sql protocol execution while resultSet.next(): queueId = resultSet.getString(1) appId = resultSet.getString(2) name = resultSet.getString(3) maxProcesses = resultSet.getString(4) runningProcesses = resultSet.getString(5) host = resultSet.getString(6) displayName = resultSet.getString(7) description = resultSet.getString(8) managerName = resultSet.getString(9) managerDescription = resultSet.getString(10) if managerName == None: continue managerOSH = mapManagerToOSH.get(managerName) if managerOSH == None: managerOSH = ObjectStateHolder('oracleappservicemanager') managerOSH.setAttribute('data_name', managerName) if managerDescription != None: managerOSH.setAttribute('oracleappservicemanager_description', managerDescription) managerOSH.setContainer(systemOSH) mapManagerToOSH.put(managerName, managerOSH) OSHVResult.add(managerOSH) if description == None: description = '' if logger.isDebugEnabled(): logger.debug('-------------------------------------------------') logger.debug('name = ', name) logger.debug('displayName = ', displayName) logger.debug('appId = ', appId) logger.debug('description = ', description) if host != None: logger.debug('host = ', host) logger.debug('-------------------------------------------------') appOSH = mapAppIdToOSH.get(appId) serverOSH = hostToServerOSH.get(host) if appOSH != None: if (name == None) and (displayName != None): name = displayName if name != None: serviceOSH = ObjectStateHolder('oracleappservice') serviceOSH.setAttribute('data_name', name) serviceOSH.setAttribute('oracleappservice_displayname', displayName) serviceOSH.setAttribute('oracleappservice_description', description) serviceOSH.setAttribute('oracleappservice_maxprocesses', int(maxProcesses)) serviceOSH.setAttribute('oracleappservice_runningprocesses', int(runningProcesses)) serviceOSH.setContainer(appOSH) OSHVResult.add(serviceOSH) mapServiceToOSH.put(name, serviceOSH) processes = mapProcessIDToOSH.get(queueId) if processes != None: logger.debug('Found processes for service [', name, ']') itProcesses = processes.iterator() while itProcesses.hasNext(): processOSH = itProcesses.next() resourceOSH = modeling.createLinkOSH( 'resource', serviceOSH, processOSH) OSHVResult.add(resourceOSH) else: logger.debug('No processes found for service [', name, ']') if managerOSH != None: memberOSH = modeling.createLinkOSH('member', managerOSH, serviceOSH) OSHVResult.add(memberOSH) if serverOSH != None: deployedOSH = modeling.createLinkOSH( 'deployed', serverOSH, serviceOSH) OSHVResult.add(deployedOSH) else: logger.debug('Server not found for host [', host, ']') resultSet.close()
def infrastructure(client, OSHVResult, Framework, schemaName=None, viewSchemaName=None): retOSHs = ArrayList(4) retOSHs.add(None) retOSHs.add(None) retOSHs.add(None) retOSHs.add(None) systemOSH = ObjectStateHolder('oraclesystem') systemOSH.setAttribute('data_name', client.getSid()) systemOSH.setAttribute('oraclesystem_dbaddress', client.getIpAddress()) modeling.setAppSystemVendor(systemOSH) webServerOSH = None nameToHostOSH = HashMap() hostToServerOSH = HashMap() hostToIpAddress = HashMap() databasesOSH = HashMap() resultSet = None try: objs = __assocWithSchemaName(['FND_OAM_APP_SYS_STATUS'], schemaName, viewSchemaName) # query a special table that holds Applications System Status related information resultSet = client.executeQuery( 'SELECT * FROM %s' % objs) #@@CMD_PERMISION sql protocol execution except: logger.debugException( 'SQL query failure. "SELECT * FROM FND_OAM_APP_SYS_STATUS"') Framework.reportWarning('No Oracle E-Business Suite components found.') if resultSet: OSHVResult.add(systemOSH) retOSHs.set(0, systemOSH) else: return None while resultSet.next(): name = resultSet.getString(1) dbSid = resultSet.getString(4) status = resultSet.getString(6) host = resultSet.getString(7) port = client.getPort() if logger.isDebugEnabled(): logger.debug('-----------------------------') logger.debug('name = ', name) logger.debug('status = ', status) if host != None: logger.debug('host = ', host) else: logger.debug('skipping Application system with None host') continue logger.debug('-----------------------------') hostOSH = nameToHostOSH.get(host) serverOSH = hostToServerOSH.get(host) hostIP = hostToIpAddress.get(host) if not hostIP: hostIP = netutils.getHostAddress(host, host) if hostOSH == None and netutils.isValidIp(hostIP): hostOSH = modeling.createHostOSH(hostIP) OSHVResult.add(hostOSH) nameToHostOSH.put(host, hostOSH) hostToIpAddress.put(host, hostIP) if hostOSH == None: logger.warn('Failed to created host [', host, ']') continue if serverOSH == None: serverOSH = modeling.createJ2EEServer('oracleias', hostIP, None, hostOSH, host) OSHVResult.add(serverOSH) hostToServerOSH.put(host, serverOSH) serverMemberOSH = modeling.createLinkOSH('member', systemOSH, serverOSH) OSHVResult.add(serverMemberOSH) if name.find('WEB_SERVER') == 0 and host != None: webServerOSH = serverOSH serverOSH.setBoolAttribute('oracleias_web', 1) elif name.find('FORMS_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_form', 1) elif name.find('ADMIN_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_admin', 1) elif name.find('CP_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_concurrentprocessing', 1) elif name.find('DATABASE') == 0 and host != None: dbOSH = modeling.createDatabaseOSH('oracle', dbSid, port, hostIP, hostOSH) OSHVResult.add(dbOSH) databasesOSH.put(dbSid, dbOSH) memberOSH = modeling.createLinkOSH('member', systemOSH, dbOSH) OSHVResult.add(memberOSH) resultSet.close() try: systemMetrics(client, systemOSH, webServerOSH, OSHVResult, schemaName, viewSchemaName) except: logger.debug("Failed to get system metrics") retOSHs.set(1, hostToServerOSH) retOSHs.set(2, nameToHostOSH) retOSHs.set(3, databasesOSH) return retOSHs
def createInstalledSoftwareOSH(hostOSH, installedSoftware): softwareOSH = ObjectStateHolder('installed_software') softwareOSH.setAttribute('data_name', installedSoftware.name) if installedSoftware.path: softwareOSH.setAttribute('software_installpath', installedSoftware.path) if installedSoftware.version: softwareOSH.setAttribute('software_version', installedSoftware.version) if installedSoftware.vendor: softwareOSH.setAttribute('software_vendor', installedSoftware.vendor) if installedSoftware.productId: softwareOSH.setAttribute('software_productid', installedSoftware.productId) if installedSoftware.productCode: softwareOSH.setAttribute('software_productcode', installedSoftware.productCode) if installedSoftware.installationDateAsDate: softwareOSH.setAttribute('installation_date', installedSoftware.installationDateAsDate) if installedSoftware.installDate: softwareOSH.setAttribute('software_data', installedSoftware.installDate) if installedSoftware.softwareType: softwareOSH.setAttribute('software_type', installedSoftware.softwareType) if installedSoftware.description: softwareOSH.setAttribute('data_description', installedSoftware.description.strip()) softwareOSH.setContainer(hostOSH) return softwareOSH
def osh_createJobOsh(lparOsh, jobsLists): _vector = ObjectStateHolderVector() str_name = 'name' for job in jobsLists: if isNotNull(job[0]): jobOsh = ObjectStateHolder('iseries_job') jobOsh.setAttribute(str_name, job[0].strip()) jobOsh.setAttribute('owner', job[1]) jobOsh.setAttribute('job_id', int(job[2])) jobOsh.setAttribute('job_int_id', job[3]) jobOsh.setAttribute('job_status', job[4]) jobOsh.setAttribute('job_type', job[5]) jobOsh.setContainer(lparOsh) _vector.add(jobOsh) subsystem = job[6].strip() if isNotNull(subsystem): subsystemOSH = ObjectStateHolder('iseriessubsystem') subsystemOSH.setAttribute(str_name, subsystem) subsystemOSH.setAttribute('discovered_product_name', subsystem) subsystemOSH.setContainer(lparOsh) _vector.add(subsystemOSH) memberOsh = modeling.createLinkOSH('membership', jobOsh, subsystemOSH) _vector.add(memberOsh) return _vector
def build(self, pdo, cit=None): osh = ObjectStateHolder(cit or self.CIT) osh.setStringAttribute('name', pdo.name) if pdo.id: osh.setStringAttribute('pool_id', pdo.id) return osh
def report(self): tenant_osh = ObjectStateHolder('openstack_tenant') tenant_osh.setStringAttribute('name', self.name) tenant_osh.setStringAttribute('tenant_id', self.id) return tenant_osh
def report(self, container): region_osh = ObjectStateHolder('openstack_region') region_osh.setStringAttribute('name', self.name) region_osh.setContainer(container) return region_osh
def createSharedResourceOsh(resource, containerOsh, oshVector): ''' Shared resource OSH creation helper method @return: None, returned value are stored in parameter oshVector ''' is90 = modeling.checkAttributeExists('file_system_export', LOCAL_NAMES) if is90: shareOsh = ObjectStateHolder(NETWORK_SHARE) shareOsh.setAttribute("data_name", resource.path) shareOsh.setAttribute("share_path", resource.path) stringVector = StringVector() for instance in resource.getInstances(): stringVector.add(instance.name) shareOsh.setAttribute(LOCAL_NAMES, stringVector) shareOsh.setContainer(containerOsh) oshVector.add(shareOsh) else: for instance in resource.getInstances(): shareOsh = ObjectStateHolder(NETWORK_SHARE) shareOsh.setAttribute("data_name", instance.name) shareOsh.setAttribute("share_path", resource.path) if instance.description: shareOsh.setAttribute("data_description", instance.description) shareOsh.setContainer(containerOsh) oshVector.add(shareOsh)
def buildGenericHostObject(host_class, hostDo, report_serial=True): if not host_class: raise ValueError('Failed to create Node no host class passed') host_osh = ObjectStateHolder(host_class) if hostDo.hostname: host_osh.setStringAttribute('name', hostDo.hostname) host_osh.setBoolAttribute('host_iscomplete', 1) key = hostDo.hostname or hostDo.ipList if hostDo.domain_name: host_osh.setStringAttribute('domain_name', hostDo.domain_name) if hostDo.is_virtual: host_osh.setBoolAttribute('host_isvirtual', 1) if hostDo.serial and report_serial: host_osh.setStringAttribute('serial_number', hostDo.serial) if hostDo.model: host_osh.setStringAttribute('discovered_model', hostDo.model) if hostDo.vendor: host_osh.setStringAttribute('discovered_vendor', hostDo.vendor) if hostDo.sys_obj_id: host_osh.setStringAttribute('sys_object_id', hostDo.sys_obj_id) if hostDo.architecture and ARCHITECTURE_TRANSFORMATION.get( hostDo.architecture): host_osh.setStringAttribute( 'os_architecture', ARCHITECTURE_TRANSFORMATION.get(hostDo.architecture)) return host_osh
def buildSharedResource(self, sharedResource): shareOsh = ObjectStateHolder(NETWORK_SHARE) shareOsh.setAttribute("data_name", sharedResource.resource.path) shareOsh.setAttribute("share_path", sharedResource.resource.path) return shareOsh
def report(self, region_osh): vector = ObjectStateHolderVector() flavorOsh = ObjectStateHolder("openstack_flavor") flavorOsh.setAttribute("flavor_id", self.id) flavorOsh.setAttribute("name", self.name) flavorOsh.setAttribute("vcpus", self.vcpus) flavorOsh.setAttribute("ram", self.ram) flavorOsh.setAttribute("root_disk", self.root_disk) flavorOsh.setAttribute("ephemeral_disk", self.ephemeral_disk) flavorOsh.setAttribute("swap_disk", self.swap_disk) vector.add(flavorOsh) vector.add(modeling.createLinkOSH('membership', region_osh, flavorOsh)) return flavorOsh, vector
def createProcessorPoolOsh(processorPool, hypervisorOsh): """ Creates Shared Processor Pool Object State Holder @param processorPool: the discovered Shared Processor Pool @type processorPool: instance of the IbmProcessorPool Data Object @param hypervisorOsh: @type hypervisorOsh: @return: Object State Holder of the IBM Processor Pool CI """ if processorPool and processorPool.name and hypervisorOsh: processorPoolOsh = ObjectStateHolder('ibm_resource_pool') processorPoolOsh.setContainer(hypervisorOsh) processorPoolOsh.setStringAttribute('data_name', processorPool.name) processorPoolOsh.setStringAttribute('pool_id', processorPool.name) if processorPool.physCpuAvail is not None: processorPoolOsh.setFloatAttribute('physical_cpus_available', processorPool.physCpuAvail) if processorPool.physCpuConf is not None: processorPoolOsh.setFloatAttribute('physical_cpus_configurable', processorPool.physCpuConf) if processorPool.physCpuPendingAvail is not None: processorPoolOsh.setFloatAttribute( 'physical_cpus_pending', processorPool.physCpuPendingAvail) return processorPoolOsh
def osh_createOutQueueOsh(lparOsh, outQueueLists): _vector = ObjectStateHolderVector() str_name = 'name' for queue in outQueueLists: if isNotNull(queue[0]): key = concatenate(queue[0].strip(), queue[1].strip()) outqueueOsh = ObjectStateHolder('iseries_outqueue') outqueueOsh.setAttribute(str_name, key) outqueueOsh.setAttribute('queue_name', queue[0].strip()) outqueueOsh.setAttribute('library_name', queue[1].strip()) outqueueOsh.setAttribute('number_of__files', int(queue[2])) outqueueOsh.setAttribute('writer', queue[3].strip()) outqueueOsh.setAttribute('queue_status', queue[4].strip()) outqueueOsh.setContainer(lparOsh) _vector.add(outqueueOsh) subsystem = queue[3].strip() if isNotNull(subsystem): subsystemOSH = ObjectStateHolder('iseriessubsystem') subsystemOSH.setAttribute(str_name, subsystem) subsystemOSH.setAttribute('discovered_product_name', subsystem) subsystemOSH.setContainer(lparOsh) _vector.add(subsystemOSH) memberOsh = modeling.createLinkOSH('membership', outqueueOsh, subsystemOSH) _vector.add(memberOsh) return _vector
def createLparProfileOsh(lparProfile, hostOsh): """ Creates the Lpar Profile Object State Holder @param lparProfile: the discovered parameters of the Lpar or VIO Server @type lparProfile: instance of the LparProfile Data Object @param hostOsh: lpar of vio server host @type hostOsh: Object State Holder of the Host CI or any of its children @return: Object State Holder for the LPar Profile """ if lparProfile: lparProfileOsh = ObjectStateHolder('ibm_lpar_profile') lparProfileOsh.setStringAttribute('data_name', lparProfile.lparProfile.name) lparProfileOsh.setContainer(hostOsh) if lparProfile.logicalSerialNumber: lparProfileOsh.setStringAttribute('logical_serial_number', lparProfile.logicalSerialNumber) if lparProfile.lparProfile.sharingMode: lparProfileOsh.setStringAttribute( 'sharing_mode', lparProfile.lparProfile.sharingMode) if lparProfile.lparProfile.cpuMode: lparProfileOsh.setStringAttribute('proc_mode', lparProfile.lparProfile.cpuMode) if lparProfile.lparProfile.uncapWeight is not None: lparProfileOsh.setIntegerAttribute( 'uncap_weight', lparProfile.lparProfile.uncapWeight) if lparProfile.powerCtrlIds: lparProfileOsh.setStringAttribute('power_ctrl_lpar_ids', lparProfile.powerCtrlIds) if lparProfile.bootMode: lparProfileOsh.setStringAttribute('boot_mode', lparProfile.bootMode) if lparProfile.lparProfile.connMonEnabled is not None: lparProfileOsh.setBoolAttribute( 'conn_monitoring', lparProfile.lparProfile.connMonEnabled) if lparProfile.lparProfile.maxVirtSlots is not None: lparProfileOsh.setIntegerAttribute( 'max_virtual_slots', lparProfile.lparProfile.maxVirtSlots) if lparProfile.autoStart is not None: lparProfileOsh.setBoolAttribute('auto_start', lparProfile.autoStart) if lparProfile.lparProfile.ioPoolIds: lparProfileOsh.setStringAttribute( 'lpar_io_pool_ids', lparProfile.lparProfile.ioPoolIds) if lparProfile.redunErrPathRep is not None: lparProfileOsh.setBoolAttribute('redundant_err_path_reporting', lparProfile.redunErrPathRep) if lparProfile.lparProfile.desNumHugePages is not None: lparProfileOsh.setIntegerAttribute( 'desired_num_huge_pages', lparProfile.lparProfile.desNumHugePages) if lparProfile.lparProfile.minNumHugePages is not None: lparProfileOsh.setIntegerAttribute( 'min_num_huge_pages', lparProfile.lparProfile.minNumHugePages) if lparProfile.lparProfile.maxNumHugePages is not None: lparProfileOsh.setIntegerAttribute( 'max_num_huge_pages', lparProfile.lparProfile.maxNumHugePages) if lparProfile.lparProfile.desCpu is not None: lparProfileOsh.setIntegerAttribute('desired_procs', lparProfile.lparProfile.desCpu) if lparProfile.lparProfile.minCpu is not None: lparProfileOsh.setIntegerAttribute('min_procs', lparProfile.lparProfile.minCpu) if lparProfile.lparProfile.maxCpu is not None: lparProfileOsh.setIntegerAttribute('max_procs', lparProfile.lparProfile.maxCpu) if lparProfile.lparProfile.desPhysCpu is not None: lparProfileOsh.setFloatAttribute( 'desired_proc_units', lparProfile.lparProfile.desPhysCpu) if lparProfile.lparProfile.minPhysCpu is not None: lparProfileOsh.setFloatAttribute( 'min_proc_units', lparProfile.lparProfile.minPhysCpu) if lparProfile.lparProfile.maxPhysCpu is not None: lparProfileOsh.setFloatAttribute( 'max_proc_units', lparProfile.lparProfile.maxPhysCpu) if lparProfile.lparProfile.desMem is not None: lparProfileOsh.setLongAttribute('desired_mem', lparProfile.lparProfile.desMem) if lparProfile.lparProfile.minMem is not None: lparProfileOsh.setLongAttribute('min_mem', lparProfile.lparProfile.minMem) if lparProfile.lparProfile.maxMem is not None: lparProfileOsh.setLongAttribute('max_mem', lparProfile.lparProfile.maxMem) if lparProfile.workgroupId: lparProfileOsh.setStringAttribute('work_group_id', lparProfile.workgroupId) if lparProfile.defaultProfName: lparProfileOsh.setStringAttribute('default_profile_name', lparProfile.defaultProfName) if lparProfile.profileName: lparProfileOsh.setStringAttribute('profile_name', lparProfile.profileName) if lparProfile.state: lparProfileOsh.setStringAttribute('lpar_state', lparProfile.state) if lparProfile.type: lparProfileOsh.setStringAttribute('lpar_type', lparProfile.type) if lparProfile.lparId is not None: lparProfileOsh.setIntegerAttribute('lpar_id', lparProfile.lparId) if lparProfile.lparName: lparProfileOsh.setStringAttribute('lpar_name', lparProfile.lparName) if lparProfile.lparProfile.virtSerialAdapters: lparProfileOsh.setStringAttribute( 'virtual_serial_adapters', lparProfile.lparProfile.virtSerialAdapters) return lparProfileOsh
def osh_createLibOsh(lparOsh, liblists): _vector = ObjectStateHolderVector() str_name = 'name' for lib in liblists: if isNotNull(lib[0]): key = concatenate(lib[0].strip(), lib[1].strip()) libraryOsh = ObjectStateHolder('iseries_library') libraryOsh.setAttribute(str_name, key) libraryOsh.setAttribute('object_name', lib[0].strip()) libraryOsh.setAttribute('library_name', lib[1].strip()) libraryOsh.setAttribute('type', lib[2].strip()) libraryOsh.setAttribute('program_create_time', lib[3].strip()) libraryOsh.setAttribute('program_change_time', lib[4].strip()) libraryOsh.setAttribute('creator', lib[5].strip()) libraryOsh.setAttribute('owner', lib[6].strip()) libraryOsh.setAttribute('size', lib[7].strip()) libraryOsh.setAttribute('description', lib[9].strip()) libraryOsh.setContainer(lparOsh) _vector.add(libraryOsh) return _vector
def osh_createPgmOsh(lparOsh, pgmlists): _vector = ObjectStateHolderVector() str_name = 'name' for pgm in pgmlists: if isNotNull(pgm[0]): key = concatenate(pgm[0].strip(), pgm[1].strip()) programOsh = ObjectStateHolder('iseries_program') programOsh.setAttribute(str_name, key) programOsh.setAttribute('object_name', pgm[0].strip()) programOsh.setAttribute('library_name', pgm[1].strip()) programOsh.setAttribute('type', pgm[2].strip()) programOsh.setAttribute('program_create_time', pgm[3].strip()) programOsh.setAttribute('program_change_time', pgm[4].strip()) programOsh.setAttribute('creator', pgm[5].strip()) programOsh.setAttribute('owner', pgm[6].strip()) programOsh.setAttribute('size', pgm[7].strip()) programOsh.setAttribute('description', pgm[9].strip()) programOsh.setContainer(lparOsh) _vector.add(programOsh) return _vector
def systemMetrics(client, systemOSH, webServerOSH, OSHVResult, schemaName=None, viewSchemaName=None): objs = __assocWithSchemaName(['FND_OAM_METVAL_VL'], schemaName, viewSchemaName) resultSet = client.executeQuery( 'SELECT METRIC_SHORT_NAME,METRIC_VALUE,STATUS_CODE,METRIC_DISPLAY_NAME,DESCRIPTION FROM %s' % objs) #@@CMD_PERMISION sql protocol execution while resultSet.next(): name = resultSet.getString(1) value = resultSet.getString(2) status = resultSet.getString(3) displayName = resultSet.getString(4) description = resultSet.getString(5) if value == None: value = '999' if name.find('_GEN') > 0: logger.debug('found web component ', name, ' in status [', status, ']') webComponentOSH = ObjectStateHolder('oraclewebcomponent') webComponentOSH.setAttribute('data_name', name) webComponentOSH.setAttribute('oraclewebcomponent_status', getWebComponentStatus(status)) if displayName != None: webComponentOSH.setAttribute('oraclewebcomponent_displayname', displayName) if description != None: webComponentOSH.setAttribute('oraclewebcomponent_description', description) webComponentOSH.setContainer(webServerOSH) OSHVResult.add(webComponentOSH) elif name.find('FORM_SESSIONS') == 0: systemOSH.setAttribute('oraclesystem_formssessions', int(value)) elif name.find('DB_SESSIONS') == 0: systemOSH.setAttribute('oraclesystem_databasesessions', int(value)) elif name.find('RUNNING_REQ') == 0: systemOSH.setAttribute('oraclesystem_requests', int(value)) elif name.find('SERVICE_PROCS') == 0: systemOSH.setAttribute('oraclesystem_processes', int(value)) elif name.find('SERVICES_UP') == 0: systemOSH.setAttribute('oraclesystem_servicesup', int(value)) elif name.find('SERVICES_DOWN') == 0: systemOSH.setAttribute('oraclesystem_servicesdown', int(value)) elif name.find('INVALID_OBJECTS') == 0: systemOSH.setAttribute('oraclesystem_invaliddataobjects', int(value)) elif name.find('WFM_WAIT_MSG') == 0: systemOSH.setAttribute('oraclesystem_unsentmails', int(value)) elif name.find('WFM_PROC_MSG') == 0: systemOSH.setAttribute('oraclesystem_sentmails', int(value)) elif name.find('COMPLETED_REQ') == 0: systemOSH.setAttribute('oraclesystem_completedrequests', int(value)) resultSet.close()
def doAll(snmpClient, hostOSH, OSHVResult, ucmdbversion, Framework): vlanTableMib = '1.3.6.1.4.1.9.9.46.1.3.1.1.4,1.3.6.1.4.1.9.9.46.1.3.1.1.5,string' elanNameTableMib = '1.3.6.1.4.1.353.5.3.1.1.2.1.14,1.3.6.1.4.1.353.5.3.1.1.2.1.15,string' vlanNumberPerElanTableMib = '1.3.6.1.4.1.9.9.77.1.1.1.1.1,1.3.6.1.4.1.9.9.77.1.1.1.1.2,string' credentialsId = Framework.getDestinationAttribute('credentialsId') snmp_version = Framework.getProtocolProperty(credentialsId, "snmpprotocol_version") vlanTableRes = snmpClient.executeQuery( vlanTableMib) #@@CMD_PERMISION snmp protocol execution elanNameTableRes = snmpClient.executeQuery( elanNameTableMib) #@@CMD_PERMISION snmp protocol execution vlanNumberPerElanTableRes = snmpClient.executeQuery( vlanNumberPerElanTableMib) #@@CMD_PERMISION snmp protocol execution vlanTable = vlanTableRes.asTable() elanNameTable = elanNameTableRes.asTable() vlanNumberPerElanTable = vlanNumberPerElanTableRes.asTable() if len(vlanTable) == 0: raise Exception, "No VLANs Configured on the device." vlan_context_dict = {} if snmp_version and snmp_version == 'version 3': vlan_context_dict = snmputils.get_snmp_vlan_context_dict(snmpClient) if snmpClient: snmpClient.close() for i in range(len(vlanTable)): vlanOid = vlanTable[i][0] vlanName = vlanTable[i][1] vlanNumberA = vlanOid[vlanOid.find('.') + 1:] vlanOSH = ObjectStateHolder('vlan') vlanOSH.setContainer(hostOSH) modeling.setVlanIdAttribute(vlanOSH, vlanNumberA) try: linkedPorts = discoverPorts(vlanNumberA, vlanOSH, hostOSH, ucmdbversion, Framework, vlan_context_dict) except ValueError: logger.debug( 'No ports are assigned for VLAN %s, discarding port from result vector, Vlan will not be reported.' % vlanNumberA) continue except: logger.debug('Failed to discover ports for VLAN %s' % vlanNumberA) logger.debugException('') continue else: OSHVResult.addAll(linkedPorts) vlanOSH.setAttribute('data_name', vlanName) OSHVResult.add(vlanOSH) for j in range(len(elanNameTable)): elanIndexA = elanNameTable[j][0] elanName = elanNameTable[j][1] for k in range(len(vlanNumberPerElanTable)): elanIndexB = vlanNumberPerElanTable[k][0] vlanNumberB = vlanNumberPerElanTable[k][1] if (vlanNumberB == vlanNumberA) and (elanIndexB == elanIndexA): vlanOSH.setAttribute('vlan_aliasname', elanName) elanOSH = ObjectStateHolder('elan') elanOSH.setAttribute('data_name', elanName) OSHVResult.add(elanOSH) elanvlanmap_link = modeling.createLinkOSH( 'elanvlanmap', elanOSH, vlanOSH) OSHVResult.add(elanvlanmap_link) bcastdomain_link = modeling.createLinkOSH( 'bcastdomain', hostOSH, elanOSH) OSHVResult.add(bcastdomain_link) Framework.sendObjects(OSHVResult) Framework.flushObjects() logger.debug( 'Vlan %s successfully discovered. Result vector contains %d objects.' % (vlanName, OSHVResult.size())) OSHVResult = ObjectStateHolderVector()