Search in sources :

Example 1 with SystemDefinition

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));
}
Also used : SystemDefinition(org.opennms.netmgt.config.wsman.SystemDefinition) OnmsNode(org.opennms.netmgt.model.OnmsNode) SystemDefinition(org.opennms.netmgt.config.wsman.SystemDefinition) Definition(org.opennms.netmgt.config.wsman.Definition) CollectionAgent(org.opennms.netmgt.collection.api.CollectionAgent) Test(org.junit.Test)

Example 2 with SystemDefinition

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;
    }
}
Also used : SystemDefinition(org.opennms.netmgt.config.wsman.SystemDefinition)

Example 3 with SystemDefinition

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;
}
Also used : SystemDefinition(org.opennms.netmgt.config.wsman.SystemDefinition) Group(org.opennms.netmgt.config.wsman.Group)

Aggregations

SystemDefinition (org.opennms.netmgt.config.wsman.SystemDefinition)3 Test (org.junit.Test)1 CollectionAgent (org.opennms.netmgt.collection.api.CollectionAgent)1 Definition (org.opennms.netmgt.config.wsman.Definition)1 Group (org.opennms.netmgt.config.wsman.Group)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1