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);
}
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);
}
Aggregations