예제 #1
0
def buildPduOSH(deviceName, deviceAssetNumber, deviceSerialNumber, rowName,
                gridLocation, spaceName, floorName, buildingName, pduOshDict,
                datacenterOshDict):
    try:
        pduDictKey = '%s ** %s ** %s ** %s ** %s ** %s ** %s' % (
            deviceName, deviceAssetNumber, deviceSerialNumber, gridLocation,
            spaceName, floorName, buildingName)
        if pduDictKey in pduOshDict.keys():
            debugPrint(
                3, '[buildPduOSH] Already processed PDU <%s>! Skipping...' %
                deviceName)
        else:
            debugPrint(2, '[buildPduOSH] PDU <%s> found' % deviceName)
            pduOSH = ObjectStateHolder('power_distribution_unit')
            populateOSH(
                pduOSH, {
                    'name': deviceName,
                    'serial_number': deviceSerialNumber,
                    'floor': floorName,
                    'space_name': spaceName,
                    'grid_location': gridLocation,
                    'row_name': rowName
                })
            pduOSH.setContainer(datacenterOshDict[buildingName])
            pduOshDict[pduDictKey] = pduOSH
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.debug('[' + SCRIPT_NAME +
                     ':buildPduOSH] Exception: <%s>' % excInfo)
        pass
예제 #2
0
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
예제 #3
0
def osh_createDb2Tablespace(db2SubsystemOsh, tb):
    str_name = 'name'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'

    if isNotNull(tb) and isNotNull(tb[0]):
        tbOsh = ObjectStateHolder('mainframe_db2_tablespace')
        tbOsh.setAttribute(str_name, tb[0])
        tbOsh.setAttribute('dbtablespace_status', tb[1])
        tbOsh.setAttribute('type', tb[2])
        tbOsh.setAttribute('encoding_scheme', tb[3])
        tbOsh.setAttribute('dbtablespace_initialextent', tb[4])
        if isNotNull(tb[5]) and isnumeric(tb[5]):
            tbOsh.setIntegerAttribute('max_dataset_size', int(tb[5]))
        if isNotNull(tb[6]) and isnumeric(tb[6]):
            tbOsh.setIntegerAttribute('number_tables', int(tb[6]))
        if isNotNull(tb[7]) and isnumeric(tb[7]):
            tbOsh.setIntegerAttribute('number_partitions', int(tb[7]))
        try:
            if len(tb[8]) > 19:
                tb[8] = tb[8][0:18]
                created = modeling.getDateFromString(tb[8], 'yyyy-MM-dd-kk.mm.ss', None)
                tbOsh.setDateAttribute('create_date', created)
        except:
            logger.debug("Ignoring create_date. Unable to parse date string")
        tbOsh.setContainer(db2SubsystemOsh)
        return tbOsh
    return None
예제 #4
0
    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)
예제 #5
0
def discoverPhysicalVolumes(wmiProvider, OSHVec, hostOSH):
    queryBuilder = wmiProvider.getBuilder("MSFT_Disk")
    queryBuilder.addWmiObjectProperties("ObjectId", "Path", "FriendlyName", "SerialNumber", "Number", "Size")
    wmicAgent = wmiProvider.getAgent()
    idToOshMap = {}
    numberToOshMap = {}
    try:
        phyVolumes = wmicAgent.getWmiData(queryBuilder)
    except:
        logger.debugException("Failed getting partition to volume map via wmi")
        return idToOshMap

    for volume in phyVolumes:
        id = volume.ObjectId and volume.ObjectId.strip() or ""
        id = id.replace("&amp;", "&")
        name = volume.Path and volume.Path.strip() or ""
        name = name.replace("&amp;", "&")
        description = volume.FriendlyName
        serialNumber = volume.SerialNumber
        number = volume.Number
        size = volume.Size
        phyVolumeOsh = ObjectStateHolder("physicalvolume")
        phyVolumeOsh.setStringAttribute("name", name)
        phyVolumeOsh.setStringAttribute("description", description)
        phyVolumeOsh.setStringAttribute("serial_number", serialNumber)
        phyVolumeOsh.setStringAttribute("volume_id", id)
        phyVolumeOsh.setDoubleAttribute("volume_size", _bytesToMB(size))
        phyVolumeOsh.setContainer(hostOSH)
        OSHVec.add(phyVolumeOsh)
        idToOshMap[id] = phyVolumeOsh
        numberToOshMap[number] = phyVolumeOsh

    return idToOshMap, numberToOshMap
예제 #6
0
def createVlanOshv(vlMap, portOshMap):
	vlanHostOshMap = {}
	oshv = ObjectStateHolderVector()
	# process VLANs
	for (vlanId, vlanObj) in vlMap.items():
		ports = vlanObj.ports
		ports.sort()
		for portId in ports:
			if notNull(portOshMap) and portOshMap.has_key(portId):
				vlanOsh = ObjectStateHolder('vlan')
				vlanOsh.setIntegerAttribute('vlan_number', int(vlanObj.vlanId))
				vlanOsh.setAttribute('vlan_aliasname', vlanObj.name)
				vlanOsh.setAttribute('data_name', vlanObj.vlanId)

				if vlanHostOshMap.has_key(vlanObj.vlanId):
					hostOsh = vlanHostOshMap[vlanObj.vlanId]
				else:
					hostOsh = portOshMap[portId].getAttributeValue('root_container')
					oshv.add(vlanOsh)
					vlanHostOshMap[vlanObj.vlanId] = hostOsh
				vlanOsh.setContainer(hostOsh)
				membershipLink = modeling.createLinkOSH("member", portOshMap[portId], vlanOsh)
				oshv.add(membershipLink)

	return oshv
예제 #7
0
    def _addWebApp(self, appName, resourcePath, parentOsh, vHostDir,
                   vHostJdbcOshMap, globalJdbcOshMap):
        webAppOsh = ObjectStateHolder('webapplication')
        webAppOsh.setAttribute('data_name', appName)
        webAppOsh.setAttribute('resource_path', resourcePath)
        webAppOsh.setContainer(parentOsh)
        self.OSHVResult.add(webAppOsh)

        appJdbcOshMap = HashMap(vHostJdbcOshMap)

        #report context and web config files
        logger.debug("report context and web config file for web application:",
                     appName)

        for configFileName in ['context.xml', 'web.xml']:
            configFileToReport = self.createCF(
                webAppOsh, resourcePath + self.FileSeparator + "WEB-INF" +
                self.FileSeparator + configFileName)
            if configFileToReport:
                logger.debug(
                    "found config file:", resourcePath + self.FileSeparator +
                    "WEB-INF" + self.FileSeparator + configFileName)
                self.OSHVResult.add(configFileToReport)

        appContextPath = vHostDir + appName + '.xml'
        if len(self.fileMonitor.getFilesInPath(vHostDir,
                                               appName + '.xml')) == 1:
            self.getContextJdbcResouces(appContextPath, appJdbcOshMap,
                                        globalJdbcOshMap)
        for appJdbcOsh in appJdbcOshMap.values():
            link = modeling.createLinkOSH('usage', webAppOsh, appJdbcOsh)
            self.OSHVResult.add(link)
예제 #8
0
    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]
예제 #9
0
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
예제 #10
0
 def buildClusteredMailBox(self, orgOsh, clusteredMailBox):
     if orgOsh and clusteredMailBox and clusteredMailBox.name:
         osh = ObjectStateHolder('ms_exchange_clustered_mailbox')
         osh.setAttribute('data_name', clusteredMailBox.name)
         osh.setAttribute('name', clusteredMailBox.name)
         osh.setContainer(orgOsh)
         return osh
예제 #11
0
def createCimOsh(ipAddress, containerOsh, credentialId, category=None):
    '''
    Builds a CIM OSH representing successful connection.
    @param ipAddress: string
    @param containerOsh: corresponding container OSH
    @param credentialId: protocol entry
    @raise ValueError: no credential or no IP.  
    @return: OSH
    '''
    if not credentialId:
        raise ValueError('CredentialsId must be set')
    if not netutils.isValidIp(ipAddress):
        raise ValueError('IP Address must be set')

    cimOsh = ObjectStateHolder('cim')
    cimOsh.setAttribute('data_name', Protocol.FULL)
    cimOsh.setAttribute('credentials_id', credentialId)
    cimOsh.setAttribute('application_ip', ipAddress)
    cimOsh.setContainer(containerOsh)

    if category:
        list_ = StringVector((category, ))
        categoryAttribute = AttributeStateHolder('cim_category', list_)
        cimOsh.addAttributeToList(categoryAttribute)

    return cimOsh
예제 #12
0
파일: ivm.py 프로젝트: deezeesms/dd-git
def createVirtualServerConfigOsh(virtualServerConfig, virtualServerOsh):
    virtualServerConfigOsh = ObjectStateHolder("hp_ivm_config")
    setStringAttribute(virtualServerConfigOsh, "name", "HP IVM Config")
    setStringAttribute(virtualServerConfigOsh, "vm_name",
                       virtualServerConfig.name)
    setStringAttribute(virtualServerConfigOsh, "vm_os_type",
                       virtualServerConfig.os_type)
    setStringAttribute(virtualServerConfigOsh, "vm_state",
                       virtualServerConfig.state)
    setStringAttribute(virtualServerConfigOsh, "serial_number",
                       virtualServerConfig.serial_number)
    setStringAttribute(virtualServerConfigOsh, "vm_uuid",
                       virtualServerConfig.uuid)
    setStringAttribute(virtualServerConfigOsh, "vm_type",
                       virtualServerConfig.machine_type)
    setStringAttribute(virtualServerConfigOsh, "vm_start_type",
                       virtualServerConfig.start_type)
    setStringAttribute(virtualServerConfigOsh, "vm_config_version",
                       virtualServerConfig.config_version)

    setIntegerAttribute(virtualServerConfigOsh, "vm_devs_number",
                        virtualServerConfig.devs_number)
    setIntegerAttribute(virtualServerConfigOsh, "vm_memory",
                        virtualServerConfig.memory)
    setIntegerAttribute(virtualServerConfigOsh, "vm_nets_number",
                        virtualServerConfig.nets_number)
    setIntegerAttribute(virtualServerConfigOsh, "vm_vcpus_number",
                        virtualServerConfig.vcpus_number)
    setIntegerAttribute(virtualServerConfigOsh, "vm_id",
                        virtualServerConfig.vm_number)

    virtualServerConfigOsh.setContainer(virtualServerOsh)
    return virtualServerConfigOsh
예제 #13
0
def buildRppOSH(deviceName, deviceAssetNumber, deviceSerialNumber, rowName,
                gridLocation, spaceName, floorName, buildingName, rppOshDict,
                datacenterOshDict):
    try:
        rppDictKey = '%s ** %s ** %s ** %s ** %s ** %s ** %s' % (
            deviceName, deviceAssetNumber, deviceSerialNumber, gridLocation,
            spaceName, floorName, buildingName)
        if rppDictKey in rppOshDict.keys():
            debugPrint(
                3, '[buildRppOSH] Already processed RPP <%s>! Skipping...' %
                deviceName)
        else:
            debugPrint(2, '[buildRppOSH] RPP <%s> found' % deviceName)
            rppOSH = ObjectStateHolder('remote_power_panel')
            populateOSH(
                rppOSH, {
                    'name': deviceName,
                    'serial_number': deviceSerialNumber,
                    'floor': floorName,
                    'space_name': spaceName,
                    'grid_location': gridLocation,
                    'row_name': rowName
                })
            rppOSH.setContainer(datacenterOshDict[buildingName])
            rppOshDict[rppDictKey] = rppOSH
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.debug('[' + SCRIPT_NAME +
                     ':buildRppOSH] Exception: <%s>' % excInfo)
        pass
예제 #14
0
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 _createHttpContext(self, uri, transport, serverName, webServerOsh):
        if uri and transport.hostIp and transport.port:
            compositeKey = "_".join(
                [uri, transport.hostIp,
                 str(transport.port)])
            httpContextOsh = ObjectStateHolder('httpcontext')
            httpContextOsh.setAttribute('data_name', compositeKey)

            if transport.hostName:
                httpContextOsh.setAttribute('httpcontext_webapplicationhost',
                                            transport.hostName)

            httpContextOsh.setAttribute('httpcontext_webapplicationcontext',
                                        uri)

            if serverName:
                httpContextOsh.setAttribute('httpcontext_webapplicationserver',
                                            serverName)

            if netutils.isValidIp(transport.hostIp):
                httpContextOsh.setAttribute('httpcontext_webapplicationip',
                                            transport.hostIp)

            if transport.protocol:
                httpContextOsh.setAttribute('applicationresource_type',
                                            transport.protocol)

            httpContextOsh.setContainer(webServerOsh)
            return httpContextOsh
예제 #16
0
 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)
예제 #17
0
def makeUserOSH(hostCmdbId, userName, desc, uid, gid, homeDir):
    'host OSH, str, str, str, str, str -> OSH vector'
    iuid = -1
    igid = -1
    try:
        iuid = Long(uid)
    except:
        iuid = -1

    try:
        igid = Long(gid)
    except:
        igid = -1

    myVec = ObjectStateHolderVector()

    u_obj = ObjectStateHolder('osuser')
    host_objSH = modeling.createOshByCmdbIdString('host', hostCmdbId)
    u_obj.setContainer(host_objSH)

    u_obj.setAttribute('data_name', userName)
    if (len(uid) > 0):
        u_obj.setAttribute('user_id', Long(iuid))
    if (len(gid) > 0):
        u_obj.setAttribute('group_id', Long(igid))
    if (len(desc) > 0):
        u_obj.setAttribute('data_note', desc)
    if (len(homeDir) > 0):
        u_obj.setAttribute('homedir', homeDir)
    myVec.add(u_obj)

    return (myVec)
예제 #18
0
def createResourceGroupObject(resourceGroup, clusteredServerOsh,
                              resultsVector):
    resourceGroupOsh = ObjectStateHolder('sunresourcegroup')
    resourceGroupOsh.setAttribute('data_name', resourceGroup.name)
    resourceGroupOsh.setContainer(clusteredServerOsh)

    resourceGroupOsh.setAttribute('mode', resourceGroup.mode)
    if resourceGroup.description:
        resourceGroupOsh.setAttribute('data_description',
                                      resourceGroup.description)
    if resourceGroup.maxPrimaries is not None:
        resourceGroupOsh.setIntegerAttribute('maximum_primaries',
                                             resourceGroup.maxPrimaries)
    if resourceGroup.desiredPrimaries is not None:
        resourceGroupOsh.setIntegerAttribute('desired_primaries',
                                             resourceGroup.desiredPrimaries)
    if resourceGroup.isManaged is not None:
        resourceGroupOsh.setBoolAttribute('is_managed',
                                          resourceGroup.isManaged)
    if resourceGroup.isSystem is not None:
        resourceGroupOsh.setBoolAttribute('is_system', resourceGroup.isSystem)
    if resourceGroup.isFailback is not None:
        resourceGroupOsh.setBoolAttribute('failback', resourceGroup.isFailback)
    if resourceGroup.autoStartOnNewCluster is not None:
        resourceGroupOsh.setBoolAttribute('auto_start_on_new_cluster',
                                          resourceGroup.autoStartOnNewCluster)

    resultsVector.add(resourceGroupOsh)
    return resourceGroupOsh
예제 #19
0
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 
예제 #20
0
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
예제 #21
0
    def getStoredProcedureFromDB(self, dbName, container, filterInternal):
        result = ObjectStateHolderVector()
        if not self.discoveryOptions.discoverProcedures:
            return result
        # if we working with master table need to ignore MSSQL internal storage procedure
        additionalFilter = ""
        if filterInternal:
            additionalFilter = self.__genAdditionalFilter()

        rs = self.connection.getTable('SELECT ROUTINE_NAME, ROUTINE_TYPE, CREATED, LAST_ALTERED FROM [%s].information_schema.routines WHERE routine_type = \'PROCEDURE\'%s' % (dbName, additionalFilter))
        while rs.next():
            name = rs.getString('ROUTINE_NAME')
            dba_type = rs.getString('ROUTINE_TYPE')
            created = rs.getTimestamp('CREATED')
            last_updated = rs.getTimestamp('LAST_ALTERED')

            if name:
                storedProcedure = ObjectStateHolder('dbaobjects')
                storedProcedure.setContainer(container)
                storedProcedure.setAttribute('name', name)
                storedProcedure.setAttribute('dbaobjects_owner', dbName)
                storedProcedure.setAttribute('dbaobjects_type', dba_type)
                if created:
                    storedProcedure.setDateAttribute('dbaobjects_created', created)
                if last_updated:
                    storedProcedure.setDateAttribute('dbaobjects_lastddltime', last_updated)
                result.add(storedProcedure)
        return result
예제 #22
0
def osh_createDdfOsh(db2SubsystemOsh, ddfObj):
    str_name = 'name'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'

    _vector = ObjectStateHolderVector()
    if isNotNull(ddfObj.locationName):
        ddfOsh = ObjectStateHolder('db2_ddf')
        ddfOsh.setAttribute(str_name, ddfObj.locationName)
        ddfOsh.setAttribute('ddf_status', ddfObj.status)
        ddfOsh.setAttribute('ddf_luname', ddfObj.locationLuName)
        ddfOsh.setAttribute('ddf_generic_luname', ddfObj.locationGenericLuName)
        ddfOsh.setAttribute('ddf_ip_address', ddfObj.ipAddress)
        if isNotNull(ddfObj.ipAddress) and isnumeric(ddfObj.ipAddress):
            ddfOsh.setAttribute('ddf_tcp_port', int(ddfObj.tcpPort))
        ddfOsh.setAttribute('ddf_sql_domain', ddfObj.sqlDomain)
        ddfOsh.setContainer(db2SubsystemOsh)
        _vector.add(ddfOsh)
        for alias in ddfObj.ddfAlias:
            ddfAliasOsh = ObjectStateHolder('db2_ddf_alias')
            ddfAliasOsh.setAttribute(str_name, alias.aliasName)
            if isNotNull(alias.aliasPort) and isnumeric(alias.aliasPort):
                ddfAliasOsh.setIntegerAttribute('ddf_alias_port', int(alias.aliasPort))
            ddfAliasOsh.setContainer(ddfOsh)
            _vector.add(ddfAliasOsh)
    return _vector
예제 #23
0
    def getStoredProcedureFromDB(self, dbName, container, filterInternal):
        result = ObjectStateHolderVector()
        if not self.discoveryOptions.discoverProcedures:
            return result
        # if we working with master table need to ignore MSSQL internal storage procedure
        additionalFilter = ""
        if filterInternal:
            additionalFilter = self.__genAdditionalFilter()

        rs = self.connection.getTable(
            'SELECT ROUTINE_NAME, ROUTINE_TYPE, CREATED, LAST_ALTERED FROM [%s].information_schema.routines WHERE routine_type = \'PROCEDURE\'%s'
            % (dbName, additionalFilter))
        while rs.next():
            name = rs.getString('ROUTINE_NAME')
            dba_type = rs.getString('ROUTINE_TYPE')
            created = rs.getTimestamp('CREATED')
            last_updated = rs.getTimestamp('LAST_ALTERED')

            if name:
                storedProcedure = ObjectStateHolder('dbaobjects')
                storedProcedure.setContainer(container)
                storedProcedure.setAttribute('name', name)
                storedProcedure.setAttribute('dbaobjects_owner', dbName)
                storedProcedure.setAttribute('dbaobjects_type', dba_type)
                if created:
                    storedProcedure.setDateAttribute('dbaobjects_created',
                                                     created)
                if last_updated:
                    storedProcedure.setDateAttribute('dbaobjects_lastddltime',
                                                     last_updated)
                result.add(storedProcedure)
        return result
예제 #24
0
def discoverPhysicalVolumes(wmiProvider, OSHVec, hostOSH):
    queryBuilder = wmiProvider.getBuilder('MSFT_Disk')
    queryBuilder.addWmiObjectProperties('ObjectId', 'Path', 'FriendlyName',
                                        'SerialNumber', 'Number', 'Size')
    wmicAgent = wmiProvider.getAgent()
    idToOshMap = {}
    numberToOshMap = {}
    try:
        phyVolumes = wmicAgent.getWmiData(queryBuilder)
    except:
        logger.debugException('Failed getting partition to volume map via wmi')
        return idToOshMap

    for volume in phyVolumes:
        id = volume.ObjectId and volume.ObjectId.strip() or ''
        id = id.replace('&amp;', '&')
        name = volume.Path and volume.Path.strip() or ''
        name = name.replace('&amp;', '&')
        description = volume.FriendlyName
        serialNumber = volume.SerialNumber
        number = volume.Number
        size = volume.Size
        phyVolumeOsh = ObjectStateHolder("physicalvolume")
        phyVolumeOsh.setStringAttribute("name", name)
        phyVolumeOsh.setStringAttribute("description", description)
        phyVolumeOsh.setStringAttribute("serial_number", serialNumber)
        phyVolumeOsh.setStringAttribute("volume_id", id)
        phyVolumeOsh.setDoubleAttribute("volume_size", _bytesToMB(size))
        phyVolumeOsh.setContainer(hostOSH)
        OSHVec.add(phyVolumeOsh)
        idToOshMap[id] = phyVolumeOsh
        numberToOshMap[number] = phyVolumeOsh

    return idToOshMap, numberToOshMap
예제 #25
0
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
예제 #26
0
 def discoverPlans(self,oshv,sqlServerId,dbs):
     logger.debug("going to get jobs and plans")
     if self.discoveryOptions and self.discoveryOptions.discoverSqlJob:
         jobById=self.getSqlJobs(oshv, sqlServerId)
     else:
         jobById=HashMap()
     rs = self.connection.getTable(self.plansQuery)
     plans = HashMap()
     while(rs.next()):
         name = rs.getString('plan_name')
         id = rs.getString('plan_id')
         osh = ObjectStateHolder('sqlservermaintenanceplan')
         osh.setAttribute(Queries.DATA_NAME,name)
         osh.setAttribute('planId',id)
         osh.setContainer(sqlServerId)
         oshv.add(osh)
         if self.discoveryOptions and self.discoveryOptions.discoverDbUser:
             owner = rs.getString('owner')
             # Some plans may not have an owner so we need to check
             if owner:
                 user = ObjectStateHolder('dbuser')
                 user.setAttribute(Queries.DATA_NAME,owner)
                 user.setContainer(sqlServerId)
                 oshv.add(user)
                 oshv.add(modeling.createLinkOSH('owner',user,osh))
         plans.put(name,osh)
     rs.close()
     logger.debug("got plans: ", plans.keySet().toString())
     self.discoverPlanJobs(oshv,sqlServerId,plans,jobById)
     self.discoverPlanDbs(oshv,plans,dbs)
def _reportNonStopTopology(resultCollection, hostOsh, hostIp,
                           catalogUidToSqlMx, catalogUidToMxSchema, sqlmpList):
    for catalogUid, sqlmx in catalogUidToSqlMx.items():
        sqlmxOsh = modeling.createApplicationOSH("nonstop_sql_mx",
                                                 sqlmx.data_name, hostOsh,
                                                 "Database", sqlmx.vendor)
        sqlmxOsh.setStringAttribute('database_dbsid', sqlmx.database_dbsid)
        sqlmxOsh.setStringAttribute('database_dbversion', sqlmx.version)
        sqlmxOsh.setStringAttribute('application_version', sqlmx.version)
        sqlmxOsh.setStringAttribute('catalog_uuid', sqlmx.catalog_uuid)

        resultCollection.add(sqlmxOsh)

        sqlmxSchemaNames = catalogUidToMxSchema.get(catalogUid)
        if sqlmxSchemaNames:
            for sqlmxSchemaName in sqlmxSchemaNames:
                sqlmxSchemaOsh = ObjectStateHolder('database_instance')
                sqlmxSchemaOsh.setStringAttribute('data_name', sqlmxSchemaName)
                sqlmxSchemaOsh.setContainer(sqlmxOsh)
                resultCollection.add(sqlmxSchemaOsh)

    for sqlmp in sqlmpList:
        sqlmpOsh = modeling.createApplicationOSH("database", sqlmp.data_name,
                                                 hostOsh, "Database",
                                                 sqlmp.vendor)
        sqlmpOsh.setStringAttribute('database_dbsid', sqlmp.database_dbsid)
        sqlmpOsh.setStringAttribute('database_dbversion', sqlmp.version)
        sqlmpOsh.setStringAttribute('application_version', sqlmp.version)
        resultCollection.add(sqlmpOsh)
예제 #28
0
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
예제 #29
0
파일: cim.py 프로젝트: ddonnelly19/dd-git
def createCimOsh(ipAddress, containerOsh, credentialId, category=None):
    '''
    Builds a CIM OSH representing successful connection.
    @param ipAddress: string
    @param containerOsh: corresponding container OSH
    @param credentialId: protocol entry
    @raise ValueError: no credential or no IP.  
    @return: OSH
    '''
    if not credentialId:
        raise ValueError('CredentialsId must be set')
    if not netutils.isValidIp(ipAddress):
        raise ValueError('IP Address must be set')
    
    cimOsh = ObjectStateHolder('cim')
    cimOsh.setAttribute('data_name', Protocol.FULL)
    cimOsh.setAttribute('credentials_id', credentialId)
    cimOsh.setAttribute('application_ip', ipAddress)
    cimOsh.setContainer(containerOsh)
    
    if category:
        list_ = StringVector((category,))
        categoryAttribute = AttributeStateHolder('cim_category', list_)
        cimOsh.addAttributeToList(categoryAttribute)
    
    return cimOsh
예제 #30
0
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
예제 #31
0
 def getSqlFilesFromMaster(self, oshv, dbmap, hostId, users):
     rs = self.connection.getTable(Queries.MASTER_FILES)
     while rs.next():
         path = Util.replaceFileSeparator(rs.getString('physical_name'))
         fileName = rs.getString('name').strip()
         size = self.normalizeSize(rs.getString('size'))
         growth = self.normalizeSize(rs.getString('growth'))
         max = self.normalizeSize(rs.getString('max_size'))
         dbname = rs.getString('dbname').strip()
         logger.debug("Get DB configuration::", dbname)
         if (max == '-1'):
             max = 'unlimited'
         osh = ObjectStateHolder('sqlfile')
         osh.setAttribute(Queries.DATA_NAME, fileName)
         osh.setAttribute('sqlfile_path', path)
         osh.setAttribute('sqlfile_size', size)
         osh.setAttribute('sqlfile_growth', growth)
         db = dbmap.get(dbname)
         if db:
             osh.setContainer(db)
             oshv.add(osh)
             disk = Util.getDisk(path, hostId)
             oshv.add(disk)
             oshv.add(modeling.createLinkOSH('depend', osh, disk))
             self.attachToUsers(db, users, oshv, dbname)
         else:
             logger.debug("Failed to get db from dbmap:", dbname)
     rs.close()
예제 #32
0
 def getDistributors(self,oshv,sqlServerId):
     #is there is a chance that we have more than one distributor?
     rs = self.connection.doCall(Queries.SERVER_DIST_CALL)
     distributor = None
     databaseName = None
     while rs.next():
         name = rs.getString('distributor')
         if(name is None):
             rs.close()
             return None
         databaseName = rs.getString('distribution database')
         max = int(rs.getInt('max distrib retention'))
         min = int(rs.getInt('min distrib retention'))
         history = int(rs.getInt('history retention'))
         cleanup = String(rs.getString('history cleanup agent'))
         idx = cleanup.indexOf('Agent history clean up:')
         if(idx>=0):
             cleanup=cleanup.substring(len("Agent history clean up:"))
         distributor = ObjectStateHolder('sqlserverdistributor')
         sqlServer = self.createSqlServer(name,oshv,sqlServerId)
         distributor.setContainer(sqlServer)
         distributor.setAttribute(Queries.DATA_NAME,name)
         distributor.setIntegerAttribute('maxTxRetention',max)
         distributor.setIntegerAttribute('minTxRetention',min)
         distributor.setIntegerAttribute('historyRetention',history)
         distributor.setAttribute('cleanupAgentProfile',cleanup)
         oshv.add(sqlServer)
         oshv.add(distributor)        
         database = self.getDatabase(sqlServer,databaseName)
         oshv.add(database)
         oshv.add(modeling.createLinkOSH('use',distributor,database))
     rs.close()
     if(distributor!=None):
         logger.debug('we got a distributor')
     return [distributor,databaseName]
예제 #33
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)
예제 #34
0
 def _create_osh(self, parent_osh):
     osh = ObjectStateHolder('sap_process_step')
     osh.setAttribute('data_name', self.__name)
     if self.__component:
         osh.setAttribute('logical_component', self.__component)
     osh.setContainer(parent_osh)
     return osh
 def _createRunningSoftwareOsh(self, description, hostOsh):
     runningSoftwareOsh = ObjectStateHolder("j2eeserver")
     if description:
         runningSoftwareOsh.setStringAttribute("description", description)
         runningSoftwareOsh.setStringAttribute("j2eeserver_fullname", description)
     runningSoftwareOsh.setContainer(hostOsh)
     return runningSoftwareOsh
예제 #36
0
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)
예제 #37
0
 def _create_osh(self, parent_osh):
     osh = ObjectStateHolder('sap_process_step')
     osh.setAttribute('data_name', self.__name)
     if self.__component:
         osh.setAttribute('logical_component', self.__component)
     osh.setContainer(parent_osh)
     return osh
예제 #38
0
def discoverPhysicalDiskByWmi(shell, OSHVec, hostOSH):
    wmiProvider = wmiutils.getWmiProvider(shell)
    queryBuilder = wmiProvider.getBuilder("Win32_DiskDrive")
    queryBuilder.addWmiObjectProperties("DeviceID", "SerialNumber", "Size")

    wmiAgent = wmiProvider.getAgent()

    diskDevices = []
    try:
        diskDevices = wmiAgent.getWmiData(queryBuilder)
    except:
        logger.debugException("Failed getting physical disk via wmi")

    for diskDevice in diskDevices:
        diskOsh = ObjectStateHolder("disk_device")
        diskName = diskDevice.DeviceID and diskDevice.DeviceID.strip() or None
        if diskName:
            diskOsh.setStringAttribute("name", diskName.upper())
        else:
            continue
        diskSerialNumber = diskDevice.SerialNumber and diskDevice.SerialNumber.strip() or None
        if diskSerialNumber:
            diskOsh.setStringAttribute("serial_number", diskSerialNumber)
        diskOsh.setStringAttribute("disk_type", "fixed_disk")
        diskSize = diskDevice.Size and diskDevice.Size.strip() or None
        # Byte to MB
        if diskSize:
            diskSize = int(diskSize) / 0x100000
            diskOsh.setIntegerAttribute("disk_size", diskSize)
        diskOsh.setContainer(hostOSH)
        OSHVec.add(diskOsh)
예제 #39
0
def makeUserOSH(hostCmdbId, userName, desc, uid, gid, homeDir):
    'host OSH, str, str, str, str, str -> OSH vector'
    iuid = -1
    igid = -1
    try:
        iuid = Long(uid)
    except:
        iuid = -1

    try:
        igid = Long(gid)
    except:
        igid = -1

    myVec = ObjectStateHolderVector()

    u_obj = ObjectStateHolder('osuser')
    host_objSH = modeling.createOshByCmdbIdString('host', hostCmdbId)
    u_obj.setContainer(host_objSH)

    u_obj.setAttribute('data_name', userName)
    if(len(uid) > 0):
        u_obj.setAttribute('user_id', Long(iuid))
    if(len(gid) > 0):
        u_obj.setAttribute('group_id', Long(igid))
    if(len(desc) > 0):
        u_obj.setAttribute('data_note', desc)
    if(len(homeDir) > 0):
        u_obj.setAttribute('homedir', homeDir)
    myVec.add(u_obj)

    return(myVec)
예제 #40
0
 def buildClusteredMailBox(self, orgOsh, clusteredMailBox):
     if orgOsh and clusteredMailBox and clusteredMailBox.name:
         osh = ObjectStateHolder('ms_exchange_clustered_mailbox')
         osh.setAttribute('data_name', clusteredMailBox.name)
         osh.setAttribute('name', clusteredMailBox.name)
         osh.setContainer(orgOsh)
         return osh
예제 #41
0
def createResourcePoolObjects(resourcePoolsByName, globalZoneOsh, resultsVector):
    for resourcePool in resourcePoolsByName.values():
        resourcePoolOsh = ObjectStateHolder('solaris_resource_pool')
        resourcePoolOsh.setAttribute('data_name', resourcePool.name)
        if resourcePool.isDefault is not None:
            resourcePoolOsh.setBoolAttribute('is_default', resourcePool.isDefault)
        if resourcePool.isActive is not None:
            resourcePoolOsh.setBoolAttribute('is_active', resourcePool.isActive)
        if resourcePool.scheduler:
            resourcePoolOsh.setAttribute('scheduler', resourcePool.scheduler)
        if resourcePool.importance is not None:
            resourcePoolOsh.setIntegerAttribute('importance', resourcePool.importance)
        pset = resourcePool.pset
        if pset is not None:
            resourcePoolOsh.setAttribute('pset_name', pset.name)
            if pset.minCpus is not None:
                resourcePoolOsh.setIntegerAttribute('pset_min_cpus', pset.minCpus)
            if pset.maxCpus is not None:
                resourcePoolOsh.setIntegerAttribute('pset_max_cpus', pset.maxCpus)
            if pset.objectives:
                resourcePoolOsh.setAttribute('pset_objectives', pset.objectives)


        resourcePoolOsh.setContainer(globalZoneOsh)
        resultsVector.add(resourcePoolOsh)
        resourcePool.osh = resourcePoolOsh
예제 #42
0
파일: ivm.py 프로젝트: ddonnelly19/dd-git
def createHypervisorOsh(hypervisor, containerOsh):
    hypervisorOsh = ObjectStateHolder("virtualization_layer")
    hypervisorOsh.setStringAttribute("name", hypervisor.name)
    hypervisorOsh.setStringAttribute("version", hypervisor.version)
    hypervisorOsh.setStringAttribute("discovered_product_name", "Integrity Virtual Machine Hypervisor")
    hypervisorOsh.setContainer(containerOsh)
    return hypervisorOsh
예제 #43
0
 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
예제 #44
0
 def getSqlFilesFromMaster(self, oshv, dbmap, hostId, users):
     rs = self.connection.getTable(Queries.MASTER_FILES)
     while rs.next():
         path = Util.replaceFileSeparator(rs.getString('physical_name'))
         fileName = rs.getString('name').strip()
         size = self.normalizeSize(rs.getString('size'))
         growth = self.normalizeSize(rs.getString('growth'))
         max = self.normalizeSize(rs.getString('max_size'))
         dbname = rs.getString('dbname').strip()
         logger.debug("Get DB configuration::", dbname)
         if (max == '-1'):
             max = 'unlimited'
         osh = ObjectStateHolder('sqlfile')
         osh.setAttribute(Queries.DATA_NAME, fileName)
         osh.setAttribute('sqlfile_path', path)
         osh.setAttribute('sqlfile_size', size)
         osh.setAttribute('sqlfile_growth', growth)
         db = dbmap.get(dbname)
         if db:
             osh.setContainer(db)
             oshv.add(osh)
             disk = Util.getDisk(path, hostId)
             oshv.add(disk)
             oshv.add(modeling.createLinkOSH('depend', osh, disk))
             self.attachToUsers(db, users, oshv, dbname)
         else:
             logger.debug("Failed to get db from dbmap:", dbname)
     rs.close()
예제 #45
0
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)
예제 #46
0
def osh_createDsgAndMemberOsh(db2SubsystemName, db2SubsystemOsh, dsg):
    str_name = 'name'
    str_membership = 'membership'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'
        str_membership = 'member'

    _vector = ObjectStateHolderVector()
    if isNotNull(dsg) and isNotNull(dsg.name):
        dsgOsh = ObjectStateHolder('db2_datasharing_group')
        dsgOsh.setAttribute(str_name, dsg.name)
        dsgOsh.setAttribute('group_attach_name', dsg.attachName)
        dsgOsh.setAttribute('group_mode', dsg.mode)
        if isNotNull(dsg.level) and isnumeric(dsg.level):
            dsgOsh.setIntegerAttribute('group_level', int(dsg.level))
        if isNotNull(dsg.protocolLevel) and isnumeric(dsg.protocolLevel):
            dsgOsh.setIntegerAttribute('group_protocol_level', int(dsg.protocolLevel))
        _vector.add(dsgOsh)
        for member in dsg.members:
            if isNotNull(member) and isNotNull(member.db2Member) and isNotNull(member.subsys) and upper(member.subsys) == db2SubsystemName:
                dsgMemberOsh = ObjectStateHolder('db2_datasharing_group_member')
                dsgMemberOsh.setAttribute(str_name, member.db2Member)
                dsgMemberOsh.setAttribute('member_id', member.id)
                dsgMemberOsh.setAttribute('member_level', member.db2Level)
                dsgMemberOsh.setAttribute('member_status', member.status)
                dsgMemberOsh.setContainer(db2SubsystemOsh)
                _vector.add(dsgMemberOsh)

                # if DSG Member available, make subsystem member of DSB --------s
                memberLinkOsh = modeling.createLinkOSH(str_membership, dsgOsh, db2SubsystemOsh)
                _vector.add(memberLinkOsh)
    return _vector
예제 #47
0
def build_layer2_connection(net_device_osh, net_device_interface_name, net_device_ip_address, end_node_osh, end_node_mac_address, end_node_interface_osh):
    '''
    Build Layer 2 connection topology.
    @type param: str,str,osh,str -> OSHV
    '''
    net_device_id = net_device_ip_address or net_device_osh.getCmdbId().toString()
    end_node_id = end_node_mac_address
    #is it enough data to build Layer 2 topology
    if net_device_id and end_node_id and net_device_osh and net_device_interface_name and end_node_osh and end_node_interface_osh:
        oshv = ObjectStateHolderVector()
        net_device_interface_osh = ObjectStateHolder('interface')
        net_device_interface_osh.setContainer(net_device_osh)
        net_device_interface_osh.setAttribute('interface_name', net_device_interface_name)

        layer2_osh = ObjectStateHolder('layer2_connection')
        layer2_osh.setAttribute('layer2_connection_id',str(hash(net_device_id + end_node_id)))
        layer2_member_net_device_interface_osh = modeling.createLinkOSH('member', layer2_osh, net_device_interface_osh)
        layer2_member_end_node_interface_osh = modeling.createLinkOSH('member', layer2_osh, end_node_interface_osh)

        oshv.add(net_device_osh)
        oshv.add(net_device_interface_osh)
        oshv.add(end_node_osh)
        oshv.add(end_node_interface_osh)
        oshv.add(layer2_osh)
        oshv.add(layer2_member_net_device_interface_osh)
        oshv.add(layer2_member_end_node_interface_osh)
        return oshv
예제 #48
0
def discoverPhysicalDiskByWmi(shell, OSHVec, hostOSH):
    wmiProvider = wmiutils.getWmiProvider(shell)
    queryBuilder = wmiProvider.getBuilder('Win32_DiskDrive')
    queryBuilder.addWmiObjectProperties('DeviceID', 'SerialNumber', 'Size')

    wmiAgent = wmiProvider.getAgent()

    diskDevices = []
    try:
        diskDevices = wmiAgent.getWmiData(queryBuilder)
    except:
        logger.debugException('Failed getting physical disk via wmi')

    for diskDevice in diskDevices:
        diskOsh = ObjectStateHolder("disk_device")
        diskName = diskDevice.DeviceID and diskDevice.DeviceID.strip() or None
        if diskName:
            diskOsh.setStringAttribute("name", diskName.upper())
        else:
            continue
        diskSerialNumber = diskDevice.SerialNumber and diskDevice.SerialNumber.strip(
        ) or None
        if diskSerialNumber:
            diskOsh.setStringAttribute("serial_number", diskSerialNumber)
        diskOsh.setStringAttribute("disk_type", "fixed_disk")
        diskSize = diskDevice.Size and diskDevice.Size.strip() or None
        # Byte to MB
        if diskSize:
            diskSize = int(diskSize) / 0x100000
            diskOsh.setIntegerAttribute("disk_size", diskSize)
        diskOsh.setContainer(hostOSH)
        OSHVec.add(diskOsh)
def createInterfaceIndexOsh(networkInterface, hostOsh):
    if hostOsh and networkInterface and networkInterface.interfaceIndex and networkInterface.speed:
        ifaceIndexOsh = ObjectStateHolder('interfaceindex')
        ifaceIndexOsh.setContainer(hostOsh)
        ifaceIndexOsh.setIntegerAttribute('interfaceindex_index', networkInterface.interfaceIndex)
        ifaceIndexOsh.setDoubleAttribute('interfaceindex_speed', networkInterface.speed)
        return ifaceIndexOsh
예제 #50
0
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
예제 #51
0
def osh_createIpOsh(lparOsh, tcpStacks):
    
    ipstoexclude = ['127.0.0.1']
    # tcpStacks  [ip, network, mask, interface name, status, type, mac address]str_name = 'name'    
    str_name = 'name'
    str_mac_address = 'mac_address'
    _vector = ObjectStateHolderVector()
    for mac, tcpentry in tcpStacks.items():
        ipAddress = tcpentry[0].strip()
        if ipAddress not in ipstoexclude:       
            ipOsh = modeling.createIpOSH(ipAddress)
            probeName = CollectorsParameters.getValue(CollectorsParameters.KEY_COLLECTORS_PROBE_NAME) 
            if isNotNull(probeName):
                ipOsh.setAttribute('ip_probename', probeName)   
                containedOsh = modeling.createLinkOSH('contained', lparOsh, ipOsh)         
            _vector.add(lparOsh)
            _vector.add(ipOsh)
            _vector.add(containedOsh)
         
            # create interface ----------------------------------------------------
        
            ifOsh = ObjectStateHolder('interface')
            interfacename = tcpentry[3].strip()
            ifOsh.setAttribute(str_name,  interfacename)       
            # default the mac address attribute to linkName and update later if MAC found 
            ifOsh.setAttribute(str_mac_address, mac) # if MAC not found for set #linkName as key       
            ifOsh.setContainer(lparOsh)
            _vector.add(ifOsh)
            if tcpStacks.has_key(mac):
                parentLinkOsh = modeling.createLinkOSH('containment', ifOsh, ipOsh)
                _vector.add(parentLinkOsh)
    return _vector
예제 #52
0
 def getDistributors(self, oshv, sqlServerId):
     #is there is a chance that we have more than one distributor?
     rs = self.connection.doCall(Queries.SERVER_DIST_CALL)
     distributor = None
     databaseName = None
     while rs.next():
         name = rs.getString('distributor')
         if (name is None):
             rs.close()
             return None
         databaseName = rs.getString('distribution database')
         max = int(rs.getInt('max distrib retention'))
         min = int(rs.getInt('min distrib retention'))
         history = int(rs.getInt('history retention'))
         cleanup = String(rs.getString('history cleanup agent'))
         idx = cleanup.indexOf('Agent history clean up:')
         if (idx >= 0):
             cleanup = cleanup.substring(len("Agent history clean up:"))
         distributor = ObjectStateHolder('sqlserverdistributor')
         sqlServer = self.createSqlServer(name, oshv, sqlServerId)
         distributor.setContainer(sqlServer)
         distributor.setAttribute(Queries.DATA_NAME, name)
         distributor.setIntegerAttribute('maxTxRetention', max)
         distributor.setIntegerAttribute('minTxRetention', min)
         distributor.setIntegerAttribute('historyRetention', history)
         distributor.setAttribute('cleanupAgentProfile', cleanup)
         oshv.add(sqlServer)
         oshv.add(distributor)
         database = self.getDatabase(sqlServer, databaseName)
         oshv.add(database)
         oshv.add(modeling.createLinkOSH('use', distributor, database))
     rs.close()
     if (distributor != None):
         logger.debug('we got a distributor')
     return [distributor, databaseName]
예제 #53
0
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
예제 #54
0
def processImageInfo(imageInspectOutput, imageInfo, nodeOSH, imageDict,
                     OSHVResult):

    json = _JSONs()
    jsonOutput = json.loads(imageInspectOutput)
    inspectJsonObj = jsonOutput[0]

    imageName = imageInfo[0].strip()
    imageTag = imageInfo[1]
    imageIdShort = imageInfo[2]
    virtualSize = imageInfo[len(imageInfo) - 2] + imageInfo[len(imageInfo) - 1]
    imageId = inspectJsonObj['Id']

    imageOSH = ObjectStateHolder('docker_image')
    if imageName == '<none>':
        imageOSH.setAttribute('name', 'Docker Image')
    else:
        imageOSH.setAttribute('name', imageName)
    imageOSH.setAttribute('docker_image_id', imageId)
    imageOSH.setAttribute('repository', imageName)
    imageOSH.setAttribute('tag', imageTag)
    imageOSH.setAttribute('virtual_size', virtualSize)
    imageOSH.setContainer(nodeOSH)

    OSHVResult.add(imageOSH)
    imageDict[imageId] = imageOSH
예제 #55
0
def osh_createDb2Tablespace(db2SubsystemOsh, tb):
    str_name = 'name'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'

    if isNotNull(tb) and isNotNull(tb[0]):
        tbOsh = ObjectStateHolder('mainframe_db2_tablespace')
        tbOsh.setAttribute(str_name, tb[0])
        tbOsh.setAttribute('dbtablespace_status', tb[1])
        tbOsh.setAttribute('type', tb[2])
        tbOsh.setAttribute('encoding_scheme', tb[3])
        tbOsh.setAttribute('dbtablespace_initialextent', tb[4])
        if isNotNull(tb[5]) and isnumeric(tb[5]):
            tbOsh.setIntegerAttribute('max_dataset_size', int(tb[5]))
        if isNotNull(tb[6]) and isnumeric(tb[6]):
            tbOsh.setIntegerAttribute('number_tables', int(tb[6]))
        if isNotNull(tb[7]) and isnumeric(tb[7]):
            tbOsh.setIntegerAttribute('number_partitions', int(tb[7]))
        try:
            if len(tb[8]) > 19:
                tb[8] = tb[8][0:18]
                created = modeling.getDateFromString(tb[8],
                                                     'yyyy-MM-dd-kk.mm.ss',
                                                     None)
                tbOsh.setDateAttribute('create_date', created)
        except:
            logger.debug("Ignoring create_date. Unable to parse date string")
        tbOsh.setContainer(db2SubsystemOsh)
        return tbOsh
    return None