From 5a6664ab12d8f47a1409c2ae10af63aa7e1b9696 Mon Sep 17 00:00:00 2001 From: kishan Date: Mon, 13 Jun 2011 19:11:12 +0530 Subject: [PATCH] bug 8373: Added new API listEventTypes --- .../com/cloud/server/ManagementService.java | 2 ++ client/tomcatconf/commands.properties.in | 1 + .../cloud/server/ManagementServerImpl.java | 20 +++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java index 3cef9faa9e0..0f540a644ca 100644 --- a/api/src/com/cloud/server/ManagementService.java +++ b/api/src/com/cloud/server/ManagementService.java @@ -497,5 +497,7 @@ public interface ManagementService { * @return Pair, List> List of all Hosts in VM's cluster and list of HostIds with enough capacity */ Pair, List> listHostsForMigrationOfVM(UserVm vm, Long startIndex, Long pageSize); + + String[] listEventTypes(); } diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index b62328bcdc2..d49d8ba7ac4 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -163,6 +163,7 @@ listZones=com.cloud.api.commands.ListZonesByCmd;15 #### events commands listEvents=com.cloud.api.commands.ListEventsCmd;15 +listEventTypes=com.cloud.api.commands.ListEventTypesCmd;15 #### alerts commands listAlerts=com.cloud.api.commands.ListAlertsCmd;3 diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 3a0434e57ff..69b46a5d6a5 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -17,6 +17,7 @@ */ package com.cloud.server; +import java.lang.reflect.Field; import java.math.BigInteger; import java.net.Inet6Address; import java.net.InetAddress; @@ -4761,4 +4762,23 @@ public class ManagementServerImpl implements ManagementServer { return true; } + @Override + public String[] listEventTypes(){ + Object eventObj = new EventTypes(); + Class c = EventTypes.class; + Field[] fields = c.getDeclaredFields(); + String[] eventTypes = new String[fields.length]; + try { + int i = 0; + for(Field field : fields){ + eventTypes[i++] = field.get(eventObj).toString(); + } + return eventTypes; + } catch (IllegalArgumentException e) { + s_logger.error("Error while listing Event Types", e); + } catch (IllegalAccessException e) { + s_logger.error("Error while listing Event Types", e); + } + return null; + } }