From 6465ba23327fbcfd67be4b07750cca496f930859 Mon Sep 17 00:00:00 2001 From: Ryan Morgan Date: Tue, 4 May 2010 10:54:16 -0700 Subject: [PATCH] [HHQ-3960] Allow filtering of alert definitions by priority. --- ChangeLog | 2 ++ .../hq/hqapi1/tools/AlertDefinitionCommand.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6a5d64ae..05172fde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ Changes in HQApi 2.4 + *) [HHQ-3960] Allow filtering of alert definitions by priority. + *) [HHQ-3925] Add agent transferPlugin() AgentAPI and associated CLI command *) [HHQ-3924] Add agent ping CLI command. diff --git a/src/org/hyperic/hq/hqapi1/tools/AlertDefinitionCommand.java b/src/org/hyperic/hq/hqapi1/tools/AlertDefinitionCommand.java index fe786bea..0cd8af73 100644 --- a/src/org/hyperic/hq/hqapi1/tools/AlertDefinitionCommand.java +++ b/src/org/hyperic/hq/hqapi1/tools/AlertDefinitionCommand.java @@ -66,6 +66,7 @@ public class AlertDefinitionCommand extends Command { private static String OPT_RESOURCE_NAME = "resourceName"; private static String OPT_RESOURCE_DESC = "resourceDescription"; private static String OPT_ALERT_NAME = "alertName"; + private static String OPT_ALERT_PRIORITY = "alertPriority"; private static String OPT_ID = "id"; private static String OPT_BATCH_SIZE = "batchSize"; private static String OPT_ESCLATION = "escalation"; @@ -146,6 +147,10 @@ private void list(String[] args) throws Exception { "which have at least one condition of the " + "given type") .withRequiredArg().ofType(Integer.class); + p.accepts(OPT_ALERT_PRIORITY, "If specified, only include alerts with " + + "the given priority. 3 = high, 2 = medium, " + + "1 = low") + .withRequiredArg().ofType(Integer.class); OptionSet options = getOptions(p, args); @@ -248,6 +253,17 @@ private void list(String[] args) throws Exception { } } + if (options.has(OPT_ALERT_PRIORITY)) { + Integer priority = (Integer)getRequired(options, OPT_ALERT_PRIORITY); + for (Iterator i = + alertDefs.getAlertDefinition().iterator(); i.hasNext(); ) { + AlertDefinition d = i.next(); + if (d.getPriority() != priority) { + i.remove(); + } + } + } + checkSuccess(alertDefs); XmlUtil.serialize(alertDefs, System.out, Boolean.TRUE); }