本文整理汇总了Python中modeling.createHostOSH函数的典型用法代码示例。如果您正苦于以下问题:Python createHostOSH函数的具体用法?Python createHostOSH怎么用?Python createHostOSH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createHostOSH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _build_fc_switch_osh
def _build_fc_switch_osh(switch):
'@types: Switch -> osh'
ipAddress = switch.address
if ipAddress and ip_addr.isValidIpAddress(ipAddress):
fcSwitchOSH = modeling.createHostOSH(str(ipAddress), 'fcswitch')
else:
logger.debug('IP address not available for Switch <%s> with ID <%s>!! Creating Switch with ID as primary key...' % (switch.name, switch.id))
hostKey = switch.id + ' (ECC ID)'
fcSwitchOSH = modeling.createCompleteHostOSH('fcswitch', hostKey)
fcSwitchOSH.setAttribute('data_note', 'IP address unavailable in ECC - Duplication of this CI is possible')
used_ports = None
if switch.portcount != None and switch.portcount_free != None:
used_ports = switch.portcount - switch.portcount_free
populateOSH(fcSwitchOSH, {
'data_description': switch.sn,
'fcswitch_wwn': switch.sn,
'data_name': switch.name,
'host_model': switch.host_model,
'fcswitch_version': switch.version,
'host_vendor': switch.host_vendor,
'fcswitch_domainid': switch.domain_id,
'fcswitch_availableports': switch.portcount,
'fcswitch_freeports': switch.portcount_free,
'fcswitch_connectedports': used_ports
})
fcSwitchOSH.setListAttribute('node_role', ['switch'])
return fcSwitchOSH
示例2: DiscoveryMain
def DiscoveryMain(Framework):
OSHVResult = ObjectStateHolderVector()
ip_address = Framework.getDestinationAttribute('ip_address')
hostOSH = modeling.createHostOSH(ip_address)
protocols = Framework.getAvailableProtocols(ip_address, ClientsConsts.SQL_PROTOCOL_NAME)
for sqlProtocol in protocols:
dbClient = None
try:
try:
if dbutils.protocolMatch(Framework, sqlProtocol, 'sybase', None, None) == 0:
continue
dbClient = Framework.createClient(sqlProtocol)
logger.debug('Connnected to sybase on ip ', dbClient.getIpAddress(), ', port ', str(dbClient.getPort()), ' to database ',dbClient.getDatabaseName(),'with user ', dbClient.getUserName())
dbversion = dbClient.getDbVersion()
logger.debug('Found sybase server of version:', dbversion)
res = dbClient.executeQuery("select srvnetname from master..sysservers where srvid = 0")#@@CMD_PERMISION sql protocol execution
if res.next():
dbname=string.strip(res.getString(1))
sybasedOSH = modeling.createDatabaseOSH('sybase', dbname, str(dbClient.getPort()),dbClient.getIpAddress(),hostOSH,sqlProtocol,dbClient.getUserName(),None,dbversion)
OSHVResult.add(sybasedOSH)
else:
Framework.reportWarning('Sybase server was not found')
except MissingJarsException, e:
logger.debugException(e.getMessage())
Framework.reportError(e.getMessage())
return
except:
logger.debugException('Failed to discover sybase with credentials ', sqlProtocol)
finally:
示例3: build
def build(self):
if self.ipAddress and self.queueName:
self.hostOsh = modeling.createHostOSH(self.ipAddress)
self.msMqManagerOsh = modeling.createApplicationOSH('msmqmanager', 'Microsoft MQ Manager', self.hostOsh)
self.queueOsh = ObjectStateHolder('msmqqueue')
self.queueOsh.setAttribute('data_name', self.queueName.lower())
self.queueOsh.setContainer(self.msMqManagerOsh)
示例4: 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
示例5: reportRemotePeer
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
示例6: buildDBObjects
def buildDBObjects(db_type, host_ip, db_port, db_name, db_sid, appServerOSH, OSHVResult):
logger.debug('building TNS Entry ', db_type, host_ip, db_name, db_port, db_sid)
oshs = []
hostOSH = modeling.createHostOSH(host_ip)
oshs.append(hostOSH)
dbOSH, ipseOsh, databaseOshs = None, None, None
platform = db_platform.findPlatformBySignature(db_type)
if not platform:
logger.warn("Failed to determine platform for %s" % db_type)
else:
dbserver = db_builder.buildDatabaseServerPdo(db_type, db_name, host_ip, db_port)
if not db_name and not db_port:
builder = db_builder.Generic()
else:
builder = db_builder.getBuilderByPlatform(platform)
dbTopologyReporter = db.TopologyReporter(builder)
result = dbTopologyReporter.reportServerWithDatabases(dbserver,
hostOSH,
(appServerOSH,))
dbOSH, ipseOsh, databaseOshs, vector_ = result
oshs.extend(vector_)
OSHVResult.addAll(oshs)
示例7: modelConnectedPortByPowerShell
def modelConnectedPortByPowerShell(context):
endpointOSHV = ObjectStateHolderVector()
try:
logger.debug("reporting endpoints for iis using powershell")
shell = NTCMD_IIS.CscriptShell(context.client)
system32Location = shell.createSystem32Link() or '%SystemRoot%\\system32'
discoverer = iis_powershell_discoverer.get_discoverer(shell)
if isinstance(discoverer, iis_powershell_discoverer.PowerShellOverNTCMDDiscoverer):
discoverer.system32_location = system32Location
executor = discoverer.get_executor(shell)
sites_info = iis_powershell_discoverer.WebSitesCmd() | executor
for site_info in sites_info:
site_name = site_info.get("name")
if site_name:
bindings = iis_powershell_discoverer.WebSiteBindingCmd(site_name) | executor
host_ips = []
host_ips.append(context.application.getApplicationIp())
logger.debug("application ip", context.application.getApplicationIp())
parse_func = partial(iis_powershell_discoverer.parse_bindings, host_ips=host_ips)
bindings = map(parse_func, bindings)
for binding in bindings:
logger.debug("reporting binding:", binding[2])
for bind in binding[2]:
endpointOSH = visitEndpoint(bind)
hostosh = context.application.getHostOsh()
ip = bind.getAddress()
hostosh = modeling.createHostOSH(ip)
endpointOSH.setContainer(hostosh)
linkOsh = modeling.createLinkOSH("usage", context.application.getOsh(), endpointOSH)
endpointOSHV.add(endpointOSH)
endpointOSHV.add(linkOsh)
except Exception, ex:
logger.debug("Cannot get port from powershell:", ex)
return None
示例8: getTopology
def getTopology(self, ipAddress):
lb = modeling.createHostOSH(ipAddress, 'host')
cisco_ace = modeling.createApplicationOSH('cisco_ace', 'Cisco_ACE', lb, 'Load Balance', 'Cisco')
self.OSHVResult.add(lb)
self.OSHVResult.add(cisco_ace)
self.discoverVirtualServers(cisco_ace)
示例9: discoverContentRules
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
示例10: process
def process(self, context):
'''
Plugin gets system information from DEFAULT profile. In case if profile
cannot be processed - system information is parsed from instance
profile path.
Default profile read for system (identified by its path) is shared
between application component instances
'''
shell = context.client
osh = context.application.applicationOsh
host_osh = context.hostOsh
attrName = sap.InstanceBuilder.INSTANCE_PROFILE_PATH_ATTR
pf_path = osh.getAttributeValue(attrName)
logger.info("Instance pf path is: %s" % pf_path)
system, pf_name = sap_discoverer.parsePfDetailsFromPath(pf_path)
logger.info("Parsed details from pf name: %s" % str((system, pf_name)))
topology = self._discover_topology(shell, system, pf_path)
if topology:
#resolver = dns_resolver.SocketDnsResolver()
resolver = dns_resolver.create(shell, local_shell=None,
dns_server=None,
hosts_filename=None)
db_host_osh, oshs = _report_db_host(topology, resolver)
application_ip = _report_application_ip(shell, topology, resolver)
if application_ip:
logger.info("application ip is: %s" % application_ip)
osh.setAttribute('application_ip', str(application_ip))
host_app_osh = modeling.createHostOSH(str(application_ip))
logger.info("set container: %s" % host_app_osh)
osh.setContainer(host_app_osh)
oshs.extend(self._report_topology(osh, host_osh, db_host_osh, topology))
context.resultsVector.addAll(oshs)
示例11: executeWmiQuery
def executeWmiQuery(client, OSHVResult, nodeOsh=None):
'''
@deprecated: Use NTCMD_HR_Dis_Disk_Lib.discoverDiskByWmic instead
'''
containerOsh = nodeOsh or modeling.createHostOSH(client.getIpAddress())
NTCMD_HR_Dis_Disk_Lib.discoverDiskByWmic(client, OSHVResult, containerOsh)
NTCMD_HR_Dis_Disk_Lib.discoverPhysicalDiskByWmi(client, OSHVResult, containerOsh)
示例12: build_network_device
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
示例13: doDiscovery
def doDiscovery(Framework, shell, ip, credentialId, codepage, shellName, warningsList, errorsList, uduid = None):
vector = ObjectStateHolderVector()
try:
try:
languageName = shell.osLanguage.bundlePostfix
langBund = Framework.getEnvironmentInformation().getBundle('langNetwork', languageName)
remoteHostnames = dns_resolver.NsLookupDnsResolver(shell).resolve_hostnames(ip)
remoteHostFqdn = None
if remoteHostnames:
remoteHostFqdn = remoteHostnames[0]
shellObj = createShellObj(shell, ip, langBund, languageName, codepage, remoteHostFqdn)
try:
vector.addAll(discover(shell, shellObj, ip, langBund, Framework, uduid))
finally:
# create shell OSH if connection established
if shellObj and not vector.size():
hostOsh = modeling.createHostOSH(ip)
shellObj.setContainer(hostOsh)
vector.add(shellObj)
except Exception, ex:
strException = ex.getMessage()
errormessages.resolveAndAddToObjectsCollections(strException, shellName, warningsList, errorsList)
except:
msg = str(sys.exc_info()[1])
logger.debugException('')
errormessages.resolveAndAddToObjectsCollections(msg, shellName, warningsList, errorsList)
示例14: osh_createiSeriesOsh
def osh_createiSeriesOsh(defaultIp, model, osversion, serialnbr,sysname, macAddress):
# Create Iseries OSH ----------------------------------
str_discovered_os_name = 'discovered_os_name'
str_discovered_os_version = 'discovered_os_version'
str_discovered_os_vendor = 'discovered_os_vendor'
str_discovered_model = 'discovered_model'
str_vendor = 'vendor'
str_os_vendor = 'os_vendor'
str_name = 'name'
host_key = 'host_key'
str_serialnbr = 'serial_number'
isComplete = 1
os400Osh = modeling.createHostOSH(defaultIp, 'as400_node', _STR_EMPTY, _STR_EMPTY, _STR_EMPTY)
os400Osh.setAttribute(str_discovered_os_name, 'os/400')
os400Osh.setBoolAttribute('host_iscomplete', isComplete)
os400Osh.setAttribute(str_discovered_os_version, osversion)
os400Osh.setAttribute(str_discovered_model, model)
os400Osh.setAttribute(str_os_vendor, 'IBM')
os400Osh.setAttribute(str_discovered_os_vendor, 'IBM')
os400Osh.setAttribute(str_vendor, 'IBM')
os400Osh.setAttribute(str_name, sysname )
os400Osh.setAttribute(str_serialnbr, serialnbr )
os400Osh.setAttribute(host_key, macAddress )
return os400Osh
示例15: 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