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
This commit is contained in:
Alena Prokharchyk 2013-12-02 16:18:08 -08:00
parent 751d8d1966
commit bd6f706b72
36 changed files with 465 additions and 249 deletions

View File

@ -39,4 +39,5 @@ public interface Alert extends Identity, InternalIdentity {
Date getResolved(); Date getResolved();
boolean getArchived(); boolean getArchived();
String getName();
} }

View File

@ -450,6 +450,10 @@ public class EventTypes {
// Object store migration // Object store migration
public static final String EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE = "MIGRATE.PREPARE.SS"; public static final String EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE = "MIGRATE.PREPARE.SS";
//Alert generation
public static final String ALERT_GENERATE = "ALERT.GENERATE";
static { static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking // TODO: need a way to force author adding event types to declare the entity details as well, with out braking

View File

@ -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);
}

View File

@ -26,14 +26,14 @@ import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.affinity.AffinityGroupService; import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService; import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService; import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService; import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import org.apache.cloudstack.query.QueryService; import org.apache.cloudstack.query.QueryService;
import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.usage.UsageService;
import org.apache.log4j.Logger;
import com.cloud.configuration.ConfigurationService; import com.cloud.configuration.ConfigurationService;
import com.cloud.domain.Domain; import com.cloud.domain.Domain;
@ -191,9 +191,12 @@ public abstract class BaseCmd {
public InternalLoadBalancerVMService _internalLbSvc; public InternalLoadBalancerVMService _internalLbSvc;
@Inject @Inject
public NetworkModel _ntwkModel; public NetworkModel _ntwkModel;
@Inject
public AlertService _alertSvc;
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException; ResourceAllocationException, NetworkRuleConflictException;
public void configure() { public void configure() {
} }

View File

@ -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;
}
}

View File

@ -19,14 +19,13 @@ package org.apache.cloudstack.api.command.admin.resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd; import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.AlertResponse; import org.apache.cloudstack.api.response.AlertResponse;
import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ListResponse;
import org.apache.log4j.Logger;
import com.cloud.alert.Alert; import com.cloud.alert.Alert;
import com.cloud.utils.Pair; 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") @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "list by alert type")
private String type; private String type;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list by alert name", since="4.3")
private String name;
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
// ///////////////// Accessors /////////////////////// // ///////////////// Accessors ///////////////////////
@ -59,6 +61,10 @@ public class ListAlertsCmd extends BaseListCmd {
public String getType() { public String getType() {
return type; return type;
} }
public String getName() {
return name;
}
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
// ///////////// API Implementation/////////////////// // ///////////// API Implementation///////////////////
@ -80,6 +86,7 @@ public class ListAlertsCmd extends BaseListCmd {
alertResponse.setAlertType(alert.getType()); alertResponse.setAlertType(alert.getType());
alertResponse.setDescription(alert.getSubject()); alertResponse.setDescription(alert.getSubject());
alertResponse.setLastSent(alert.getLastSent()); alertResponse.setLastSent(alert.getLastSent());
alertResponse.setName(alert.getName());
alertResponse.setObjectName("alert"); alertResponse.setObjectName("alert");
alertResponseList.add(alertResponse); alertResponseList.add(alertResponse);

View File

@ -42,6 +42,9 @@ public class AlertResponse extends BaseResponse {
+ "MANAGMENT_NODE = 13: lost connection to default route (to the gateway), " + "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") + "DOMAIN_ROUTER_MIGRATE = 14, CONSOLE_PROXY_MIGRATE = 15, USERVM_MIGRATE = 16, VLAN = 17, SSVM = 18, " + "USAGE_SERVER_RESULT = 19")
private Short alertType; private Short alertType;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the alert", since="4.3")
private String alertName;
@SerializedName(ApiConstants.DESCRIPTION) @SerializedName(ApiConstants.DESCRIPTION)
@Param(description = "description of the alert") @Param(description = "description of the alert")
@ -66,4 +69,8 @@ public class AlertResponse extends BaseResponse {
public void setLastSent(Date lastSent) { public void setLastSent(Date lastSent) {
this.lastSent = lastSent; this.lastSent = lastSent;
} }
public void setName(String name) {
this.alertName = name;
}
} }

View File

@ -246,6 +246,7 @@ deleteEvents=15
listAlerts=3 listAlerts=3
archiveAlerts=1 archiveAlerts=1
deleteAlerts=1 deleteAlerts=1
generateAlert=1
#### system capacity commands #### system capacity commands
listCapacity=3 listCapacity=3

View File

@ -16,43 +16,13 @@
// under the License. // under the License.
package com.cloud.alert; package com.cloud.alert;
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.ConfigKey;
import com.cloud.capacity.CapacityVO;
import com.cloud.utils.component.Manager; import com.cloud.utils.component.Manager;
public interface AlertManager extends Manager { public interface AlertManager extends Manager, AlertService{
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;
static final ConfigKey<Double> StorageCapacityThreshold = new ConfigKey<Double>(Double.class, "cluster.storage.capacity.notificationthreshold", "Alert", "0.75", 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, "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); 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, "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); ConfigKey.Scope.Cluster, null);
void clearAlert(short alertType, long dataCenterId, long podId); void clearAlert(AlertType alertType, long dataCenterId, long podId);
void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body);
void recalculateCapacity(); void recalculateCapacity();
void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String body);
} }

View File

@ -818,7 +818,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
HostPodVO podVO = _podDao.findById(host.getPodId()); HostPodVO podVO = _podDao.findById(host.getPodId());
String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); 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)) { 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"); "If the agent for host [" + hostDesc + "] is not restarted within " + AlertWait + " seconds, HA will begin on the VMs");
} }
event = Status.Event.AgentDisconnected; event = Status.Event.AgentDisconnected;
@ -828,8 +828,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId()); DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());
HostPodVO podVO = _podDao.findById(host.getPodId()); HostPodVO podVO = _podDao.findById(host.getPodId());
String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); 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, _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host in ALERT state, " + hostDesc, "In availability zone " + host.getDataCenterId()
"In availability zone " + host.getDataCenterId() + ", host is in alert state: " + host.getId() + "-" + host.getName()); + ", host is in alert state: " + host.getId() + "-" + host.getName());
} }
} else { } else {
s_logger.debug("The next status of Agent " + host.getId() + " is not Alert, no need to investigate what happened"); 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 = String hostDesc =
"name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); "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 + "Host lost connection to gateway, " + hostDesc, "Host [" + hostDesc +
"] lost connection to gateway (default route) and is possibly having network connection issues."); "] lost connection to gateway (default route) and is possibly having network connection issues.");
} else { } else {
_alertMgr.clearAlert(AlertManager.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId()); _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId());
} }
} else { } else {
s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId + s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId +

View File

@ -40,8 +40,6 @@ import javax.ejb.Local;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; 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.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO;
import org.apache.cloudstack.utils.identity.ManagementServerNode; import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener; 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()); 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())) { 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())) { } 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); VirtualMachineProfile vmSrc = new VirtualMachineProfileImpl(vm);
@ -1936,11 +1935,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
" doesn't involve migrating the volumes."); " 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())) { 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())) { } 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); _networkMgr.prepareNicForMigration(profile, destination);
@ -2555,13 +2554,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (agentState == State.Error) { if (agentState == State.Error) {
agentState = State.Stopped; agentState = State.Stopped;
short alertType = AlertManager.ALERT_TYPE_USERVM; AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM;
if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) { 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())) { } 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())) { } 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()); 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()); 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())) { 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())) { } 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); 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 // 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() + 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"); ") state is sync-ed (Starting -> Running) from out-of-context transition. VM network environment may need to be reset");
break; break;
@ -3881,7 +3880,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.warn("Unexpected VM state transition exception, race-condition?", 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() + 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"); " -> Running) from out-of-context transition. VM network environment may need to be reset");
break; break;
@ -3923,7 +3922,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.warn("Unexpected VM state transition exception, race-condition?", 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() + VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState() +
" -> Stopped) from out-of-context transition."); " -> Stopped) from out-of-context transition.");
// TODO: we need to forcely release all resource allocation // 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); VMInstanceVO vm = _vmDao.findById(vmId);
// We now only alert administrator about this situation // 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() + VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") is stuck in " + vm.getState() +
" state and its host is unreachable for too long"); " state and its host is unreachable for too long");
} }

View File

@ -2841,7 +2841,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
if (!answer.getResult()) { if (!answer.getResult()) {
s_logger.warn("Unable to setup agent " + hostId + " due to " + ((answer != null) ? answer.getDetails() : "return null")); 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(); 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); throw new ConnectionException(true, msg);
} else { } else {
if (answer.needReconnect()) { if (answer.needReconnect()) {

View File

@ -72,16 +72,14 @@ public class AlertVO implements Alert {
@Column(name = "archived") @Column(name = "archived")
private boolean archived; private boolean archived;
@Column(name="name")
private String name;
public AlertVO() { public AlertVO() {
this.uuid = UUID.randomUUID().toString(); this.uuid = UUID.randomUUID().toString();
} }
public AlertVO(Long id) {
this.id = id;
this.uuid = UUID.randomUUID().toString();
}
@Override @Override
public long getId() { public long getId() {
return id; return id;
@ -184,4 +182,14 @@ public class AlertVO implements Alert {
public void setArchived(Boolean archived) { public void setArchived(Boolean archived) {
this.archived = archived; this.archived = archived;
} }
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} }

View File

@ -364,7 +364,7 @@ public class TemplateServiceImpl implements TemplateService {
tmpltInfo.getSize() - UriUtils.getRemoteSize(tmplt.getUrl())); tmpltInfo.getSize() - UriUtils.getRemoteSize(tmplt.getUrl()));
} catch (ResourceAllocationException e) { } catch (ResourceAllocationException e) {
s_logger.warn(e.getMessage()); 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 { } finally {
_resourceLimitMgr.recalculateResourceCount(accountId, _accountMgr.getAccount(accountId).getDomainId(), _resourceLimitMgr.recalculateResourceCount(accountId, _accountMgr.getAccount(accountId).getDomainId(),
com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal()); com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());

View File

@ -63,7 +63,7 @@ public class DefaultHostListener implements HypervisorHostListener {
if (!answer.getResult()) { if (!answer.getResult()) {
String msg = "Unable to attach storage pool" + poolId + " to the host" + hostId; 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() + throw new CloudRuntimeException("Unable establish connection from storage head to storage pool " + pool.getId() + " due to " + answer.getDetails() +
pool.getId()); pool.getId());
} }

View File

@ -25,9 +25,6 @@ import java.util.Map;
import javax.inject.Inject; 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.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo; import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; 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.VolumeDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
import org.apache.cloudstack.storage.to.VolumeObjectTO; 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.Answer;
import com.cloud.agent.api.storage.ListVolumeAnswer; 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()); com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize());
} catch (ResourceAllocationException e) { } catch (ResourceAllocationException e) {
s_logger.warn(e.getMessage()); 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()); e.getMessage());
} finally { } finally {
_resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(), _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(),

View File

@ -339,10 +339,11 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
// TODO: does the resource have to create a connection? // TODO: does the resource have to create a connection?
return resources; return resources;
} catch (ConfigurationException e) { } 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); s_logger.warn("Unable to instantiate " + uri.getHost(), e);
} catch (UnknownHostException 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); s_logger.warn("Unable to instantiate " + uri.getHost(), e);
} catch (Exception e) { } catch (Exception e) {
String msg = " can't setup agent, due to " + e.toString() + " - " + e.getMessage(); String msg = " can't setup agent, due to " + e.toString() + " - " + e.getMessage();

View File

@ -402,7 +402,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
try { try {
resource.configure("VMware", params); resource.configure("VMware", params);
} catch (ConfigurationException e) { } 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); s_logger.warn("Unable to instantiate " + url.getHost(), e);
} }
resource.start(); resource.start();

View File

@ -253,7 +253,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
} }
if (!support_hvm) { if (!support_hvm) {
String msg = "Unable to add host " + record.address + " because it doesn't 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); s_logger.debug(msg);
throw new RuntimeException(msg); throw new RuntimeException(msg);
} }
@ -331,7 +331,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
try { try {
resource.configure("Xen Server", params); resource.configure("Xen Server", params);
} catch (ConfigurationException e) { } 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); s_logger.warn("Unable to instantiate " + record.address, e);
continue; continue;
} }
@ -468,7 +468,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
String msg = 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 " + "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; 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); s_logger.debug(msg);
throw new RuntimeException(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() + "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(); "in this host " + host.getPrivateIpAddress();
s_logger.warn(msg); 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); return new DeleteHostAnswer(true);
} }

View File

@ -82,7 +82,7 @@ public class SolidFireHostListener implements HypervisorHostListener {
if (!answer.getResult()) { if (!answer.getResult()) {
String msg = "Unable to attach storage pool " + storagePoolId + " to host " + hostId; 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() + throw new CloudRuntimeException("Unable to establish a connection from agent to storage pool " + storagePool.getId() + " due to " + answer.getDetails() +
" (" + storagePool.getId() + ")"); " (" + storagePool.getId() + ")");

View File

@ -40,12 +40,7 @@ import javax.mail.URLName;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.log4j.Logger; import org.apache.cloudstack.alert.AlertService.AlertType;
import com.sun.mail.smtp.SMTPMessage;
import com.sun.mail.smtp.SMTPSSLTransport;
import com.sun.mail.smtp.SMTPTransport;
import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable; 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.managed.context.ManagedContextTimerTask;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import com.cloud.alert.dao.AlertDao; import com.cloud.alert.dao.AlertDao;
import com.cloud.api.ApiDBUtils; 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.DataCenterDao;
import com.cloud.dc.dao.DataCenterIpAddressDao; import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.dc.dao.HostPodDao; import com.cloud.dc.dao.HostPodDao;
import com.cloud.event.ActionEvent;
import com.cloud.event.AlertGenerator; import com.cloud.event.AlertGenerator;
import com.cloud.event.EventTypes;
import com.cloud.host.Host; import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.network.dao.IPAddressDao; 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.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB; import com.cloud.utils.db.DB;
import com.cloud.utils.db.SearchCriteria; 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}) @Local(value = {AlertManager.class})
public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable { public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable {
@ -228,10 +229,10 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
} }
@Override @Override
public void clearAlert(short alertType, long dataCenterId, long podId) { public void clearAlert(AlertType alertType, long dataCenterId, long podId) {
try { try {
if (_emailAlert != null) { if (_emailAlert != null) {
_emailAlert.clearAlert(alertType, dataCenterId, podId); _emailAlert.clearAlert(alertType.getType(), dataCenterId, podId);
} }
} catch (Exception ex) { } catch (Exception ex) {
s_logger.error("Problem clearing email alert", ex); s_logger.error("Problem clearing email alert", ex);
@ -239,10 +240,10 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
} }
@Override @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 // 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, // 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? // 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() { public void recalculateCapacity() {
// FIXME: the right way to do this is to register a listener (see RouterStatsListener, VMSyncListener) // 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 // 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 msgContent = null;
String totalStr; String totalStr;
String usedStr; String usedStr;
String pctStr = formatPercent(usedCapacity / totalCapacity); String pctStr = formatPercent(usedCapacity/totalCapacity);
short alertType = -1; AlertType alertType = null;
Long podId = pod == null ? null : pod.getId(); Long podId = pod == null ? null : pod.getId();
Long clusterId = cluster == null ? null : cluster.getId(); Long clusterId = cluster == null ? null : cluster.getId();
@ -615,21 +555,21 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
totalStr = formatBytesToMegabytes(totalCapacity); totalStr = formatBytesToMegabytes(totalCapacity);
usedStr = formatBytesToMegabytes(usedCapacity); usedStr = formatBytesToMegabytes(usedCapacity);
msgContent = "System memory is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; msgContent = "System memory is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
alertType = ALERT_TYPE_MEMORY; alertType = AlertManager.AlertType.ALERT_TYPE_MEMORY;
break; break;
case Capacity.CAPACITY_TYPE_CPU: case Capacity.CAPACITY_TYPE_CPU:
msgSubject = "System Alert: Low Unallocated CPU in cluster " + cluster.getName() + " pod " + pod.getName() + " of availability zone " + dc.getName(); msgSubject = "System Alert: Low Unallocated CPU in cluster " + cluster.getName() + " pod " + pod.getName() + " of availability zone " + dc.getName();
totalStr = _dfWhole.format(totalCapacity); totalStr = _dfWhole.format(totalCapacity);
usedStr = _dfWhole.format(usedCapacity); usedStr = _dfWhole.format(usedCapacity);
msgContent = "Unallocated CPU is low, total: " + totalStr + " Mhz, used: " + usedStr + " Mhz (" + pctStr + "%)"; msgContent = "Unallocated CPU is low, total: " + totalStr + " Mhz, used: " + usedStr + " Mhz (" + pctStr + "%)";
alertType = ALERT_TYPE_CPU; alertType = AlertManager.AlertType.ALERT_TYPE_CPU;
break; break;
case Capacity.CAPACITY_TYPE_STORAGE: case Capacity.CAPACITY_TYPE_STORAGE:
msgSubject = "System Alert: Low Available Storage in cluster " + cluster.getName() + " pod " + pod.getName() + " of availability zone " + dc.getName(); msgSubject = "System Alert: Low Available Storage in cluster " + cluster.getName() + " pod " + pod.getName() + " of availability zone " + dc.getName();
totalStr = formatBytesToMegabytes(totalCapacity); totalStr = formatBytesToMegabytes(totalCapacity);
usedStr = formatBytesToMegabytes(usedCapacity); usedStr = formatBytesToMegabytes(usedCapacity);
msgContent = "Available storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; msgContent = "Available storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)";
alertType = ALERT_TYPE_STORAGE; alertType = AlertManager.AlertType.ALERT_TYPE_STORAGE;
break; break;
case Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED: case Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED:
msgSubject = msgSubject =
@ -638,7 +578,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
totalStr = formatBytesToMegabytes(totalCapacity); totalStr = formatBytesToMegabytes(totalCapacity);
usedStr = formatBytesToMegabytes(usedCapacity); usedStr = formatBytesToMegabytes(usedCapacity);
msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)"; 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; break;
case Capacity.CAPACITY_TYPE_LOCAL_STORAGE: case Capacity.CAPACITY_TYPE_LOCAL_STORAGE:
msgSubject = msgSubject =
@ -647,7 +587,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
totalStr = formatBytesToMegabytes(totalCapacity); totalStr = formatBytesToMegabytes(totalCapacity);
usedStr = formatBytesToMegabytes(usedCapacity); usedStr = formatBytesToMegabytes(usedCapacity);
msgContent = "Unallocated storage space is low, total: " + totalStr + " MB, allocated: " + usedStr + " MB (" + pctStr + "%)"; 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; break;
//Pod Level //Pod Level
@ -656,7 +596,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
totalStr = Double.toString(totalCapacity); totalStr = Double.toString(totalCapacity);
usedStr = Double.toString(usedCapacity); usedStr = Double.toString(usedCapacity);
msgContent = "Number of unallocated private IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)"; 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; break;
//Zone Level //Zone Level
@ -665,28 +605,28 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
totalStr = formatBytesToMegabytes(totalCapacity); totalStr = formatBytesToMegabytes(totalCapacity);
usedStr = formatBytesToMegabytes(usedCapacity); usedStr = formatBytesToMegabytes(usedCapacity);
msgContent = "Available secondary storage space is low, total: " + totalStr + " MB, used: " + usedStr + " MB (" + pctStr + "%)"; 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; break;
case Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP: 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(); msgSubject = "System Alert: Number of unallocated virtual network public IPs is low in availability zone " + dc.getName();
totalStr = Double.toString(totalCapacity); totalStr = Double.toString(totalCapacity);
usedStr = Double.toString(usedCapacity); usedStr = Double.toString(usedCapacity);
msgContent = "Number of unallocated public IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)"; 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; break;
case Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP: case Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP:
msgSubject = "System Alert: Number of unallocated shared network IPs is low in availability zone " + dc.getName(); msgSubject = "System Alert: Number of unallocated shared network IPs is low in availability zone " + dc.getName();
totalStr = Double.toString(totalCapacity); totalStr = Double.toString(totalCapacity);
usedStr = Double.toString(usedCapacity); usedStr = Double.toString(usedCapacity);
msgContent = "Number of unallocated shared network IPs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)"; 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; break;
case Capacity.CAPACITY_TYPE_VLAN: case Capacity.CAPACITY_TYPE_VLAN:
msgSubject = "System Alert: Number of unallocated VLANs is low in availability zone " + dc.getName(); msgSubject = "System Alert: Number of unallocated VLANs is low in availability zone " + dc.getName();
totalStr = Double.toString(totalCapacity); totalStr = Double.toString(totalCapacity);
usedStr = Double.toString(usedCapacity); usedStr = Double.toString(usedCapacity);
msgContent = "Number of unallocated VLANs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)"; msgContent = "Number of unallocated VLANs is low, total: " + totalStr + ", allocated: " + usedStr + " (" + pctStr + "%)";
alertType = ALERT_TYPE_VLAN; alertType = AlertManager.AlertType.ALERT_TYPE_VLAN;
break; 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 // 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, public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long clusterId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
UnsupportedEncodingException { s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " +
s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + podId + " // clusterId:: " + null + podId + " // clusterId:: " + null + " // message:: " + subject);
" // message:: " + subject);
AlertVO alert = null; AlertVO alert = null;
if ((alertType != AlertManager.ALERT_TYPE_HOST) && (alertType != AlertManager.ALERT_TYPE_USERVM) && (alertType != AlertManager.ALERT_TYPE_DOMAIN_ROUTER) && if ((alertType != AlertManager.AlertType.ALERT_TYPE_HOST) &&
(alertType != AlertManager.ALERT_TYPE_CONSOLE_PROXY) && (alertType != AlertManager.ALERT_TYPE_SSVM) && (alertType != AlertManager.AlertType.ALERT_TYPE_USERVM) &&
(alertType != AlertManager.ALERT_TYPE_STORAGE_MISC) && (alertType != AlertManager.ALERT_TYPE_MANAGMENT_NODE) && (alertType != AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER) &&
(alertType != AlertManager.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED)) { (alertType != AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY) &&
alert = _alertDao.getLastAlert(alertType, dataCenterId, podId, clusterId); (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) { if (alert == null) {
// set up a new alert // set up a new alert
AlertVO newAlert = new AlertVO(); AlertVO newAlert = new AlertVO();
newAlert.setType(alertType); newAlert.setType(alertType.getType());
newAlert.setSubject(subject); newAlert.setSubject(subject);
newAlert.setClusterId(clusterId); newAlert.setClusterId(clusterId);
newAlert.setPodId(podId); newAlert.setPodId(podId);
newAlert.setDataCenterId(dataCenterId); newAlert.setDataCenterId(dataCenterId);
newAlert.setSentCount(1); // initialize sent count to 1 since we are now sending an alert newAlert.setSentCount(1); // initialize sent count to 1 since we are now sending an alert
newAlert.setLastSent(new Date()); newAlert.setLastSent(new Date());
newAlert.setName(alertType.getName());
_alertDao.persist(newAlert); _alertDao.persist(newAlert);
} else { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
@ -904,4 +848,16 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
public ConfigKey<?>[] getConfigKeys() { public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold}; 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;
}
}
} }

View File

@ -72,7 +72,7 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter {
s_logger.debug("Management server node " + mshost.getServiceIP() + " is up, send alert"); 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; break;
} }
} }
@ -92,7 +92,7 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, send alert"); 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 { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set"); s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set");

View File

@ -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() + s_logger.debug("Console proxy is up, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() +
", private IP: " + proxy.getPrivateIpAddress()); ", 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: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " +
(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy up (zone " + dc.getName() + ")"); (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy up (zone " + dc.getName() + ")");
break; 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() + 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())); ", 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: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " +
(proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy down (zone " + dc.getName() + ")"); (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy down (zone " + dc.getName() + ")");
break; 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() + 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())); ", 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() + "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() + ", 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: " + 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())); 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() + "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(), ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
"Console proxy creation failure (zone " + dc.getName() + ")"); "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: " + 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())); 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() + "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(), ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
"Console proxy startup failure (zone " + dc.getName() + ")"); "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())); proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
_alertMgr.sendAlert( _alertMgr.sendAlert(
AlertManager.ALERT_TYPE_CONSOLE_PROXY, AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY,
args.getZoneId(), args.getZoneId(),
proxy.getPodIdToDeployIn(), proxy.getPodIdToDeployIn(),
"Failed to open console proxy firewall port. zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + "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: " + s_logger.debug("Console proxy storage alert, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " +
proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress() + ", message: " + args.getMessage()); 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() + ")"); "Console proxy storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(), "Console proxy alert (zone " + dc.getName() + ")");
break; break;
} }

View File

@ -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: " + s_logger.debug("Secondary Storage Vm is up, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " +
secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress()); 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: " + 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() + ")"); (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()), "Secondary Storage Vm up (zone " + dc.getName() + ")");
break; break;
@ -79,7 +79,7 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert
secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())); secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
_alertMgr.sendAlert( _alertMgr.sendAlert(
AlertManager.ALERT_TYPE_SSVM, AlertManager.AlertType.ALERT_TYPE_SSVM,
args.getZoneId(), args.getZoneId(),
secStorageVm.getPodIdToDeployIn(), secStorageVm.getPodIdToDeployIn(),
"Secondary Storage Vm down in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + "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())); secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
_alertMgr.sendAlert( _alertMgr.sendAlert(
AlertManager.ALERT_TYPE_SSVM, AlertManager.AlertType.ALERT_TYPE_SSVM,
args.getZoneId(), args.getZoneId(),
secStorageVm.getPodIdToDeployIn(), secStorageVm.getPodIdToDeployIn(),
"Secondary Storage Vm rebooted in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + "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: " + 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())); 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: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()) + ", error details: " + args.getMessage(), (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
"Secondary Storage Vm creation failure (zone " + dc.getName() + ")"); "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: " + 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())); 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: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
(secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()) + ", error details: " + args.getMessage(), (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()) + ", error details: " + args.getMessage(),
"Secondary Storage Vm startup failure (zone " + dc.getName() + ")"); "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: " + 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())); 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: " + "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()), secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
"Secondary Storage Vm alert (zone " + dc.getName() + ")"); "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: " + 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()); 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() + "Secondary Storage Vm storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(), "Secondary Storage Vm alert (zone " + dc.getName() +
")"); ")");
break; break;

View File

@ -403,12 +403,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (localCidrs.length > 0) { if (localCidrs.length > 0) {
s_logger.warn("Management network CIDR is not configured originally. Set it default to " + localCidrs[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], ""); localCidrs[0], "");
_configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]); _configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]);
} else { } else {
s_logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting"); 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", ""); "Management network CIDR is not properly configured and we are not able to find a default setting", "");
} }
} }

View File

@ -92,10 +92,10 @@ public class HighAvailabilityManagerExtImpl extends HighAvailabilityManagerImpl
} }
if (!isRunning) { 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"); "No usage server process has been detected, some attention is required");
} else { } else {
_alertMgr.clearAlert(AlertManager.ALERT_TYPE_USAGE_SERVER, 0, 0); _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER, 0, 0);
} }
} catch (Exception ex) { } catch (Exception ex) {
s_logger.warn("Error while monitoring usage job", ex); s_logger.warn("Error while monitoring usage job", ex);

View File

@ -36,6 +36,8 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.managed.context.ManagedContext; import org.apache.cloudstack.managed.context.ManagedContext;
import org.apache.cloudstack.managed.context.ManagedContextRunnable; 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.agent.AgentManager;
import com.cloud.alert.AlertManager; import com.cloud.alert.AlertManager;
@ -243,7 +245,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
HostPodVO podVO = _podDao.findById(host.getPodId()); HostPodVO podVO = _podDao.findById(host.getPodId());
String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); 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() : "")); ((sb != null) ? sb.toString() : ""));
for (final VMInstanceVO vm : vms) { 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()); 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())) { 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())) { } 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())) { } else if (VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType())) {
alertType = AlertManager.ALERT_TYPE_SSVM; alertType = AlertManager.AlertType.ALERT_TYPE_SSVM;
} }
if (!(_forceHA || vm.isHaEnabled())) { if (!(_forceHA || vm.isHaEnabled())) {
@ -415,13 +417,13 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
return null; return null;
} }
short alertType = AlertManager.ALERT_TYPE_USERVM; AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM;
if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) { 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())) { } 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())) { } 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()); HostVO host = _hostDao.findById(work.getHostId());

View File

@ -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() + ") " + "Site-to-site Vpn Connection to " + gw.getName() + " on router " + router.getHostName() + "(id: " + router.getId() + ") " +
" just switch from " + oldState + " to " + conn.getState(); " just switch from " + oldState + " to " + conn.getState();
s_logger.info(context); 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 { } finally {
_s2sVpnConnectionDao.releaseFromLockTable(lock.getId()); _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; "Redundant virtual router (name: " + router.getHostName() + ", id: " + router.getId() + ") " + " just switch from " + prevState + " to " + currState;
s_logger.info(context); s_logger.info(context);
if (currState == RedundantState.MASTER) { 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()) { if (s_logger.isDebugEnabled()) {
s_logger.debug(title); 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 { try {
rebootRouter(backupRouter.getId(), true); rebootRouter(backupRouter.getId(), true);
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
@ -1277,8 +1277,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
String context = String context =
"Virtual router (name: " + router.getHostName() + ", id: " + router.getId() + " and router (name: " + dupRouter.getHostName() + ", id: " + "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. "; 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.AlertType.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, dupRouter.getDataCenterId(), dupRouter.getPodIdToDeployIn(), title, context);
s_logger.warn(context); s_logger.warn(context);
} else { } else {
networkRouterMaps.put(routerGuestNtwkId, router); networkRouterMaps.put(routerGuestNtwkId, router);
@ -3571,7 +3571,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
String context = String context =
"Virtual router (name: " + disconnectedRouter.getInstanceName() + ", id: " + disconnectedRouter.getId() + "Virtual router (name: " + disconnectedRouter.getInstanceName() + ", id: " + disconnectedRouter.getId() +
") would be stopped after connecting back, due to: " + reason; ") 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.setStopPending(true);
disconnectedRouter = _routerDao.persist(disconnectedRouter); disconnectedRouter = _routerDao.persist(disconnectedRouter);
@ -3589,7 +3589,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
} }
} else { } else {
String t = "Can't bump up virtual router " + connectedRouter.getInstanceName() + "'s priority due to it's already bumped up!"; 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);
} }
} }
} }

View File

@ -253,7 +253,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
long numToDecrement = (delta.length == 0) ? 1 : delta[0].longValue(); long numToDecrement = (delta.length == 0) ? 1 : delta[0].longValue();
if (!updateResourceCountForAccount(accountId, type, false, numToDecrement)) { 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 + accountId, "Failed to decrement resource count of type " + type + " for account id=" + accountId +
"; use updateResourceCount API to recalculate/fix the problem"); "; use updateResourceCount API to recalculate/fix the problem");
} }

View File

@ -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.EnableAccountCmd;
import org.apache.cloudstack.api.command.admin.account.LockAccountCmd; 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.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.CreateCounterCmd;
import org.apache.cloudstack.api.command.admin.autoscale.DeleteCounterCmd; import org.apache.cloudstack.api.command.admin.autoscale.DeleteCounterCmd;
import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd; 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 id = cmd.getId();
Object type = cmd.getType(); Object type = cmd.getType();
Object keyword = cmd.getKeyword(); Object keyword = cmd.getKeyword();
Object name = cmd.getName();
Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null); Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), null);
if (id != null) { if (id != null) {
@ -2273,6 +2275,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (type != null) { if (type != null) {
sc.addAnd("type", SearchCriteria.Op.EQ, type); sc.addAnd("type", SearchCriteria.Op.EQ, type);
} }
if (name != null) {
sc.addAnd("name", SearchCriteria.Op.EQ, name);
}
sc.addAnd("archived", SearchCriteria.Op.EQ, false); sc.addAnd("archived", SearchCriteria.Op.EQ, false);
Pair<List<AlertVO>, Integer> result = _alertDao.searchAndCount(sc, searchFilter); 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(ListSslCertsCmd.class);
cmdList.add(AssignCertToLoadBalancerCmd.class); cmdList.add(AssignCertToLoadBalancerCmd.class);
cmdList.add(RemoveCertFromLoadBalancerCmd.class); cmdList.add(RemoveCertFromLoadBalancerCmd.class);
cmdList.add(GenerateAlertCmd.class);
return cmdList; return cmdList;
} }

View File

@ -1077,7 +1077,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
if (snapshotType != Type.MANUAL) { if (snapshotType != Type.MANUAL) {
String msg = "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots"; String msg = "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots";
s_logger.warn(msg); 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"); ". Failed to create recurring snapshots; please use updateResourceLimit to increase the limit");
} }
throw e; throw e;

View File

@ -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; 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 // Get serviceOffering for Virtual Machine
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId()); ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
@ -3977,14 +3977,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (srcExplDedicated && !destExplDedicated) { if (srcExplDedicated && !destExplDedicated) {
//raise an alert //raise an alert
String msg = "VM is being migrated from a explicitly dedicated host " + srcHost.getName() + " to non-dedicated host " + destHost.getName(); 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); s_logger.warn(msg);
} }
//if srcHost is non dedicated but destination Host is explicitly dedicated //if srcHost is non dedicated but destination Host is explicitly dedicated
if (!srcExplDedicated && destExplDedicated) { if (!srcExplDedicated && destExplDedicated) {
//raise an alert //raise an alert
String msg = "VM is being migrated from a non dedicated host " + srcHost.getName() + " to a explicitly dedicated host " + destHost.getName(); 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); s_logger.warn(msg);
} }
@ -3994,14 +3994,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
String msg = String msg =
"VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(srcHost) + " to host " + "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(srcHost) + " to host " +
destHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(destHost); 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); s_logger.warn(msg);
} }
if ((domainOfDedicatedHost(srcHost) != null) && (domainOfDedicatedHost(srcHost) != domainOfDedicatedHost(destHost))) { if ((domainOfDedicatedHost(srcHost) != null) && (domainOfDedicatedHost(srcHost) != domainOfDedicatedHost(destHost))) {
String msg = String msg =
"VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(srcHost) + " to host " + "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(srcHost) + " to host " +
destHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(destHost); 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); 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); s_logger.warn(msg);
} else { } else {
@ -4064,12 +4064,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
} else { } else {
msg = "VM is being migrated from implicitly dedicated host " + srcHost.getName() + " to shared host " + destHost.getName(); 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); s_logger.warn(msg);
} else { } else {
if (destImplDedicated) { if (destImplDedicated) {
msg = "VM is being migrated from shared host " + srcHost.getName() + " to implicitly dedicated host " + destHost.getName(); 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); s_logger.warn(msg);
} }
} }

View File

@ -63,7 +63,7 @@ public class MockAlertManagerImpl extends ManagerBase implements AlertManager {
* @see com.cloud.alert.AlertManager#clearAlert(short, long, long) * @see com.cloud.alert.AlertManager#clearAlert(short, long, long)
*/ */
@Override @Override
public void clearAlert(short alertType, long dataCenterId, long podId) { public void clearAlert(AlertType alertType, long dataCenterId, long podId) {
// TODO Auto-generated method stub // 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) * @see com.cloud.alert.AlertManager#sendAlert(short, long, java.lang.Long, java.lang.String, java.lang.String)
*/ */
@Override @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 // 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;
}
} }

View File

@ -799,3 +799,7 @@ CREATE TABLE `cloud`.`network_acl_item_details` (
PRIMARY KEY (`id`), 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 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; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`alert` ADD COLUMN `name` varchar(255) DEFAULT NULL COMMENT 'name of the alert';

View File

@ -32,20 +32,18 @@ import javax.mail.URLName;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; 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.AlertManager;
import com.cloud.alert.AlertVO; import com.cloud.alert.AlertVO;
import com.cloud.alert.dao.AlertDao; import com.cloud.alert.dao.AlertDao;
import com.cloud.utils.NumbersUtil; import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.ManagerBase; 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 @Component
@Local(value = {AlertManager.class}) @Local(value = {AlertManager.class})
@ -88,10 +86,10 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
} }
@Override @Override
public void clearAlert(short alertType, long dataCenterId, long podId) { public void clearAlert(AlertType alertType, long dataCenterId, long podId) {
try { try {
if (_emailAlert != null) { if (_emailAlert != null) {
_emailAlert.clearAlert(alertType, dataCenterId, podId); _emailAlert.clearAlert(alertType.getType(), dataCenterId, podId);
} }
} catch (Exception ex) { } catch (Exception ex) {
s_logger.error("Problem clearing email alert", ex); s_logger.error("Problem clearing email alert", ex);
@ -99,7 +97,7 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
} }
@Override @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, // 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? // shouldn't we have a type/severity as part of the API so that severe errors get sent right away?
try { try {
@ -177,25 +175,30 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
} }
// TODO: make sure this handles SSL transport (useAuth is true) and regular // TODO: make sure this handles SSL transport (useAuth is true) and regular
public void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String content) throws MessagingException, UnsupportedEncodingException { protected void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + podId + " // clusterId:: " + null + s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " +
" // message:: " + subject); podId + " // clusterId:: " + null + " // message:: " + subject);
AlertVO alert = null; AlertVO alert = null;
if ((alertType != AlertManager.ALERT_TYPE_HOST) && (alertType != AlertManager.ALERT_TYPE_USERVM) && (alertType != AlertManager.ALERT_TYPE_DOMAIN_ROUTER) && if ((alertType != AlertManager.AlertType.ALERT_TYPE_HOST) &&
(alertType != AlertManager.ALERT_TYPE_CONSOLE_PROXY) && (alertType != AlertManager.ALERT_TYPE_SSVM) && (alertType != AlertManager.AlertType.ALERT_TYPE_USERVM) &&
(alertType != AlertManager.ALERT_TYPE_STORAGE_MISC) && (alertType != AlertManager.ALERT_TYPE_MANAGMENT_NODE)) { (alertType != AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER) &&
alert = _alertDao.getLastAlert(alertType, dataCenterId, podId); (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) { if (alert == null) {
// set up a new alert // set up a new alert
AlertVO newAlert = new AlertVO(); AlertVO newAlert = new AlertVO();
newAlert.setType(alertType); newAlert.setType(alertType.getType());
newAlert.setSubject(subject); newAlert.setSubject(subject);
newAlert.setPodId(podId); newAlert.setPodId(podId);
newAlert.setDataCenterId(dataCenterId); newAlert.setDataCenterId(dataCenterId);
newAlert.setSentCount(1); // initialize sent count to 1 since we are now sending an alert newAlert.setSentCount(1); // initialize sent count to 1 since we are now sending an alert
newAlert.setLastSent(new Date()); newAlert.setLastSent(new Date());
newAlert.setName(alertType.getName());
_alertDao.persist(newAlert); _alertDao.persist(newAlert);
} else { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
@ -245,4 +248,16 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
// TODO Auto-generated method stub // 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;
}
}
} }

View File

@ -818,10 +818,10 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
// switch back to CLOUD_DB // switch back to CLOUD_DB
TransactionLegacy swap = TransactionLegacy.open(TransactionLegacy.CLOUD_DB); TransactionLegacy swap = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
if (!success) { 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()); "Usage job failed. Job id: " + job.getId());
} else { } else {
_alertMgr.clearAlert(AlertManager.ALERT_TYPE_USAGE_SERVER_RESULT, 0, 0); _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER_RESULT, 0, 0);
} }
swap.close(); swap.close();
@ -1863,9 +1863,9 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
try { try {
String errors = usc.runSanityCheck(); String errors = usc.runSanityCheck();
if (errors.length() > 0) { 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 { } 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) { } catch (SQLException e) {
s_logger.error("Error in sanity check", e); s_logger.error("Error in sanity check", e);