本文整理汇总了Python中modeling.createIpOSH函数的典型用法代码示例。如果您正苦于以下问题:Python createIpOSH函数的具体用法?Python createIpOSH怎么用?Python createIpOSH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createIpOSH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reporterMSCluster
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
示例2: setObjectVectorByResStringArray
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))
示例3: DiscoveryMain
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)
示例4: createScpOSHV
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
示例5: DiscoveryMain
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
示例6: createIPEndpointOSHV
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: discoveryILOs
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
示例8: DiscoveryMain
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
示例9: _buildVirtualServerOsh
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
示例10: processIpsAndSubnets
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
示例11: _buildIp
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)
示例12: reportAddressRecord
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)
示例13: reportMqServerWithEndpoint
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
示例14: reportIpAddressOfVm
def reportIpAddressOfVm(self, vm):
'''
VmComputerSystem -> ObjectStateHolder
'''
if vm.primaryIpAddress:
ipOsh = modeling.createIpOSH(vm.primaryIpAddress)
return ipOsh
示例15: getUrl
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