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.String
PROVISIOND
-
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 OnmsMonitoredService
addMonitoredService(java.lang.Integer ipInterfaceId, java.lang.String svcName)
OnmsMonitoredService
addMonitoredService(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)
void
afterPropertiesSet()
io.opentracing.Span
buildAndStartSpan(java.lang.String name, io.opentracing.SpanContext spanContext)
void
clearCache()
clearCacheOnmsCategory
createCategoryIfNecessary(java.lang.String name)
Look up the OnmsCategory with the give name, creating one if none exists.protected OnmsMonitoringLocation
createLocationDefIfNecessary(OnmsMonitoringLocation location)
OnmsMonitoringLocation
createLocationIfNecessary(java.lang.String locationName)
Lookup a monitoring location in the database, creating it if necessary.OnmsServiceType
createServiceTypeIfNecessary(java.lang.String serviceName)
Look up the OnmsServiceType with the given name, creating one if it doesn't exist.OnmsNode
createUndiscoveredNode(java.lang.String ipAddress, java.lang.String foreignSource, java.lang.String locationString)
void
deleteInterface(java.lang.Integer nodeId, java.lang.String ipAddr)
void
deleteNode(java.lang.Integer nodeId)
Delete the indicated node from the database.void
deleteObsoleteInterfaces(java.lang.Integer nodeId, java.util.Date scanStamp)
void
deleteService(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)
OnmsNode
getDbNodeInitCat(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.ForeignSourceRepository
getForeignSourceRepository()
getForeignSourceRepositoryHostnameResolver
getHostnameResolver()
java.util.List<IpInterfacePolicy>
getIpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)
LocationAwareDetectorClient
getLocationAwareDetectorClient()
LocationAwareDnsLookupClient
getLocationAwareDnsLookupClient()
LocationAwareSnmpClient
getLocationAwareSnmpClient()
OnmsNode
getNode(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)
getPluginsForForeignSourceOnmsIpInterface
getPrimaryInterfaceForNode(OnmsNode node)
OnmsNode
getRequisitionedNode(java.lang.String foreignSource, java.lang.String foreignId)
NodeScanSchedule
getScheduleForNode(int nodeId, boolean force)
java.util.List<NodeScanSchedule>
getScheduleForNodes()
getScheduleForNodesjava.util.List<SnmpInterfacePolicy>
getSnmpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)
SnmpProfileMapper
getSnmpProfileMapper()
void
insertNode(OnmsNode node)
Insert the provided node into the databaseboolean
isDiscoveryEnabled()
isDiscoveryEnabledRequisition
loadRequisition(org.springframework.core.io.Resource resource)
void
setEventForwarder(EventForwarder eventForwarder)
void
setForeignSourceRepository(ForeignSourceRepository foreignSourceRepository)
void
setHostnameResolver(HostnameResolver resolver)
void
setIpInterfaceDao(IpInterfaceDao dao)
OnmsIpInterface
setIsPrimaryFlag(java.lang.Integer nodeId, java.lang.String ipAddress)
void
setMonitoredServiceDao(MonitoredServiceDao dao)
void
setMonitoringLocationDao(MonitoringLocationDao dao)
void
setNodeDao(NodeDao dao)
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.void
setServiceTypeDao(ServiceTypeDao dao)
void
setSnmpInterfaceDao(SnmpInterfaceDao dao)
void
setSnmpProfileMapper(SnmpProfileMapper snmpProfileMapper)
static void
setTag(io.opentracing.Span span, java.lang.String name, java.lang.String value)
void
setTracer(io.opentracing.Tracer tracer)
OnmsIpInterface
updateIpInterfaceAttributes(java.lang.Integer nodeId, OnmsIpInterface scannedIface)
OnmsMonitoredService
updateMonitoredServiceState(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)
void
updateNode(OnmsNode node, java.lang.String rescanExisting)
Update the database entry for the given node.OnmsNode
updateNodeAttributes(OnmsNode node)
void
updateNodeScanStamp(java.lang.Integer nodeId, java.util.Date scanStamp)
OnmsSnmpInterface
updateSnmpInterfaceAttributes(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:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
java.lang.Exception
-
isDiscoveryEnabled
public boolean isDiscoveryEnabled()
isDiscoveryEnabled
- Specified by:
isDiscoveryEnabled
in interfaceProvisionService
- Returns:
- a boolean.
-
insertNode
@Transactional public void insertNode(OnmsNode node)
Insert the provided node into the database- Specified by:
insertNode
in 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:
updateNode
in 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:
deleteNode
in interfaceProvisionService
-
deleteInterface
@Transactional public void deleteInterface(java.lang.Integer nodeId, java.lang.String ipAddr)
- Specified by:
deleteInterface
in 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:
deleteService
in 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:
updateIpInterfaceAttributes
in interfaceProvisionService
-
updateSnmpInterfaceAttributes
@Transactional public OnmsSnmpInterface updateSnmpInterfaceAttributes(java.lang.Integer nodeId, OnmsSnmpInterface snmpInterface)
- Specified by:
updateSnmpInterfaceAttributes
in interfaceProvisionService
-
addMonitoredService
@Transactional public OnmsMonitoredService addMonitoredService(java.lang.Integer ipInterfaceId, java.lang.String svcName)
- Specified by:
addMonitoredService
in interfaceProvisionService
-
addMonitoredService
@Transactional public OnmsMonitoredService addMonitoredService(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)
- Specified by:
addMonitoredService
in interfaceProvisionService
-
updateMonitoredServiceState
@Transactional public OnmsMonitoredService updateMonitoredServiceState(java.lang.Integer nodeId, java.lang.String ipAddress, java.lang.String svcName)
- Specified by:
updateMonitoredServiceState
in interfaceProvisionService
-
clearCache
@Transactional public void clearCache()
clearCache
- Specified by:
clearCache
in interfaceProvisionService
-
createLocationIfNecessary
public OnmsMonitoringLocation createLocationIfNecessary(java.lang.String locationName)
Description copied from interface:ProvisionService
Lookup a monitoring location in the database, creating it if necessary. This method looks up theOnmsMonitoringLocation
object with the ID 'locationId' in the database and returns it. If there is noOnmsMonitoringLocation
with that name then one is created using the name provided, saved in the database, and returned.- Specified by:
createLocationIfNecessary
in interfaceProvisionService
- Parameters:
locationName
- The ID of theOnmsMonitoringLocation
that is needed- Returns:
- a new
OnmsMonitoringLocation
that 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:
getRequisitionedNode
in 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:
createServiceTypeIfNecessary
in 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:
createCategoryIfNecessary
in 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:
getForeignIdToNodeIdMap
in 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:
setNodeParentAndDependencies
in 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:
getScheduleForNode
in interfaceProvisionService
-
getScheduleForNodes
@Transactional(readOnly=true) public java.util.List<NodeScanSchedule> getScheduleForNodes()
getScheduleForNodes
- Specified by:
getScheduleForNodes
in interfaceProvisionService
- Returns:
- a
List
object.
-
setForeignSourceRepository
public void setForeignSourceRepository(ForeignSourceRepository foreignSourceRepository)
- Specified by:
setForeignSourceRepository
in interfaceProvisionService
-
getForeignSourceRepository
public ForeignSourceRepository getForeignSourceRepository()
getForeignSourceRepository
- Returns:
- a
ForeignSourceRepository
object.
-
loadRequisition
public Requisition loadRequisition(org.springframework.core.io.Resource resource)
- Specified by:
loadRequisition
in interfaceProvisionService
-
updateNodeAttributes
@Transactional public OnmsNode updateNodeAttributes(OnmsNode node)
- Specified by:
updateNodeAttributes
in 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:
getDetectorsForForeignSource
in interfaceProvisionService
-
getNodePoliciesForForeignSource
public java.util.List<NodePolicy> getNodePoliciesForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getNodePoliciesForForeignSource
in interfaceProvisionService
-
getIpInterfacePoliciesForForeignSource
public java.util.List<IpInterfacePolicy> getIpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getIpInterfacePoliciesForForeignSource
in interfaceProvisionService
-
getSnmpInterfacePoliciesForForeignSource
public java.util.List<SnmpInterfacePolicy> getSnmpInterfacePoliciesForForeignSource(java.lang.String foreignSourceName)
- Specified by:
getSnmpInterfacePoliciesForForeignSource
in 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
- aClass
object.foreignSourceName
- aString
object.- Returns:
- a
List
object.
-
deleteObsoleteInterfaces
@Transactional public void deleteObsoleteInterfaces(java.lang.Integer nodeId, java.util.Date scanStamp)
- Specified by:
deleteObsoleteInterfaces
in interfaceProvisionService
-
updateNodeScanStamp
@Transactional public void updateNodeScanStamp(java.lang.Integer nodeId, java.util.Date scanStamp)
- Specified by:
updateNodeScanStamp
in interfaceProvisionService
-
setIsPrimaryFlag
@Transactional public OnmsIpInterface setIsPrimaryFlag(java.lang.Integer nodeId, java.lang.String ipAddress)
- Specified by:
setIsPrimaryFlag
in interfaceProvisionService
-
getPrimaryInterfaceForNode
@Transactional public OnmsIpInterface getPrimaryInterfaceForNode(OnmsNode node)
- Specified by:
getPrimaryInterfaceForNode
in interfaceProvisionService
-
createUndiscoveredNode
@Transactional public OnmsNode createUndiscoveredNode(java.lang.String ipAddress, java.lang.String foreignSource, java.lang.String locationString)
- Specified by:
createUndiscoveredNode
in interfaceProvisionService
-
getNode
@Transactional public OnmsNode getNode(java.lang.Integer nodeId)
- Specified by:
getNode
in interfaceProvisionService
-
getDbNodeInitCat
@Transactional public OnmsNode getDbNodeInitCat(java.lang.Integer nodeId)
- Specified by:
getDbNodeInitCat
in interfaceProvisionService
-
setHostnameResolver
public void setHostnameResolver(HostnameResolver resolver)
- Specified by:
setHostnameResolver
in interfaceProvisionService
-
getHostnameResolver
public HostnameResolver getHostnameResolver()
- Specified by:
getHostnameResolver
in interfaceProvisionService
-
getLocationAwareDetectorClient
public LocationAwareDetectorClient getLocationAwareDetectorClient()
- Specified by:
getLocationAwareDetectorClient
in interfaceProvisionService
-
getLocationAwareSnmpClient
public LocationAwareSnmpClient getLocationAwareSnmpClient()
- Specified by:
getLocationAwareSnmpClient
in interfaceProvisionService
-
getSnmpProfileMapper
public SnmpProfileMapper getSnmpProfileMapper()
- Specified by:
getSnmpProfileMapper
in interfaceProvisionService
-
setSnmpProfileMapper
public void setSnmpProfileMapper(SnmpProfileMapper snmpProfileMapper)
- Specified by:
setSnmpProfileMapper
in interfaceProvisionService
-
setTracer
public void setTracer(io.opentracing.Tracer tracer)
- Specified by:
setTracer
in interfaceProvisionService
-
getLocationAwareDnsLookupClient
public LocationAwareDnsLookupClient getLocationAwareDnsLookupClient()
- Specified by:
getLocationAwareDnsLookupClient
in 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:
buildAndStartSpan
in interfaceProvisionService
-
setTag
public static void setTag(io.opentracing.Span span, java.lang.String name, java.lang.String value)
-
-