cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/2] CLOUDSTACK-5261: added support for Alert publishing via ROOT Admin API
Date Wed, 04 Dec 2013 18:05:03 GMT
Updated Branches:
  refs/heads/master 751d8d196 -> bd6f706b7


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 9174456..9d4de55 100644
--- a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
+++ b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java
@@ -68,7 +68,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                     s_logger.debug("Secondary Storage Vm is up, zone: " + dc.getName() +
", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
                         secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress());
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(),
"Secondary Storage Vm up in zone: " +
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(),
secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm up in zone: " +
                     dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public
IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
                     (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
"Secondary Storage Vm up (zone " + dc.getName() + ")");
                 break;
@@ -79,7 +79,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                         secStorageVm.getPublicIpAddress() + ", private IP: " + (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: " +
@@ -93,7 +93,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                         secStorageVm.getPublicIpAddress() + ", private IP: " + (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: " +
@@ -106,7 +106,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                     s_logger.debug("Secondary Storage Vm creation failure, zone: " + dc.getName()
+ ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
                         secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress()
== null ? "N/A" : secStorageVm.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(),
"Secondary Storage Vm creation failure. zone: " +
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(),
secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm creation failure. zone: " +
                     dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public
IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
                     (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
+ ", error details: " + args.getMessage(),
                     "Secondary Storage Vm creation failure (zone " + dc.getName() + ")");
@@ -117,7 +117,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                     s_logger.debug("Secondary Storage Vm startup failure, zone: " + dc.getName()
+ ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
                         secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress()
== null ? "N/A" : secStorageVm.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(),
"Secondary Storage Vm startup failure. zone: " +
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(),
secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm startup failure. zone: " +
                     dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public
IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
                     (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
+ ", error details: " + args.getMessage(),
                     "Secondary Storage Vm startup failure (zone " + dc.getName() + ")");
@@ -128,7 +128,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                     s_logger.debug("Secondary Storage Vm firewall alert, zone: " + dc.getName()
+ ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
                         secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress()
== null ? "N/A" : secStorageVm.getPrivateIpAddress()));
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(),
secStorageVm.getPodIdToDeployIn(),
                     "Failed to open secondary storage vm firewall port. zone: " + dc.getName()
+ ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
                         secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress()
== null ? "N/A" : secStorageVm.getPrivateIpAddress()),
                     "Secondary Storage Vm alert (zone " + dc.getName() + ")");
@@ -139,7 +139,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements
Alert
                     s_logger.debug("Secondary Storage Vm storage alert, zone: " + dc.getName()
+ ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
                         secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress()
+ ", message: " + args.getMessage());
 
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_STORAGE_MISC, args.getZoneId(),
secStorageVm.getPodIdToDeployIn(),
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC, args.getZoneId(),
secStorageVm.getPodIdToDeployIn(),
                     "Secondary Storage Vm storage issue. zone: " + dc.getName() + ", message:
" + args.getMessage(), "Secondary Storage Vm alert (zone " + dc.getName() +
                         ")");
                 break;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 854c089..a2c0204 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -403,12 +403,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
             if (localCidrs.length > 0) {
                 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),
"Management network CIDR is not configured originally. Set it default to " +
+                _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]);
             } else {
                 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, 0, new Long(0),
+                _alertMgr.sendAlert(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/bd6f706b/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 5d975fe..56db8ef 100644
--- a/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerExtImpl.java
@@ -92,10 +92,10 @@ public class HighAvailabilityManagerExtImpl extends HighAvailabilityManagerImpl
                 }
 
                 if (!isRunning) {
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USAGE_SERVER, 0, new Long(0),
"No usage server process running",
+                    _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/bd6f706b/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 fc65a21..aec1b8d 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -36,6 +36,8 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
 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;
@@ -243,7 +245,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) {
@@ -317,13 +319,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())) {
@@ -415,13 +417,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());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 d5b9d3c..2e8cde3 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1109,7 +1109,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                                 "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, router.getDataCenterId(),
router.getPodIdToDeployIn(), title, context);
+                            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
                         }
                     } finally {
                         _s2sVpnConnectionDao.releaseFromLockTable(lock.getId());
@@ -1170,7 +1170,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                     "Redundant virtual router (name: " + router.getHostName() + ", id: "
+ router.getId() + ") " + " just switch from " + prevState + " to " + currState;
                 s_logger.info(context);
                 if (currState == RedundantState.MASTER) {
-                    _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(),
router.getPodIdToDeployIn(), title, context);
+                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER,
router.getDataCenterId(), router.getPodIdToDeployIn(), title, context);
                 }
             }
         }
@@ -1186,7 +1186,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(title);
                 }
-                _alertMgr.sendAlert(AlertManager.ALERT_TYPE_DOMAIN_ROUTER, backupRouter.getDataCenterId(),
backupRouter.getPodIdToDeployIn(), title, title);
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, backupRouter.getDataCenterId(),
backupRouter.getPodIdToDeployIn(), title, title);
                 try {
                     rebootRouter(backupRouter.getId(), true);
                 } catch (ConcurrentOperationException e) {
@@ -1277,8 +1277,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                             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);
@@ -3571,7 +3571,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
         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, disconnectedRouter.getDataCenterId(),
disconnectedRouter.getPodIdToDeployIn(), title, context);
+        _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, disconnectedRouter.getDataCenterId(),
disconnectedRouter.getPodIdToDeployIn(), title, context);
         disconnectedRouter.setStopPending(true);
         disconnectedRouter = _routerDao.persist(disconnectedRouter);
 
@@ -3589,7 +3589,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, connectedRouter.getDataCenterId(),
connectedRouter.getPodIdToDeployIn(), t, t);
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, connectedRouter.getDataCenterId(),
connectedRouter.getPodIdToDeployIn(), t, t);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd6f706b/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 70e8cdf..6e5dce6 100755
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -253,7 +253,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=" +
+            _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/bd6f706b/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 ee9c04a..dbb3647 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -59,6 +59,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;
@@ -2254,6 +2255,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) {
@@ -2273,6 +2275,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);
@@ -2857,6 +2863,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/bd6f706b/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 3c5e6a4..ef89fe2 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -1077,7 +1077,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, "Snapshot resource limit exceeded for account id : " + owner.getId() +
+                _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/bd6f706b/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 ff519ea..4e78ba1 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1756,7 +1756,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());
@@ -3977,14 +3977,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);
         }
 
@@ -3994,14 +3994,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
                 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);
             }
         }
@@ -4041,7 +4041,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 {
@@ -4064,12 +4064,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/bd6f706b/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/bd6f706b/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 45f874c..6fbe288 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/bd6f706b/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 640adb9..0f86e85 100644
--- a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
@@ -32,20 +32,18 @@ import javax.mail.URLName;
 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;
 
-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;
-
 import com.cloud.alert.AlertManager;
 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;
 
 @Component
 @Local(value = {AlertManager.class})
@@ -88,10 +86,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);
@@ -99,7 +97,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 {
@@ -177,25 +175,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 {
-            s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId
+ " // podId:: " + podId + " // clusterId:: " + null +
-                " // message:: " + subject);
+        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()) {
@@ -245,4 +248,16 @@ 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/bd6f706b/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 3da7d48..b6c9ea6 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -818,10 +818,10 @@ 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(),
+                    _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();
 
@@ -1863,9 +1863,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);


Mime
View raw message