use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class WsManCollector method getRuntimeAttributes.
@Override
public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) {
final Map<String, Object> runtimeAttributes = new HashMap<>();
final String collectionName = ParameterMap.getKeyedString(parameters, "collection", null);
if (collectionName == null) {
throw new IllegalArgumentException("Collector configuration does not include the required 'collection' parameter.");
}
final Collection collection = m_wsManDataCollectionConfigDao.getCollectionByName(collectionName);
if (collection == null) {
throw new IllegalArgumentException("No collection found with name: " + collectionName);
}
final OnmsNode node = m_nodeDao.get(agent.getNodeId());
if (node == null) {
throw new IllegalArgumentException("Could not find node with id: " + agent.getNodeId());
}
final Definition agentConfig = m_wsManConfigDao.getAgentConfig(agent.getAddress());
final Groups groups = new Groups(m_wsManDataCollectionConfigDao.getGroupsForAgent(collection, agent, agentConfig, node));
runtimeAttributes.put(WSMAN_AGENT_CONFIG_KEY, agentConfig);
runtimeAttributes.put(WSMAN_GROUPS_KEY, groups);
return runtimeAttributes;
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class DnsProvisioningAdapter method createDnsRecordMap.
private void createDnsRecordMap() {
List<OnmsNode> nodes = m_nodeDao.findAllProvisionedNodes();
m_nodeDnsRecordMap = new ConcurrentHashMap<Integer, DnsRecord>(nodes.size());
for (OnmsNode onmsNode : nodes) {
m_nodeDnsRecordMap.putIfAbsent(onmsNode.getId(), new DnsRecord(onmsNode, m_level));
}
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class DnsProvisioningAdapter method doUpdate.
private void doUpdate(AdapterOperation op) {
OnmsNode node = null;
LOG.debug("doUpdate: operation: {}", op.getType().name());
try {
node = m_nodeDao.get(op.getNodeId());
if (node == null) {
doDelete(op);
return;
}
DnsRecord record = new DnsRecord(node, m_level);
LOG.debug("doUpdate: DnsRecord: hostname: {} zone: {} ip address {}", record.getIp().getHostAddress(), record.getHostname(), record.getZone());
DnsRecord oldRecord = m_nodeDnsRecordMap.get(Integer.valueOf(node.getId()));
Update update = new Update(Name.fromString(record.getZone()));
if (oldRecord != null && oldRecord.getHostname() != record.getHostname()) {
update.delete(Name.fromString(oldRecord.getHostname()), Type.A);
}
update.replace(Name.fromString(record.getHostname()), Type.A, 3600, record.getIp().getHostAddress());
m_resolver.send(update);
m_nodeDnsRecordMap.put(Integer.valueOf(op.getNodeId()), record);
} catch (Throwable e) {
LOG.error("addNode: Error handling node added event.", e);
sendAndThrow(op.getNodeId(), e);
}
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class WSManDataCollectionConfigDaoJaxbTest method canEvaluteSystemDefinitionRules.
@Test
public void canEvaluteSystemDefinitionRules() throws UnknownHostException {
OnmsNode node = mock(OnmsNode.class);
CollectionAgent agent = mock(CollectionAgent.class);
Definition config = new Definition();
config.setProductVendor("Dell Inc.");
config.setProductVersion(" iDRAC 6");
SystemDefinition sysDef = new SystemDefinition();
sysDef.addRule("#productVendor matches 'Dell.*' and #productVersion matches '.*DRAC.*'");
assertTrue("agent should be matched", WSManDataCollectionConfigDaoJaxb.isAgentSupportedBySystemDefinition(sysDef, agent, config, node));
}
use of org.opennms.netmgt.model.OnmsNode in project opennms by OpenNMS.
the class HibernateCriteriaConverterIT method testDistinctQuery.
@Test
@JUnitTemporaryDatabase
public void testDistinctQuery() {
List<OnmsNode> nodes = null;
final CriteriaBuilder cb = new CriteriaBuilder(OnmsNode.class);
cb.isNotNull("id").distinct();
cb.eq("label", "node1").join("ipInterfaces", "ipInterface", JoinType.LEFT_JOIN).eq("ipInterface.ipAddress", "192.168.1.1");
nodes = m_nodeDao.findMatching(cb.toCriteria());
assertEquals(1, nodes.size());
assertEquals(Integer.valueOf(1), nodes.get(0).getId());
}
Aggregations