Hello Christian, I have 2 comments to your patch:
* you do not handle situations, when ( server.getPushClient() == null ) in sendOsaPing method - thrown exception is good in these cases (I do not mean a NullPointerException :)
* in case the required time isn't available, I rather wouldn't return lastMessageTime or lastPingTime within the structure at all than to return new Date(0)
Otherwise the patch looks good and I'll be happy to commit it, when at least the 1st situation is solved. Those few checkstyle issues I'll handle for you.
Regards, Tomas -- Tomas Lestach RHN Satellite Engineering, Red Hat On 10/29/2011 11:31 PM, Christian Berendt wrote:
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; + } }
_______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel