cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [2/2] git commit: updated refs/heads/master to bd6f706
Date Wed, 04 Dec 2013 18:05:04 GMT
CLOUDSTACK-5261: added support for Alert publishing via ROOT Admin API

Conflicts:
	engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
	engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
	engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
	engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
	engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
	plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
	plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
	plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
	server/src/com/cloud/alert/AlertManagerImpl.java
	server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java
	server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
	server/src/com/cloud/configuration/ConfigurationManagerImpl.java
	server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
	server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
	server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
	server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
	server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
	server/src/com/cloud/vm/UserVmManagerImpl.java
	usage/src/com/cloud/usage/UsageAlertManagerImpl.java
	usage/src/com/cloud/usage/UsageManagerImpl.java

listAlerts: introduced new parameter "name" to the alertResponse

Conflicts:
	api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
	server/src/com/cloud/alert/AlertManagerImpl.java
	usage/src/com/cloud/usage/UsageAlertManagerImpl.java

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

Conflicts:
	api/src/org/apache/cloudstack/alert/AlertService.java
	api/src/org/apache/cloudstack/api/BaseCmd.java
	usage/src/com/cloud/usage/UsageAlertManagerImpl.java

listAlerts: implemented search by alert name

Conflicts:
	api/src/org/apache/cloudstack/alert/AlertService.java
	api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java
	engine/schema/src/com/cloud/alert/AlertVO.java


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

Branch: refs/heads/master
Commit: bd6f706b7261948ff44cffeebab0c7fcddfae857
Parents: 751d8d1
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Dec 2 16:18:08 2013 -0800
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Wed Dec 4 10:05:46 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  |  11 +-
 .../command/admin/alert/GenerateAlertCmd.java   | 123 ++++++++++++++++
 .../command/admin/resource/ListAlertsCmd.java   |  11 +-
 .../cloudstack/api/response/AlertResponse.java  |   7 +
 client/tomcatconf/commands.properties.in        |   1 +
 .../src/com/cloud/alert/AlertManager.java       |  43 +-----
 .../cloud/agent/manager/AgentManagerImpl.java   |  10 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  37 +++--
 .../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      |   5 +-
 .../vmware/VmwareServerDiscoverer.java          |   2 +-
 .../xen/discoverer/XcpServerDiscoverer.java     |   9 +-
 .../provider/SolidFireHostListener.java         |   2 +-
 .../src/com/cloud/alert/AlertManagerImpl.java   | 142 +++++++------------
 .../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   |  20 +--
 .../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  |  49 ++++---
 usage/src/com/cloud/usage/UsageManagerImpl.java |   8 +-
 36 files changed, 465 insertions(+), 249 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 d835bf8..6555b6f 100644
--- a/api/src/com/cloud/alert/Alert.java
+++ b/api/src/com/cloud/alert/Alert.java
@@ -39,4 +39,5 @@ public interface Alert extends Identity, InternalIdentity {
     Date getResolved();
 
     boolean getArchived();
+    String getName();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 0554d7a..c539066 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -450,6 +450,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/bd6f706b/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..2143fe8
--- /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/bd6f706b/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 b060f43..86a7c72 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -26,14 +26,14 @@ import java.util.regex.Pattern;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.AffinityGroupService;
+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;
 import com.cloud.domain.Domain;
@@ -191,9 +191,12 @@ public abstract class BaseCmd {
     public InternalLoadBalancerVMService _internalLbSvc;
     @Inject
     public NetworkModel _ntwkModel;
-
+    @Inject 
+    public AlertService _alertSvc;
+    
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-        ResourceAllocationException, NetworkRuleConflictException;
+    ResourceAllocationException, NetworkRuleConflictException;
+
 
     public void configure() {
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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/bd6f706b/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 90ab67c..2fc4084 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
@@ -19,14 +19,13 @@ package org.apache.cloudstack.api.command.admin.resource;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.response.AlertResponse;
 import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.alert.Alert;
 import com.cloud.utils.Pair;
@@ -47,6 +46,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 +61,10 @@ public class ListAlertsCmd extends BaseListCmd {
     public String getType() {
         return type;
     }
+    
+    public String getName() {
+        return name;
+    }
 
     // ///////////////////////////////////////////////////
     // ///////////// API Implementation///////////////////
@@ -80,6 +86,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/bd6f706b/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 5a27915..a2554c3 100644
--- a/api/src/org/apache/cloudstack/api/response/AlertResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/AlertResponse.java
@@ -42,6 +42,9 @@ public class AlertResponse extends BaseResponse {
         + "MANAGMENT_NODE = 13: lost connection to default route (to the gateway), "
         + "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")
@@ -66,4 +69,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/bd6f706b/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/bd6f706b/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 5aea465..56a27df 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);
@@ -65,9 +35,10 @@ public interface AlertManager extends Manager {
         "Alert", "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/bd6f706b/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 1e8b148..42648df 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -818,7 +818,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;
@@ -828,8 +828,8 @@ 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() + ", host is in alert state: " + host.getId() + "-" + host.getName());
+                    _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 {
                 s_logger.debug("The next status of Agent " + host.getId() + " is not Alert, no need to investigate what happened");
@@ -1201,11 +1201,11 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
                                         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(),
+                                        _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() + " for agent id=" + cmdHostId +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 6b551cc..cbaddc9 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -40,8 +40,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -69,6 +67,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.Listener;
@@ -1676,11 +1675,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);
@@ -1936,11 +1935,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);
@@ -2555,13 +2554,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());
@@ -3506,11 +3505,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);
@@ -3859,7 +3858,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;
@@ -3881,7 +3880,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;
@@ -3923,7 +3922,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
@@ -3984,7 +3983,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/bd6f706b/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 75caabe..b5c1539 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -2841,7 +2841,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/bd6f706b/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 98d8557..ade505d 100755
--- a/engine/schema/src/com/cloud/alert/AlertVO.java
+++ b/engine/schema/src/com/cloud/alert/AlertVO.java
@@ -72,16 +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() {
         return id;
@@ -184,4 +182,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/bd6f706b/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 b884602..dbd95e8 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
@@ -364,7 +364,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, e.getMessage(), e.getMessage());
+                                            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, zoneId, null, e.getMessage(), e.getMessage());
                                         } finally {
                                             _resourceLimitMgr.recalculateResourceCount(accountId, _accountMgr.getAccount(accountId).getDomainId(),
                                                 com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 d2984e2..4838bf6 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
@@ -63,7 +63,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/bd6f706b/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 284f993..9f71abd 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;
@@ -1204,7 +1203,7 @@ public class VolumeServiceImpl implements VolumeService {
                                             com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize());
                                     } catch (ResourceAllocationException e) {
                                         s_logger.warn(e.getMessage());
-                                        _alertMgr.sendAlert(AlertManager.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, volume.getDataCenterId(), volume.getPodId(), e.getMessage(),
+                                        _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/bd6f706b/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 e3dcd8f..2a630c7 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
@@ -339,10 +339,11 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
             // TODO: does the resource have to create a connection?
             return resources;
         } catch (ConfigurationException e) {
-            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + uri.getHost(), "Error is " + e.getMessage());
+            _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, "Unable to add " + uri.getHost(), "Error is " + e.getMessage());
+            _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 (Exception e) {
             String msg = " can't setup agent, due to " + e.toString() + " - " + e.getMessage();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 8ed445f..ad3620d 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -402,7 +402,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
                 try {
                     resource.configure("VMware", params);
                 } catch (ConfigurationException e) {
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
+                    _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);
                 }
                 resource.start();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 6dfc0d4..705aa4c 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
@@ -253,7 +253,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);
                     }
@@ -331,7 +331,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;
                 }
@@ -468,7 +468,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);
     }
@@ -741,10 +741,9 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
                     "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);
             }
         }
-
         return new DeleteHostAnswer(true);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 5314314..d8e4ec6 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
@@ -82,7 +82,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/bd6f706b/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 fd24c02..c742813 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 {
@@ -228,10 +229,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);
@@ -239,10 +240,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?
@@ -258,67 +259,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.CPU";
-        } 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)
         //        for the vm sync state.  The listener model has connects/disconnects to keep things in sync much better
@@ -602,8 +542,8 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
         String msgContent = null;
         String totalStr;
         String usedStr;
-        String pctStr = formatPercent(usedCapacity / totalCapacity);
-        short alertType = -1;
+        String pctStr = formatPercent(usedCapacity/totalCapacity);
+        AlertType alertType = null;
         Long podId = pod == null ? null : pod.getId();
         Long clusterId = cluster == null ? null : cluster.getId();
 
@@ -615,21 +555,21 @@ 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 Capacity.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 Capacity.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 Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED:
                 msgSubject =
@@ -638,7 +578,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
                 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 Capacity.CAPACITY_TYPE_LOCAL_STORAGE:
                 msgSubject =
@@ -647,7 +587,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
                 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
@@ -656,7 +596,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
@@ -665,28 +605,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 Capacity.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 Capacity.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 Capacity.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;
         }
 
@@ -805,28 +745,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 {
-            s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + podId + " // clusterId:: " + null +
-                " // message:: " + subject);
+        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()) {
@@ -904,4 +848,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/bd6f706b/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 a06800e..568fc0f 100644
--- a/server/src/com/cloud/alert/ClusterAlertAdapter.java
+++ b/server/src/com/cloud/alert/ClusterAlertAdapter.java
@@ -72,7 +72,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;
             }
         }
@@ -92,7 +92,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/bd6f706b/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 1c04b22..86f7fc1 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
                     s_logger.debug("Console proxy is up, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
                         ", private IP: " + proxy.getPrivateIpAddress());
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy up in zone: " + dc.getName() +
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy up in zone: " + dc.getName() +
                     ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " +
                     (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy up (zone " + dc.getName() + ")");
                 break;
@@ -78,7 +78,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                     s_logger.debug("Console proxy is down, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
                         ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy down in zone: " + dc.getName() +
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy down in zone: " + dc.getName() +
                     ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " +
                     (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy down (zone " + dc.getName() + ")");
                 break;
@@ -88,7 +88,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                     s_logger.debug("Console proxy is rebooted, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
                         ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
                     "Console proxy rebooted in zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
                         ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy rebooted (zone " + dc.getName() +
                         ")");
@@ -99,7 +99,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                     s_logger.debug("Console proxy creation failure, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " +
                         proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
                     "Console proxy creation failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
                         ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
                     "Console proxy creation failure (zone " + dc.getName() + ")");
@@ -110,7 +110,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                     s_logger.debug("Console proxy startup failure, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " +
                         proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(),
                     "Console proxy startup failure. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
                         ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
                     "Console proxy startup failure (zone " + dc.getName() + ")");
@@ -122,7 +122,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                         proxy.getPublicIpAddress() + ", private IP: " + (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() + ", public IP: " +
@@ -135,7 +135,7 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte
                     s_logger.debug("Console proxy storage alert, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " +
                         proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress() + ", message: " + args.getMessage());
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_STORAGE_MISC, args.getZoneId(), proxy.getPodIdToDeployIn(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC, args.getZoneId(), proxy.getPodIdToDeployIn(),
                     "Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(), "Console proxy alert (zone " + dc.getName() + ")");
                 break;
         }


Mime
View raw message