示例#1
0
 def buildHostByHostname(self, hostname):
     r'@types: str -> ObjectStateHolder[node]'
     if not (hostname and hostname.strip()):
         raise ValueError("Hostname is not specified or empty")
     osh = ObjectStateHolder('node')
     osh.setStringAttribute('name', hostname)
     return osh
示例#2
0
文件: smis.py 项目: deezeesms/dd-git
    def build(self, fcPort):
        '''
        @param fcPort: fcPort DO
        @return: fcport OSH
        '''
        if not fcPort:
            raise ValueError("fcPort object is None")
        fcPortOsh = ObjectStateHolder("fcport")
        if fcPort.id is not None:
            fcPortOsh.setIntegerAttribute("fcport_portid", fcPort.id)
        if fcPort.index is not None:
            fcPortOsh.setIntegerAttribute("port_index", fcPort.index)

        wwnFormated = ''
        try:
            wwnFormated = str(wwn.parse_from_str(fcPort.wwn))
        except:
            logger.debug('error about fcPort.wwn: %s' % fcPort.wwn)

        fcPort.wwn and fcPortOsh.setStringAttribute("fcport_wwn", wwnFormated)
        fcPort.name and fcPortOsh.setStringAttribute("fcport_symbolicname", fcPort.name)
        fcPort.status and fcPortOsh.setStringAttribute("fcport_status", fcPort.status)
        fcPort.state and fcPortOsh.setStringAttribute("fcport_state", fcPort.state)
        fcPort.portType and fcPortOsh.setStringAttribute("fcport_type", fcPort.portType)
        if fcPort.maxSpeedGbps is not None:
            fcPortOsh.setAttribute("fcport_maxspeed", fcPort.maxSpeedGbps)
        if fcPort.speedGbps is not None:
            fcPortOsh.setAttribute("fcport_speed", fcPort.speedGbps)
        return fcPortOsh
    class OshBuilder(CiBuilder):
        def __init__(self, targetCiType):
            self.__type = targetCiType
            self.__osh = ObjectStateHolder(self.__type)

        def setCiAttribute(self, name, value):
            attributeType = self.__getAttributeType(self.__type, name)
            self.__setValue(name, attributeType, value)

        def build(self):
            return self.__osh

        def __setValue(self, name, attributeType, value):
            if attributeType == 'string':
                self.__osh.setStringAttribute(name, value)
            elif attributeType == 'integer':
                self.__osh.setIntegerAttribute(name, int(value))
            elif attributeType.endswith('enum'):
                self.__osh.setAttribute(name, value)
            else:
                raise ValueError('no setter defined for type %s' % attributeType)

        def __getAttributeType(self, ciType, attributeName):
            #TODO: memoize this function
            try:
                attributeDefinition = modeling._CMDB_CLASS_MODEL.getAttributeDefinition(ciType, attributeName)
                return attributeDefinition.getType()
            except:
                logger.errorException("%s.%s" % (ciType, attributeName))
                raise ValueError("Failed to determine type of %s.%s" % (ciType, attributeName))
 def build(self):
     lbcOsh = ObjectStateHolder('loadbalancecluster')
     lbcOsh.setStringAttribute('name', self.vServer.name)
     containment_link = modeling.createLinkOSH('containment', lbcOsh, self.crgOsh)
     membershipLink = modeling.createLinkOSH('membership', lbcOsh, self.netscaler_software_osh)
     self.osh = lbcOsh
     return self.newVector(lbcOsh, containment_link, membershipLink)
示例#5
0
    def build(self, unitaryComputerSystem):
        if unitaryComputerSystem is None:
            raise ValueError("unitaryComputerSystem is None")
        
        hypervisorOsh = ObjectStateHolder('virtualization_layer')
        hypervisorOsh.setStringAttribute('data_name', 'Virtualization Layer Software')
        hypervisorOsh.setStringAttribute('vendor', 'v_mware_inc')

        if unitaryComputerSystem.elementName:
            hypervisorOsh.setAttribute('hypervisor_name', unitaryComputerSystem.elementName)
        
        software = unitaryComputerSystem._hypervisorSoftwareIdentity
        if software:

            if software.elementName:
                hypervisorOsh.setStringAttribute('data_description', software.elementName)
            
            versionTokens = self._getVersionTokens(software)
            
            if versionTokens and versionTokens[0]:
                shortVersion = ".".join(map(str, versionTokens[:3]))
                longVersion = ".".join(map(str, versionTokens))
                hypervisorOsh.setStringAttribute('version', shortVersion)
                hypervisorOsh.setStringAttribute('application_version', longVersion)

        return hypervisorOsh
示例#6
0
文件: hana.py 项目: deezeesms/dd-git
 def buildHanaSoftware(self, software):
     r'@types: Software -> ObjectStateHolder'
     assert software
     osh = ObjectStateHolder("running_software")
     osh.setStringAttribute('name', software.name)
     self.updateDiscoveredProductName(osh, software.name)
     return osh
示例#7
0
class Cluster:
    '''Data Object represents Service Guard Cluster
    '''
    def __init__(self,
                 name,
                 version,
                 ipAddress,
                 propertiesFileContent,
                 quorumServer=None):
        r'@types: str, str, str, str, QuorumServer'
        self.name = name
        self.version = version
        self.propertiesFileContent = propertiesFileContent
        self.ipAddress = ipAddress
        self.osh = None
        self.nodes = []
        self.packages = []
        self.quorumServer = quorumServer

    def build(self):
        '''
            Creates serviceguardcluster OSH
            @returns: instance of serviceguardcluster OSH
        '''
        if self.name:
            self.osh = ObjectStateHolder('serviceguardcluster')
            self.osh.setAttribute('data_name', self.name)
            modeling.setAppSystemVendor(self.osh)
            if self.version:
                self.osh.setStringAttribute('version', self.version)

        return self.osh
示例#8
0
 def buildHostByHostname(self, hostname):
     r'@types: str -> ObjectStateHolder[node]'
     if not (hostname and hostname.strip()):
         raise ValueError("Hostname is not specified or empty")
     osh = ObjectStateHolder('node')
     osh.setStringAttribute('name', hostname)
     return osh
示例#9
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
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)
示例#11
0
文件: jdbc.py 项目: deezeesms/dd-git
 def buildDataSourceOsh(self, datasource):
     r'@types: jdbc.Datasource'
     datasourceOsh = ObjectStateHolder("jdbcdatasource")
     datasourceOsh.setAttribute('data_name', datasource.getName())
     if datasource.jndiName is not None:
         datasourceOsh.setAttribute('jdbcdatasource_jndiname',
                                    datasource.jndiName)
     if datasource.driverClass is not None:
         datasourceOsh.setStringAttribute('jdbcdatasource_drivername',
                                          datasource.driverClass)
     initialCapacity = datasource.initialCapacity
     maxCapacity = datasource.maxCapacity
     capacityIncrement = datasource.capacityIncrement
     if initialCapacity and initialCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_initialcapacity',
                                           initialCapacity.value())
     if maxCapacity and maxCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_maxcapacity',
                                           maxCapacity.value())
     if capacityIncrement and capacityIncrement.value() is not None:
         datasourceOsh.setIntegerAttribute(
             'jdbcdatasource_capacityincrement', capacityIncrement.value())
     if datasource.testOnRelease is not None:
         datasourceOsh.setBoolAttribute(
             'jdbcdatasource_testconnectionsonrelease',
             datasource.testOnRelease)
     logger.debug('Found datasource ', datasource.getName())
     if datasource.url:
         datasourceOsh.setAttribute('jdbcdatasource_url', datasource.url)
         datasourceOsh.setAttribute("jdbcdatasource_poolname",
                                    datasource.url)
     else:
         datasourceOsh.setAttribute("jdbcdatasource_poolname", 'None')
     return datasourceOsh
示例#12
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
示例#13
0
    class OshBuilder(CiBuilder):
        def __init__(self, targetCiType):
            self.__type = targetCiType
            self.__osh = ObjectStateHolder(self.__type)

        def setCiAttribute(self, name, value):
            attributeType = self.__getAttributeType(self.__type, name)
            self.__setValue(name, attributeType, value)

        def build(self):
            return self.__osh

        def __setValue(self, name, attributeType, value):
            if attributeType == 'string':
                self.__osh.setStringAttribute(name, value)
            elif attributeType == 'integer':
                self.__osh.setIntegerAttribute(name, int(value))
            elif attributeType.endswith('enum'):
                self.__osh.setAttribute(name, value)
            else:
                raise ValueError('no setter defined for type %s' %
                                 attributeType)

        def __getAttributeType(self, ciType, attributeName):
            #TODO: memoize this function
            try:
                attributeDefinition = modeling._CMDB_CLASS_MODEL.getAttributeDefinition(
                    ciType, attributeName)
                return attributeDefinition.getType()
            except:
                logger.errorException("%s.%s" % (ciType, attributeName))
                raise ValueError("Failed to determine type of %s.%s" %
                                 (ciType, attributeName))
示例#14
0
 def buildHanaSoftware(self, software):
     r'@types: Software -> ObjectStateHolder'
     assert software
     osh = ObjectStateHolder("running_software")
     osh.setStringAttribute('name', software.name)
     self.updateDiscoveredProductName(osh, software.name)
     return osh
示例#15
0
class Cluster:
    '''Data Object represents Service Guard Cluster
    '''
    def __init__(self, name, version, ipAddress, propertiesFileContent,
                 quorumServer=None):
        r'@types: str, str, str, str, QuorumServer'
        self.name = name
        self.version = version
        self.propertiesFileContent = propertiesFileContent
        self.ipAddress = ipAddress
        self.osh = None
        self.nodes = []
        self.packages = []
        self.quorumServer = quorumServer

    def build(self):
        '''
            Creates serviceguardcluster OSH
            @returns: instance of serviceguardcluster OSH
        '''
        if self.name:
            self.osh = ObjectStateHolder('serviceguardcluster')
            self.osh.setAttribute('data_name', self.name)
            modeling.setAppSystemVendor(self.osh)
            if self.version:
                self.osh.setStringAttribute('version', self.version)

        return self.osh
示例#16
0
    def build(self, unitaryComputerSystem):
        if unitaryComputerSystem is None:
            raise ValueError("unitaryComputerSystem is None")

        hypervisorOsh = ObjectStateHolder('virtualization_layer')
        hypervisorOsh.setStringAttribute('data_name',
                                         'Virtualization Layer Software')
        hypervisorOsh.setStringAttribute('vendor', 'v_mware_inc')

        if unitaryComputerSystem.elementName:
            hypervisorOsh.setAttribute('hypervisor_name',
                                       unitaryComputerSystem.elementName)

        software = unitaryComputerSystem._hypervisorSoftwareIdentity
        if software:

            if software.elementName:
                hypervisorOsh.setStringAttribute('data_description',
                                                 software.elementName)

            versionTokens = self._getVersionTokens(software)

            if versionTokens and versionTokens[0]:
                shortVersion = ".".join(map(str, versionTokens[:3]))
                longVersion = ".".join(map(str, versionTokens))
                hypervisorOsh.setStringAttribute('version', shortVersion)
                hypervisorOsh.setStringAttribute('application_version',
                                                 longVersion)

        return hypervisorOsh
示例#17
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
示例#18
0
 def buildDataSourceOsh(self, datasource):
     r'@types: jdbc.Datasource'
     datasourceOsh = ObjectStateHolder("jdbcdatasource")
     datasourceOsh.setAttribute('data_name', datasource.getName())
     if datasource.jndiName is not None:
         datasourceOsh.setAttribute('jdbcdatasource_jndiname', datasource.jndiName)
     if datasource.driverClass is not None:
         datasourceOsh.setStringAttribute('jdbcdatasource_drivername', datasource.driverClass)
     initialCapacity = datasource.initialCapacity
     maxCapacity = datasource.maxCapacity
     capacityIncrement = datasource.capacityIncrement
     if initialCapacity and initialCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_initialcapacity', initialCapacity.value())
     if maxCapacity and maxCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_maxcapacity',maxCapacity.value())
     if capacityIncrement and capacityIncrement.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_capacityincrement', capacityIncrement.value())
     if datasource.testOnRelease is not None:
         datasourceOsh.setBoolAttribute('jdbcdatasource_testconnectionsonrelease', datasource.testOnRelease)
     logger.debug('Found datasource ', datasource.getName())
     if datasource.url:
         datasourceOsh.setAttribute('jdbcdatasource_url', datasource.url)
         datasourceOsh.setAttribute("jdbcdatasource_poolname", datasource.url)
     else:
         datasourceOsh.setAttribute("jdbcdatasource_poolname", 'None')
     return datasourceOsh
 def _createRunningSoftwareOsh(self, description, hostOsh):
     runningSoftwareOsh = ObjectStateHolder("j2eeserver")
     if description:
         runningSoftwareOsh.setStringAttribute("description", description)
         runningSoftwareOsh.setStringAttribute("j2eeserver_fullname", description)
     runningSoftwareOsh.setContainer(hostOsh)
     return runningSoftwareOsh
 def _createRunningSoftwareOsh(self, description, hostOsh):
     runningSoftwareOsh = ObjectStateHolder("j2eeserver")
     if description:
         runningSoftwareOsh.setStringAttribute("description", description)
         runningSoftwareOsh.setStringAttribute("j2eeserver_fullname",
                                               description)
     runningSoftwareOsh.setContainer(hostOsh)
     return runningSoftwareOsh
def createSeaOsh(seaAdapter, hostOsh):
    if seaAdapter and hostOsh:
        seaOsh = ObjectStateHolder('sea_adapter')
        seaOsh.setContainer(hostOsh)
        seaOsh.setStringAttribute('data_name', seaAdapter.name)
        if seaAdapter.speed:
            seaOsh.setLongAttribute('speed', seaAdapter.speed)
        return seaOsh
示例#22
0
def createBridgeOsh(bridgeMac, bridgeInterfaceName, hostOsh):
    if bridgeMac and hostOsh:
        bridgeOsh = ObjectStateHolder('bridge')
        bridgeOsh.setStringAttribute('bridge_basemacaddr', bridgeMac)
        bridgeOsh.setContainer(hostOsh)
        if bridgeInterfaceName:
            bridgeOsh.setStringAttribute('data_name', bridgeInterfaceName)
        return bridgeOsh
示例#23
0
 def buildTrexSystem(self, sapSystem):
     r'@types: sap.System -> ObjectStateHolder[sap_trex_system]'
     if not sapSystem:
         raise ValueError("SAP System is not specified")
     osh = ObjectStateHolder('sap_trex_system')
     osh.setStringAttribute('name', sapSystem.getName())
     osh.setStringAttribute('vendor', sap.VENDOR)
     return osh
示例#24
0
def createHypervisorObject(parentHostOsh, resultsVector):
    hypervisorOsh = ObjectStateHolder('hypervisor')
    hypervisorOsh.setAttribute('name', 'Solaris Zones Hypervisor')
    hypervisorOsh.setStringAttribute('discovered_product_name', 'Solaris Zones Hypervisor')

    hypervisorOsh.setContainer(parentHostOsh)
    resultsVector.add(hypervisorOsh)
    return hypervisorOsh
示例#25
0
 def build(self, volume):
     if volume is None: raise ValueError("volume is None")
     if not volume.deviceName: raise ValueError("backing device name is empty")
     
     logicalVolumeOsh = ObjectStateHolder('logical_volume')
     logicalVolumeOsh.setStringAttribute('name', volume.deviceName)
     
     return logicalVolumeOsh
def createSeaOsh(seaAdapter, hostOsh):
    if seaAdapter and hostOsh:
        seaOsh = ObjectStateHolder('sea_adapter')
        seaOsh.setContainer(hostOsh)
        seaOsh.setStringAttribute('data_name', seaAdapter.name)
        if seaAdapter.speed:
            seaOsh.setLongAttribute('speed', seaAdapter.speed)
        return seaOsh
示例#27
0
 def buildTrexSystem(self, sapSystem):
     r'@types: sap.System -> ObjectStateHolder[sap_trex_system]'
     if not sapSystem:
         raise ValueError("SAP System is not specified")
     osh = ObjectStateHolder('sap_trex_system')
     osh.setStringAttribute('name', sapSystem.getName())
     osh.setStringAttribute('vendor', sap.VENDOR)
     return osh
示例#28
0
 def build(self, vds):
     if vds is None: raise ValueError("VDS is None")
     if not vds.getName(): raise ValueError("name of VDS is empty")
     
     vdsOsh = ObjectStateHolder('ldom_vds')
     vdsOsh.setStringAttribute('name', vds.getName())
     
     return vdsOsh
示例#29
0
    def build(self, vcloud):
        if vcloud is None: raise ValueError("vcloud is None")

        vcloudOsh = ObjectStateHolder('vmware_vcloud')
        if vcloud.companyName:
            vcloudOsh.setStringAttribute('name', vcloud.companyName)

        return vcloudOsh
示例#30
0
 def reportVcloudUri(self, cloud, vcloudRootOsh, vector):
     if cloud.urlString:
         uriOsh = ObjectStateHolder('uri_endpoint')
         uriOsh.setStringAttribute('uri', cloud.urlString)
         vector.add(uriOsh)
         
         usageLink = modeling.createLinkOSH('usage', vcloudRootOsh, uriOsh)
         vector.add(usageLink)
示例#31
0
 def build(self, vcloud):
     if vcloud is None: raise ValueError("vcloud is None")
     
     vcloudOsh = ObjectStateHolder('vmware_vcloud')
     if vcloud.companyName:
         vcloudOsh.setStringAttribute('name', vcloud.companyName)
         
     return vcloudOsh
示例#32
0
    def reportVcloudUri(self, cloud, vcloudRootOsh, vector):
        if cloud.urlString:
            uriOsh = ObjectStateHolder('uri_endpoint')
            uriOsh.setStringAttribute('uri', cloud.urlString)
            vector.add(uriOsh)

            usageLink = modeling.createLinkOSH('usage', vcloudRootOsh, uriOsh)
            vector.add(usageLink)
示例#33
0
def createBridgeOsh(bridgeMac, bridgeInterfaceName, hostOsh):
    if bridgeMac and hostOsh: 
        bridgeOsh = ObjectStateHolder('bridge')
        bridgeOsh.setStringAttribute('bridge_basemacaddr', bridgeMac)
        bridgeOsh.setContainer(hostOsh)
        if bridgeInterfaceName:
            bridgeOsh.setStringAttribute('data_name', bridgeInterfaceName)
        return bridgeOsh 
示例#34
0
文件: sap.py 项目: deezeesms/dd-git
 def buildHostByHostname(self, hostname):
     r'''@types: str -> ObjectStateHolder
     @raise ValueError: Hostname is not specified
     '''
     if not (hostname and hostname.strip()):
         raise ValueError("Hostname is not specified")
     osh = ObjectStateHolder(self.CIT)
     osh.setStringAttribute('name', hostname)
     return osh
示例#35
0
 def build(self):
     lbcOsh = ObjectStateHolder('loadbalancecluster')
     lbcOsh.setStringAttribute('name', self.vServer.name)
     containment_link = modeling.createLinkOSH('containment', lbcOsh,
                                               self.crgOsh)
     membershipLink = modeling.createLinkOSH('membership', lbcOsh,
                                             self.netscaler_software_osh)
     self.osh = lbcOsh
     return self.newVector(lbcOsh, containment_link, membershipLink)
示例#36
0
文件: sap.py 项目: ddonnelly19/dd-git
 def buildSoftware(self, software):
     r'@types: SoftwareBuilder.Software -> ObjectStateHolder'
     assert software
     osh = ObjectStateHolder(self.SOFTWARE_CIT)
     if software.description:
         osh.setStringAttribute("description", software.description)
     if software.name:
         osh.setStringAttribute('name', software.name)
     return osh
示例#37
0
文件: sap.py 项目: ddonnelly19/dd-git
 def buildHostByHostname(self, hostname):
     r'''@types: str -> ObjectStateHolder
     @raise ValueError: Hostname is not specified
     '''
     if not (hostname and hostname.strip()):
         raise ValueError("Hostname is not specified")
     osh = ObjectStateHolder(self.CIT)
     osh.setStringAttribute('name', hostname)
     return osh
示例#38
0
文件: sap.py 项目: deezeesms/dd-git
 def buildSoftware(self, software):
     r'@types: SoftwareBuilder.Software -> ObjectStateHolder'
     assert software
     osh = ObjectStateHolder(self.SOFTWARE_CIT)
     if software.description:
         osh.setStringAttribute("description", software.description)
     if software.name:
         osh.setStringAttribute('name', software.name)
     return osh
示例#39
0
def discoveriSCSIInfo(shell, OSHVec, hostOSH):
    wmiProvider = wmiutils.getWmiProvider(shell)
    queryBuilder = wmiProvider.getBuilder('MSFT_iSCSISession')
    queryBuilder.addWmiObjectProperties('InitiatorNodeAddress',
                                        'TargetNodeAddress',
                                        'SessionIdentifier')
    wmicAgent = wmiProvider.getAgent()
    try:
        wmicAgent.setNamespace('root/Microsoft/Windows/Storage')
    except:
        logger.debug(
            'Cannot change to name space root/Microsoft/Windows/Storage for iSCSI discovery'
        )
        return

    try:
        sessionItems = []
        try:
            sessionItems = wmicAgent.getWmiData(queryBuilder)
        except:
            logger.debugException('Failed getting iSCSI information')
            return

        sessionToDiskMap = discoveriSCSISessionToDiskMap(wmiProvider)
        phyVolumeIdToOshMap, phyVolumeNumberToOshMap = discoverPhysicalVolumes(
            wmiProvider, OSHVec, hostOSH)
        discoverDiskMountPoints(wmiProvider, OSHVec, hostOSH,
                                phyVolumeNumberToOshMap)
        for session in sessionItems:
            initiatorOsh = None
            targetOsh = None
            if session.InitiatorNodeAddress:
                initiatorOsh = ObjectStateHolder("iscsi_adapter")
                initiatorOsh.setStringAttribute("iqn",
                                                session.InitiatorNodeAddress)
                initiatorOsh.setContainer(hostOSH)
                OSHVec.add(initiatorOsh)

            if session.TargetNodeAddress:
                targetOsh = ObjectStateHolder("iscsi_adapter")
                targetOsh.setStringAttribute("iqn", session.TargetNodeAddress)
                OSHVec.add(targetOsh)

            if initiatorOsh and targetOsh:
                OSHVec.add(
                    modeling.createLinkOSH('usage', initiatorOsh, targetOsh))

            sessionId = session.SessionIdentifier
            disks = sessionToDiskMap.get(sessionId) or {}
            for disk in disks:
                diskOsh = phyVolumeIdToOshMap.get(disk)
                if diskOsh and targetOsh:
                    OSHVec.add(
                        modeling.createLinkOSH('dependency', diskOsh,
                                               targetOsh))
    finally:
        wmicAgent.setNamespace()  #set back to default
示例#40
0
    def __buildServerApplicationOsh(self,
                                    citName,
                                    server,
                                    productName=None,
                                    dbType=None,
                                    platform=None):
        r'''@types: str, db.DatabaseServer, str, str, db_platform.Platform -> ObjectStateHolderVector
        @param citName: any inheritor of 'database' CIT
        '''

        osh = ObjectStateHolder(citName)

        if server.instance:
            osh.setAttribute('name', server.instance)
            osh.setAttribute('database_dbsid', server.instance)

        if not productName and platform:
            productName = platform.productName

        if not dbType and platform:
            dbType = platform.dbType

        vendor = platform and platform.vendor or server.vendor
        if vendor:
            osh.setStringAttribute('vendor', vendor)

        ip = server.address
        if ip and ip_addr.isValidIpAddress(ip):
            osh.setAttribute('application_ip', str(ip))
        if server.getPort():
            osh.setAttribute('application_port', server.getPort())

        if server.getDescription():
            osh.setAttribute('description', server.getDescription())

        if server.getVersion():
            osh.setAttribute('version', server.getVersion())

        if server.getVersionDescription():
            osh.setAttribute('application_version',
                             server.getVersionDescription())

        if server.startTime:
            osh.setAttribute('startup_time', server.startTime)

        if server.installationPath:
            osh.setAttribute('application_path', server.installationPath)

        osh.setAttribute('database_dbtype', dbType)

        osh.setAttribute('application_category', 'Database')
        if productName:
            modeling.setApplicationProductName(osh,
                                               applicationName=productName)
            osh.setAttribute('discovered_product_name', productName)
        return osh
示例#41
0
    def build(self, volume):
        if volume is None:
            raise ValueError("volume is None")
        if not volume.deviceName:
            raise ValueError("backing device name is empty")

        logicalVolumeOsh = ObjectStateHolder("logical_volume")
        logicalVolumeOsh.setStringAttribute("name", volume.deviceName)

        return logicalVolumeOsh
示例#42
0
    def build(self, module):
        if module is None:
            raise ValueError("module is None")

        fanOsh = ObjectStateHolder("fan")
        fanOsh.setStringAttribute("name", module.slot)
        fanOsh.setStringAttribute("serial_number", module.serialNumber)
        fanOsh.setIntegerAttribute("fan_index", int(module.slotNumber))

        return fanOsh
示例#43
0
 def buildClusteredService(self, cluster, group):
     r'@types: Cluster, ResourceGroup -> ObjectStateHolder'
     assert cluster and group
     osh = ObjectStateHolder('clusteredservice')
     osh.setAttribute('data_name', group.name)
     osh.setAttribute('host_key', '%s:%s' % (cluster.name, group.name))
     osh.setBoolAttribute('host_iscomplete', 1)
     if group.fqdn:
         osh.setStringAttribute('primary_dns_name', group.fqdn)
     return osh
def reportWebSeal(host_id, credential_id):
    vector = ObjectStateHolderVector()
    hostOsh = modeling.createOshByCmdbId('node', host_id)
    websealOsh = ObjectStateHolder('isam_web')
    websealOsh.setContainer(hostOsh)
    websealOsh.setStringAttribute('discovered_product_name', 'IBM Security Access Manager')
    websealOsh.setStringAttribute('isam_credentials_id', credential_id)
    vector.add(hostOsh)
    vector.add(websealOsh)
    return vector
示例#45
0
    def build(self, vds):
        if vds is None:
            raise ValueError("VDS is None")
        if not vds.getName():
            raise ValueError("name of VDS is empty")

        vdsOsh = ObjectStateHolder("ldom_vds")
        vdsOsh.setStringAttribute("name", vds.getName())

        return vdsOsh
示例#46
0
 def build(self, vappTemplate):
     if vappTemplate is None: raise ValueError("vappTemplate is None")
     
     vappTemplateOsh = ObjectStateHolder('vcloud_vapp_template')
     vappTemplateOsh.setStringAttribute('name', vappTemplate.getName())
     
     if vappTemplate.description:
         vappTemplateOsh.setStringAttribute('description', vappTemplate.description)
     
     return vappTemplateOsh
示例#47
0
 def buildHost(self, host):
     r'''@types: db2_host.Host -> ObjectStateHolder
     '''
     if not host.name:
         raise ValueError('Invalid name')
     osh = ObjectStateHolder(self.CIT)
     osh.setStringAttribute('name', host.name)
     if host.fqdn:
         osh.setStringAttribute('primary_dns_name', host.fqdn)
     return osh
示例#48
0
    def build(self, module):
        if module is None:
            raise ValueError("module is None")

        fanOsh = ObjectStateHolder("fan")
        fanOsh.setStringAttribute('name', module.slot)
        fanOsh.setStringAttribute('serial_number', module.serialNumber)
        fanOsh.setIntegerAttribute('fan_index', int(module.slotNumber))

        return fanOsh
示例#49
0
 def buildHost(self, host):
     r'''@types: db2_host.Host -> ObjectStateHolder
     '''
     if not host.name:
         raise ValueError('Invalid name')
     osh = ObjectStateHolder(self.CIT)
     osh.setStringAttribute('name', host.name)
     if host.fqdn:
         osh.setStringAttribute('primary_dns_name', host.fqdn)
     return osh
示例#50
0
 def buildClusteredService(self, cluster, group):
     r'@types: Cluster, ResourceGroup -> ObjectStateHolder'
     assert cluster and group
     osh = ObjectStateHolder('clusteredservice')
     osh.setAttribute('data_name', group.name)
     osh.setAttribute('host_key', '%s:%s' % (cluster.name, group.name))
     osh.setBoolAttribute('host_iscomplete', 1)
     if group.fqdn:
         osh.setStringAttribute('primary_dns_name', group.fqdn)
     return osh
示例#51
0
    def build(self, module):
        if module is None:
            raise ValueError("module is None")

        powerSupplyOsh = ObjectStateHolder("power_supply")
        powerSupplyOsh.setStringAttribute("name", module.slot)
        powerSupplyOsh.setStringAttribute("serial_number", module.serialNumber)
        powerSupplyOsh.setIntegerAttribute("power_supply_index", int(module.slotNumber))

        return powerSupplyOsh
def reportWebSeal(host_id, credential_id):
    vector = ObjectStateHolderVector()
    hostOsh = modeling.createOshByCmdbId('node', host_id)
    websealOsh = ObjectStateHolder('isam_web')
    websealOsh.setContainer(hostOsh)
    websealOsh.setStringAttribute('discovered_product_name',
                                  'IBM Security Access Manager')
    websealOsh.setStringAttribute('isam_credentials_id', credential_id)
    vector.add(hostOsh)
    vector.add(websealOsh)
    return vector
示例#53
0
def createNetworkShare(path, hostOsh, ucmdbVersion):
    if path and hostOsh: 
        shareOsh = None
        if ucmdbVersion < 9:
            shareOsh = ObjectStateHolder('networkshare')
        else:
            shareOsh = ObjectStateHolder('file_system_export')
        shareOsh.setStringAttribute('data_name', path)
        shareOsh.setStringAttribute('share_path', path)
        shareOsh.setContainer(hostOsh)
        return shareOsh
示例#54
0
 def buildOu(self, ou):
     r'@types: OrganizationalUnit -> ObjectStateHolder'
     if not ou:
         raise ValueError("Organizational Unit is not specified")
     if not ou.name:
         raise ValueError("Organizational Unit name is not specified")
     osh = ObjectStateHolder(self.OU_CIT)
     osh.setStringAttribute('name', ou.name)
     if ou.description:
         osh.setStringAttribute('description', ou.description)
     return osh
示例#55
0
 def build_host(self, host):
     r'''@types: hana_host.Host -> ObjectStateHolder
     '''
     if host.name:
         osh = ObjectStateHolder(self.CIT)
         osh.setStringAttribute('name', host.name)
         if host.fqdn:
             osh.setStringAttribute('primary_dns_name', host.fqdn)
     else:
         osh = self.build_complete_host(str(host.ips[0]))
     return osh
示例#56
0
    def build(self, vappTemplate):
        if vappTemplate is None: raise ValueError("vappTemplate is None")

        vappTemplateOsh = ObjectStateHolder('vcloud_vapp_template')
        vappTemplateOsh.setStringAttribute('name', vappTemplate.getName())

        if vappTemplate.description:
            vappTemplateOsh.setStringAttribute('description',
                                               vappTemplate.description)

        return vappTemplateOsh
示例#57
0
 def build_xen_domain_config(self, vm, vm_metrics):
     xen_domain_config_osh = ObjectStateHolder('xen_domain_config')
     xen_domain_config_osh.setStringAttribute('name', 'Xen Domain Config')
     xen_domain_config_osh.setIntegerAttribute('xen_domain_id', int(vm['domid']))
     xen_domain_config_osh.setStringAttribute('xen_domain_name', vm.getLabel())
     xen_domain_config_osh.setIntegerAttribute('xen_domain_vcpus', int(vm_metrics['VCPUs_number']))
     xen_domain_config_osh.setLongAttribute('xen_domain_memory', long(vm['memory_static_max']))
     xen_domain_config_osh.setStringAttribute('xen_domain_on_restart', vm['actions_after_reboot'])
     xen_domain_config_osh.setStringAttribute('xen_domain_on_poweroff', vm['actions_after_shutdown'])
     xen_domain_config_osh.setStringAttribute('xen_domain_on_crash', vm['actions_after_crash'])
     return xen_domain_config_osh
示例#58
0
文件: ivm.py 项目: ddonnelly19/dd-git
def createVirtualServerOsh(vm, report_name=True):
    virtualServerOsh = ObjectStateHolder("host")
    if report_name:
        setStringAttribute(virtualServerOsh, "name", vm.vserver_config.name)
    setStringAttribute(virtualServerOsh, "serial_number", vm.vserver_config.serial_number)
    setStringAttribute(virtualServerOsh, "bios_uuid", vm.vserver_config.uuid and vm.vserver_config.uuid.upper())
    setStringAttribute(virtualServerOsh, "discovered_os_name", vm.vserver_config.discovered_os_name)
    virtualServerOsh.setBoolAttribute("host_iscomplete", 1)
    virtualServerOsh.setBoolAttribute("host_isvirtual", 1)
    virtualServerOsh.setStringAttribute("os_family", "unix")
    return virtualServerOsh