Search in sources :

Example 1 with DetectResultsImpl

use of org.opennms.netmgt.provision.support.DetectResultsImpl in project opennms by OpenNMS.

the class WsManDetector method isServiceDetected.

public DetectResults isServiceDetected(InetAddress address, WSManEndpoint endpoint) {
    // Issue the "Identify" request
    final WSManClient client = m_factory.getClient(endpoint);
    Identity identity = null;
    final Map<String, String> attributes = new HashMap<>();
    try {
        identity = client.identify();
        LOG.info("Identify succeeded for address {} with product vendor '{}' and product version '{}'.", address, identity.getProductVendor(), identity.getProductVersion());
        attributes.put(UPDATE_ASSETS, Boolean.toString(m_updateAssets));
        attributes.put(PRODUCT_VENDOR, identity.getProductVendor());
        attributes.put(PRODUCT_VERSION, identity.getProductVersion());
    } catch (WSManException e) {
        LOG.info("Identify failed for address {} with endpoint {}.", address, endpoint, e);
    }
    return new DetectResultsImpl(identity != null, attributes);
}
Also used : WSManException(org.opennms.core.wsman.exceptions.WSManException) HashMap(java.util.HashMap) WSManClient(org.opennms.core.wsman.WSManClient) Identity(org.opennms.core.wsman.Identity) DetectResultsImpl(org.opennms.netmgt.provision.support.DetectResultsImpl)

Example 2 with DetectResultsImpl

use of org.opennms.netmgt.provision.support.DetectResultsImpl in project opennms by OpenNMS.

the class XmpDetector method detect.

@Override
public final DetectResults detect(DetectRequest request) {
    final InetAddress address = request.getAddress();
    XmpSession aSession;
    XmpMessage aReply;
    XmpVar[] vars, replyVars;
    LOG.debug("XmpDetector: isServiceDetected starting to query " + address);
    // try to establish session
    aSession = new XmpSession(sockopts, address, xmpPort, xmpAuthenUser);
    if (aSession.isClosed()) {
        LOG.debug("XmpDetector: null session to " + address);
        return new DetectResultsImpl(false);
    }
    LOG.debug("XmpDetector: isServiceDetected session established with " + address);
    // query for core.sysName, core.sysDescr,
    // core.sysUpTime, core.xmpdVersion
    vars = new XmpVar[] { new XmpVar("core", "sysName", "", "", Xmp.SYNTAX_NULLSYNTAX), new XmpVar("core", "sysDescr", "", "", Xmp.SYNTAX_NULLSYNTAX), new XmpVar("core", "sysUpTime", "", "", Xmp.SYNTAX_NULLSYNTAX), new XmpVar("core", "xmpdVersion", "", "", Xmp.SYNTAX_NULLSYNTAX) };
    if ((aReply = aSession.queryVars(vars)) == null) {
        LOG.debug("XmpDetector: isServiceDetected no vars from " + address);
        aSession.closeSession();
        return new DetectResultsImpl(false);
    }
    aSession.closeSession();
    // log what we retrieved
    if ((replyVars = aReply.getMIBVars()) == null) {
        LOG.debug("XmpDetector: isServiceDetected no replyVars for " + address);
        return new DetectResultsImpl(false);
    }
    /* if replyVars == null */
    LOG.debug("XmpDetector: isServiceDetected " + address + " reports " + replyVars[0].getValue() + "," + replyVars[1].getValue());
    LOG.debug("XmpDetector: isServiceDetected true for " + address);
    return new DetectResultsImpl(true);
}
Also used : XmpVar(org.krupczak.xmp.XmpVar) XmpSession(org.krupczak.xmp.XmpSession) XmpMessage(org.krupczak.xmp.XmpMessage) DetectResultsImpl(org.opennms.netmgt.provision.support.DetectResultsImpl) InetAddress(java.net.InetAddress)

Aggregations

DetectResultsImpl (org.opennms.netmgt.provision.support.DetectResultsImpl)2 InetAddress (java.net.InetAddress)1 HashMap (java.util.HashMap)1 XmpMessage (org.krupczak.xmp.XmpMessage)1 XmpSession (org.krupczak.xmp.XmpSession)1 XmpVar (org.krupczak.xmp.XmpVar)1 Identity (org.opennms.core.wsman.Identity)1 WSManClient (org.opennms.core.wsman.WSManClient)1 WSManException (org.opennms.core.wsman.exceptions.WSManException)1