use of org.opennms.netmgt.config.wsman.SystemDefinition 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.config.wsman.SystemDefinition in project opennms by OpenNMS.
the class WSManDataCollectionConfigDaoJaxb method getSystemDefinitionsForCollection.
public List<SystemDefinition> getSystemDefinitionsForCollection(Collection collection) {
if (collection.getIncludeAllSystemDefinitions() != null) {
// Return all available system definitions if requested
return getConfig().getSystemDefinition();
} else {
// Map all of the available system definitions by name for easy lookup
final Map<String, SystemDefinition> sysDefsByName = Maps.uniqueIndex(getConfig().getSystemDefinition(), SystemDefinition::getName);
// Gather the requested system definitions
final List<SystemDefinition> sysDefs = Lists.newArrayList();
for (String sysDefName : collection.getIncludeSystemDefinition()) {
SystemDefinition sysDef = sysDefsByName.get(sysDefName);
if (sysDef == null) {
LOG.warn("Collection with name {} includes system definition with name {}, but no such definition was found.", collection.getName(), sysDefName);
continue;
}
sysDefs.add(sysDef);
}
return sysDefs;
}
}
use of org.opennms.netmgt.config.wsman.SystemDefinition in project opennms by OpenNMS.
the class WSManDataCollectionConfigDaoJaxb method getGroupsForAgent.
@Override
public List<Group> getGroupsForAgent(Collection collection, CollectionAgent agent, WsmanAgentConfig agentConfig, OnmsNode node) {
// Fetch the system definitions for the given collection
List<SystemDefinition> sysDefs = getSystemDefinitionsForCollection(collection);
// Map all of the available groups by name for easy lookup
final Map<String, Group> groupsByName = Maps.uniqueIndex(getConfig().getGroup(), Group::getName);
// Gather the groups from all of the supported system definitions
final List<Group> groups = Lists.newArrayList();
for (SystemDefinition sysDef : sysDefs) {
if (isAgentSupportedBySystemDefinition(sysDef, agent, agentConfig, node)) {
for (String groupName : sysDef.getIncludeGroup()) {
Group group = groupsByName.get(groupName);
if (group == null) {
LOG.warn("System definition with name {} includes group with name {}, " + "but no such group was found.", sysDef.getName(), groupName);
continue;
}
groups.add(group);
}
}
}
return groups;
}
Aggregations