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 Object implements ProvisionService, org.springframework.beans.factory.InitializingBean
DefaultProvisionService- Version:
- $Id: $
- Author:
- brozow
-
-
Field Summary
Fields Modifier and Type Field Description static 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
-
-
-
Field Detail
-
PROVISIOND
public static final String PROVISIOND
- See Also:
- Constant Field Values
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
isDiscoveryEnabled
public boolean isDiscoveryEnabled()
isDiscoveryEnabled
- Specified by:
isDiscoveryEnabled
in interfaceProvisionService
- Returns:
- a boolean.
-
insertNode
@Transactional public void insertNode(OnmsNode node, String monitorKey)
Insert the provided node into the database- Specified by:
insertNode
in interfaceProvisionService
-
updateNode
@Transactional public void updateNode(OnmsNode node, String rescanExisting, String monitorKey)
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(Integer nodeId)
Delete the indicated node from the database.- Specified by:
deleteNode
in interfaceProvisionService
-
deleteInterface
@Transactional public void deleteInterface(Integer nodeId, String ipAddr)
- Specified by:
deleteInterface
in interfaceProvisionService
-
deleteService
@Transactional public void deleteService(Integer nodeId, InetAddress addr, 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(Integer nodeId, OnmsIpInterface scannedIface, String monitorKey)
- Specified by:
updateIpInterfaceAttributes
in interfaceProvisionService
-
updateSnmpInterfaceAttributes
@Transactional public OnmsSnmpInterface updateSnmpInterfaceAttributes(Integer nodeId, OnmsSnmpInterface snmpInterface)
- Specified by:
updateSnmpInterfaceAttributes
in interfaceProvisionService
-
addMonitoredService
@Transactional public OnmsMonitoredService addMonitoredService(Integer ipInterfaceId, String svcName, String monitorKey)
- Specified by:
addMonitoredService
in interfaceProvisionService
-
addMonitoredService
@Transactional public OnmsMonitoredService addMonitoredService(Integer nodeId, String ipAddress, String svcName, String monitorKey)
- Specified by:
addMonitoredService
in interfaceProvisionService
-
updateMonitoredServiceState
@Transactional public OnmsMonitoredService updateMonitoredServiceState(Integer nodeId, String ipAddress, String svcName)
- Specified by:
updateMonitoredServiceState
in interfaceProvisionService
-
clearCache
@Transactional public void clearCache()
clearCache
- Specified by:
clearCache
in interfaceProvisionService
-
createLocationIfNecessary
public OnmsMonitoringLocation createLocationIfNecessary(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(String foreignSource, String foreignId) throws ForeignSourceRepositoryException
- Specified by:
getRequisitionedNode
in interfaceProvisionService
- Throws:
ForeignSourceRepositoryException
-
createServiceTypeIfNecessary
@Transactional public OnmsServiceType createServiceTypeIfNecessary(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(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 Map<String,Integer> getForeignIdToNodeIdMap(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(String foreignSource, String foreignId, String parentForeignSource, String parentForeignId, 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, String monitorKey)
- Specified by:
getScheduleForNode
in interfaceProvisionService
-
getScheduleForNodes
@Transactional(readOnly=true) public List<NodeScanSchedule> getScheduleForNodes(String monitorKey)
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
-
getDetectorsForForeignSource
public List<PluginConfig> getDetectorsForForeignSource(String foreignSourceName)
- Specified by:
getDetectorsForForeignSource
in interfaceProvisionService
-
getNodePoliciesForForeignSource
public List<NodePolicy> getNodePoliciesForForeignSource(String foreignSourceName)
- Specified by:
getNodePoliciesForForeignSource
in interfaceProvisionService
-
getIpInterfacePoliciesForForeignSource
public List<IpInterfacePolicy> getIpInterfacePoliciesForForeignSource(String foreignSourceName)
- Specified by:
getIpInterfacePoliciesForForeignSource
in interfaceProvisionService
-
getSnmpInterfacePoliciesForForeignSource
public List<SnmpInterfacePolicy> getSnmpInterfacePoliciesForForeignSource(String foreignSourceName)
- Specified by:
getSnmpInterfacePoliciesForForeignSource
in interfaceProvisionService
-
getPluginsForForeignSource
public <T> List<T> getPluginsForForeignSource(Class<T> pluginClass, String foreignSourceName)
getPluginsForForeignSource
-
deleteObsoleteInterfaces
@Transactional public void deleteObsoleteInterfaces(Integer nodeId, Date scanStamp)
- Specified by:
deleteObsoleteInterfaces
in interfaceProvisionService
-
updateNodeScanStamp
@Transactional public void updateNodeScanStamp(Integer nodeId, Date scanStamp)
- Specified by:
updateNodeScanStamp
in interfaceProvisionService
-
setIsPrimaryFlag
@Transactional public OnmsIpInterface setIsPrimaryFlag(Integer nodeId, String ipAddress)
- Specified by:
setIsPrimaryFlag
in interfaceProvisionService
-
getPrimaryInterfaceForNode
@Transactional public OnmsIpInterface getPrimaryInterfaceForNode(OnmsNode node)
- Specified by:
getPrimaryInterfaceForNode
in interfaceProvisionService
-
createUndiscoveredNode
@Transactional public OnmsNode createUndiscoveredNode(String ipAddress, String foreignSource, String locationString, String monitorKey)
- Specified by:
createUndiscoveredNode
in interfaceProvisionService
-
getNode
@Transactional public OnmsNode getNode(Integer nodeId)
- Specified by:
getNode
in interfaceProvisionService
-
getDbNodeInitCat
@Transactional public OnmsNode getDbNodeInitCat(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(String name, io.opentracing.SpanContext spanContext)
- Specified by:
buildAndStartSpan
in interfaceProvisionService
-
-