コード例 #1
0
def setObjectVectorByResStringArray(objectVector,
                                    ipsResult,
                                    virtualMode,
                                    netAddress=None,
                                    netMask=None):
    # create new network for link object
    if netAddress and netMask:
        networkOSHForLink = modeling.createNetworkOSH(netAddress, netMask)
    else:
        networkOSHForLink = None
    # run on the string array (Holding all live pinged ips)
    for ipResult in ipsResult:
        isVirtual = 0
        # pingedIp - the ip we sent the ping to
        # replyIp - the ip replied to the ping

        # Break the curr result by ':' <Reply-IP>:<Pinged-IP>
        token = ipResult.split(':')

        if (len(token) == 2):
            # In case where we ping a virtual ip we get the reply from the real ip
            # If we are pinging a virtual ip
            if virtualMode:
                replyIp, pingedIp = token[0], token[1]
                isVirtual = 1
            else:
                replyIp, pingedIp = token[1], token[1]
        else:
            replyIp, pingedIp = ipResult, ipResult

        # Create Ip OSH and add to vector
        pingedIpOSH = modeling.createIpOSH(ip_addr.IPAddress(pingedIp),
                                           netMask)
        objectVector.add(pingedIpOSH)

        if networkOSHForLink:
            # Create MEMBER link and set end1(discovered network) and end2(host)
            objectVector.add(
                modeling.createLinkOSH('member', networkOSHForLink,
                                       pingedIpOSH))

        if isVirtual:
            # Create Ip OSH
            replyIpOSH = modeling.createIpOSH(replyIp, netMask)

            # Create a depend  link and set end1(pingedIp) and end2(replyIp)
            newDependLink = modeling.createLinkOSH('depend', pingedIpOSH,
                                                   replyIpOSH)

            objectVector.add(replyIpOSH)
            objectVector.add(newDependLink)

            if networkOSHForLink:
                replyIpNetAddress = IPv4(replyIp,
                                         netMask).getFirstIp().toString()
                if replyIpNetAddress == netAddress:
                    # Create MEMBER link and set end1(discovered network) and end2(host)
                    objectVector.add(
                        modeling.createLinkOSH('member', networkOSHForLink,
                                               replyIpOSH))
コード例 #2
0
    def reporterMSCluster(self, vector, ms_cluster, groups, ipDictByGroupName, nodesWithIP):
        clusterOsh = ms_cluster.create_osh()
        vector.add(clusterOsh)
        vector.add(modeling.createLinkOSH('membership', clusterOsh, self.applicationOsh))

        for node in nodesWithIP:
            ips = nodesWithIP[node]
            hostOsh = (modeling.createHostOSH(str(ips[0]), 'nt')
                       or ObjectStateHolder('nt'))
            hostOsh.setStringAttribute('name', node)
            hostOsh.setStringAttribute('os_family', 'windows')
            for ip_obj in ips:
                ipOSH = modeling.createIpOSH(ip_obj)
                vector.add(ipOSH)
                vector.add(modeling.createLinkOSH('containment', hostOsh, ipOSH))
            softwareOsh = modeling.createClusterSoftwareOSH(hostOsh,
                                                            'Microsoft Cluster SW', ms_cluster.version)
            softwareOsh.setAttribute("application_version_number", ms_cluster.version)
            vector.add(softwareOsh)
            vector.add(modeling.createLinkOSH('membership', clusterOsh, softwareOsh))

        for group in groups:
            ips = ipDictByGroupName.get(group.name, None)
            if ips:
                for ip in ips:
                    groupOsh = group.create_osh()
                    vector.add(groupOsh)
                    vector.add(modeling.createLinkOSH('contained', clusterOsh, groupOsh))

                    ipOsh = modeling.createIpOSH(ip)
                    vector.add(modeling.createLinkOSH('contained', groupOsh, ipOsh))
                    vector.add(ipOsh)
                    self.__crgMap[str(ip)] = groupOsh
コード例 #3
0
ファイル: icmp_utils.py プロジェクト: ddonnelly19/dd-git
def setObjectVectorByResStringArray(objectVector, ipsResult, virtualMode, netAddress=None, netMask=None):
    # create new network for link object
    if netAddress and netMask:
        networkOSHForLink = modeling.createNetworkOSH(netAddress, netMask)
    else:
        networkOSHForLink = None
    # run on the string array (Holding all live pinged ips)
    for ipResult in ipsResult:
        isVirtual = 0
        # pingedIp - the ip we sent the ping to
        # replyIp - the ip replied to the ping

        # Break the curr result by ':' <Reply-IP>:<Pinged-IP>
        token = ipResult.split(':')

        if (len(token) == 2):
            # In case where we ping a virtual ip we get the reply from the real ip
            # If we are pinging a virtual ip
            if virtualMode:
                replyIp, pingedIp = token[0], token[1]
                isVirtual = 1
            else:
                replyIp, pingedIp = token[1], token[1]
        else:
            replyIp, pingedIp = ipResult, ipResult

        # Create Ip OSH and add to vector
        pingedIpOSH = modeling.createIpOSH(ip_addr.IPAddress(pingedIp), netMask)
        objectVector.add(pingedIpOSH)

        if networkOSHForLink:
            # Create MEMBER link and set end1(discovered network) and end2(host)
            objectVector.add(modeling.createLinkOSH('member', networkOSHForLink, pingedIpOSH))

        if isVirtual:
            # Create Ip OSH
            replyIpOSH = modeling.createIpOSH(replyIp, netMask)

            # Create a depend  link and set end1(pingedIp) and end2(replyIp)
            newDependLink = modeling.createLinkOSH('depend', pingedIpOSH, replyIpOSH)

            objectVector.add(replyIpOSH)
            objectVector.add(newDependLink)

            if networkOSHForLink:
                replyIpNetAddress = IPv4(replyIp, netMask).getFirstIp().toString()
                if replyIpNetAddress == netAddress:
                    # Create MEMBER link and set end1(discovered network) and end2(host)
                    objectVector.add(modeling.createLinkOSH('member', networkOSHForLink, replyIpOSH))
コード例 #4
0
ファイル: dns.py プロジェクト: deezeesms/dd-git
 def reportAddressRecord(self, record, zoneOsh):
     r''' Report address `realization` link between `dns_record`
     and `ip_address`
     @types: ResourceRecord, ObjectStateHolder \
     -> tuple[ObjectStateHolder, ObjectStateHolder, ObjectStateHolderVector]
     @raise ValueError: Record is not specified
     @raise ValueError: Record is not of A type (address)
     @raise ValueError: Zone OSH is not specified
     @raise ValueError: Canonical name is not IP address
     @return: tuple of IP OSH, record OSH itself and resulted vector
     '''
     if not record:
         raise ValueError("Record is not specified")
     if not record.type in (ResourceRecord.Type.A,
                            ResourceRecord.Type.AAAA):
         raise ValueError("Record is not of A type (address)")
     if not zoneOsh:
         raise ValueError("Zone OSH is not specified")
     ipAddress = ip_addr.IPAddress(record.cname)
     ipOsh = modeling.createIpOSH(ipAddress)
     recordOsh = self.reportRecord(record, zoneOsh)
     vector = ObjectStateHolderVector()
     vector.add(modeling.createLinkOSH('realization', recordOsh, ipOsh))
     vector.add(ipOsh)
     vector.add(recordOsh)
     return (ipOsh, recordOsh, vector)
コード例 #5
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    jobId = Framework.getDiscoveryJobId()
    host_id = Framework.getDestinationAttribute('id')
    host_name = Framework.getTriggerCIData('host_name')
    dnsServers = Framework.getTriggerCIDataAsList('dnsServers') or None

    try:
        host_name = host_name.split(" ")
        ips = pi_utils.getIPs(host_name[0], Framework)

        if not ips:
            raise ValueError()

        hostOSH = modeling.createOshByCmdbIdString('node', host_id)
        modeling.addHostAttributes(hostOSH, None, host_name[0])
        #OSHVResult.add(hostOSH)

        for ip in ips:
            ipRes = pi_utils.getIPOSHV(Framework, ip, None, dnsServers, False,
                                       True)
            if ipRes.size() > 0:
                OSHVResult.add(
                    modeling.createLinkOSH('containment', hostOSH,
                                           modeling.createIpOSH(ip)))
                OSHVResult.addAll(ipRes)
        if OSHVResult.size() <= 0:
            raise ValueError()
    except Exception, e:
        msg = logger.prepareJythonStackTrace(
            "Error getting IPs for %s: " % (host_name), e)
        errormessages.resolveAndReport(msg, jobId, Framework)
        logger.error(msg)
コード例 #6
0
def createIPEndpointOSHV(framework,
                         ipAddress,
                         portNum,
                         portName,
                         hostname=None,
                         protocol=modeling.SERVICEADDRESS_TYPE_TCP):
    OSHVResult = ObjectStateHolderVector()
    if ip_addr.isValidIpAddress(hostname):
        hostname = None

    fqdn, aliasList = getHostNames(ipAddress, framework)

    hostOSH = modeling.createHostOSH(ipAddress, 'node', None, fqdn)
    ipOSH = modeling.createIpOSH(ipAddress, None, fqdn)
    link = modeling.createLinkOSH('containment', hostOSH, ipOSH)

    OSHVResult.add(hostOSH)
    OSHVResult.add(ipOSH)
    OSHVResult.add(link)

    ipPort = modeling.createServiceAddressOsh(hostOSH, ipAddress, portNum,
                                              protocol, portName)
    if fqdn:
        ipPort.setStringAttribute('ipserver_address', fqdn)

    if isValidFQDN(hostname):
        ipPort.setStringAttribute('ipserver_address', hostname)

    #ipPort.addAttributeToList('itrc_alias', sv)
    #ipOSH.addAttributeToList('itrc_alias', sv)

    #OSHVResult.add(modeling.createLinkOSH('usage', ipPort, ipOSH))
    OSHVResult.add(ipPort)

    return hostOSH, ipOSH, OSHVResult
コード例 #7
0
    def report(self, region_osh, event_osh=None):
        vector = ObjectStateHolderVector()

        osh = ObjectStateHolder('host_node')
        osh.setAttribute('name', self.name)
        logger.debug("self.id:", self.id)
        vector.add(osh)
        if self.ips:
            for ip in self.ips:
                ip_osh = modeling.createIpOSH(str(ip))
                vector.add(ip_osh)
                vector.add(modeling.createLinkOSH('contained', osh, ip_osh))
        if self.image:
            imageOsh, image_vector = self.image.report(region_osh)
            vector.addAll(image_vector)
            vector.add(modeling.createLinkOSH('dependency', osh, imageOsh))
        if self.hypervisorHostName:
            hypervisorOsh, hypervisor_vector = Hypervisor(self.hypervisorHostName).report(region_osh)
            vector.addAll(hypervisor_vector)
            vector.add(modeling.createLinkOSH('execution_environment', hypervisorOsh, osh))
        if self.flavor:
            flavorOsh, flavor_vector = self.flavor.report(region_osh)
            vector.addAll(flavor_vector)
            vector.add(modeling.createLinkOSH('dependency', osh, flavorOsh))
        if event_osh:
            vector.add(modeling.createLinkOSH('dependency', osh, event_osh))
        return osh, vector
コード例 #8
0
 def reportIpAddressOfVm(self, vm):
     '''
     VmComputerSystem -> ObjectStateHolder
     '''
     if vm.primaryIpAddress:
         ipOsh = modeling.createIpOSH(vm.primaryIpAddress)
         return ipOsh
コード例 #9
0
ファイル: jms.py プロジェクト: ddonnelly19/dd-git
    def reportMqServerWithEndpoint(self, server):
        r''' Make reporting of MQ server based on its IP where contains
        is incomplete host built using IP address and if port specified
        linked with corresponding service endpoint

        @types: jms.MqServer -> ObjectStateHolderVector
        @raise ValueError: JMS Server is not specified
        @raise ValueError: MQ Server IP address is empty or not resolved
        '''
        if not server:
            raise ValueError("JMS Server is not specified")
        ip = server.address
        if not (ip and netutils.isValidIp(ip)):
            raise ValueError("MQ Server IP address is empty or not resolved")
        vector = ObjectStateHolderVector()
        hostOsh = modeling.createIpOSH(ip)
        vector.add(hostOsh)
        serverOsh = self.reportMqServer(server, hostOsh)
        vector.add(serverOsh)
        if server.getPort() is not None:
            vector.add(modeling.createServiceAddressOsh(hostOsh, ip,
                                                        server.getPort(),
                                                        modeling.SERVICEADDRESS_TYPE_TCP
                       )
            )
        return vector
コード例 #10
0
 def __init__(self, props, nlbClusterOsh, hostOSH, framework):
     if not nlbClusterOsh:
         raise Exception(
             'NLB cluster discovery misconfigured; NLB node have to be linked to existing cluster'
         )
     self.nlbClusterOsh = nlbClusterOsh
     self.hostOSH = hostOSH
     self.priority = props['HostPriority']
     self.modeOnStart = props['ClusterModeOnStart']
     if props['DedicatedIPAddresses/']:
         self.ip = props['DedicatedIPAddresses/'].split('/')[0]
         netMask = props['DedicatedIPAddresses/'].split('/')[1]
     else:
         self.ip = props['DedicatedIPAddress']
         netMask = props['DedicatedNetworkMask']
     self.dedicatedIpOSH = None
     #check the IP
     #very unreal situation but we have to handle it
     if not netutils.isValidIp(self.ip) or netutils.isLocalIp(self.ip):
         msg = 'Dedicated IP of cluster node is local or invalid: ' + str(
             self.ip)
         logger.warn(msg)
         framework.reportWarning(
             'Dedicated IP of cluster node is local or invalid')
     else:
         self.dedicatedIpOSH = modeling.createIpOSH(self.ip, netMask)
コード例 #11
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    jobId = Framework.getDiscoveryJobId()
    host_id    = Framework.getDestinationAttribute('id')
    host_name = Framework.getTriggerCIData('host_name')
    dnsServers = Framework.getTriggerCIDataAsList('dnsServers') or None
        
    try:
        host_name = host_name.split(" ")
        ips = pi_utils.getIPs(host_name[0], Framework)
        
        if not ips:
            raise ValueError()
        
        hostOSH = modeling.createOshByCmdbIdString('node', host_id)
        modeling.addHostAttributes(hostOSH, None, host_name[0])
        #OSHVResult.add(hostOSH)       
        
        for ip in ips:
            ipRes = pi_utils.getIPOSHV(Framework, ip, None, dnsServers, False, True)
            if ipRes.size() > 0:               
                OSHVResult.add(modeling.createLinkOSH('containment',hostOSH,modeling.createIpOSH(ip)))
                OSHVResult.addAll(ipRes)
        if OSHVResult.size() <=0:
            raise ValueError()       
    except Exception, e:
        msg = logger.prepareJythonStackTrace("Error getting IPs for %s: " % (host_name), e)
        errormessages.resolveAndReport(msg, jobId, Framework)
        logger.error(msg)
コード例 #12
0
ファイル: scp.py プロジェクト: ddonnelly19/dd-git
def createScpOSHV(container, type, host, port, context, shell, localIP=None, dnsServers=None):
    OSHVResult = ObjectStateHolderVector()
    if not host:
        return OSHVResult
    ipAddresses = []
    if (host in LOCALHOST) and localIP:
        logger.debug("found local ip: %s , use %s instead" % (host, localIP))
        host = localIP
    if netutils.isValidIp(host):
        ipAddresses.append(host)
    else:
        # try to resolve ip address from hostname
        logger.debug('Trying to resolve ip address from hostname:', host)
        ipAddresses = resolveIPByNsLookup(dnsServers, shell, host)
        if len(ipAddresses) == 0:
            ipAddresses = resolveIPByINet(host, port)
        if len(ipAddresses) == 0:
            ipAddresses = resolveIPBySocket(host)

    for ipAddress in ipAddresses:
        if not netutils.isValidIp(ipAddress):
            logger.debug("ignore invalid ip address: ", ipAddress)
            continue
        scpOsh = createScpOsh(container, type, ipAddress, port, context, host)
        OSHVResult.add(scpOsh)
        # Add additional ip CIs for all next hops to make sure new jobs could be triggered.
        ip = ip_addr.IPAddress(ipAddress)
        OSHVResult.add(modeling.createIpOSH(ip))

    return OSHVResult
コード例 #13
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # # Write implementation to return new result CIs here...
    ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS')
    portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT')
    service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT')
    service_type = Framework.getDestinationAttribute('SERVICE_TYPE')
    cluster_id = Framework.getDestinationAttribute('CLUSTER_ID')
    application_resource_id = Framework.getDestinationAttribute(
        'APPLICATION_RESOURCE_ID')
    cluster_root_class = Framework.getDestinationAttribute('CLUSTER_CLASS')
    application_resource_class = Framework.getDestinationAttribute(
        'APPLICATION_RESOURCE_CLASS')
    SCPId = Framework.getDestinationAttribute('id')

    clusterOsh = modeling.createOshByCmdbIdString(cluster_root_class,
                                                  cluster_id)

    OSHVResult.addAll(
        scp.createCPLink(application_resource_id, application_resource_class,
                         cluster_id, cluster_root_class, SCPId,
                         service_context))

    for index in range(len(ipList)):
        scpOsh = scp.createScpOsh(clusterOsh,
                                  service_type,
                                  ip=ipList[index],
                                  port=portList[index],
                                  context=service_context)
        ipOsh = modeling.createIpOSH(ipList[index])
        OSHVResult.add(scpOsh)
        OSHVResult.add(ipOsh)

    return OSHVResult
コード例 #14
0
ファイル: pi_utils.py プロジェクト: ddonnelly19/dd-git
def createIPEndpointOSHV(framework, ipAddress, portNum, portName, hostname = None, protocol = modeling.SERVICEADDRESS_TYPE_TCP):
    OSHVResult = ObjectStateHolderVector()
    if ip_addr.isValidIpAddress(hostname):
        hostname = None
    
    fqdn, aliasList = getHostNames(ipAddress, framework)
    
    hostOSH = modeling.createHostOSH(ipAddress, 'node', None, fqdn)
    ipOSH = modeling.createIpOSH(ipAddress, None, fqdn)
    link = modeling.createLinkOSH('containment', hostOSH, ipOSH)
    
    OSHVResult.add(hostOSH)
    OSHVResult.add(ipOSH)
    OSHVResult.add(link)
    
    ipPort = modeling.createServiceAddressOsh(hostOSH, ipAddress, portNum, protocol, portName)
    if fqdn:
        ipPort.setStringAttribute('ipserver_address', fqdn)
    
    if isValidFQDN(hostname):         
        ipPort.setStringAttribute('ipserver_address', hostname)
    
    #ipPort.addAttributeToList('itrc_alias', sv)
    #ipOSH.addAttributeToList('itrc_alias', sv)        
         
    #OSHVResult.add(modeling.createLinkOSH('usage', ipPort, ipOSH)) 
    OSHVResult.add(ipPort)
   
    return hostOSH, ipOSH, OSHVResult
コード例 #15
0
ファイル: cluster_tunnel.py プロジェクト: ddonnelly19/dd-git
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # # Write implementation to return new result CIs here...
    ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS')
    portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT')
    service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT')
    service_type = Framework.getDestinationAttribute('SERVICE_TYPE')
    cluster_id = Framework.getDestinationAttribute('CLUSTER_ID')
    application_resource_id = Framework.getDestinationAttribute('APPLICATION_RESOURCE_ID')
    cluster_root_class = Framework.getDestinationAttribute('CLUSTER_CLASS')
    application_resource_class = Framework.getDestinationAttribute('APPLICATION_RESOURCE_CLASS')
    SCPId = Framework.getDestinationAttribute('id')

    clusterOsh = modeling.createOshByCmdbIdString(cluster_root_class, cluster_id)

    OSHVResult.addAll(scp.createCPLink(application_resource_id, application_resource_class, cluster_id,
                                       cluster_root_class, SCPId, service_context))
    
    for index in range(len(ipList)):
        scpOsh = scp.createScpOsh(clusterOsh, service_type, ip=ipList[index], port=portList[index], context=service_context)
        ipOsh = modeling.createIpOSH(ipList[index])
        OSHVResult.add(scpOsh)
        OSHVResult.add(ipOsh)           

    return OSHVResult
コード例 #16
0
ファイル: webseal_tunnel.py プロジェクト: ddonnelly19/dd-git
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # # Write implementation to return new result CIs here...
    ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS')
    portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT')
    service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT')
    service_type = Framework.getDestinationAttribute('SERVICE_TYPE')
    application_resource_id = Framework.getDestinationAttribute('APPLICATION_RESOURCE_ID')
    application_resource_class = Framework.getDestinationAttribute('APPLICATION_RESOURCE_CLASS')
    junction_id = Framework.getDestinationAttribute('JUNCTION_ID')
    junction_root_class = Framework.getDestinationAttribute('JUNCTION_CLASS')
    junction_name = Framework.getDestinationAttribute('JUNCTION_NAME')
    SCPId = Framework.getDestinationAttribute('id')

    junctionOsh = modeling.createOshByCmdbIdString(junction_root_class, junction_id)

    url = urlparse(service_context)
    if url:
        # get context root path from url
        path = url.path
        if path.startswith(junction_name + '/'):
            logger.info('Create one consumer-provider link between application and junction')
            OSHVResult.addAll(scp.createCPLink(application_resource_id, application_resource_class, junction_id,
                                               junction_root_class, SCPId, service_context))
            for index in range(len(ipList)):
                scpOsh = scp.createScpOsh(junctionOsh, service_type, ip=ipList[index], port=portList[index], context=service_context)
                logger.info('Create scp with ip %s and port %s' % (ipList[index], portList[index]))
                ipOsh = modeling.createIpOSH(ipList[index])
                OSHVResult.add(scpOsh)
                OSHVResult.add(ipOsh)

    return OSHVResult
コード例 #17
0
def discoveryILOs(client, hostOSH):
    vector = ObjectStateHolderVector()
    logger.debug("Try to detect iLO...")
    controllerTable = SNMP_Networking_Utils.getILOsControllerBySNMP(client)
    logger.debug("controllerTable:", controllerTable)
    controlModel = None
    if controllerTable:
        controlModel = int(controllerTable[0].cpqSm2CntlrModel)
    desc = ILO_CARD_MODEL_DESC_DICT.get(controlModel) or 'Remote Lights-Out'
    table = SNMP_Networking_Utils.getILOsTableBySNMP(client)
    if table:
        for nic in table:
            logger.debug("iLO:", nic)
            iLODesc = desc + '( ' + nic.cpqSm2NicModel + ' )'
            iLO = createILOCard(hostOSH, iLODesc, nic)
            if nic.cpqSm2NicIpAddress:
                try:
                    ipaddress = ip_addr_util.IPAddress(nic.cpqSm2NicIpAddress)
                    ipOSH = modeling.createIpOSH(ipaddress, nic.cpqSm2NicIpSubnetMask)
                    link = modeling.createLinkOSH('containment', iLO, ipOSH)
                    vector.add(ipOSH)
                    vector.add(link)
                except:
                    logger.debug('got an invalid ipaddress: %s' %nic.cpqSm2NicIpAddress)
            vector.add(iLO)

    return vector
コード例 #18
0
 def _buildVirtualServerOsh(self):
     domainName = DomainScopeManager.getDomainByIp(self.ipAddress.strip())
     name = '%s:%s %s' % (self.ipAddress, self.port, domainName)
     virtualServerOsh = modeling.createCompleteHostOSH('clusteredservice', name, None, self.name)
     self.ipOSH = modeling.createIpOSH(self.ipAddress)
     self.linkIpOSH = modeling.createLinkOSH('contained', virtualServerOsh, self.ipOSH)
     self.osh = virtualServerOsh
コード例 #19
0
def processIpsAndSubnets(_vector, hostIpMap, hostId, ipMap, nwMap, hostOSH):
	if hostIpMap.has_key(hostId):
		iplist = hostIpMap[hostId]
		for ip in iplist:
			if ipMap.has_key(ip):
				ipObj = ipMap[ip]
				## create IPs and contained links for the rest of the IPs of that host
				ipOSH = modeling.createIpOSH(ipObj.ipValue)
				containedLink = modeling.createLinkOSH('contained', hostOSH, ipOSH)
				_vector.add(ipOSH)
				_vector.add(containedLink)

				## create the network for each IP
				ipSubnetId = ipObj.ipSubnetId
				if nwMap.has_key(ipSubnetId):
					netmaskPrefixLength = nwMap[ipSubnetId].prefixLength
					if notNull(netmaskPrefixLength):
						netOSH = modeling.createNetworkOSH(ipObj.ipValue, computeStringNetmaskFromPrefix(netmaskPrefixLength))
						_vector.add(netOSH)

						## create member link between ip and network
						memberLink = modeling.createLinkOSH('member', netOSH, ipOSH)
						_vector.add(memberLink)

						## create member link between host and network
						memberLink = modeling.createLinkOSH('member', netOSH, hostOSH)
						_vector.add(memberLink)
	return _vector
コード例 #20
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
コード例 #21
0
def reportConnectedEsxTopology(context, unitaryComputerSystem):
    '''
    UnitaryComputersystem -> OSHVector
    '''
    resultVector = ObjectStateHolderVector()

    unitaryComputerSystemReporter = vmware_cim_report.UnitaryComputerSystemReporter(
    )

    resultVector.addAll(
        unitaryComputerSystemReporter.reportConnectionTopology(
            unitaryComputerSystem, context.ipAddress))
    esxOsh = unitaryComputerSystem.getOsh(
        vmware_cim_report.UnitaryComputerSystemReporter.UCS_KEY_HOST)
    if esxOsh is None:
        raise ValueError("ESX OSH cannot be found")

    cimOsh = cim.createCimOsh(context.ipAddress, esxOsh, context.credentialId,
                              vmware_cim_discover.CimCategory.VMWARE)
    resultVector.add(cimOsh)

    ipAddressOsh = modeling.createIpOSH(context.ipAddress)
    resultVector.add(ipAddressOsh)

    containmentLink = modeling.createLinkOSH('containment', esxOsh,
                                             ipAddressOsh)
    resultVector.add(containmentLink)

    return resultVector
コード例 #22
0
def _buildIp(ipAddress, netmask=None, dnsname=None, ipProps=None):
    r'@types: str, str, str, dict -> bool'
    if _isValidIpV4(ipAddress):
        return modeling.createIpOSH(ipAddress, netmask, dnsname, ipProps)
    elif _isValidIpV6(ipAddress):
        return _buildIpV6(ipAddress, netmask, dnsname, ipProps)
    raise ValueError("Invalid IP format %s" % ipAddress)
コード例 #23
0
def getUrl(WSDLUrl, containerOSH):

    res = ObjectStateHolderVector()
    urlIP = None
    try:
        url = URL(WSDLUrl)
        hostName = url.getHost()
        urlIP = netutils.getHostAddress(hostName, None)

        if (not netutils.isValidIp(urlIP)) or netutils.isLocalIp(urlIP):
            urlIP = None
    except:
        urlIP = None
    
    urlOSH = modeling.createUrlOsh(containerOSH, WSDLUrl, 'wsdl')

    urlIpOSH = None
    if urlIP != None:
        try:
            urlIpOSH = modeling.createIpOSH(urlIP)
        except:
            urlIpOSH = None

    res.add(urlOSH)

    if urlIpOSH:
        res.add(urlIpOSH)
        urlToIpOSH = modeling.createLinkOSH('depend', urlOSH, urlIpOSH)
        res.add(urlToIpOSH)

    return res
コード例 #24
0
ファイル: ec2.py プロジェクト: deezeesms/dd-git
 def reportPrivateIpAddress(self, ipAddress, hostOsh):
     r'@types: str, OSH -> OSHV'
     vector = self._createOshVector()
     ipOsh = modeling.createIpOSH(ipAddress)
     vector.add(ipOsh)
     vector.add(modeling.createLinkOSH('containment', hostOsh, ipOsh))
     return vector
コード例 #25
0
ファイル: layer2.py プロジェクト: ddonnelly19/dd-git
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
コード例 #26
0
ファイル: SNMP_CDP_LLDP.py プロジェクト: ddonnelly19/dd-git
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
コード例 #27
0
 def reportIpAddressOfVm(self, vm):
     '''
     VmComputerSystem -> ObjectStateHolder
     '''
     if vm.primaryIpAddress:
         ipOsh = modeling.createIpOSH(vm.primaryIpAddress)
         return ipOsh
コード例 #28
0
def build_client_ip_osh(ip_addr, mac):
    if not (ip_addr and mac):
        return None

    ip_osh = modeling.createIpOSH(ip_addr)
    ip_osh.setStringAttribute('arp_mac', mac)
    return ip_osh
コード例 #29
0
ファイル: nnm_netutils.py プロジェクト: ddonnelly19/dd-git
def _buildIp(ipAddress, netmask=None, dnsname=None, ipProps = None):
    r'@types: str, str, str, dict -> bool'
    if _isValidIpV4(ipAddress):
        return modeling.createIpOSH(ipAddress, netmask, dnsname, ipProps)
    elif _isValidIpV6(ipAddress):
        return _buildIpV6(ipAddress, netmask, dnsname, ipProps)
    raise ValueError("Invalid IP format %s" % ipAddress)
コード例 #30
0
    def reportMqServerWithEndpoint(self, server):
        r''' Make reporting of MQ server based on its IP where contains
        is incomplete host built using IP address and if port specified
        linked with corresponding service endpoint

        @types: jms.MqServer -> ObjectStateHolderVector
        @raise ValueError: JMS Server is not specified
        @raise ValueError: MQ Server IP address is empty or not resolved
        '''
        if not server:
            raise ValueError("JMS Server is not specified")
        ip = server.address
        if not (ip and netutils.isValidIp(ip)):
            raise ValueError("MQ Server IP address is empty or not resolved")
        vector = ObjectStateHolderVector()
        hostOsh = modeling.createIpOSH(ip)
        vector.add(hostOsh)
        serverOsh = self.reportMqServer(server, hostOsh)
        vector.add(serverOsh)
        if server.getPort() is not None:
            vector.add(
                modeling.createServiceAddressOsh(
                    hostOsh, ip, server.getPort(),
                    modeling.SERVICEADDRESS_TYPE_TCP))
        return vector
コード例 #31
0
def build_client_ip_osh(ip_addr, mac):
    if not (ip_addr and mac):
        return None
        
    ip_osh = modeling.createIpOSH(ip_addr)
    ip_osh.setStringAttribute('arp_mac', mac)
    return ip_osh    
コード例 #32
0
 def _buildVirtualServerOsh(self):
     domainName = DomainScopeManager.getDomainByIp(self.ipAddress.strip())
     name = '%s:%s %s' % (self.ipAddress, self.port, domainName)
     virtualServerOsh = modeling.createCompleteHostOSH('clusteredservice', name, None, self.name)
     self.ipOSH = modeling.createIpOSH(self.ipAddress)
     self.linkIpOSH = modeling.createLinkOSH('contained', virtualServerOsh, self.ipOSH)
     self.osh = virtualServerOsh
コード例 #33
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
コード例 #34
0
ファイル: vcloud_report.py プロジェクト: ddonnelly19/dd-git
 def _reportVmIps(self, vm, vmHostOsh, vector):
     for ip in vm._ips:
         ipOsh = modeling.createIpOSH(ip)
         if ipOsh is not None:
             vector.add(ipOsh)
             
             containmentLink = modeling.createLinkOSH('containment', vmHostOsh, ipOsh)
             vector.add(containmentLink)
コード例 #35
0
ファイル: ec2.py プロジェクト: deezeesms/dd-git
 def reportPublicIpAddress(self, account, ipAddress, hostOsh):
     r'@types: aws.Account, str, OSH -> OSHV'
     vector = self._createOshVector()
     ipOsh = modeling.createIpOSH(ipAddress)
     ipOsh.setAttribute('ip_domain', account.getId())
     vector.add(ipOsh)
     vector.add(modeling.createLinkOSH('containment', hostOsh, ipOsh))
     return vector
コード例 #36
0
    def report(self, oshVector, interaction):
        srcNode, dstNode = interaction.srcNode, interaction.dstNode
        if self.acceptorEngine.accepts(srcNode):
            srcNode.ipOsh = modeling.createIpOSH(srcNode.ip)
            srcNode.hostOsh = modeling.createHostOSH(srcNode.ip)
            srcContainedLink = modeling.createLinkOSH('contained', srcNode.hostOsh, srcNode.ipOsh)
            oshVector.add(srcNode.ipOsh)
            oshVector.add(srcNode.hostOsh)
            oshVector.add(srcContainedLink)

        if self.acceptorEngine.accepts(dstNode):
            dstNode.ipOsh = modeling.createIpOSH(dstNode.ip)
            dstNode.hostOsh = modeling.createHostOSH(dstNode.ip)
            dstContainedLink = modeling.createLinkOSH('contained', dstNode.hostOsh, dstNode.ipOsh)
            oshVector.add(dstNode.ipOsh)
            oshVector.add(dstNode.hostOsh)
            oshVector.add(dstContainedLink)
コード例 #37
0
def reportIpAddress(Framework, OSHVResult):
    ipAddress = Framework.getDestinationAttribute('ip_address')
    if ipAddress:
        logger.debug("reporting ip address:", ipAddress)
        ipOSH = modeling.createIpOSH(ipAddress)
        OSHVResult.add(ipOSH)

    return ipAddress
コード例 #38
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    snmpMethod = getFrameworkParameter(Framework, 'snmpMethod', SnmpQueries.defaultSnmpMethod)
    backupSnmpMethod = getFrameworkParameter(Framework, 'backupSnmpMethod', SnmpQueries.defaultBackupSnmpMethod)
    moonWalkBulkSize = int(getFrameworkParameter(Framework, 'moonWalkBulkSize', SnmpQueries.defaultMoonWalkBulkSize))
    moonWalkSleep = long(getFrameworkParameter(Framework, 'moonWalkSleep', SnmpQueries.defaultMoonWalkSleep))
    snmpBulkSize = int(getFrameworkParameter(Framework, 'snmpBulkSize', SnmpQueries.defaultSnmpBulkSize))
    discoverUnknownIPs = Boolean.parseBoolean(Framework.getParameter('discoverUnknownIPs'))
    
    #getting DestinationData from Framework; the method is protected.
    destination = Framework.getCurrentDestination()
    
    discoveredHostIpList = SnmpQueries.getSnmpIpDataOneDestination(snmpMethod, snmpBulkSize, moonWalkBulkSize, moonWalkSleep, Boolean.FALSE, destination)
    logger.debug('Discover ARP by %s returned %s objects' % (snmpMethod, str(discoveredHostIpList.size())))
    if (discoveredHostIpList.size() == 0) and (snmpMethod != backupSnmpMethod):
        discoveredHostIpList = SnmpQueries.getSnmpIpDataOneDestination(backupSnmpMethod, snmpBulkSize, moonWalkBulkSize, moonWalkSleep, Boolean.FALSE, destination)
        logger.debug('Discover ARP by %s returned %s objects' % (backupSnmpMethod, str(discoveredHostIpList.size())))
        if (discoveredHostIpList.size()==0):
            Framework.reportWarning('Failed to discover SNMP IP data')
            return OSHVResult
    
    discoveredHostArpList = SnmpQueries.getSnmpArpDataOneDestination(snmpMethod, snmpBulkSize, moonWalkBulkSize, moonWalkSleep, Boolean.FALSE, destination)
    discoveredHostArpList.addAll(SnmpQueries.getSnmpArpDataOneDestination(snmpMethod, snmpBulkSize, moonWalkBulkSize, moonWalkSleep, Boolean.FALSE, Boolean.TRUE, destination))
    if (discoveredHostArpList.size()==0) and (snmpMethod != backupSnmpMethod):
        discoveredHostArpList = SnmpQueries.getSnmpArpDataOneDestination(backupSnmpMethod, snmpBulkSize, moonWalkBulkSize, moonWalkSleep, Boolean.FALSE, destination)
        discoveredHostArpList.addAll(SnmpQueries.getSnmpArpDataOneDestination(backupSnmpMethod, snmpBulkSize, moonWalkBulkSize, moonWalkSleep, Boolean.FALSE, Boolean.TRUE, destination))
        if (discoveredHostArpList.size()==0):
            Framework.reportWarning('Failed to discover SNMP ARP data')
            return OSHVResult

    networkOSH = None
    for i in range(discoveredHostArpList.size()):
        currArp = discoveredHostArpList.get(i)
        for currIp in discoveredHostIpList:
            if networkOSH is None:
                networkOSH = modeling.createNetworkOSH(currIp.netaddr, currIp.netmask)
                OSHVResult.add(networkOSH)
            if (currIp.domain == 'unknown') and not discoverUnknownIPs:
                continue
            if not netutils.isValidMac(currArp.designatedMacAddress):
                continue
            
            #report start
            designatedIpNetAddress = IPv4(currArp.designatedIpAddress, currIp.netmask).getFirstIp().toString();
            if designatedIpNetAddress == currIp.netaddr:
                hostOSH = modeling.createHostOSH(currArp.designatedIpAddress)
                OSHVResult.add(hostOSH)
                OSHVResult.add(modeling.createLinkOSH('member', networkOSH, hostOSH))
                
                ipOsh = modeling.createIpOSH(currArp.designatedIpAddress, currIp.netmask)
                OSHVResult.add(ipOsh)
                OSHVResult.add(modeling.createLinkOSH('member', networkOSH, ipOsh))
                
                ifOsh = modeling.createInterfaceOSH(netutils.parseMac(currArp.designatedMacAddress), hostOSH)
                OSHVResult.add(ifOsh)
                OSHVResult.add(modeling.createLinkOSH('containment', ifOsh, ipOsh))
    
    return OSHVResult
コード例 #39
0
    def buildTopology(self):
        '''
        Construct as400 node topology
        @types AS400Client -> ObjectStateHolderVector
        '''
        myvec = ObjectStateHolderVector()
        ip_address = self.__client.getIpAddress()
        # create as400 agent OSH

        interfaceList = self.__interfacesInfo
        as400HostOsh = None
        if interfaceList and len(interfaceList) > 0:
            # Create as400 CIT       
            try: 
                # Get the host_key - lowest mac address of the valid interface list
                as400HostOsh = modeling.createCompleteHostOSHByInterfaceList('as400_node', interfaceList, 'OS400', self.__sysInfo.hostName)
                as400HostOsh.setAttribute('host_model', self.__sysInfo.hostModel)
                as400HostOsh.setAttribute('host_serialnumber', self.__sysInfo.hostSerialNum)
                as400HostOsh.setAttribute('host_osversion', self.__sysInfo.hostOSVersion)
                as400HostOsh.setAttribute('host_vendor', 'IBM')
                myvec.add(as400HostOsh)
                
                as400Osh = self.__createAS400AgentOSH(ip_address)
                as400Osh.setAttribute('credentials_id', self.__client.getCredentialId())
                as400Osh.setContainer(as400HostOsh)
                myvec.add(as400Osh)

            except:
                logger.warn('Could not find a valid MAC addresses for key on ip : ', self.__client.getIpAddress())
       
        # add all interfaces to the host
        if as400HostOsh is not None:
            for interface in interfaceList:
                interfaceOsh = modeling.createInterfaceOSH(interface.macAddress, as400HostOsh, interface.description, interface.interfaceIndex, interface.type, interface.adminStatus, interface.adminStatus, interface.speed, interface.name, interface.alias, interface.className)
                ips = interface.ips
                masks = interface.masks
                if interfaceOsh:
                    myvec.add(interfaceOsh)
                    if ips and masks:
                        for i in xrange(len(ips)):
                            ipAddress = ips[i]
                            ipMask = masks[i]

                            ipProp = modeling.getIpAddressPropertyValue(ipAddress, ipMask, interface.dhcpEnabled, interface.description)
                            ipOSH = modeling.createIpOSH(ipAddress, ipMask, ipProp)
                            myvec.add(ipOSH)
                            
                            myvec.add(modeling.createLinkOSH('containment', as400HostOsh, ipOSH))
                            netOSH = modeling.createNetworkOSH(ipAddress, ipMask)   
                            myvec.add(netOSH)
                            
                            myvec.add(modeling.createLinkOSH('member', netOSH, as400HostOsh))
                            myvec.add(modeling.createLinkOSH('member', netOSH, ipOSH))
                            myvec.add(modeling.createLinkOSH('containment', interfaceOsh, ipOSH))
        else:
            logger.warn('Parent host wasn\'t created. No interfaces will be reported.')
        return myvec
コード例 #40
0
ファイル: URL_Resolver.py プロジェクト: ddonnelly19/dd-git
def createHostOSHwithIP(OSHVResult, ipAddress):
    # create Host and ipAddress CIs and relations
    hostOSH = modeling.createHostOSH(ipAddress)
    ipOSH = modeling.createIpOSH(ipAddress)
    link = modeling.createLinkOSH('containment', hostOSH, ipOSH)
    OSHVResult.add(hostOSH)
    OSHVResult.add(ipOSH)
    OSHVResult.add(link)
    return hostOSH, ipOSH
コード例 #41
0
def createHostOSHwithIP(OSHVResult, ipAddress):
    # create Host and ipAddress CIs and relations
    hostOSH = modeling.createHostOSH(ipAddress)
    ipOSH = modeling.createIpOSH(ipAddress)
    link = modeling.createLinkOSH('containment', hostOSH, ipOSH)
    OSHVResult.add(hostOSH)
    OSHVResult.add(ipOSH)
    OSHVResult.add(link)
    return hostOSH, ipOSH
コード例 #42
0
    def _reportVmIps(self, vm, vmHostOsh, vector):
        for ip in vm._ips:
            ipOsh = modeling.createIpOSH(ip)
            if ipOsh is not None:
                vector.add(ipOsh)

                containmentLink = modeling.createLinkOSH(
                    'containment', vmHostOsh, ipOsh)
                vector.add(containmentLink)
コード例 #43
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # # Write implementation to return new result CIs here...
    ipList = Framework.getTriggerCIDataAsList('REAL_IP_ADDRESS')
    for ip in ipList:
        ipOSH = modeling.createIpOSH(ip)
        OSHVResult.add(ipOSH)

    return OSHVResult
コード例 #44
0
 def reportClusterResourceGroupIp(self, resourceGroup, managedIp, resultsVector):
     clusterResourceGroupOsh = resourceGroup.getOsh(AutoStartReporter.RESOURCE_GROUP_KEY_GROUP)
     ipState = managedIp.ipState
     if clusterResourceGroupOsh is not None and ipState and ipState.lower() == 'assigned':
         ipString = managedIp.ipAddress
         ipOsh = modeling.createIpOSH(ipString)
         resultsVector.add(ipOsh)
         
         containmentLink = modeling.createLinkOSH('containment', clusterResourceGroupOsh, ipOsh)
         resultsVector.add(containmentLink)
コード例 #45
0
 def build(self):
     domainName = DomainScopeManager.getDomainByIp(self.vServer.ip)
     name = '%s:%s %s' % (self.vServer.ip, self.vServer.port, domainName)
     vServerOsh = modeling.createCompleteHostOSH('cluster_resource_group', name, None, self.vServer.name)
     ipOSH = modeling.createIpOSH(self.vServer.ip)
     linkIpOSH = modeling.createLinkOSH('contained', vServerOsh, ipOSH)
     ownership_link = modeling.createLinkOSH('ownership', self.netscaler_software_osh, vServerOsh)
     vipServiceOsh = modeling.createServiceAddressOsh(vServerOsh, self.vServer.ip, self.vServer.port,
                                                      modeling.SERVICEADDRESS_TYPE_TCP, self.vServer.server_type)
     self.osh = vServerOsh
     return self.newVector(vServerOsh, ipOSH, ownership_link, linkIpOSH, vipServiceOsh)
コード例 #46
0
def _reportHost(ips, fqnd):
    r'@types: [ip_addr.IPAddress] -> tuple[ObjectStateHolder, ObjectStateHolderVector]'
    assert ips
    vector = ObjectStateHolderVector()
    nodeOsh = _buildWindowsHost(ips[0], fqnd)
    for ip_obj in ips:
        ipOSH = modeling.createIpOSH(ip_obj)
        vector.add(ipOSH)
        vector.add(modeling.createLinkOSH('containment', nodeOsh, ipOSH))
    vector.add(nodeOsh)
    return nodeOsh, vector
コード例 #47
0
 def buildOshAndIps(self):
     self.__prepareForBuild()
     switchVector = ObjectStateHolderVector()
     switchOsh = self.build()
     switchVector.add(switchOsh)
     for ip in self.__ips:
         if ip and netutils.isValidIp(ip):
             ipOsh = modeling.createIpOSH(ip)
             linkOsh = modeling.createLinkOSH('containment', switchOsh, ipOsh)
             switchVector.add(ipOsh)
             switchVector.add(linkOsh)
     return switchOsh, switchVector
コード例 #48
0
def reportVirtualMachine(vm_map, server, server_osh, host_class, lpar,
                         server_serial_to_interfaces):
    vector = ObjectStateHolderVector()
    key = '%s%s' % (server.serial, lpar.lparId)
    hostDo = vm_map.get(key)

    if not hostDo:
        logger.warn('Failed to report lpar with id %s and name %s' %
                    (lpar.lparId, lpar.lparName))
        return vector, None

    vm_osh = buildGenericHostObject(host_class, hostDo, False)
    if lpar.type != 'os400':
        vm_osh.setStringAttribute("os_family", 'unix')

    if lpar.logicalSerialNumber:
        vm_osh.setStringAttribute('serial_number', lpar.logicalSerialNumber)
    elif hostDo.serial:
        vm_osh.setStringAttribute('serial_number',
                                  'derived:%s' % hostDo.serial)

    if hostDo.ipList:
        vm_osh.setStringAttribute('host_key', str(hostDo.ipList[0]))
    if not hostDo.ipList and hostDo.macs:
        vm_osh.setStringAttribute('host_key', str(hostDo.macs[0]))
    hypervisor_osh = createIbmHypervisorOsh(server_osh)
    link_osh = modeling.createLinkOSH('execution_environment', hypervisor_osh,
                                      vm_osh)
    vector.add(vm_osh)
    vector.add(hypervisor_osh)
    vector.add(link_osh)
    if lpar.rmcIp:
        hostDo.ipList.append(lpar.rmcIp)
    if hostDo.ipList:
        for ip in hostDo.ipList:
            #logger.debug('Reporting %s ip for lpar %s' % (ip, hostDo.displayName))
            ip_osh = modeling.createIpOSH(ip)
            link_osh = modeling.createLinkOSH('containment', vm_osh, ip_osh)
            vector.add(ip_osh)
            vector.add(link_osh)

    interfaces_map = server_serial_to_interfaces.get(hostDo.serial, {})
    if hostDo.macs:
        for mac in hostDo.macs:
            interface_osh = modeling.createInterfaceOSH(mac, vm_osh)
            vector.add(interface_osh)
            server_iface_osh = interfaces_map.get(mac)
            if server_iface_osh:
                link_osh = modeling.createLinkOSH('realization', interface_osh,
                                                  server_iface_osh)
                vector.add(link_osh)

    return vector, vm_osh
コード例 #49
0
    def addTraffic(self, currSrcAddr, currDstAddr, portsSet, octetsCount, packetsCount):
        host1OSH = modeling.createHostOSH(currSrcAddr)
        ip1OSH = modeling.createIpOSH(currSrcAddr)
        containedLink1OSH = modeling.createLinkOSH('contained', host1OSH, ip1OSH)
        self.Framework.sendObject(host1OSH)
        self.Framework.sendObject(ip1OSH)
        self.Framework.sendObject(containedLink1OSH)

        host2OSH = modeling.createHostOSH(currDstAddr)
        ip2OSH = modeling.createIpOSH(currDstAddr)
        containedLink2OSH = modeling.createLinkOSH('contained', host2OSH, ip2OSH)
        self.Framework.sendObject(host2OSH)
        self.Framework.sendObject(ip2OSH)
        self.Framework.sendObject(containedLink2OSH)

        if portsSet.size() > 0:
            trafficLinkOSH = modeling.createLinkOSH('traffic', ip1OSH, ip2OSH)
            ash = AttributeStateHolder('traffic_portlist', portsSet)
            trafficLinkOSH.addAttributeToList(ash)
            trafficLinkOSH.setLongAttribute('traffic_octets', octetsCount)
            trafficLinkOSH.setLongAttribute('traffic_pkts', packetsCount)
            self.Framework.sendObject(trafficLinkOSH)
コード例 #50
0
 def buildStorageArrays(self):
     for storage in self.storageArrays.values():
         storageArrayOSHV = ObjectStateHolderVector()
         oshDict = storage.build()
         for name in oshDict.keys():
             arrayOsh = storage.oshs[name]
             ip = storage.ips[name]
             if ip and netutils.isValidIp(ip):
                 ipOsh = modeling.createIpOSH(storage.ips[name])
                 containmentOsh = modeling.createLinkOSH('containment', arrayOsh, ipOsh)
                 storageArrayOSHV.add(ipOsh)
                 storageArrayOSHV.add(containmentOsh)
             storageArrayOSHV.add(arrayOsh)
         hbaIdToOsh = {}
         for hba in storage.hbas.values():
             hbaOsh = hba.build()
             if storage.isClustered:
                 for name in storage.names:
                     if hba.name.startswith(name):
                         hbaOsh.setContainer(oshDict[name])
             else:
                 hbaOsh.setContainer(oshDict[oshDict.keys()[0]])
             hbaIdToOsh[hba.hbaId] = hbaOsh
             self.addWwnOsh(hba.wwn, hbaOsh)
             storageArrayOSHV.add(hbaOsh)
         for port in storage.ports.values():
             portOsh = port.build()
             if storage.isClustered:
                 for name in storage.names:
                     if port.name.startswith(name):
                         portOsh.setContainer(oshDict[name])
             else:
                 portOsh.setContainer(oshDict[oshDict.keys()[0]])
             if port.nodeId and port.nodeId in hbaIdToOsh.keys():
                 containmentLinkOsh = modeling.createLinkOSH('containment', hbaIdToOsh[port.nodeId], portOsh)
                 storageArrayOSHV.add(containmentLinkOsh)
             self.portIdToOsh[port.portId] = portOsh
             self.addWwnOsh(port.wwn, portOsh)
             storageArrayOSHV.add(portOsh)
         for volume in storage.volumes.values():
             volumeOsh = volume.build()
             if storage.isClustered:
                 for name in storage.names:
                     if volume.name.startswith(name):
                         volumeOsh.setContainer(oshDict[name])
             else:
                 volumeOsh.setContainer(oshDict[oshDict.keys()[0]])
             self.volumeIdToOsh[volume.volumeId] = volumeOsh
             storageArrayOSHV.add(volumeOsh)
         self.framework.sendObjects(storageArrayOSHV)
         self.framework.flushObjects()