system.sendOsaPing: send a ping using to a system using osa (like "Ping System" in the webinterface)
system.getOsaPing: get details about the status of a system, the time of the last received response and the time of the last sent ping (like "OSA Status" in the webinterface) Signed-off-by: Christian Berendt <bere...@b1-systems.de> --- .../rhn/frontend/xmlrpc/system/SystemHandler.java | 66 ++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-) diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java index 8ddfc3d..f8d12a4 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java @@ -4939,4 +4939,70 @@ public class SystemHandler extends BaseHandler { ServerFactory.removeTagFromSnapshot(server.getId(), tag); return 1; } + + /** + * send a ping to a system using OSA + * @param sessionKey the session key + * @param serverId server id + * @return 1 on success, exception thrown otherwise. + * + * @xmlrpc.doc send a ping to a system using OSA + * @xmlrpc.param #param("string", "sessionKey") + * @xmlrpc.param #param("int", "serverId") + * @xmlrpc.returntype #return_int_success() + */ + public int sendOsaPing(String sessionKey, Integer serverId) { + User loggedInUser = getLoggedInUser(sessionKey); + Server server = lookupServer(loggedInUser, serverId); + server.getPushClient().setLastPingTime(new Date(System.currentTimeMillis())); + server.getPushClient().setNextActionTime(null); + SystemManager.storeServer(server); + return 1; + } + + /** + * get details about a ping sent to a system using OSA + * @param sessionKey the session key + * @param serverId server id + * @return details about a ping sent to a system using OSA + * + * @xmlrpc.doc get details about a ping sent to a system using OSA + * @xmlrpc.param #param("string", "sessionKey") + * @xmlrpc.param #param("int", "serverId") + * @xmlrpc.returntype + * #struct("osaPing") + * #prop_desc("String" "state" "state of the system (unknown, online, offline)") + * #prop_desc("dateTime.iso8601" "lastMessageTime" "time of the last received response (1970/01/01 00:00:00 if never received a response)") + * #prop_desc("dateTime.iso8601" "lastPingTime" "time of the last sent ping (1970/01/01 00:00:00 if no ping is pending") + * #struct_end() + */ + public Map getOsaPing(String sessionKey, Integer serverId) { + User loggedInUser = getLoggedInUser(sessionKey); + Server server = lookupServer(loggedInUser, serverId); + Map m = new HashMap(); + if(server.getPushClient() != null) { + if(server.getPushClient().getState().getName() == null) { + m.put("state", "unknown"); + } else { + m.put("state", server.getPushClient().getState().getName()); + } + + if(server.getPushClient().getLastMessageTime() == null) { + m.put("lastMessageTime", new Date(0)); + } else { + m.put("lastMessageTime", server.getPushClient().getLastMessageTime()); + } + + if(server.getPushClient().getLastPingTime() == null) { + m.put("lastPingTime", new Date(0)); + } else { + m.put("lastPingTime", server.getPushClient().getLastPingTime()); + } + } else { + m.put("state", "unknown"); + m.put("lastMessageTime", new Date(0)); + m.put("lastPingTime", new Date(0)); + } + return m; + } } -- 1.7.1 _______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel