Class DefaultProvisionService
- java.lang.Object
-
- org.opennms.netmgt.provision.service.DefaultProvisionService
-
- All Implemented Interfaces:
ProvisionService,org.springframework.beans.factory.InitializingBean
@Service public class DefaultProvisionService extends java.lang.Object implements ProvisionService, org.springframework.beans.factory.InitializingBean
DefaultProvisionService- Version:
- $Id: $
- Author:
- brozow
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROVISIOND-
Fields inherited from interface org.opennms.netmgt.provision.service.ProvisionService
ABORT, DETECTOR_NAME, ERROR, FOREIGN_ID, FOREIGN_SOURCE, IP_ADDRESS, LOCATION, NODE_ID
-
-
Constructor Summary
Constructors Constructor Description DefaultProvisionService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OnmsMonitoredServiceaddMonitoredService(java.lang.Integer ipInterfaceId, java.lang.String svcName)OnmsMonitoredServiceaddMonitoredService(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)voidafterPropertiesSet()io.opentracing.SpanbuildAndStartSpan(java.lang.String name, io.opentracing.SpanContext spanContext)voidclearCache()clearCacheOnmsCategorycreateCategoryIfNecessary(java.lang.String name)Look up the OnmsCategory with the give name, creating one if none exists.protected OnmsMonitoringLocationcreateLocationDefIfNecessary(OnmsMonitoringLocation location)OnmsMonitoringLocationcreateLocationIfNecessary(java.lang.String locationName)Lookup a monitoring location in the database, creating it if necessary.OnmsServiceTypecreateServiceTypeIfNecessary(java.lang.String serviceName)Look up the OnmsServiceType with the given name, creating one if it doesn't exist.OnmsNodecreateUndiscoveredNode(java.lang.String ipAddress, java.lang.String foreignSource, java.lang.String locationString)voiddeleteInterface(java.lang.Integer nodeId, java.lang.String ipAddr)voiddeleteNode(java.lang.Integer nodeId)Delete the indicated node from the database.voiddeleteObsoleteInterfaces(java.lang.Integer nodeId, java.util.Date scanStamp)voiddeleteService(java.lang.Integer nodeId, java.net.InetAddress addr, java.lang.String svcName, boolean ignoreUnmanaged)Delete the indicated service from the database.java.util.Set<java.lang.String>getCategoriesForNode(OnmsNode node)OnmsNodegetDbNodeInitCat(java.lang.Integer nodeId)java.util.List<PluginConfig>getDetectorsForForeignSource(java.lang.String foreignSourceName)java.util.Map<java.lang.String,java.lang.Integer>getForeignIdToNodeIdMap(java.lang.String foreignSource)Creates a map of foreignIds to nodeIds for all nodes that have the indicated foreignSorce.ForeignSourceRepositorygetForeignSourceRepository()getForeignSourceRepositoryHostnameResolvergetHostnameResolver()java.util.List<IpInterfacePolicy>getIpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)LocationAwareDetectorClientgetLocationAwareDetectorClient()LocationAwareDnsLookupClientgetLocationAwareDnsLookupClient()LocationAwareSnmpClientgetLocationAwareSnmpClient()OnmsNodegetNode(java.lang.Integer nodeId)java.util.List<NodePolicy>getNodePoliciesForForeignSource(java.lang.String foreignSourceName)<T> java.util.List<T>getPluginsForForeignSource(java.lang.Class<T> pluginClass, java.lang.String foreignSourceName)getPluginsForForeignSourceOnmsIpInterfacegetPrimaryInterfaceForNode(OnmsNode node)OnmsNodegetRequisitionedNode(java.lang.String foreignSource, java.lang.String foreignId)NodeScanSchedulegetScheduleForNode(int nodeId, boolean force)java.util.List<NodeScanSchedule>getScheduleForNodes()getScheduleForNodesjava.util.List<SnmpInterfacePolicy>getSnmpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)SnmpProfileMappergetSnmpProfileMapper()voidinsertNode(OnmsNode node)Insert the provided node into the databasebooleanisDiscoveryEnabled()isDiscoveryEnabledRequisitionloadRequisition(org.springframework.core.io.Resource resource)voidsetEventForwarder(EventForwarder eventForwarder)voidsetForeignSourceRepository(ForeignSourceRepository foreignSourceRepository)voidsetHostnameResolver(HostnameResolver resolver)voidsetIpInterfaceDao(IpInterfaceDao dao)OnmsIpInterfacesetIsPrimaryFlag(java.lang.Integer nodeId, java.lang.String ipAddress)voidsetMonitoredServiceDao(MonitoredServiceDao dao)voidsetMonitoringLocationDao(MonitoringLocationDao dao)voidsetNodeDao(NodeDao dao)voidsetNodeParentAndDependencies(java.lang.String foreignSource, java.lang.String foreignId, java.lang.String parentForeignSource, java.lang.String parentForeignId, java.lang.String parentNodeLabel)Sets the parent of the node and adds the relationship to the path element for the node.voidsetServiceTypeDao(ServiceTypeDao dao)voidsetSnmpInterfaceDao(SnmpInterfaceDao dao)voidsetSnmpProfileMapper(SnmpProfileMapper snmpProfileMapper)static voidsetTag(io.opentracing.Span span, java.lang.String name, java.lang.String value)voidsetTracer(io.opentracing.Tracer tracer)OnmsIpInterfaceupdateIpInterfaceAttributes(java.lang.Integer nodeId, OnmsIpInterface scannedIface)OnmsMonitoredServiceupdateMonitoredServiceState(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)voidupdateNode(OnmsNode node, java.lang.String rescanExisting)Update the database entry for the given node.OnmsNodeupdateNodeAttributes(OnmsNode node)voidupdateNodeScanStamp(java.lang.Integer nodeId, java.util.Date scanStamp)OnmsSnmpInterfaceupdateSnmpInterfaceAttributes(java.lang.Integer nodeId, OnmsSnmpInterface snmpInterface)
-
-
-
Field Detail
-
PROVISIOND
public static final java.lang.String PROVISIOND
- See Also:
- Constant Field Values
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
isDiscoveryEnabled
public boolean isDiscoveryEnabled()
isDiscoveryEnabled
- Specified by:
isDiscoveryEnabledin interfaceProvisionService- Returns:
- a boolean.
-
insertNode
@Transactional public void insertNode(OnmsNode node)
Insert the provided node into the database- Specified by:
insertNodein interfaceProvisionService
-
updateNode
@Transactional public void updateNode(OnmsNode node, java.lang.String rescanExisting)
Update the database entry for the given node. The node supplied is used to update the database. Entries that have been change in the node are copied into the database. It is assumed that the node passed in has been previously loaded from the database and modified.- Specified by:
updateNodein interfaceProvisionService- Parameters:
node- The node that has been updated and should be written to the databaserescanExisting- true, if the node must be rescanned. false, if the node should not be rescanned (perform only add/delete operations on the DB) dbonly, if the node should not be rescanned (perform all DB operations)
-
deleteNode
@Transactional public void deleteNode(java.lang.Integer nodeId)
Delete the indicated node from the database.- Specified by:
deleteNodein interfaceProvisionService
-
deleteInterface
@Transactional public void deleteInterface(java.lang.Integer nodeId, java.lang.String ipAddr)- Specified by:
deleteInterfacein interfaceProvisionService
-
deleteService
@Transactional public void deleteService(java.lang.Integer nodeId, java.net.InetAddress addr, java.lang.String svcName, boolean ignoreUnmanaged)Delete the indicated service from the database. If the service is the last service on the interface, delete the interface as well. If the interface is the last interface on the node, delete the node as well.- Specified by:
deleteServicein interfaceProvisionService- Parameters:
nodeId- the node containing the serviceaddr- the IP address containing the servicesvcName- the service to deleteignoreUnmanaged- if true, cascade delete the containing interface if only unmanaged services remain
-
updateIpInterfaceAttributes
@Transactional public OnmsIpInterface updateIpInterfaceAttributes(java.lang.Integer nodeId, OnmsIpInterface scannedIface)
- Specified by:
updateIpInterfaceAttributesin interfaceProvisionService
-
updateSnmpInterfaceAttributes
@Transactional public OnmsSnmpInterface updateSnmpInterfaceAttributes(java.lang.Integer nodeId, OnmsSnmpInterface snmpInterface)
- Specified by:
updateSnmpInterfaceAttributesin interfaceProvisionService
-
addMonitoredService
@Transactional public OnmsMonitoredService addMonitoredService(java.lang.Integer ipInterfaceId, java.lang.String svcName)
- Specified by:
addMonitoredServicein interfaceProvisionService
-
addMonitoredService
@Transactional public OnmsMonitoredService addMonitoredService(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)
- Specified by:
addMonitoredServicein interfaceProvisionService
-
updateMonitoredServiceState
@Transactional public OnmsMonitoredService updateMonitoredServiceState(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)
- Specified by:
updateMonitoredServiceStatein interfaceProvisionService
-
clearCache
@Transactional public void clearCache()
clearCache
- Specified by:
clearCachein interfaceProvisionService
-
createLocationIfNecessary
public OnmsMonitoringLocation createLocationIfNecessary(java.lang.String locationName)
Description copied from interface:ProvisionServiceLookup a monitoring location in the database, creating it if necessary. This method looks up theOnmsMonitoringLocationobject with the ID 'locationId' in the database and returns it. If there is noOnmsMonitoringLocationwith that name then one is created using the name provided, saved in the database, and returned.- Specified by:
createLocationIfNecessaryin interfaceProvisionService- Parameters:
locationName- The ID of theOnmsMonitoringLocationthat is needed- Returns:
- a new
OnmsMonitoringLocationthat will be saved to the database when the transaction is committed.
-
createLocationDefIfNecessary
protected OnmsMonitoringLocation createLocationDefIfNecessary(OnmsMonitoringLocation location)
-
getRequisitionedNode
@Transactional public OnmsNode getRequisitionedNode(java.lang.String foreignSource, java.lang.String foreignId) throws ForeignSourceRepositoryException
- Specified by:
getRequisitionedNodein interfaceProvisionService- Throws:
ForeignSourceRepositoryException
-
createServiceTypeIfNecessary
@Transactional public OnmsServiceType createServiceTypeIfNecessary(java.lang.String serviceName)
Look up the OnmsServiceType with the given name, creating one if it doesn't exist.- Specified by:
createServiceTypeIfNecessaryin interfaceProvisionService- Parameters:
serviceName- the name of the OnmsServiceType to look up- Returns:
- a OnmsServiceType object with the given name, if none existed in the database then a new one will been created and saved in the database.
-
createCategoryIfNecessary
@Transactional public OnmsCategory createCategoryIfNecessary(java.lang.String name)
Look up the OnmsCategory with the give name, creating one if none exists.- Specified by:
createCategoryIfNecessaryin interfaceProvisionService- Parameters:
name- the name of the OnmsCategory to look up- Returns:
- an OnmsCategory that represents the given name, if none existed in the database a new one will have been created.
-
getForeignIdToNodeIdMap
@Transactional(readOnly=true) public java.util.Map<java.lang.String,java.lang.Integer> getForeignIdToNodeIdMap(java.lang.String foreignSource)
Creates a map of foreignIds to nodeIds for all nodes that have the indicated foreignSorce.- Specified by:
getForeignIdToNodeIdMapin interfaceProvisionService
-
setNodeParentAndDependencies
@Transactional public void setNodeParentAndDependencies(java.lang.String foreignSource, java.lang.String foreignId, java.lang.String parentForeignSource, java.lang.String parentForeignId, java.lang.String parentNodeLabel)Sets the parent of the node and adds the relationship to the path element for the node. The foreignId is used to reference the node and the parentForeignId and the parentNodeLabel are used to locate the parentNodeId- Specified by:
setNodeParentAndDependenciesin interfaceProvisionService- Parameters:
foreignSource- the foreignSource to use when looking for the nodeId and parentNodeId by foreignId.foreignId- the foreignId for the node being setparentForeignId- the foreignId of the parent nodeparentNodeLabel- if the parent node cannot be found using its foreignId then an attempt to locate it using the its nodeLabel is made
-
getScheduleForNode
@Transactional(readOnly=true) public NodeScanSchedule getScheduleForNode(int nodeId, boolean force)
- Specified by:
getScheduleForNodein interfaceProvisionService
-
getScheduleForNodes
@Transactional(readOnly=true) public java.util.List<NodeScanSchedule> getScheduleForNodes()
getScheduleForNodes
- Specified by:
getScheduleForNodesin interfaceProvisionService- Returns:
- a
Listobject.
-
setForeignSourceRepository
public void setForeignSourceRepository(ForeignSourceRepository foreignSourceRepository)
- Specified by:
setForeignSourceRepositoryin interfaceProvisionService
-
getForeignSourceRepository
public ForeignSourceRepository getForeignSourceRepository()
getForeignSourceRepository
- Returns:
- a
ForeignSourceRepositoryobject.
-
loadRequisition
public Requisition loadRequisition(org.springframework.core.io.Resource resource)
- Specified by:
loadRequisitionin interfaceProvisionService
-
updateNodeAttributes
@Transactional public OnmsNode updateNodeAttributes(OnmsNode node)
- Specified by:
updateNodeAttributesin interfaceProvisionService
-
getCategoriesForNode
public java.util.Set<java.lang.String> getCategoriesForNode(OnmsNode node)
-
getDetectorsForForeignSource
public java.util.List<PluginConfig> getDetectorsForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getDetectorsForForeignSourcein interfaceProvisionService
-
getNodePoliciesForForeignSource
public java.util.List<NodePolicy> getNodePoliciesForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getNodePoliciesForForeignSourcein interfaceProvisionService
-
getIpInterfacePoliciesForForeignSource
public java.util.List<IpInterfacePolicy> getIpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getIpInterfacePoliciesForForeignSourcein interfaceProvisionService
-
getSnmpInterfacePoliciesForForeignSource
public java.util.List<SnmpInterfacePolicy> getSnmpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getSnmpInterfacePoliciesForForeignSourcein interfaceProvisionService
-
getPluginsForForeignSource
public <T> java.util.List<T> getPluginsForForeignSource(java.lang.Class<T> pluginClass, java.lang.String foreignSourceName)getPluginsForForeignSource
- Type Parameters:
T- a T object.- Parameters:
pluginClass- aClassobject.foreignSourceName- aStringobject.- Returns:
- a
Listobject.
-
deleteObsoleteInterfaces
@Transactional public void deleteObsoleteInterfaces(java.lang.Integer nodeId, java.util.Date scanStamp)- Specified by:
deleteObsoleteInterfacesin interfaceProvisionService
-
updateNodeScanStamp
@Transactional public void updateNodeScanStamp(java.lang.Integer nodeId, java.util.Date scanStamp)- Specified by:
updateNodeScanStampin interfaceProvisionService
-
setIsPrimaryFlag
@Transactional public OnmsIpInterface setIsPrimaryFlag(java.lang.Integer nodeId, java.lang.String ipAddress)
- Specified by:
setIsPrimaryFlagin interfaceProvisionService
-
getPrimaryInterfaceForNode
@Transactional public OnmsIpInterface getPrimaryInterfaceForNode(OnmsNode node)
- Specified by:
getPrimaryInterfaceForNodein interfaceProvisionService
-
createUndiscoveredNode
@Transactional public OnmsNode createUndiscoveredNode(java.lang.String ipAddress, java.lang.String foreignSource, java.lang.String locationString)
- Specified by:
createUndiscoveredNodein interfaceProvisionService
-
getNode
@Transactional public OnmsNode getNode(java.lang.Integer nodeId)
- Specified by:
getNodein interfaceProvisionService
-
getDbNodeInitCat
@Transactional public OnmsNode getDbNodeInitCat(java.lang.Integer nodeId)
- Specified by:
getDbNodeInitCatin interfaceProvisionService
-
setHostnameResolver
public void setHostnameResolver(HostnameResolver resolver)
- Specified by:
setHostnameResolverin interfaceProvisionService
-
getHostnameResolver
public HostnameResolver getHostnameResolver()
- Specified by:
getHostnameResolverin interfaceProvisionService
-
getLocationAwareDetectorClient
public LocationAwareDetectorClient getLocationAwareDetectorClient()
- Specified by:
getLocationAwareDetectorClientin interfaceProvisionService
-
getLocationAwareSnmpClient
public LocationAwareSnmpClient getLocationAwareSnmpClient()
- Specified by:
getLocationAwareSnmpClientin interfaceProvisionService
-
getSnmpProfileMapper
public SnmpProfileMapper getSnmpProfileMapper()
- Specified by:
getSnmpProfileMapperin interfaceProvisionService
-
setSnmpProfileMapper
public void setSnmpProfileMapper(SnmpProfileMapper snmpProfileMapper)
- Specified by:
setSnmpProfileMapperin interfaceProvisionService
-
setTracer
public void setTracer(io.opentracing.Tracer tracer)
- Specified by:
setTracerin interfaceProvisionService
-
getLocationAwareDnsLookupClient
public LocationAwareDnsLookupClient getLocationAwareDnsLookupClient()
- Specified by:
getLocationAwareDnsLookupClientin interfaceProvisionService
-
setMonitoringLocationDao
public void setMonitoringLocationDao(MonitoringLocationDao dao)
-
setNodeDao
public void setNodeDao(NodeDao dao)
-
setIpInterfaceDao
public void setIpInterfaceDao(IpInterfaceDao dao)
-
setSnmpInterfaceDao
public void setSnmpInterfaceDao(SnmpInterfaceDao dao)
-
setMonitoredServiceDao
public void setMonitoredServiceDao(MonitoredServiceDao dao)
-
setServiceTypeDao
public void setServiceTypeDao(ServiceTypeDao dao)
-
setEventForwarder
public void setEventForwarder(EventForwarder eventForwarder)
-
buildAndStartSpan
public io.opentracing.Span buildAndStartSpan(java.lang.String name, io.opentracing.SpanContext spanContext)- Specified by:
buildAndStartSpanin interfaceProvisionService
-
setTag
public static void setTag(io.opentracing.Span span, java.lang.String name, java.lang.String value)
-
-