示例#1
0
 def build(self, virtualVolume):
     if virtualVolume is None: raise ValueError("virtualVolume is None")
     if not virtualVolume.getName(): raise ValueError("name of virtualVolume is empty")
     
     volumeOsh = ObjectStateHolder('ldom_virtual_volume')
     
     volumeOsh.setStringAttribute('name', virtualVolume.getName())
     
     if virtualVolume.deviceName:
         volumeOsh.setStringAttribute('vv_device', virtualVolume.deviceName)
     
     optionValues = virtualVolume.options.values()
     if optionValues:
         optionsString = ", ".join([optionValue.value() for optionValue in optionValues])
         volumeOsh.setStringAttribute('vv_options', optionsString)
     
     if virtualVolume.multiPathGroupName:
         volumeOsh.setStringAttribute('vv_mpgroup', virtualVolume.multiPathGroupName)
         
     return volumeOsh
示例#2
0
 def discoverPools(self, poolNameToVirtualServer, f5):
     queryBuilder = SnmpQueryBuilder('7.2.1')
     queryBuilder.addQueryElement(1, 'name')
     pools = self.snmpAgent.getSnmpData(queryBuilder)
     
     poolNameToPool = {}
     for pool in pools:
         poolOsh = ObjectStateHolder('loadbalancecluster')
         poolOsh.setAttribute('data_name', pool.name)
         memberLink = modeling.createLinkOSH('membership', f5, poolOsh)
         self.OSHVResult.add(memberLink)
         poolNameToPool[pool.name] = poolOsh
         self.OSHVResult.add(poolOsh)
         if poolNameToVirtualServer.has_key(pool.name):
             virtualServerHelper = poolNameToVirtualServer[pool.name]
             virtualServerHelper.linkToContainingCluster(poolOsh, pool.name)
         else:
             logger.debug('Pool %s is not related to any virtual server.' % pool.name)
         
     self.discoverPoolMembers(poolNameToPool)
示例#3
0
def buildDatacenterOSH(datacenterName, datacenterOshDict):
    try:
        if datacenterName in datacenterOshDict.keys():
            debugPrint(
                3,
                '[buildDatacenterOSH] Already processed DATACENTER <%s>! Skipping...'
                % datacenterName)
        else:
            debugPrint(
                2,
                '[buildDatacenterOSH] DATACENTER <%s> found' % datacenterName)
            datacenterOSH = ObjectStateHolder('datacenter')
            populateOSH(datacenterOSH, {'name': datacenterName})
            datacenterOshDict[datacenterName] = datacenterOSH
            return datacenterOSH
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.debug('[' + SCRIPT_NAME +
                     ':buildDatacenterOSH] Exception: <%s>' % excInfo)
        pass
示例#4
0
    def build(self, fcportpdo):
        osh = ObjectStateHolder(self.CIT)
        osh.setAttribute('fcport_wwn', fcportpdo.wwn)
        if fcportpdo.name is not None:
            osh.setAttribute('name', unicode(fcportpdo.name))

        if fcportpdo.porttype:
            if isinstance(fcportpdo.porttype, int):
                osh.setEnumAttribute('port_type', fcportpdo.porttype)
            else:
                osh.setEnumAttribute('port_type',
                                     PORT_TYPES.get(fcportpdo.porttype, 5))

        if fcportpdo.portindex is not None:
            osh.setAttribute('port_index', fcportpdo.portindex)
        if fcportpdo.type:
            osh.setAttribute('fcport_type', fcportpdo.type)
        if fcportpdo.trunkedstate:
            osh.setAttribute('fcport_trunkedstate', fcportpdo.trunkedstate)
        if fcportpdo.symbolicname:
            osh.setAttribute('fcport_symbolicname', fcportpdo.symbolicname)
        if fcportpdo.status:
            osh.setAttribute('fcport_status', fcportpdo.status)
        if fcportpdo.state:
            osh.setAttribute('fcport_state', fcportpdo.state)
        if fcportpdo.speed is not None:
            osh.setAttribute('fcport_speed', fcportpdo.speed)
        if fcportpdo.scsiport:
            osh.setAttribute('fcport_scsiport', fcportpdo.scsiport)
        if fcportpdo.id is not None:
            osh.setAttribute('fcport_portid', fcportpdo.id)
        if fcportpdo.maxspeed:
            osh.setAttribute('fcport_maxspeed', fcportpdo.maxspeed)
        if fcportpdo.fibertype:
            osh.setAttribute('fcport_fibertype', fcportpdo.fibertype)
        if fcportpdo.domainid:
            osh.setAttribute('fcport_domainid', fcportpdo.domainid)
        if fcportpdo.connectedtowwn:
            osh.setAttribute('fcport_connectedtowwn', fcportpdo.connectedtowwn)

        return osh
示例#5
0
    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
示例#6
0
文件: smis.py 项目: deezeesms/dd-git
    def build(self, storage_processor):
        if not storage_processor:
            raise ValueError('Storage Processor is not specified.')

        storageProcessorOsh = ObjectStateHolder('storageprocessor')
        storageProcessorOsh.setStringAttribute('name', storage_processor.name)

        if storage_processor.version is not None:
            storageProcessorOsh.setStringAttribute('storageprocessor_version', storage_processor.version)
        if storage_processor.serial is not None:
            storageProcessorOsh.setStringAttribute('serial_number', storage_processor.serial)
        if storage_processor.status is not None:
            storageProcessorOsh.setStringAttribute('storageprocessor_status', storage_processor.status)
        if storage_processor.ip is not None:
            storageProcessorOsh.setStringAttribute('storageprocessor_ip', storage_processor.ip)
        if storage_processor.model is not None:
            storageProcessorOsh.setStringAttribute('storageprocessor_model', storage_processor.model)
        if storage_processor.vendor is not None:
            storageProcessorOsh.setStringAttribute('storageprocessor_vendor', storage_processor.vendor)
            
        return storageProcessorOsh
示例#7
0
 def buildGroup(self, group):
     r'@types: ResourceGroup -> ObjectStateHolder'
     assert group
     osh = ObjectStateHolder('mscsgroup')
     osh.setAttribute('data_name', group.name)
     if group.details:
         details = group.details
         if details.description:
             osh.setStringAttribute('data_description', details.description)
         persistentState = details.persistentState
         if persistentState is not None:
             osh.setBoolAttribute('persistentstate', persistentState)
         threshold = details.failoverThreshold
         if (threshold is not None and threshold < Integer.MAX_VALUE):
             osh.setIntegerAttribute('failoverthreshold', threshold)
         period = details.failoverPeriod
         if (period is not None and period < Integer.MAX_VALUE):
             osh.setIntegerAttribute('failoverperiod', period)
         if details.autoFailbackType is not None:
             osh.setAttribute('autofailbacktype', details.autoFailbackType)
     return osh
示例#8
0
def osh_createSoftwareOsh(lparOsh, prodLists):
    str_name = 'name'
    str_description = 'description'
    str_version = 'version'
    str_software_type = 'software_type'
    str_software_productid = 'software_productid'
    str_discovered_vendor = 'software_vendor'
    _vector = ObjectStateHolderVector()
    if len(prodLists) > 0:
        for prod in prodLists:
            swOsh = None
            swOsh = ObjectStateHolder('installed_software')
            swOsh.setAttribute(str_name,
                               prod[0] + '-' + prod[1] + '-' + prod[2])  # Name
            swOsh.setAttribute(str_description, prod[6])
            swOsh.setAttribute(str_version, prod[5])
            swOsh.setAttribute(str_software_type, prod[3])
            swOsh.setAttribute(str_software_productid, prod[0])
            swOsh.setContainer(lparOsh)
            _vector.add(swOsh)
    return _vector
示例#9
0
 def visitJmsDatasource(self, server):
     '@types: jms.Server -> ObjectStateHolder'
     osh = ObjectStateHolder('jmsserver')
     osh.setAttribute('name', server.getName())
     self._setNotNoneOshAttributeValue(osh, 'jmsserver_messagescurrent',
                                       server.messagesCurrentCount.value())
     self._setNotNoneOshAttributeValue(osh, 'jmsserver_messagesmaximum',
                                       server.messagesHighCount.value())
     self._setNotNoneOshAttributeValue(osh, 'jmsserver_messagespending',
                                       server.messagesPendingCount.value())
     self._setNotNoneOshAttributeValue(osh, 'jmsserver_messagesreceived',
                                       server.messagesReceivedCount.value())
     self._setNotNoneOshAttributeValue(
         osh, 'jmsserver_sessionpoolscurrent',
         server.sessionPoolsCurrentCount.value())
     self._setNotNoneOshAttributeValue(
         osh, 'jmsserver_sessionpoolstotal',
         server.sessionPoolsTotalCount.value())
     self._setNotNoneOshAttributeValue(osh, 'j2eemanagedobject_objectname',
                                       server.getObjectName())
     return osh
示例#10
0
    def build(self, vdc):
        if vdc is None: raise ValueError("vDC is None")

        vdcOsh = ObjectStateHolder('vcloud_vdc')
        self._setNameAttribute(vdc, vdcOsh)
        self._setDescriptionAttribute(vdc, vdcOsh)
        self._setStatusAttribute(vdc, vdcOsh)
        self._setEnabledAttribute(vdc, vdcOsh)
        self._setAllocationModelAttribute(vdc, vdcOsh)

        self._setCapacityAttributes(vdc.cpuCapacity,
                                    BaseVdcBuilder._CAPACITY_PREFIX_CPU,
                                    vdcOsh)
        self._setCapacityAttributes(vdc.memoryCapacity,
                                    BaseVdcBuilder._CAPACITY_PREFIX_MEMORY,
                                    vdcOsh)
        self._setCapacityAttributes(vdc.storageCapacity,
                                    BaseVdcBuilder._CAPACITY_PREFIX_STORAGE,
                                    vdcOsh)

        return vdcOsh
示例#11
0
    def build(self, virtualDisk):
        if virtualDisk is None: raise ValueError("virtualDisk is None")
        if not virtualDisk.getName(): raise ValueError("name of virtualDisk is empty")

        diskOsh = ObjectStateHolder('ldom_virtual_disk')
        
        diskOsh.setStringAttribute('name', virtualDisk.getName())
        
        if virtualDisk.deviceName:
            diskOsh.setStringAttribute('vd_device', virtualDisk.deviceName)
            
        if virtualDisk.multiPathGroupName:
            diskOsh.setStringAttribute('vd_mpgroup', virtualDisk.multiPathGroupName)
        
        if virtualDisk.timeout.value() is not None:
            diskOsh.setIntegerAttribute('vd_timeout', virtualDisk.timeout.value())
            
        if virtualDisk.diskId.value() is not None:
            diskOsh.setIntegerAttribute('vd_id', virtualDisk.diskId.value())
            
        return diskOsh
示例#12
0
def osh_createEviewOsh(localshell, iSeriesOsh, appPath, confFolder, file,
                       nodeName, eviewVersion, defaultIp):
    # Create EView agent OSH ---------------------------------------------------

    logger.debug('Creating EView object')
    eviewOSH = ObjectStateHolder('eview')
    eviewOSH.setAttribute('name', nodeName)
    eviewOSH.setAttribute('discovered_product_name', nodeName)
    eviewOSH.setAttribute('version', eviewVersion)
    eviewOSH.setAttribute('application_path', appPath)
    eviewOSH.setAttribute('application_ip', defaultIp)
    eviewOSH.setAttribute('vendor', 'EView Technology Inc.')
    eviewOSH.setAttribute('eview_agent_type', 'iSeries')
    fileContents = localshell.safecat('%s%s' % (confFolder, file))
    address, port = eview400_lib.getEviewAgentAddress(localshell, fileContents)
    if eview400_lib.isNotNull(address):
        eviewOSH.setAttribute('application_ip', address)
    if eview400_lib.isNotNull(port) and eview400_lib.isnumeric(port):
        eviewOSH.setIntegerAttribute('application_port', int(port))
    eviewOSH.setContainer(iSeriesOsh)
    return eviewOSH
示例#13
0
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
示例#14
0
 def addOshToVector(self, resultVector):
     nlbNodeOSH = ObjectStateHolder('nlb_clustersoftware')
     nlbNodeOSH.setAttribute('vendor', 'microsoft_corp')
     nlbNodeOSH.setIntegerAttribute('host_priority', self.priority)
     nlbNodeOSH.setStringAttribute('cluster_mode_on_start',
                                   self.modeOnStart)
     nlbNodeOSH.setStringAttribute('data_name', 'NLB Cluster SW')
     clusterIp = self.nlbClusterOsh.getAttribute(
         'cluster_ip_address').getValue()
     modeling.setAdditionalKeyAttribute(nlbNodeOSH, 'cluster_ip_address',
                                        clusterIp)
     resultVector.add(self.hostOSH)
     nlbNodeOSH.setContainer(self.hostOSH)
     if self.dedicatedIpOSH:
         resultVector.add(self.dedicatedIpOSH)
         resultVector.add(
             modeling.createLinkOSH('contained', self.hostOSH,
                                    self.dedicatedIpOSH))
     resultVector.add(nlbNodeOSH)
     resultVector.add(
         modeling.createLinkOSH('member', self.nlbClusterOsh, nlbNodeOSH))
示例#15
0
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
示例#16
0
    def build(self, device):
        if device is None:
            raise ValueError("device is None")

        deviceClass = self.getDeviceClass(device)
        deviceOsh = ObjectStateHolder(deviceClass)
        deviceOsh.setBoolAttribute('host_iscomplete', True)

        deviceOsh = self.setDeviceRoles(device, deviceOsh)

        hostName = device.hostName
        domainName = None

        if hostName and not ip_addr.isValidIpAddress(hostName):
            hostName, domainName = self.getHostNameAndDomain(hostName)

        if hostName:
            deviceOsh.setStringAttribute('name', hostName)
        if domainName:
            deviceOsh.setStringAttribute('host_osdomain', domainName)

        if device.serialNumber:
            modeling.setHostSerialNumberAttribute(deviceOsh,
                                                  device.serialNumber)

        if device.model:
            modeling.setHostModelAttribute(deviceOsh, device.model)

        if device.vendor:
            deviceOsh.setStringAttribute('discovered_vendor', device.vendor)

        if device.softwareVersion:
            deviceOsh.setStringAttribute('discovered_os_version',
                                         device.softwareVersion)

        if device.memory:
            memoryMb = int(device.memory / (1024 * 1024))
            modeling.setHostMemorySizeAttribute(deviceOsh, memoryMb)

        return deviceOsh
示例#17
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
     ]
示例#18
0
    def buildProcessOsh(self, process):
        if not process:
            raise ValueError, "process is empty"

        #shallow copy to not affect original DO
        cleanProcess = copy.copy(process)
        self._sanitizer.sanitize(cleanProcess)

        processOSH = ObjectStateHolder('process')

        processOSH.setStringAttribute('name', cleanProcess.getName())

        if cleanProcess.commandLine:
            processOSH.setStringAttribute('process_cmdline',
                                          cleanProcess.commandLine)

        if cleanProcess.getPid() is not None:
            processOSH.setIntegerAttribute('process_pid',
                                           cleanProcess.getPid())

        if cleanProcess.executablePath:
            processOSH.setStringAttribute('process_path',
                                          cleanProcess.executablePath)

        if cleanProcess.argumentLine:
            processOSH.setStringAttribute('process_parameters',
                                          cleanProcess.argumentLine)

        if cleanProcess.owner:
            processOSH.setStringAttribute('process_user', cleanProcess.owner)

        if cleanProcess.getStartupTime() is not None:
            processOSH.setDateAttribute('process_startuptime',
                                        cleanProcess.getStartupTime())

        if cleanProcess.description is not None:
            processOSH.setStringAttribute('data_description',
                                          cleanProcess.description)

        return processOSH
def makeComponent(client, compObj, compDataRow, ip, enterprise):
	attrNum = len(compObj)

	ccRunMode = ''
	cpMaxTask = ''
	cpMaxMTS = ''
	ccDesc = ''

	# must
	ccAlias = compObj[1]
	ccName = compObj[2]

	# On Siebel 2000 (6.3) the record contains CG_NAME instead of CG_ALIAS
	if attrNum > 5:
		ccRunMode = compObj[5]
	if attrNum > 8:
		cpMaxTask = compObj[8]
	if attrNum > 10:
		cpMaxMTS = compObj[10]

	if attrNum > 15:
		ccDesc = compObj[15]

	compOSH = ObjectStateHolder('siebel_component')
	compOSH.setAttribute('data_name', ccName)
	compOSH.setAttribute('alias', ccAlias)
	compOSH.setAttribute('run_mode', ccRunMode)

	if string.strip(cpMaxTask) != '':
		compOSH.setIntegerAttribute('max_task', int(cpMaxTask))
	if string.strip(cpMaxMTS) != '':
		compOSH.setIntegerAttribute('max_mts', int(cpMaxMTS))
	compOSH.setAttribute('desc', ccDesc)

	paramsFileOSH = getComponentParams(client, ccAlias, compOSH)

	compOSH.setAttribute('server_ip', ip)
	compOSH.setAttribute('site', enterprise)

	return (compOSH, paramsFileOSH)
示例#20
0
def reportRemotePeer(remote_peer, localInterfaceOsh, local_mac):
    vector = ObjectStateHolderVector()
    if remote_peer.peer_ips:
        hostOsh = modeling.createHostOSH(str(remote_peer.peer_ips[0]))
    if remote_peer.platform in VIRTUAL_HOST_PLATFORMS:
        hostOsh.setBoolAttribute('host_isvirtual', 1)
        vector.add(hostOsh)
        for ip in remote_peer.peer_ips:
            ipOsh = modeling.createIpOSH(ip)
            linkOsh = modeling.createLinkOSH('containment', hostOsh, ipOsh)
            vector.add(ipOsh)
            vector.add(linkOsh)
    else:
        hostOsh = ObjectStateHolder('node')
        hostOsh.setBoolAttribute('host_iscomplete', 1)
        hostOsh.setStringAttribute('name', remote_peer.system_name)
        if remote_peer.platform in VIRTUAL_HOST_PLATFORMS:
            hostOsh.setBoolAttribute('host_isvirtual', 1)
        vector.add(hostOsh)

    if remote_peer.interface_name or remote_peer.interface_mac:
        remoteInterfaceOsh = modeling.createInterfaceOSH(
            mac=remote_peer.interface_mac,
            hostOSH=hostOsh,
            name=remote_peer.interface_name)
        if not remoteInterfaceOsh:
            return ObjectStateHolderVector()
        if remote_peer.interface_name:
            remoteInterfaceOsh.setStringAttribute('name',
                                                  remote_peer.interface_name)
        vector.add(remoteInterfaceOsh)
        l2id = str(
            hash(':'.join([
                remote_peer.interface_mac or remote_peer.interface_name,
                local_mac
            ])))
        vector.addAll(
            reportLayer2Connection(localInterfaceOsh, remoteInterfaceOsh,
                                   l2id))
    return vector
示例#21
0
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
示例#22
0
 def buildResource(self, resource):
     r'@types: Resource -> ObjectStateHolder'
     osh = ObjectStateHolder('mscsresource')
     osh.setAttribute('data_name', resource.name)
     if resource.details:
         details = resource.details
         if details.description:
             osh.setStringAttribute('data_description', details.description)
         if details.type is not None:
             osh.setStringAttribute('type', details.type)
         if details.debugPrefix:
             osh.setStringAttribute('debugPrefix', details.debugPrefix)
         if details.separateMonitor is not None:
             osh.setBoolAttribute('separateMonitor',
                                  details.separateMonitor)
         if details.persistentState is not None:
             osh.setBoolAttribute('persistentState',
                                  details.persistentState)
         if details.looksAlivePollInterval is not None:
             osh.setStringAttribute('looksAlivePollInterval',
                                    str(details.looksAlivePollInterval))
         if details.isAlivePollInterval is not None:
             osh.setStringAttribute('isAlivePollInterval',
                                    str(details.isAlivePollInterval))
         if details.restartAction is not None:
             osh.setStringAttribute('restartAction',
                                    str(details.restartAction))
         if details.restartThreshold is not None:
             osh.setIntegerAttribute('restartThreshold',
                                     int(details.restartThreshold))
         if details.restartPeriod is not None:
             osh.setStringAttribute('restartPeriod',
                                    str(details.restartPeriod))
         if details.retryPeriodOnFailure is not None:
             osh.setStringAttribute('retryPeriodonFailure',
                                    str(details.retryPeriodOnFailure))
         if details.pendingTimeout is not None:
             osh.setStringAttribute('pendingTimeout',
                                    str(details.pendingTimeout))
     return osh
示例#23
0
文件: smis.py 项目: deezeesms/dd-git
 def build(self, logVolume):
     '''
     @param logVolume: LogicalVolume DO instance
     @raise ValueError: logVolume is not set
     '''
     if not logVolume:
         raise ValueError("logVolume is not specified")
     lvOsh = ObjectStateHolder("logical_volume")
     lvOsh.setStringAttribute("name", logVolume.name)
     if logVolume.freeSpaceInMb is not None:
         lvOsh.setAttribute("logicalvolume_free", logVolume.freeSpaceInMb)
     if logVolume.sizeInMb is not None:
         lvOsh.setAttribute("logicalvolume_size", logVolume.sizeInMb)
     if logVolume.usedSpaceInMb is not None:
         lvOsh.setAttribute("logicalvolume_used", logVolume.usedSpaceInMb)
     if logVolume.humanReadableName is not None:
         lvOsh.setStringAttribute('user_label', logVolume.humanReadableName)
     if logVolume.status is not None:
         lvOsh.setStringAttribute('logicalvolume_status', logVolume.status)
     if logVolume.systemObjId is not None:
         lvOsh.setStringAttribute('logical_volume_global_id', logVolume.systemObjId)
     return lvOsh
示例#24
0
    def build(self, controlDomain, ldm = None):
        hypervisorOsh = ObjectStateHolder('hypervisor')
        hypervisorOsh.setAttribute('name', 'LDOM Hypervisor')
        hypervisorOsh.setStringAttribute('discovered_product_name', 'Oracle LDOM Hypervisor')
        if controlDomain._hostname:
            hypervisorOsh.setStringAttribute('hypervisor_name', controlDomain._hostname)
            
        if ldm is not None:

            if ldm.hypervisorVersionString:
                hypervisorOsh.setStringAttribute('application_version', ldm.hypervisorVersionString)
                
            if ldm.hypervisorVersionMajor.value() is not None:
                version = None
                if ldm.hypervisorVersionMinor.value() is not None:
                    version = "%s.%s" % (ldm.hypervisorVersionMajor.value(), ldm.hypervisorVersionMinor.value())
                else:
                    version = str(ldm.hypervisorVersionMajor.value())
            
                hypervisorOsh.setStringAttribute('version', version)
                
        return hypervisorOsh
示例#25
0
def createZoneConfigObject(zone, resultsVector):
    zoneConfigOsh = ObjectStateHolder('solaris_zone_config')
    zoneConfigOsh.setAttribute('data_name', 'Solaris Zone Configuration')
    zoneConfigOsh.setAttribute('zone_name', zone.name)
    zoneConfigOsh.setAttribute('zone_path', zone.path)
    zoneConfigOsh.setAttribute('zone_status', zone.status)
    zoneConfigOsh.setAttribute('zone_brand', zone.brand)

    if zone.uuid:
        zoneConfigOsh.setAttribute('zone_uuid', zone.uuid)
    if zone.autoboot is not None:
        zoneConfigOsh.setBoolAttribute('zone_autoboot', zone.autoboot)
    if zone.limitPrivileges:
        zoneConfigOsh.setAttribute('limit_privileges', zone.limitPrivileges)
    if zone.schedulingClass:
        zoneConfigOsh.setAttribute('scheduling_class', zone.schedulingClass)
    if zone.cpuShares is not None:
        zoneConfigOsh.setIntegerAttribute('cpu_shares', zone.cpuShares)
    if zone.cpuCap is not None:
        zoneConfigOsh.setFloatAttribute('capped_cpu_ncpus', zone.cpuCap)

    if zone.dedicatedCpu:
        if zone.dedicatedCpu.ncpus:
            zoneConfigOsh.setAttribute('dedicated_cpu_ncpus', zone.dedicatedCpu.ncpus)
        if zone.dedicatedCpu.importance:
            zoneConfigOsh.setIntegerAttribute('dedicated_cpu_importance', zone.dedicatedCpu.importance)

    if zone.memoryCaps:
        if zone.memoryCaps.physicalCap is not None:
            zoneConfigOsh.setLongAttribute('capped_memory_physical', zone.memoryCaps.physicalCap)
        if zone.memoryCaps.swapCap is not None:
            zoneConfigOsh.setLongAttribute('capped_memory_swap', zone.memoryCaps.swapCap)
        if zone.memoryCaps.lockedCap is not None:
            zoneConfigOsh.setLongAttribute('capped_memory_locked', zone.memoryCaps.lockedCap)

    zoneConfigOsh.setContainer(zone.hostOsh)
    resultsVector.add(zoneConfigOsh)

    zone.configOsh = zoneConfigOsh
示例#26
0
 def getSqlFilesByDBName(self, oshv, dbName, db, hostId):
     query = Util.replaceAll(Queries.DATABASE_FILES, dbName)
     rs = self.connection.getTable(query)
     while rs.next():
         path = Util.replaceFileSeparator(rs.getString('filename'))
         fileName = rs.getString('name').strip()
         size = self.normalizeSize(rs.getString('size'))
         growth = self.normalizeSize(rs.getString('growth'))
         max = self.normalizeSize(rs.getString('maxsize'))
         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)
         osh.setContainer(db)
         oshv.add(osh)
         disk = Util.getDisk(path, hostId)
         oshv.add(disk)
         oshv.add(modeling.createLinkOSH('depend', osh, disk))
     rs.close()
示例#27
0
    def discoverGroups(self, groupNameToVirtualServer, a10_vthunder):
        queryBuilder = SnmpQueryBuilder(A10_OID_TABLE_GROUP)
        queryBuilder.addQueryElement(1, 'name')
        queryBuilder.addQueryElement(3, 'server_name')
        groups = self.snmpAgent.getSnmpData(queryBuilder)

        serverNameToGroup = {}
        for group in groups:
            groupOsh = ObjectStateHolder('loadbalancecluster')
            groupOsh.setAttribute('data_name', group.name)
            self.OSHVResult.add(groupOsh)
            memberLink = modeling.createLinkOSH('membership', groupOsh, a10_vthunder)
            self.OSHVResult.add(memberLink)
            serverNameToGroup[group.server_name] = groupOsh
            self.OSHVResult.add(groupOsh)
            if groupNameToVirtualServer.has_key(group.name):
                virtualServerHelper = groupNameToVirtualServer[group.name]
                virtualServerHelper.linkToContainingCluster(groupOsh, group.name)
            else:
                logger.debug('Group %s is not related to any virtual server.' % group.name)

        self.discoverGroupMembers(serverNameToGroup)
示例#28
0
def buildClusterOsh(oshv, f5, cluster):
    """
    @param oshv:ObjectStateHost
    @param f5:  ObjectStateHost
    """
    clusterOsh = ObjectStateHolder('loadbalancecluster')
    clusterOsh.setAttribute('data_name', cluster.getName())
    oshv.add(modeling.createLinkOSH('membership', clusterOsh, f5))
    oshv.add(clusterOsh)

    virtualHosts = cluster.getVirtualHosts()
    for virtualHost in virtualHosts:
        virtualHostOsh = buildVirtualHostOsh(oshv, f5, virtualHost)
        oshv.add(
            modeling.createLinkOSH('containment', clusterOsh, virtualHostOsh))

    for ipPort in cluster.getIpPorts():
        clusterMemberOsh = modeling.createHostOSH(ipPort.getIp(), 'host')
        ipPortOsh = buildIpServiceEndPointOsh(clusterMemberOsh, ipPort)
        oshv.add(clusterMemberOsh)
        oshv.add(ipPortOsh)
        oshv.add(modeling.createLinkOSH('membership', clusterOsh, ipPortOsh))
示例#29
0
    def _buildDataFileOsh(self,
                          id_,
                          name=None,
                          size=None,
                          maxSize=None,
                          tablespaceName=None):
        r'@types: str, str, long, long, str -> ObjectStateHolder(dbdatafile)'
        if id_ is None:
            raise ValueError('Id is invalid')

        osh = ObjectStateHolder('dbdatafile')
        osh.setAttribute('dbdatafile_fileid', id_)

        name and osh.setAttribute('name', name)
        if size is not None:
            osh.setAttribute('dbdatafile_byte', str(size))
        if maxSize is not None:
            osh.setAttribute('dbdatafile_maxbytes', str(maxSize))
        if tablespaceName is not None:
            osh.setAttribute('dbdatafile_tablespacename', tablespaceName)

        return osh
示例#30
0
    def __buildJmsDestination(self, destination, destinationType):
        '@types: jms.Destination, str -> ObjectStateHolder'
        osh = ObjectStateHolder('jmsdestination')
        osh.setAttribute('name', destination.getName())
        if destination.getObjectName():
            osh.setAttribute('j2eemanagedobject_objectname',
                             destination.getObjectName())
        if destination.getJndiName():
            osh.setAttribute('j2eemanagedobject_jndiname',
                             destination.getJndiName())
        if destinationType:
            osh.setAttribute('jmsdestination_type', destinationType)

        messagescurrent = destination.messagesCurrentCount.value()
        if messagescurrent is not None:
            osh.setIntegerAttribute('jmsdestination_messagescurrent',
                                    messagescurrent)
        messagespending = destination.messagesPendingCount.value()
        if messagespending is not None:
            osh.setIntegerAttribute('jmsdestination_messagespending',
                                    messagespending)
        messagesreceived = destination.messagesReceivedCount.value()
        if messagesreceived is not None:
            osh.setIntegerAttribute('jmsdestination_messagesreceived',
                                    messagesreceived)
        consumerscurrent = destination.consumersCurrentCount.value()
        if consumerscurrent is not None:
            osh.setIntegerAttribute('jmsdestination_consumerscurrent',
                                    consumerscurrent)
        subscribers = destination.getDurableSubscribers()
        if subscribers:
            vectorOfNames = StringVector()
            for subscriber in subscribers:
                vectorOfNames.add(subscriber.getName())
            ash = AttributeStateHolder('jmsdestination_durablesubscribers',
                                       vectorOfNames)
            osh.addAttributeToList(ash)
        return osh