You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2013/12/04 02:28:28 UTC

[1/2] CLOUDSTACK-5261: support for alert publishing via Root admin web api

Updated Branches:
  refs/heads/4.3 8367a8fae -> b315ca189


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 806e3af..85c5bc1 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -960,7 +960,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                             String context = "Site-to-site Vpn Connection to " + gw.getName() + " on router " + router.getHostName() +
                                     "(id: " + router.getId() + ") " + " just switch from " + oldState + " to " + conn.getState();
                             s_logger.info(context);
-                            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER,
+                            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
                                     router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
                         }
                     } finally {
@@ -1023,7 +1023,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                         " just switch from " + prevState + " to " + currState;
                 s_logger.info(context);
                 if (currState == RedundantState.MASTER) {
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER,
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
                             router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
                 }
             }
@@ -1040,7 +1040,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(title);
                 }
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER,
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
                         backupRouter.getDataCenterId(), backupRouter.getPodIdToDeployIn(), title, title);
                 try {
                     rebootRouter(backupRouter.getId(), true);
@@ -1130,8 +1130,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                         String title = "More than one redundant virtual router is in MASTER state! Router " + router.getHostName() + " and router " + dupRouter.getHostName();
                         String context =  "Virtual router (name: " + router.getHostName() + ", id: " + router.getId() + " and router (name: "
                                 + dupRouter.getHostName() + ", id: " + router.getId() + ") are both in MASTER state! If the problem persist, restart both of routers. ";
-                        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
-                        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER, dupRouter.getDataCenterId(), dupRouter.getPodIdToDeployIn(), title, context);
+                        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
+                        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, dupRouter.getDataCenterId(), dupRouter.getPodIdToDeployIn(), title, context);
                         s_logger.warn(context);
                     } else {
                             networkRouterMaps.put(routerGuestNtwkId, router);
@@ -3491,7 +3491,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
         }
         String title = "Virtual router " + disconnectedRouter.getInstanceName() + " would be stopped after connecting back, due to " + reason;
         String context =  "Virtual router (name: " + disconnectedRouter.getInstanceName() + ", id: " + disconnectedRouter.getId() + ") would be stopped after connecting back, due to: " + reason;
-        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER,
+        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
                 disconnectedRouter.getDataCenterId(), disconnectedRouter.getPodIdToDeployIn(), title, context);
         disconnectedRouter.setStopPending(true);
         disconnectedRouter = _routerDao.persist(disconnectedRouter);
@@ -3510,7 +3510,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 }
             } else {
                 String t = "Can't bump up virtual router " + connectedRouter.getInstanceName() + "'s priority due to it's already bumped up!";
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER,
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
                         connectedRouter.getDataCenterId(), connectedRouter.getPodIdToDeployIn(), t, t);
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index 269f04f..c0e9ad7 100755
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -255,7 +255,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
         long numToDecrement = (delta.length == 0) ? 1 : delta[0].longValue();
 
         if (!updateResourceCountForAccount(accountId, type, false, numToDecrement)) {
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, "Failed to decrement resource count of type " + type + " for account id=" + accountId,
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, "Failed to decrement resource count of type " + type + " for account id=" + accountId,
                     "Failed to decrement resource count of type " + type + " for account id=" + accountId + "; use updateResourceCount API to recalculate/fix the problem");
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index ff664bc..1761e52 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -60,6 +60,7 @@ import org.apache.cloudstack.api.command.admin.account.DisableAccountCmd;
 import org.apache.cloudstack.api.command.admin.account.EnableAccountCmd;
 import org.apache.cloudstack.api.command.admin.account.LockAccountCmd;
 import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
+import org.apache.cloudstack.api.command.admin.alert.GenerateAlertCmd;
 import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd;
 import org.apache.cloudstack.api.command.admin.autoscale.DeleteCounterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
@@ -2288,6 +2289,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         Object id = cmd.getId();
         Object type = cmd.getType();
         Object keyword = cmd.getKeyword();
+        Object name = cmd.getName();
 
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
         if (id != null) {
@@ -2307,6 +2309,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         if (type != null) {
             sc.addAnd("type", SearchCriteria.Op.EQ, type);
         }
+        
+        if (name != null) {
+            sc.addAnd("name", SearchCriteria.Op.EQ, name);
+        }
 
         sc.addAnd("archived", SearchCriteria.Op.EQ, false);
         Pair<List<AlertVO>, Integer> result = _alertDao.searchAndCount(sc, searchFilter);
@@ -2891,6 +2897,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(ListSslCertsCmd.class);
         cmdList.add(AssignCertToLoadBalancerCmd.class);
         cmdList.add(RemoveCertFromLoadBalancerCmd.class);
+        cmdList.add(GenerateAlertCmd.class);
         return cmdList;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 4f6a455..4cabd55 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -1083,7 +1083,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
             if (snapshotType != Type.MANUAL){
                 String msg = "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots";
                 s_logger.warn(msg);
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, msg,
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, msg,
                         "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots; please use updateResourceLimit to increase the limit");
             }
             throw e;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 37b346f..d630fd5 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1820,7 +1820,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
                     }
                 }
                 String msg = "Failed to deploy Vm with Id: " + vmId + ", on Host with Id: " + hostId;
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
 
                 // Get serviceOffering for Virtual Machine
                 ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
@@ -4233,14 +4233,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
         if (srcExplDedicated && !destExplDedicated) {
             //raise an alert
             String msg = "VM is being migrated from a explicitly dedicated host " + srcHost.getName() +" to non-dedicated host " + destHost.getName();
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
             s_logger.warn(msg);
         }
         //if srcHost is non dedicated but destination Host is explicitly dedicated
         if (!srcExplDedicated && destExplDedicated) {
             //raise an alert
             String msg = "VM is being migrated from a non dedicated host " + srcHost.getName() + " to a explicitly dedicated host "+ destHost.getName();
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
             s_logger.warn(msg);
         }
 
@@ -4249,13 +4249,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
             if((accountOfDedicatedHost(srcHost) != null) && (accountOfDedicatedHost(srcHost)!= accountOfDedicatedHost(destHost))) {
                 String msg = "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(srcHost) +
                         " to host " + destHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(destHost);
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
                 s_logger.warn(msg);
             }
             if((domainOfDedicatedHost(srcHost) != null) && (domainOfDedicatedHost(srcHost)!= domainOfDedicatedHost(destHost))) {
                 String msg = "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(srcHost) +
                         " to host " + destHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(destHost);
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
                 s_logger.warn(msg);
             }
         }
@@ -4294,7 +4294,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
                     }
                 }
             }
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
             s_logger.warn(msg);
 
         } else {
@@ -4317,12 +4317,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
                 } else {
                     msg = "VM is being migrated from implicitly dedicated host " + srcHost.getName() + " to shared host " + destHost.getName();
                 }
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
                 s_logger.warn(msg);
             } else {
                 if (destImplDedicated) {
                     msg = "VM is being migrated from shared host " + srcHost.getName() + " to implicitly dedicated host " + destHost.getName();
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
                     s_logger.warn(msg);
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/test/com/cloud/alert/MockAlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/alert/MockAlertManagerImpl.java b/server/test/com/cloud/alert/MockAlertManagerImpl.java
index f0c67f9..597d479 100644
--- a/server/test/com/cloud/alert/MockAlertManagerImpl.java
+++ b/server/test/com/cloud/alert/MockAlertManagerImpl.java
@@ -63,7 +63,7 @@ public class MockAlertManagerImpl extends ManagerBase implements AlertManager {
      * @see com.cloud.alert.AlertManager#clearAlert(short, long, long)
      */
     @Override
-    public void clearAlert(short alertType, long dataCenterId, long podId) {
+    public void clearAlert(AlertType alertType, long dataCenterId, long podId) {
         // TODO Auto-generated method stub
 
     }
@@ -72,7 +72,7 @@ public class MockAlertManagerImpl extends ManagerBase implements AlertManager {
      * @see com.cloud.alert.AlertManager#sendAlert(short, long, java.lang.Long, java.lang.String, java.lang.String)
      */
     @Override
-    public void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body) {
+    public void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String body) {
         // TODO Auto-generated method stub
 
     }
@@ -86,4 +86,10 @@ public class MockAlertManagerImpl extends ManagerBase implements AlertManager {
 
     }
 
+    @Override
+    public boolean generateAlert(AlertType alertType, long dataCenterId, Long podId, String msg) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index dae1d2c..a9c850f 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -799,3 +799,7 @@ CREATE TABLE `cloud`.`network_acl_item_details` (
   PRIMARY KEY (`id`),
   CONSTRAINT `fk_network_acl_item_details__network_acl_item_id` FOREIGN KEY `fk_network_acl_item_details__network_acl_item_id`(`network_acl_item_id`) REFERENCES `network_acl_item`(`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+ALTER TABLE `cloud`.`alert` ADD COLUMN `name` varchar(255) DEFAULT NULL COMMENT 'name of the alert';
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
index 0786742..01e6bec 100644
--- a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
@@ -24,14 +24,15 @@ import java.util.Properties;
 import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.mail.Authenticator;
+import javax.mail.Message.RecipientType;
 import javax.mail.MessagingException;
 import javax.mail.PasswordAuthentication;
 import javax.mail.Session;
 import javax.mail.URLName;
-import javax.mail.Message.RecipientType;
 import javax.mail.internet.InternetAddress;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -40,13 +41,10 @@ import com.cloud.alert.AlertVO;
 import com.cloud.alert.dao.AlertDao;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.component.ManagerBase;
-
 import com.sun.mail.smtp.SMTPMessage;
 import com.sun.mail.smtp.SMTPSSLTransport;
 import com.sun.mail.smtp.SMTPTransport;
 
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-
 @Component
 @Local(value={AlertManager.class})
 public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
@@ -86,10 +84,10 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
     }
 
     @Override
-    public void clearAlert(short alertType, long dataCenterId, long podId) {
+    public void clearAlert(AlertType alertType, long dataCenterId, long podId) {
         try {
             if (_emailAlert != null) {
-                _emailAlert.clearAlert(alertType, dataCenterId, podId);
+                _emailAlert.clearAlert(alertType.getType(), dataCenterId, podId);
             }
         } catch (Exception ex) {
             s_logger.error("Problem clearing email alert", ex);
@@ -97,7 +95,7 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
     }
 
     @Override
-    public void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body) {
+    public void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String body) {
         // TODO:  queue up these messages and send them as one set of issues once a certain number of issues is reached?  If that's the case,
         //         shouldn't we have a type/severity as part of the API so that severe errors get sent right away?
         try {
@@ -175,29 +173,30 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
         }
 
         // TODO:  make sure this handles SSL transport (useAuth is true) and regular
-        public void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
+        protected void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
             s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " +
                 podId + " // clusterId:: " + null + " // message:: " + subject);
             AlertVO alert = null;
-            if ((alertType != AlertManager.ALERT_TYPE_HOST) &&
-                (alertType != AlertManager.ALERT_TYPE_USERVM) &&
-                (alertType != AlertManager.ALERT_TYPE_DOMAIN_ROUTER) &&
-                (alertType != AlertManager.ALERT_TYPE_CONSOLE_PROXY) &&
-                (alertType != AlertManager.ALERT_TYPE_SSVM) &&
-                (alertType != AlertManager.ALERT_TYPE_STORAGE_MISC) &&
-                (alertType != AlertManager.ALERT_TYPE_MANAGMENT_NODE)) {
-                alert = _alertDao.getLastAlert(alertType, dataCenterId, podId);
+            if ((alertType != AlertManager.AlertType.ALERT_TYPE_HOST) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_USERVM) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_SSVM) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE)) {
+                alert = _alertDao.getLastAlert(alertType.getType(), dataCenterId, podId);
             }
 
             if (alert == null) {
                 // set up a new alert
                 AlertVO newAlert = new AlertVO();
-                newAlert.setType(alertType);
+                newAlert.setType(alertType.getType());
                 newAlert.setSubject(subject);
                 newAlert.setPodId(podId);
                 newAlert.setDataCenterId(dataCenterId);
                 newAlert.setSentCount(1); // initialize sent count to 1 since we are now sending an alert
                 newAlert.setLastSent(new Date());
+                newAlert.setName(alertType.getName());
                 _alertDao.persist(newAlert);
             } else {
                 if (s_logger.isDebugEnabled()) {
@@ -247,4 +246,14 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
         // TODO Auto-generated method stub
         
     }
+
+    @Override
+    public boolean generateAlert(AlertType alertType, long dataCenterId, Long podId, String msg) {
+        try {
+            sendAlert(alertType, dataCenterId, podId, msg, msg);
+            return true;
+        } catch (Exception ex) {
+            s_logger.warn("Failed to generate an alert of type=" + alertType + "; msg=" + msg);
+            return false;
+        }    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/usage/src/com/cloud/usage/UsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java
index 407237c..8b3127d 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -784,9 +784,9 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
                 // switch back to CLOUD_DB
                 TransactionLegacy swap = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                 if(!success){
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USAGE_SERVER_RESULT, 0, new Long(0), "Usage job failed. Job id: "+job.getId(), "Usage job failed. Job id: "+job.getId());
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER_RESULT, 0, new Long(0), "Usage job failed. Job id: "+job.getId(), "Usage job failed. Job id: "+job.getId());
                 } else {
-                    _alertMgr.clearAlert(AlertManager.ALERT_TYPE_USAGE_SERVER_RESULT, 0, 0);
+                    _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER_RESULT, 0, 0);
                 }
                 swap.close();
                 
@@ -1806,9 +1806,9 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
             try {
                 String errors = usc.runSanityCheck();
                 if(errors.length() > 0){
-                   _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USAGE_SANITY_RESULT, 0, new Long(0), "Usage Sanity Check failed", errors);
+                   _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SANITY_RESULT, 0, new Long(0), "Usage Sanity Check failed", errors);
                 } else {
-                    _alertMgr.clearAlert(AlertManager.ALERT_TYPE_USAGE_SANITY_RESULT, 0, 0);
+                    _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SANITY_RESULT, 0, 0);
                 }
             } catch (SQLException e) {
                 s_logger.error("Error in sanity check", e);


[2/2] git commit: updated refs/heads/4.3 to b315ca1

Posted by al...@apache.org.
CLOUDSTACK-5261: support for alert publishing via Root admin web api

listAlerts: introduced new parameter "name" to the alertResponse

Added new Admin API - generateAlert. Available to ROOT admin only

listAlerts: implemented search by alert name


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b315ca18
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b315ca18
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b315ca18

Branch: refs/heads/4.3
Commit: b315ca189535a58b2eb5ba4b9c17587b6acb37ef
Parents: 8367a8f
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Mon Dec 2 16:18:08 2013 -0800
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Tue Dec 3 17:08:23 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/alert/Alert.java              |   1 +
 api/src/com/cloud/event/EventTypes.java         |   4 +
 .../apache/cloudstack/alert/AlertService.java   | 103 ++++++++++++++
 api/src/org/apache/cloudstack/api/BaseCmd.java  |   9 +-
 .../command/admin/alert/GenerateAlertCmd.java   | 123 +++++++++++++++++
 .../command/admin/resource/ListAlertsCmd.java   |   8 ++
 .../cloudstack/api/response/AlertResponse.java  |   7 +
 client/tomcatconf/commands.properties.in        |   1 +
 .../src/com/cloud/alert/AlertManager.java       |  43 +-----
 .../cloud/agent/manager/AgentManagerImpl.java   |   8 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  34 ++---
 .../orchestration/NetworkOrchestrator.java      |   2 +-
 engine/schema/src/com/cloud/alert/AlertVO.java  |  18 ++-
 .../storage/image/TemplateServiceImpl.java      |   2 +-
 .../datastore/provider/DefaultHostListener.java |   2 +-
 .../storage/volume/VolumeServiceImpl.java       |   7 +-
 .../discoverer/HypervServerDiscoverer.java      |   4 +-
 .../vmware/VmwareServerDiscoverer.java          |   2 +-
 .../xen/discoverer/XcpServerDiscoverer.java     |   8 +-
 .../provider/SolidFireHostListener.java         |   2 +-
 .../src/com/cloud/alert/AlertManagerImpl.java   | 137 +++++++------------
 .../com/cloud/alert/ClusterAlertAdapter.java    |   4 +-
 .../cloud/alert/ConsoleProxyAlertAdapter.java   |  14 +-
 .../alert/SecondaryStorageVmAlertAdapter.java   |  14 +-
 .../configuration/ConfigurationManagerImpl.java |   4 +-
 .../ha/HighAvailabilityManagerExtImpl.java      |   4 +-
 .../cloud/ha/HighAvailabilityManagerImpl.java   |  22 +--
 .../VirtualNetworkApplianceManagerImpl.java     |  14 +-
 .../resourcelimit/ResourceLimitManagerImpl.java |   2 +-
 .../com/cloud/server/ManagementServerImpl.java  |   7 +
 .../storage/snapshot/SnapshotManagerImpl.java   |   2 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  16 +--
 .../com/cloud/alert/MockAlertManagerImpl.java   |  10 +-
 setup/db/db/schema-421to430.sql                 |   4 +
 .../com/cloud/usage/UsageAlertManagerImpl.java  |  43 +++---
 usage/src/com/cloud/usage/UsageManagerImpl.java |   8 +-
 36 files changed, 450 insertions(+), 243 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/com/cloud/alert/Alert.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/alert/Alert.java b/api/src/com/cloud/alert/Alert.java
index 31768cf..85ee431 100644
--- a/api/src/com/cloud/alert/Alert.java
+++ b/api/src/com/cloud/alert/Alert.java
@@ -31,4 +31,5 @@ public interface Alert extends Identity, InternalIdentity {
     Date getLastSent();
     Date getResolved();
     boolean getArchived();
+    String getName();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index a3e45fa..f3fb879 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -456,6 +456,10 @@ public class EventTypes {
     // Object store migration
     public static final String EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE = "MIGRATE.PREPARE.SS";
 
+    //Alert generation
+    public static final String ALERT_GENERATE = "ALERT.GENERATE";
+
+    
     static {
 
         // TODO: need a way to force author adding event types to declare the entity details as well, with out braking

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/org/apache/cloudstack/alert/AlertService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/alert/AlertService.java b/api/src/org/apache/cloudstack/alert/AlertService.java
new file mode 100644
index 0000000..ad3d319
--- /dev/null
+++ b/api/src/org/apache/cloudstack/alert/AlertService.java
@@ -0,0 +1,103 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.alert;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.cloud.capacity.Capacity;
+import com.cloud.exception.InvalidParameterValueException;
+
+public interface AlertService {
+    public static class AlertType {
+        private static Set<AlertType> defaultAlertTypes = new HashSet<AlertType>();
+        private final String name;
+        private final short type;
+        
+        private AlertType(short type, String name, boolean isDefault) {
+            this.name = name;
+            this.type = type;
+            if (isDefault) {
+                defaultAlertTypes.add(this);
+            }
+        }
+        
+        public static final AlertType ALERT_TYPE_MEMORY = new AlertType(Capacity.CAPACITY_TYPE_MEMORY, "ALERT.MEMORY", true);
+        public static final AlertType ALERT_TYPE_CPU = new AlertType(Capacity.CAPACITY_TYPE_CPU, "ALERT.CPU", true);
+        public static final AlertType ALERT_TYPE_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_STORAGE, "ALERT.STORAGE", true);
+        public static final AlertType ALERT_TYPE_STORAGE_ALLOCATED = new AlertType(Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, "ALERT.STORAGE.ALLOCATED", true);
+        public static final AlertType ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = new AlertType(Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP, "ALERT.NETWORK.PUBLICIP", true);
+        public static final AlertType ALERT_TYPE_PRIVATE_IP = new AlertType(Capacity.CAPACITY_TYPE_PRIVATE_IP, "ALERT.NETWORK.PRIVATEIP", true);
+        public static final AlertType ALERT_TYPE_SECONDARY_STORAGE = new AlertType(Capacity.CAPACITY_TYPE_SECONDARY_STORAGE, "ALERT.STORAGE.SECONDARY", true);
+        public static final AlertType ALERT_TYPE_HOST = new AlertType((short)7, "ALERT.COMPUTE.HOST", true);
+        public static final AlertType ALERT_TYPE_USERVM = new AlertType((short)8, "ALERT.USERVM", true);
+        public static final AlertType ALERT_TYPE_DOMAIN_ROUTER = new AlertType((short)9, "ALERT.SERVICE.DOMAINROUTER", true);
+        public static final AlertType ALERT_TYPE_CONSOLE_PROXY = new AlertType((short)10, "ALERT.SERVICE.CONSOLEPROXY", true);
+        public static final AlertType ALERT_TYPE_ROUTING = new AlertType((short)11, "ALERT.NETWORK.ROUTING", true);
+        public static final AlertType ALERT_TYPE_STORAGE_MISC = new AlertType((short)12, "ALERT.STORAGE.MISC", true);
+        public static final AlertType ALERT_TYPE_USAGE_SERVER = new AlertType((short)13, "ALERT.USAGE", true);
+        public static final AlertType ALERT_TYPE_MANAGMENT_NODE = new AlertType((short)14, "ALERT.MANAGEMENT", true);      
+        public static final AlertType ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = new AlertType((short)15, "ALERT.NETWORK.DOMAINROUTERMIGRATE", true);
+        public static final AlertType ALERT_TYPE_CONSOLE_PROXY_MIGRATE = new AlertType((short)16, "ALERT.SERVICE.CONSOLEPROXYMIGRATE", true);
+        public static final AlertType ALERT_TYPE_USERVM_MIGRATE = new AlertType((short)17, "ALERT.USERVM.MIGRATE", true); 
+        public static final AlertType ALERT_TYPE_VLAN = new AlertType((short)18, "ALERT.NETWORK.VLAN", true);
+        public static final AlertType ALERT_TYPE_SSVM = new AlertType((short)19, "ALERT.SERVICE.SSVM", true);
+        public static final AlertType ALERT_TYPE_USAGE_SERVER_RESULT = new AlertType((short)20, "ALERT.USAGE.RESULT", true);
+        public static final AlertType ALERT_TYPE_STORAGE_DELETE = new AlertType((short)21, "ALERT.STORAGE.DELETE", true);
+        public static final AlertType ALERT_TYPE_UPDATE_RESOURCE_COUNT = new AlertType((short)22, "ALERT.RESOURCE.COUNT", true);
+        public static final AlertType ALERT_TYPE_USAGE_SANITY_RESULT = new AlertType((short)23, "ALERT.USAGE.SANITY", true);
+        public static final AlertType ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = new AlertType((short)24, "ALERT.NETWORK.DIRECTPUBLICIP", true);
+        public static final AlertType ALERT_TYPE_LOCAL_STORAGE = new AlertType((short)25, "ALERT.STORAGE.LOCAL", true);
+        public static final AlertType ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = new AlertType((short)26, "ALERT.RESOURCE.EXCEED", true);
+        public static final AlertType ALERT_TYPE_SYNC = new AlertType((short)27, "ALERT.TYPE.SYNC", true);
+
+        public short getType() {
+            return type;
+        }
+        
+        public String getName() {
+            return name;
+        }
+
+        
+        private static AlertType getAlertType(short type) {
+            for (AlertType alertType : defaultAlertTypes) {
+                if (alertType.getType() == type) {
+                    return alertType;
+                }
+            }
+            return null;
+        }
+        
+        @Override
+        public String toString() {
+            return String.valueOf(this.getType());
+        }
+        
+        public static AlertType generateAlert(short type, String name) {
+            AlertType defaultAlert = getAlertType(type);
+            if (defaultAlert != null && !defaultAlert.getName().equalsIgnoreCase(name)) {
+                throw new InvalidParameterValueException("There is a default alert having type " + type + " and name " + defaultAlert.getName());
+            } else {
+                return new AlertType(type, name, false);
+            }
+        }
+    }
+    
+    boolean generateAlert(AlertType alertType, long dataCenterId, Long podId, String msg);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 01d9b53..acc1568 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -27,15 +27,12 @@ import java.util.regex.Pattern;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.affinity.AffinityGroupService;
-
-import com.cloud.server.ResourceMetaDataService;
-
+import org.apache.cloudstack.alert.AlertService;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
 import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
 import org.apache.cloudstack.query.QueryService;
 import org.apache.cloudstack.usage.UsageService;
-
 import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ConfigurationService;
@@ -54,10 +51,10 @@ import com.cloud.network.StorageNetworkService;
 import com.cloud.network.VpcVirtualNetworkApplianceService;
 import com.cloud.network.as.AutoScaleService;
 import com.cloud.network.firewall.FirewallService;
-import com.cloud.network.vpc.NetworkACLService;
 import com.cloud.network.lb.LoadBalancingRulesService;
 import com.cloud.network.rules.RulesService;
 import com.cloud.network.security.SecurityGroupService;
+import com.cloud.network.vpc.NetworkACLService;
 import com.cloud.network.vpc.VpcProvisioningService;
 import com.cloud.network.vpc.VpcService;
 import com.cloud.network.vpn.RemoteAccessVpnService;
@@ -66,6 +63,7 @@ import com.cloud.projects.Project;
 import com.cloud.projects.ProjectService;
 import com.cloud.resource.ResourceService;
 import com.cloud.server.ManagementService;
+import com.cloud.server.ResourceMetaDataService;
 import com.cloud.server.TaggedResourceService;
 import com.cloud.storage.DataStoreProviderApiService;
 import com.cloud.storage.StorageService;
@@ -151,6 +149,7 @@ public abstract class BaseCmd {
     @Inject public InternalLoadBalancerElementService _internalLbElementSvc;
     @Inject public InternalLoadBalancerVMService _internalLbSvc;
     @Inject public NetworkModel _ntwkModel;
+    @Inject public AlertService _alertSvc;
 
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java b/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java
new file mode 100644
index 0000000..b23a3be
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java
@@ -0,0 +1,123 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.alert;
+
+import org.apache.cloudstack.alert.AlertService;
+import org.apache.cloudstack.alert.AlertService.AlertType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.event.EventTypes;
+
+@APICommand(name = "generateAlert", description = "Generates an alert", responseObject = SuccessResponse.class, since="4.3")
+public class GenerateAlertCmd extends BaseAsyncCmd {
+
+    public static final Logger s_logger = Logger.getLogger(GenerateAlertCmd.class.getName());
+
+    private static final String s_name = "generatealertresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.TYPE, type = CommandType.SHORT, description = "Type of the alert", required=true)
+    private Short type;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the alert", required=true)
+    private String name;
+    
+    @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Alert description", required=true)
+    private String description;
+    
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, description="Zone id for which alert is generated")
+    private Long zoneId;
+    
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class, description="Pod id for which alert is generated")
+    private Long podId;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public Short getType() {
+        return type;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public long getZoneId() {
+        if (zoneId == null) {
+            return 0L;
+        }
+        return zoneId;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+    
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+
+
+    @Override
+    public void execute() {
+        AlertType alertType = AlertService.AlertType.generateAlert(getType(), getName());
+        if (_alertSvc.generateAlert(alertType, getZoneId(), getPodId(), getDescription())) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to generate an alert");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.ALERT_GENERATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Generating alert of type " + type + "; name " + name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return 0;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
index 015d82b..724ae11 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
@@ -47,6 +47,9 @@ public class ListAlertsCmd extends BaseListCmd {
 
     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "list by alert type")
     private String type;
+    
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list by alert name", since="4.3")
+    private String name;
 
     // ///////////////////////////////////////////////////
     // ///////////////// Accessors ///////////////////////
@@ -59,6 +62,10 @@ public class ListAlertsCmd extends BaseListCmd {
     public String getType() {
         return type;
     }
+    
+    public String getName() {
+        return name;
+    }
 
     // ///////////////////////////////////////////////////
     // ///////////// API Implementation///////////////////
@@ -80,6 +87,7 @@ public class ListAlertsCmd extends BaseListCmd {
             alertResponse.setAlertType(alert.getType());
             alertResponse.setDescription(alert.getSubject());
             alertResponse.setLastSent(alert.getLastSent());
+            alertResponse.setName(alert.getName());
 
             alertResponse.setObjectName("alert");
             alertResponseList.add(alertResponse);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/api/src/org/apache/cloudstack/api/response/AlertResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/AlertResponse.java b/api/src/org/apache/cloudstack/api/response/AlertResponse.java
index f3755e5..89de605 100644
--- a/api/src/org/apache/cloudstack/api/response/AlertResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/AlertResponse.java
@@ -41,6 +41,9 @@ public class AlertResponse extends BaseResponse {
       "DOMAIN_ROUTER_MIGRATE = 14, CONSOLE_PROXY_MIGRATE = 15, USERVM_MIGRATE = 16, VLAN = 17, SSVM = 18, " +
       "USAGE_SERVER_RESULT = 19")
     private Short alertType;
+    
+    @SerializedName(ApiConstants.NAME) @Param(description="the name of the alert", since="4.3")
+    private String alertName;
 
     @SerializedName(ApiConstants.DESCRIPTION) @Param(description="description of the alert")
     private String description;
@@ -63,4 +66,8 @@ public class AlertResponse extends BaseResponse {
     public void setLastSent(Date lastSent) {
         this.lastSent = lastSent;
     }
+    
+    public void setName(String name) {
+        this.alertName = name;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 28490a9..10afdcc 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -246,6 +246,7 @@ deleteEvents=15
 listAlerts=3
 archiveAlerts=1
 deleteAlerts=1
+generateAlert=1
 
 #### system capacity commands
 listCapacity=3

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/components-api/src/com/cloud/alert/AlertManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/alert/AlertManager.java b/engine/components-api/src/com/cloud/alert/AlertManager.java
index eb5ac0c..6a3218d 100755
--- a/engine/components-api/src/com/cloud/alert/AlertManager.java
+++ b/engine/components-api/src/com/cloud/alert/AlertManager.java
@@ -16,43 +16,13 @@
 // under the License.
 package com.cloud.alert;
 
+import org.apache.cloudstack.alert.AlertService;
 import org.apache.cloudstack.framework.config.ConfigKey;
 
-import com.cloud.capacity.CapacityVO;
 import com.cloud.utils.component.Manager;
 
-public interface AlertManager extends Manager {
-    public static final short ALERT_TYPE_MEMORY = CapacityVO.CAPACITY_TYPE_MEMORY;
-    public static final short ALERT_TYPE_CPU = CapacityVO.CAPACITY_TYPE_CPU;
-    public static final short ALERT_TYPE_STORAGE = CapacityVO.CAPACITY_TYPE_STORAGE;
-    public static final short ALERT_TYPE_STORAGE_ALLOCATED = CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED;
-    public static final short ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP = CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
-    public static final short ALERT_TYPE_PRIVATE_IP = CapacityVO.CAPACITY_TYPE_PRIVATE_IP;
-    public static final short ALERT_TYPE_SECONDARY_STORAGE = CapacityVO.CAPACITY_TYPE_SECONDARY_STORAGE;
-    public static final short ALERT_TYPE_HOST = 7;
-    public static final short ALERT_TYPE_USERVM = 8;
-    public static final short ALERT_TYPE_DOMAIN_ROUTER = 9;
-    public static final short ALERT_TYPE_CONSOLE_PROXY = 10;
-    public static final short ALERT_TYPE_ROUTING = 11; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_STORAGE_MISC = 12; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_USAGE_SERVER = 13; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_MANAGMENT_NODE = 14; // lost connection to default route (to the gateway)
-    public static final short ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = 15;
-    public static final short ALERT_TYPE_CONSOLE_PROXY_MIGRATE = 16;
-    public static final short ALERT_TYPE_USERVM_MIGRATE = 17;
-    public static final short ALERT_TYPE_VLAN = 18;
-    public static final short ALERT_TYPE_SSVM = 19;
-    public static final short ALERT_TYPE_USAGE_SERVER_RESULT = 20; // Usage job result
-    public static final short ALERT_TYPE_STORAGE_DELETE = 21;
-    public static final short ALERT_TYPE_UPDATE_RESOURCE_COUNT = 22; // Generated when we fail to update the resource
-    // count
-    public static final short ALERT_TYPE_USAGE_SANITY_RESULT = 23;
-    public static final short ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 24;
-    public static final short ALERT_TYPE_LOCAL_STORAGE = 25;
-    public static final short ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = 26; // Generated when the resource limit exceeds the limit. Currently used for recurring snapshots only
-
-    public static final short ALERT_TYPE_SYNC = 27;
-    
+public interface AlertManager extends Manager, AlertService{
+       
     static final ConfigKey<Double> StorageCapacityThreshold = new ConfigKey<Double>(Double.class, "cluster.storage.capacity.notificationthreshold", "Alert", "0.75",
         "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", true, ConfigKey.Scope.Cluster, null);
     static final ConfigKey<Double> CPUCapacityThreshold = new ConfigKey<Double>(Double.class, "cluster.cpu.allocated.capacity.notificationthreshold", "Alert", "0.75",
@@ -63,9 +33,10 @@ public interface AlertManager extends Manager {
         "0.75", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", true,
         ConfigKey.Scope.Cluster, null);
     
-    void clearAlert(short alertType, long dataCenterId, long podId);
-
-    void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body);
+    void clearAlert(AlertType alertType, long dataCenterId, long podId);
 
     void recalculateCapacity();
+    
+    void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String body);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 488caf5..236d369 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -820,7 +820,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
                         HostPodVO podVO = _podDao.findById(host.getPodId());
                         String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
                         if ((host.getType() != Host.Type.SecondaryStorage) && (host.getType() != Host.Type.ConsoleProxy)) {
-                            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host disconnected, " + hostDesc,
+                            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host disconnected, " + hostDesc,
                                 "If the agent for host [" + hostDesc + "] is not restarted within " + AlertWait + " seconds, HA will begin on the VMs");
                         }
                         event = Status.Event.AgentDisconnected;
@@ -830,7 +830,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
                     DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());
                     HostPodVO podVO = _podDao.findById(host.getPodId());
                     String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host in ALERT state, " + hostDesc, "In availability zone " + host.getDataCenterId()
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host in ALERT state, " + hostDesc, "In availability zone " + host.getDataCenterId()
                             + ", host is in alert state: " + host.getId() + "-" + host.getName());
                 }
             } else {
@@ -1199,10 +1199,10 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
                                         HostPodVO podVO = _podDao.findById(host.getPodId());
                                         String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
 
-                                        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId(), "Host lost connection to gateway, " + hostDesc, "Host [" + hostDesc
+                                        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId(), "Host lost connection to gateway, " + hostDesc, "Host [" + hostDesc
                                                 + "] lost connection to gateway (default route) and is possibly having network connection issues.");
                                     } else {
-                                        _alertMgr.clearAlert(AlertManager.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId());
+                                        _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId());
                                     }
                                 } else {
                                     s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 40ab732..2bdec95 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1668,11 +1668,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             throw new CloudRuntimeException("VM is not Running, unable to migrate the vm currently " + vm + " , current state: " + vm.getState().toString());
         }
 
-        short alertType = AlertManager.ALERT_TYPE_USERVM_MIGRATE;
+        AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM_MIGRATE;
         if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_DOMAIN_ROUTER_MIGRATE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER_MIGRATE;
         } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY_MIGRATE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY_MIGRATE;
         }
 
         VirtualMachineProfile vmSrc = new VirtualMachineProfileImpl(vm);
@@ -1927,11 +1927,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                     " doesn't involve migrating the volumes.");
         }
 
-        short alertType = AlertManager.ALERT_TYPE_USERVM_MIGRATE;
+        AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM_MIGRATE;
         if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_DOMAIN_ROUTER_MIGRATE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER_MIGRATE;
         } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY_MIGRATE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY_MIGRATE;
         }
 
         _networkMgr.prepareNicForMigration(profile, destination);
@@ -2549,13 +2549,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         if (agentState == State.Error) {
             agentState = State.Stopped;
 
-            short alertType = AlertManager.ALERT_TYPE_USERVM;
+            AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM;
             if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
-                alertType = AlertManager.ALERT_TYPE_DOMAIN_ROUTER;
+                alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER;
             } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
-                alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY;
+                alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY;
             } else if (VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType())) {
-                alertType = AlertManager.ALERT_TYPE_SSVM;
+                alertType = AlertManager.AlertType.ALERT_TYPE_SSVM;
             }
 
             HostPodVO podVO = _podDao.findById(vm.getPodIdToDeployIn());
@@ -3494,11 +3494,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             throw new CloudRuntimeException("VM is not Running, unable to migrate the vm currently " + vm + " , current state: " + vm.getState().toString());
         }
 
-        short alertType = AlertManager.ALERT_TYPE_USERVM_MIGRATE;
+        AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM_MIGRATE;
         if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_DOMAIN_ROUTER_MIGRATE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER_MIGRATE;
         } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY_MIGRATE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY_MIGRATE;
         }
 
         VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
@@ -3845,7 +3845,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     		}
     		
     		// we need to alert admin or user about this risky state transition
-    		_alertMgr.sendAlert(AlertManager.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
+    		_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
     			VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (Starting -> Running) from out-of-context transition. VM network environment may need to be reset");
     		break;
     		
@@ -3866,7 +3866,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     		} catch(NoTransitionException e) {
     			s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
     		}
-      		_alertMgr.sendAlert(AlertManager.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
+      		_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
         			VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState() + " -> Running) from out-of-context transition. VM network environment may need to be reset");
           	break;
     		
@@ -3907,7 +3907,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     		} catch(NoTransitionException e) {
     			s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
     		}
-      		_alertMgr.sendAlert(AlertManager.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
+      		_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
         			VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState() + " -> Stopped) from out-of-context transition.");
       		// TODO: we need to forcely release all resource allocation
           	break;
@@ -3967,7 +3967,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     		VMInstanceVO vm = _vmDao.findById(vmId);
     		
     		// We now only alert administrator about this situation
-      		_alertMgr.sendAlert(AlertManager.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
+      		_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
         		VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") is stuck in " + vm.getState() + " state and its host is unreachable for too long");
     	}
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index 36926d2..5577db8 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -2814,7 +2814,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         if (!answer.getResult()) {
             s_logger.warn("Unable to setup agent " + hostId + " due to " + ((answer != null) ? answer.getDetails() : "return null"));
             String msg = "Incorrect Network setup on agent, Reinitialize agent after network names are setup, details : " + answer.getDetails();
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, host.getPodId(), msg, msg);
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, host.getPodId(), msg, msg);
             throw new ConnectionException(true, msg);
         } else {
             if (answer.needReconnect()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/schema/src/com/cloud/alert/AlertVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/alert/AlertVO.java b/engine/schema/src/com/cloud/alert/AlertVO.java
index 3f014aa..05c4ac4 100755
--- a/engine/schema/src/com/cloud/alert/AlertVO.java
+++ b/engine/schema/src/com/cloud/alert/AlertVO.java
@@ -72,14 +72,14 @@ public class AlertVO implements Alert {
 
     @Column(name="archived")
     private boolean archived;
+    
+    @Column(name="name")
+    private String name;
 
     public AlertVO() {
         this.uuid = UUID.randomUUID().toString();
     }
-    public AlertVO(Long id) {
-        this.id = id;
-        this.uuid = UUID.randomUUID().toString();
-    }
+
 
     @Override
     public long getId() {
@@ -180,4 +180,14 @@ public class AlertVO implements Alert {
     public void setArchived(Boolean archived) {
         this.archived = archived;
     }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index 308347d..f5f15df 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@ -369,7 +369,7 @@ public class TemplateServiceImpl implements TemplateService {
                                                     tmpltInfo.getSize() - UriUtils.getRemoteSize(tmplt.getUrl()));
                                         } catch (ResourceAllocationException e) {
                                             s_logger.warn(e.getMessage());
-                                            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, zoneId, null,
+                                            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, zoneId, null,
                                                     e.getMessage(), e.getMessage());
                                         } finally {
                                             _resourceLimitMgr.recalculateResourceCount(accountId, _accountMgr.getAccount(accountId)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
index fa5e216..9d05bc3 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
@@ -62,7 +62,7 @@ public class DefaultHostListener implements HypervisorHostListener {
 
         if (!answer.getResult()) {
             String msg = "Unable to attach storage pool" + poolId + " to the host" + hostId;
-            alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, pool.getDataCenterId(), pool.getPodId(), msg, msg);
+            alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, pool.getDataCenterId(), pool.getPodId(), msg, msg);
             throw new CloudRuntimeException("Unable establish connection from storage head to storage pool "
                     + pool.getId() + " due to " + answer.getDetails() + pool.getId());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 5818aa8..fc6225c 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -25,9 +25,6 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
 import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
@@ -60,6 +57,8 @@ import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.storage.ListVolumeAnswer;
@@ -1238,7 +1237,7 @@ public class VolumeServiceImpl implements VolumeService {
                                                 - volInfo.getPhysicalSize());
                                     } catch (ResourceAllocationException e) {
                                         s_logger.warn(e.getMessage());
-                                        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED,
+                                        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED,
                                                 volume.getDataCenterId(), volume.getPodId(), e.getMessage(), e.getMessage());
                                     } finally {
                                         _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
index f011ce0..c5fb60a 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
@@ -367,12 +367,12 @@ public class HypervServerDiscoverer extends DiscovererBase implements
             // TODO: does the resource have to create a connection?
             return resources;
         } catch (ConfigurationException e) {
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId,
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId,
                     "Unable to add " + uri.getHost(),
                     "Error is " + e.getMessage());
             s_logger.warn("Unable to instantiate " + uri.getHost(), e);
         } catch (UnknownHostException e) {
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId,
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId,
                     "Unable to add " + uri.getHost(),
                     "Error is " + e.getMessage());
             s_logger.warn("Unable to instantiate " + uri.getHost(), e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index 58255bf..89bbeb9 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -417,7 +417,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
 				try {
 					resource.configure("VMware", params);
 				} catch (ConfigurationException e) {
-					_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId,
+					_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId,
 							podId, "Unable to add " + url.getHost(),
 							"Error is " + e.getMessage());
 					s_logger.warn("Unable to instantiate " + url.getHost(), e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
index 1333af3..7174942 100755
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
@@ -247,7 +247,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                     }
                     if( !support_hvm ) {
                         String msg = "Unable to add host " + record.address + " because it doesn't support hvm";
-                        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
+                        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId, msg, msg);
                         s_logger.debug(msg);
                         throw new RuntimeException(msg);
                     }
@@ -325,7 +325,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                 try {
                     resource.configure("Xen Server", params);
                 } catch (ConfigurationException e) {
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + record.address, "Error is " + e.getMessage());
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + record.address, "Error is " + e.getMessage());
                     s_logger.warn("Unable to instantiate " + record.address, e);
                     continue;
                 }
@@ -465,7 +465,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
         }
 
         String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6,  XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0, 6.2.0 but this one is " + prodBrand + " " + prodVersion;
-        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
+        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId, msg, msg);
         s_logger.debug(msg);
         throw new RuntimeException(msg);
     }
@@ -737,7 +737,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
 				String msg = "Unable to eject host " + host.getGuid() + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid="
 				        + host.getGuid() + "in this host " + host.getPrivateIpAddress();
 				s_logger.warn(msg);
-				_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to eject host " + host.getGuid(), msg);
+				_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to eject host " + host.getGuid(), msg);
 			}
 		}
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
index 43e9830..350f32f 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
@@ -76,7 +76,7 @@ public class SolidFireHostListener implements HypervisorHostListener {
         if (!answer.getResult()) {
             String msg = "Unable to attach storage pool " + storagePoolId + " to host " + hostId;
 
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, storagePool.getDataCenterId(), storagePool.getPodId(), msg, msg);
+            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, storagePool.getDataCenterId(), storagePool.getPodId(), msg, msg);
 
             throw new CloudRuntimeException("Unable to establish a connection from agent to storage pool " + storagePool.getId() +
                     " due to " + answer.getDetails() + " (" + storagePool.getId() + ")");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index fe7990f..3786443 100755
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -40,12 +40,7 @@ import javax.mail.URLName;
 import javax.mail.internet.InternetAddress;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
-import com.sun.mail.smtp.SMTPMessage;
-import com.sun.mail.smtp.SMTPSSLTransport;
-import com.sun.mail.smtp.SMTPTransport;
-
+import org.apache.cloudstack.alert.AlertService.AlertType;
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.Configurable;
@@ -53,6 +48,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.log4j.Logger;
 
 import com.cloud.alert.dao.AlertDao;
 import com.cloud.api.ApiDBUtils;
@@ -73,7 +69,9 @@ import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.DataCenterIpAddressDao;
 import com.cloud.dc.dao.HostPodDao;
+import com.cloud.event.ActionEvent;
 import com.cloud.event.AlertGenerator;
+import com.cloud.event.EventTypes;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.network.dao.IPAddressDao;
@@ -85,6 +83,9 @@ import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.SearchCriteria;
+import com.sun.mail.smtp.SMTPMessage;
+import com.sun.mail.smtp.SMTPSSLTransport;
+import com.sun.mail.smtp.SMTPTransport;
 
 @Local(value={AlertManager.class})
 public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable {
@@ -216,10 +217,10 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
     }
 
     @Override
-    public void clearAlert(short alertType, long dataCenterId, long podId) {
+    public void clearAlert(AlertType alertType, long dataCenterId, long podId) {
         try {
             if (_emailAlert != null) {
-                _emailAlert.clearAlert(alertType, dataCenterId, podId);
+                _emailAlert.clearAlert(alertType.getType(), dataCenterId, podId);
             }
         } catch (Exception ex) {
             s_logger.error("Problem clearing email alert", ex);
@@ -227,10 +228,10 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
     }
 
     @Override
-    public void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body) {
+    public void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String body) {
 
         // publish alert
-        AlertGenerator.publishAlertOnEventBus(getAlertType(alertType), dataCenterId, podId, subject, body);
+        AlertGenerator.publishAlertOnEventBus(alertType.getName(), dataCenterId, podId, subject, body);
 
         // TODO:  queue up these messages and send them as one set of issues once a certain number of issues is reached?  If that's the case,
         //         shouldn't we have a type/severity as part of the API so that severe errors get sent right away?
@@ -246,65 +247,6 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
         }
     }
 
-    private String getAlertType(short alertType) {
-        if (alertType == ALERT_TYPE_MEMORY) {
-            return "ALERT.MEMORY";
-        } else if (alertType == ALERT_TYPE_CPU) {
-            return "ALERT.MEMORY";
-        } else if (alertType == ALERT_TYPE_STORAGE) {
-            return "ALERT.STORAGE";
-        } else if (alertType == ALERT_TYPE_STORAGE_ALLOCATED) {
-            return "ALERT.STORAGE.ALLOCATED";
-        } else if (alertType == ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP) {
-            return "ALERT.NETWORK.PUBLICIP";
-        } else if (alertType == ALERT_TYPE_PRIVATE_IP) {
-            return "ALERT.NETWORK.PRIVATEIP";
-        } else if (alertType == ALERT_TYPE_SECONDARY_STORAGE) {
-            return "ALERT.STORAGE.SECONDARY";
-        } else if (alertType == ALERT_TYPE_HOST) {
-            return "ALERT.COMPUTE.HOST";
-        } else if (alertType == ALERT_TYPE_USERVM) {
-            return "ALERT.USERVM";
-        } else if (alertType == ALERT_TYPE_DOMAIN_ROUTER) {
-            return "ALERT.SERVICE.DOMAINROUTER";
-        } else if (alertType == ALERT_TYPE_CONSOLE_PROXY) {
-            return "ALERT.SERVICE.CONSOLEPROXY";
-        } else if (alertType == ALERT_TYPE_ROUTING) {
-            return "ALERT.NETWORK.ROUTING";
-        } else if (alertType == ALERT_TYPE_STORAGE_MISC) {
-            return "ALERT.STORAGE.MISC";
-        } else if (alertType == ALERT_TYPE_USAGE_SERVER) {
-            return "ALERT.USAGE";
-        } else if (alertType == ALERT_TYPE_MANAGMENT_NODE) {
-            return "ALERT.MANAGEMENT";
-        } else if (alertType == ALERT_TYPE_DOMAIN_ROUTER_MIGRATE) {
-            return "ALERT.NETWORK.DOMAINROUTERMIGRATE";
-        } else if (alertType == ALERT_TYPE_CONSOLE_PROXY_MIGRATE) {
-            return "ALERT.SERVICE.CONSOLEPROXYMIGRATE";
-        } else if (alertType == ALERT_TYPE_USERVM_MIGRATE) {
-            return "ALERT.USERVM.MIGRATE";
-        } else if (alertType == ALERT_TYPE_VLAN) {
-            return "ALERT.NETWORK.VLAN";
-        } else if (alertType == ALERT_TYPE_SSVM) {
-            return "ALERT.SERVICE.SSVM";
-        } else if (alertType == ALERT_TYPE_USAGE_SERVER_RESULT) {
-            return "ALERT.USAGE.RESULT";
-        } else if (alertType == ALERT_TYPE_STORAGE_DELETE) {
-            return "ALERT.STORAGE.DELETE";
-        } else if (alertType == ALERT_TYPE_UPDATE_RESOURCE_COUNT) {
-            return "ALERT.RESOURCE.COUNT";
-        } else if (alertType == ALERT_TYPE_USAGE_SANITY_RESULT) {
-            return "ALERT.USAGE.SANITY";
-        } else if (alertType == ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP) {
-            return "ALERT.NETWORK.DIRECTPUBLICIP";
-        } else if (alertType == ALERT_TYPE_LOCAL_STORAGE) {
-            return "ALERT.STORAGE.LOCAL";
-        } else if (alertType == ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED) {
-            return "ALERT.RESOURCE.EXCEED";
-        }
-        return "UNKNOWN";
-    }
-
     @Override @DB
     public void recalculateCapacity() {
         // FIXME: the right way to do this is to register a listener (see RouterStatsListener, VMSyncListener)
@@ -596,7 +538,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
         String totalStr;
         String usedStr;
         String pctStr = formatPercent(usedCapacity/totalCapacity);
-        short alertType = -1;
+        AlertType alertType = null;
         Long podId = pod == null ? null : pod.getId();
         Long clusterId = cluster == null ? null : cluster.getId();
 
@@ -608,35 +550,35 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
             totalStr = formatBytesToMegabytes(totalCapacity);
             usedStr = formatBytesToMegabytes(usedCapacity);
             msgContent = "System memory is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
-            alertType = ALERT_TYPE_MEMORY;
+            alertType = AlertManager.AlertType.ALERT_TYPE_MEMORY;
             break;
         case CapacityVO.CAPACITY_TYPE_CPU:
             msgSubject = "System Alert: Low Unallocated CPU in cluster " +cluster.getName()+ " pod " +pod.getName()+ " of availability zone " + dc.getName();
             totalStr = _dfWhole.format(totalCapacity);
             usedStr = _dfWhole.format(usedCapacity);
             msgContent = "Unallocated CPU is low, total: " + totalStr + " Mhz, used: " + usedStr + " Mhz (" + pctStr + "%)";
-            alertType = ALERT_TYPE_CPU;
+            alertType = AlertManager.AlertType.ALERT_TYPE_CPU;
             break;
         case CapacityVO.CAPACITY_TYPE_STORAGE:
             msgSubject = "System Alert: Low Available Storage in cluster " +cluster.getName()+ " pod " +pod.getName()+ " of availability zone " + dc.getName();
             totalStr = formatBytesToMegabytes(totalCapacity);
             usedStr = formatBytesToMegabytes(usedCapacity);
             msgContent = "Available storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
-            alertType = ALERT_TYPE_STORAGE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_STORAGE;
             break;
         case CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED:
             msgSubject = "System Alert: Remaining unallocated Storage is low in cluster " +cluster.getName()+ " pod " +pod.getName()+ " of availability zone " + dc.getName();
             totalStr = formatBytesToMegabytes(totalCapacity);
             usedStr = formatBytesToMegabytes(usedCapacity);
             msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)";
-            alertType = ALERT_TYPE_STORAGE_ALLOCATED;
+            alertType = AlertManager.AlertType.ALERT_TYPE_STORAGE_ALLOCATED;
             break;
         case CapacityVO.CAPACITY_TYPE_LOCAL_STORAGE:
             msgSubject = "System Alert: Remaining unallocated Local Storage is low in cluster " +cluster.getName()+ " pod " +pod.getName()+ " of availability zone " + dc.getName();
             totalStr = formatBytesToMegabytes(totalCapacity);
             usedStr = formatBytesToMegabytes(usedCapacity);
             msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)";
-            alertType = ALERT_TYPE_LOCAL_STORAGE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_LOCAL_STORAGE;
             break;
 
             //Pod Level
@@ -645,7 +587,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
             totalStr = Double.toString(totalCapacity);
             usedStr = Double.toString(usedCapacity);
             msgContent = "Number of unallocated private IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
-            alertType = ALERT_TYPE_PRIVATE_IP;
+            alertType = AlertManager.AlertType.ALERT_TYPE_PRIVATE_IP;
             break;
 
             //Zone Level
@@ -654,28 +596,28 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
             totalStr = formatBytesToMegabytes(totalCapacity);
             usedStr = formatBytesToMegabytes(usedCapacity);
             msgContent = "Available secondary storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
-            alertType = ALERT_TYPE_SECONDARY_STORAGE;
+            alertType = AlertManager.AlertType.ALERT_TYPE_SECONDARY_STORAGE;
             break;
         case CapacityVO.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP:
             msgSubject = "System Alert: Number of unallocated virtual network public IPs is low in availability zone " + dc.getName();
             totalStr = Double.toString(totalCapacity);
             usedStr = Double.toString(usedCapacity);
             msgContent = "Number of unallocated public IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
-            alertType = ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
+            alertType = AlertManager.AlertType.ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP;
             break;
         case CapacityVO.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP:
             msgSubject = "System Alert: Number of unallocated shared network IPs is low in availability zone " + dc.getName();
             totalStr = Double.toString(totalCapacity);
             usedStr = Double.toString(usedCapacity);
             msgContent = "Number of unallocated shared network IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
-            alertType = ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP;
+            alertType = AlertManager.AlertType.ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP;
             break;
         case CapacityVO.CAPACITY_TYPE_VLAN:
             msgSubject = "System Alert: Number of unallocated VLANs is low in availability zone " + dc.getName();
             totalStr = Double.toString(totalCapacity);
             usedStr = Double.toString(usedCapacity);
             msgContent = "Number of unallocated VLANs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
-            alertType = ALERT_TYPE_VLAN;
+            alertType = AlertManager.AlertType.ALERT_TYPE_VLAN;
             break;
         }
 
@@ -794,31 +736,32 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
         }
 
         // TODO:  make sure this handles SSL transport (useAuth is true) and regular
-        public void sendAlert(short alertType, long dataCenterId, Long podId, Long clusterId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
+        public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long clusterId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
             s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " +
                 podId + " // clusterId:: " + null + " // message:: " + subject);
             AlertVO alert = null;
-            if ((alertType != AlertManager.ALERT_TYPE_HOST) &&
-                    (alertType != AlertManager.ALERT_TYPE_USERVM) &&
-                    (alertType != AlertManager.ALERT_TYPE_DOMAIN_ROUTER) &&
-                    (alertType != AlertManager.ALERT_TYPE_CONSOLE_PROXY) &&
-                    (alertType != AlertManager.ALERT_TYPE_SSVM) &&
-                    (alertType != AlertManager.ALERT_TYPE_STORAGE_MISC) &&
-                    (alertType != AlertManager.ALERT_TYPE_MANAGMENT_NODE) &&
-                    (alertType != AlertManager.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED)) {
-                alert = _alertDao.getLastAlert(alertType, dataCenterId, podId, clusterId);
+            if ((alertType != AlertManager.AlertType.ALERT_TYPE_HOST) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_USERVM) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_SSVM) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE) &&
+                    (alertType != AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED)) {
+                alert = _alertDao.getLastAlert(alertType.getType(), dataCenterId, podId, clusterId);
             }
 
             if (alert == null) {
                 // set up a new alert
                 AlertVO newAlert = new AlertVO();
-                newAlert.setType(alertType);
+                newAlert.setType(alertType.getType());
                 newAlert.setSubject(subject);
                 newAlert.setClusterId(clusterId);
                 newAlert.setPodId(podId);
                 newAlert.setDataCenterId(dataCenterId);
                 newAlert.setSentCount(1); // initialize sent count to 1 since we are now sending an alert
                 newAlert.setLastSent(new Date());
+                newAlert.setName(alertType.getName());
                 _alertDao.persist(newAlert);
             } else {
                 if (s_logger.isDebugEnabled()) {
@@ -896,4 +839,16 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
     public ConfigKey<?>[] getConfigKeys() {
         return new ConfigKey<?>[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold};
     }
+
+    @Override
+    @ActionEvent(eventType = EventTypes.ALERT_GENERATE, eventDescription = "generating alert", async=true)
+    public boolean generateAlert(AlertType alertType, long dataCenterId, Long podId, String msg) {
+        try {
+            sendAlert(alertType, dataCenterId, podId, msg, msg);
+            return true;
+        } catch (Exception ex) {
+            s_logger.warn("Failed to generate an alert of type=" + alertType + "; msg=" + msg);
+            return false;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/alert/ClusterAlertAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/ClusterAlertAdapter.java b/server/src/com/cloud/alert/ClusterAlertAdapter.java
index 32da042..614c34a 100644
--- a/server/src/com/cloud/alert/ClusterAlertAdapter.java
+++ b/server/src/com/cloud/alert/ClusterAlertAdapter.java
@@ -70,7 +70,7 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter {
                     s_logger.debug("Management server node " + mshost.getServiceIP() + " is up, send alert");
                 }
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is up", "");
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is up", "");
                 break;
             }
         }
@@ -90,7 +90,7 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter {
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, send alert");
                     }
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is down", "");
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is down", "");
                 } else {
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
index 512108c..82ae3e4 100644
--- a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
+++ b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
@@ -68,7 +68,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         proxy.getPrivateIpAddress());
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Console proxy up in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
@@ -84,7 +84,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Console proxy down in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
@@ -100,7 +100,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Console proxy rebooted in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
@@ -116,7 +116,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
@@ -133,7 +133,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Console proxy startup failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() 
@@ -150,7 +150,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_CONSOLE_PROXY,
+                    AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Failed to open console proxy firewall port. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() 
@@ -167,7 +167,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         proxy.getPrivateIpAddress() + ", message: " + args.getMessage());
 
             _alertMgr.sendAlert(
-                    AlertManager.ALERT_TYPE_STORAGE_MISC,
+                    AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC,
                     args.getZoneId(),
                     proxy.getPodIdToDeployIn(),
                     "Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
index 2d4a8c3..0ef2dfe 100644
--- a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
+++ b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
@@ -71,7 +71,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			secStorageVm.getPrivateIpAddress());
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_SSVM,
+				AlertManager.AlertType.ALERT_TYPE_SSVM,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Secondary Storage Vm up in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() 
@@ -87,7 +87,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_SSVM,
+				AlertManager.AlertType.ALERT_TYPE_SSVM,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Secondary Storage Vm down in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() 
@@ -103,7 +103,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_SSVM,
+				AlertManager.AlertType.ALERT_TYPE_SSVM,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Secondary Storage Vm rebooted in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() 
@@ -119,7 +119,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_SSVM,
+				AlertManager.AlertType.ALERT_TYPE_SSVM,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Secondary Storage Vm creation failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() 
@@ -136,7 +136,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_SSVM,
+				AlertManager.AlertType.ALERT_TYPE_SSVM,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Secondary Storage Vm startup failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() 
@@ -153,7 +153,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_SSVM,
+				AlertManager.AlertType.ALERT_TYPE_SSVM,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Failed to open secondary storage vm firewall port. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() 
@@ -170,7 +170,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
         			secStorageVm.getPrivateIpAddress() + ", message: " + args.getMessage());
     		
 			_alertMgr.sendAlert(
-				AlertManager.ALERT_TYPE_STORAGE_MISC,
+				AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC,
 				args.getZoneId(),
 				secStorageVm.getPodIdToDeployIn(),
 				"Secondary Storage Vm storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 9c45303..ac16ef4 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -409,7 +409,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
                 s_logger.warn("Management network CIDR is not configured originally. Set it default to "
                         + localCidrs[0]);
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0),
                         "Management network CIDR is not configured originally. Set it default to " + localCidrs[0], "");
                 _configDao
                 .update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]);
@@ -417,7 +417,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, Co
                 s_logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting");
                 _alertMgr
                 .sendAlert(
-                        AlertManager.ALERT_TYPE_MANAGMENT_NODE,
+                        AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE,
                         0,
                         new Long(0),
                         "Management network CIDR is not properly configured and we are not able to find a default setting",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
index 801e7da..a906811 100644
--- a/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
@@ -95,9 +95,9 @@ public class HighAvailabilityManagerExtImpl extends HighAvailabilityManagerImpl
                 }
 
                 if (!isRunning) {
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USAGE_SERVER, 0, new Long(0), "No usage server process running", "No usage server process has been detected, some attention is required");
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER, 0, new Long(0), "No usage server process running", "No usage server process has been detected, some attention is required");
                 } else {
-                    _alertMgr.clearAlert(AlertManager.ALERT_TYPE_USAGE_SERVER, 0, 0);
+                    _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER, 0, 0);
                 }
             } catch (Exception ex) {
                 s_logger.warn("Error while monitoring usage job", ex);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b315ca18/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index d6feaf3..d6b9ff3 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -29,12 +29,12 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-import org.apache.log4j.NDC;
 import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.managed.context.ManagedContext;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.alert.AlertManager;
@@ -238,7 +238,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
         HostPodVO podVO = _podDao.findById(host.getPodId());
         String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName();
 
-        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host is down, " + hostDesc, "Host [" + hostDesc + "] is down."
+        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host is down, " + hostDesc, "Host [" + hostDesc + "] is down."
                 + ((sb != null) ? sb.toString() : ""));
 
         for (final VMInstanceVO vm : vms) {
@@ -312,13 +312,13 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
                 s_logger.debug("VM does not require investigation so I'm marking it as Stopped: " + vm.toString());
             }
 
-            short alertType = AlertManager.ALERT_TYPE_USERVM;
+            AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM;
             if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
-                alertType = AlertManager.ALERT_TYPE_DOMAIN_ROUTER;
+                alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER;
             } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
-                alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY;
+                alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY;
             } else if (VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType())) {
-                alertType = AlertManager.ALERT_TYPE_SSVM;
+                alertType = AlertManager.AlertType.ALERT_TYPE_SSVM;
             }
 
             if (!(_forceHA || vm.isHaEnabled())) {
@@ -408,13 +408,13 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
             return null;
         }
 
-        short alertType = AlertManager.ALERT_TYPE_USERVM;
+        AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM;
         if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_DOMAIN_ROUTER;
+            alertType = AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER;
         } else if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_CONSOLE_PROXY;
+            alertType = AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY;
         } else if (VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType())) {
-            alertType = AlertManager.ALERT_TYPE_SSVM;
+            alertType = AlertManager.AlertType.ALERT_TYPE_SSVM;
         }
 
         HostVO host = _hostDao.findById(work.getHostId());