mirror of https://github.com/apache/cloudstack.git
bug 7842: events refactoring. Still wrok in progress
This commit is contained in:
parent
d1aa043aba
commit
94ec7bf27a
|
|
@ -215,7 +215,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_START;
|
||||
return EventTypes.EVENT_VM_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.lang.annotation.Target;
|
|||
@Retention(RUNTIME)
|
||||
public @interface ActionEvent {
|
||||
boolean create() default false;
|
||||
boolean async() default false;
|
||||
String eventType();
|
||||
String eventDescription();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public class UserContext {
|
|||
private String sessionId;
|
||||
private Account account;
|
||||
private long startEventId = 0;
|
||||
private long accountId;
|
||||
|
||||
private boolean apiServer;
|
||||
|
||||
|
|
@ -112,4 +113,12 @@ public class UserContext {
|
|||
return startEventId;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,19 +64,13 @@ public class ApiDispatcher {
|
|||
|
||||
public void dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map<String, String> params) {
|
||||
|
||||
boolean created = false;
|
||||
String errorMsg = "";
|
||||
long startId = 0;
|
||||
|
||||
if(cmd.getCreateEventType() != null){
|
||||
startId = cmd.saveStartedEvent(cmd.getCreateEventType(), cmd.getCreateEventDescription(), 0L);
|
||||
}
|
||||
|
||||
setupParameters(cmd, params);
|
||||
|
||||
try {
|
||||
UserContext ctx = UserContext.current();
|
||||
ctx.setAccountId(cmd.getEntityOwnerId());
|
||||
cmd.create();
|
||||
created = true;
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {
|
||||
s_logger.info(t.getMessage());
|
||||
|
|
@ -121,27 +115,21 @@ public class ApiDispatcher {
|
|||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, BaseCmd.USER_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if(cmd.getCreateEventType() != null){
|
||||
if (created){
|
||||
cmd.saveCompletedEvent(EventVO.LEVEL_INFO, cmd.getCreateEventType(), cmd.getCreateEventDescription()+" successfull. Id: "+cmd.getEntityId(), startId);
|
||||
} else {
|
||||
cmd.saveCompletedEvent(EventVO.LEVEL_ERROR, cmd.getCreateEventType(), cmd.getCreateEventDescription()+" failed. "+errorMsg, startId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatch(BaseCmd cmd, Map<String, String> params) {
|
||||
boolean success = false;
|
||||
String errorMsg = "";
|
||||
setupParameters(cmd, params);
|
||||
try {
|
||||
if(cmd instanceof BaseAsyncCmd){
|
||||
((BaseAsyncCmd)cmd).saveStartedEvent();
|
||||
UserContext ctx = UserContext.current();
|
||||
BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmd;
|
||||
ctx.setAccountId(asyncCmd.getEntityOwnerId());
|
||||
String startEventId = params.get("ctxStartEventId");
|
||||
ctx.setStartEventId(Long.valueOf(startEventId));
|
||||
}
|
||||
cmd.execute();
|
||||
success = true;
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {
|
||||
s_logger.info(t.getMessage());
|
||||
|
|
@ -186,15 +174,6 @@ public class ApiDispatcher {
|
|||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, BaseCmd.USER_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if(cmd instanceof BaseAsyncCmd){
|
||||
BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmd;
|
||||
if(success){
|
||||
asyncCmd.saveCompletedEvent(EventVO.LEVEL_INFO, asyncCmd.getEventDescription()+" completed successfully");
|
||||
} else {
|
||||
asyncCmd.saveCompletedEvent(EventVO.LEVEL_ERROR, asyncCmd.getEventDescription()+" failed. "+errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -370,6 +370,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
Long objectId = null;
|
||||
if (cmdObj instanceof BaseAsyncCreateCmd) {
|
||||
BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd)cmdObj;
|
||||
ctx.setAccountId(createCmd.getEntityOwnerId());
|
||||
_dispatcher.dispatchCreateCmd(createCmd, params);
|
||||
objectId = createCmd.getEntityId();
|
||||
params.put("id", objectId.toString());
|
||||
|
|
@ -386,13 +387,21 @@ public class ApiServer implements HttpRequestHandler {
|
|||
params.put("ctxAccountId", String.valueOf(account.getId()));
|
||||
}
|
||||
|
||||
long startEventId = ctx.getStartEventId();
|
||||
asyncCmd.setStartEventId(startEventId);
|
||||
|
||||
// save the scheduled event
|
||||
Long eventId = EventUtils.saveScheduledEvent((userId == null) ? User.UID_SYSTEM : userId, asyncCmd.getEntityOwnerId(),
|
||||
asyncCmd.getEventType(), asyncCmd.getEventDescription());
|
||||
|
||||
if (eventId != null) {
|
||||
params.put("starteventid", eventId.toString());
|
||||
asyncCmd.getEventType(), asyncCmd.getEventDescription(), startEventId);
|
||||
if(startEventId == 0){
|
||||
//There was no create event before, set current event id as start eventId
|
||||
startEventId = eventId;
|
||||
}
|
||||
|
||||
params.put("ctxStartEventId", String.valueOf(startEventId));
|
||||
|
||||
ctx.setAccountId(asyncCmd.getEntityOwnerId());
|
||||
|
||||
|
||||
AsyncJobVO job = new AsyncJobVO();
|
||||
job.setInstanceId((objectId == null) ? asyncCmd.getInstanceId() : objectId);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,5 @@ public interface ConfigurationManager extends Manager {
|
|||
|
||||
void createDefaultNetworks(long zoneId) throws ConcurrentOperationException;
|
||||
|
||||
Long saveConfigurationEvent(long userId, Long accountId, String type, String description, String... paramsList);
|
||||
|
||||
DataCenterVO getZone(long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ import com.cloud.dc.dao.VlanDao;
|
|||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
|
|
@ -115,7 +112,6 @@ import com.cloud.user.AccountManager;
|
|||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
|
|
@ -242,7 +238,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, "Successfully edited configuration value.", "name=" + name, "value=" + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -496,11 +491,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
@DB
|
||||
public boolean deletePod(DeletePodCmd cmd) {
|
||||
Long podId = cmd.getId();
|
||||
Long userId = 1L;
|
||||
|
||||
if (UserContext.current() != null) {
|
||||
userId = UserContext.current().getCallerUserId();
|
||||
}
|
||||
|
||||
// Make sure the pod exists
|
||||
if (!validPod(podId)) {
|
||||
|
|
@ -510,7 +500,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
checkIfPodIsDeletable(podId);
|
||||
|
||||
HostPodVO pod = _podDao.findById(podId);
|
||||
DataCenterVO zone = _zoneDao.findById(pod.getDataCenterId());
|
||||
|
||||
//Delete private ip addresses for the pod if there are any
|
||||
List<DataCenterIpAddressVO> privateIps = _privateIpAddressDao.listByPodIdDcId(Long.valueOf(podId), pod.getDataCenterId());
|
||||
|
|
@ -538,7 +527,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new CloudRuntimeException("Failed to delete pod " + podId);
|
||||
}
|
||||
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_POD_DELETE, "Successfully deleted pod with name: " + pod.getName() + " in zone: " + zone.getName() + ".", "podId=" + podId, "dcId=" + zone.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -554,7 +542,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String cidr = null;
|
||||
Long id = cmd.getId();
|
||||
String name = cmd.getPodName();
|
||||
Long userId = UserContext.current().getCallerUserId();
|
||||
|
||||
//verify parameters
|
||||
HostPodVO pod = _podDao.findById(id);;
|
||||
|
|
@ -658,8 +645,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new CloudRuntimeException("Failed to edit pod. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_POD_EDIT, "Successfully edited pod. New pod name is: " + name + " and new zone name is: " + zone.getName() + ".", "podId=" + pod.getId(), "dcId=" + zone.getId(), "gateway=" + gateway, "cidr=" + cidr, "startIp=" + startIp, "endIp=" + endIp);
|
||||
|
||||
return pod;
|
||||
}
|
||||
|
||||
|
|
@ -742,9 +727,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new CloudRuntimeException("Failed to create new pod. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_POD_CREATE, "Successfully created new pod with name: " + podName + " in zone: " + zone.getName() + ".", "podId=" + pod.getId(), "zoneId=" + zone.getId(), "gateway=" + gateway, "cidr=" + cidr, "startIp=" + startIp, "endIp=" + endIp);
|
||||
|
||||
return pod;
|
||||
}
|
||||
|
||||
|
|
@ -922,8 +904,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
checkIfZoneIsDeletable(zoneId);
|
||||
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
|
||||
boolean success = _zoneDao.expunge(zoneId);
|
||||
|
||||
try {
|
||||
|
|
@ -949,7 +929,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
if (success){
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_DELETE, "Successfully deleted zone with name: " + zone.getName() + ".", "dcId=" + zoneId);
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
|
|
@ -1134,8 +1113,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
}
|
||||
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_EDIT, "Successfully edited zone with name: " + zone.getName() + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "vnetRange=" + vnetRange, "guestCidr=" + guestCidr);
|
||||
|
||||
return zone;
|
||||
}
|
||||
|
||||
|
|
@ -1185,12 +1162,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
//Create deafult networks
|
||||
createDefaultNetworks(zone.getId());
|
||||
|
||||
if (vnetRange != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_CREATE, "Successfully created new zone with name: " + zoneName + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "vnetRange=" + vnetRange, "guestCidr=" + guestCidr);
|
||||
} else {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_CREATE, "Successfully created new zone with name: " + zoneName + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "guestCidr=" + guestCidr);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return zone;
|
||||
} catch (Exception ex) {
|
||||
|
|
@ -1368,8 +1339,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false,domainId);
|
||||
|
||||
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_CREATE, "Successfully created new service offering with name: " + name + ".", "soId=" + offering.getId(), "name=" + name, "numCPUs=" + cpu, "ram=" + ramSize, "cpuSpeed=" + speed,
|
||||
"displayText=" + displayText, "guestIPType=" + guestIpType, "localStorageRequired=" + localStorageRequired, "offerHA=" + offerHA, "useVirtualNetwork=" + useVirtualNetwork, "tags=" + tags);
|
||||
return offering;
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -1444,8 +1413,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
if (_serviceOfferingDao.update(id, offering)) {
|
||||
offering = _serviceOfferingDao.findById(id);
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully updated service offering with name: " + offering.getName() + ".", "soId=" + offering.getId(), "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == Network.GuestIpType.Virtual), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
|
||||
return offering;
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -1548,8 +1515,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
// }
|
||||
|
||||
if (_diskOfferingDao.update(diskOfferingId, diskOffering)) {
|
||||
saveConfigurationEvent(UserContext.current().getCallerUserId(), null, EventTypes.EVENT_DISK_OFFERING_EDIT, "Successfully updated disk offering with name: " + diskOffering.getName() + ".", "doId=" + diskOffering.getId(), "name=" + diskOffering.getName(),
|
||||
"displayText=" + diskOffering.getDisplayText(), "diskSize=" + diskOffering.getDiskSize(),"tags=" + diskOffering.getTags(),"domainId="+cmd.getDomainId());
|
||||
return _diskOfferingDao.findById(diskOfferingId);
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -1592,8 +1557,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
if (_serviceOfferingDao.remove(offeringId)) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully deleted service offering with name: " + offering.getName(), "soId=" + offeringId, "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == GuestIpType.Virtual));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -1962,13 +1925,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
eventMsg += ", end IP = " + endIP;
|
||||
}
|
||||
eventMsg += ".";
|
||||
Long accountId = ((account == null) ? Account.ACCOUNT_ID_SYSTEM : account.getId());
|
||||
saveConfigurationEvent(userId, accountId, EventTypes.EVENT_VLAN_IP_RANGE_CREATE, eventMsg, "vlanType=" + vlanType, "dcId=" + zoneId,
|
||||
"accountId=" + accountId, "podId=" + podId,
|
||||
"vlanId=" + vlanId, "vlanGateway=" + vlanGateway,
|
||||
"vlanNetmask=" + vlanNetmask, "startIP=" + startIP,
|
||||
"endIP=" + endIP);
|
||||
|
||||
if (associateIpRangeToAccount) {
|
||||
// if this is an account VLAN, now associate the IP Addresses to the account
|
||||
associateIpAddressListToAccount(userId, account.getId(), zoneId, vlan.getId());
|
||||
|
|
@ -2028,15 +1984,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String errorMsg = "Unable to assign public IP address pool";
|
||||
if (!success) {
|
||||
s_logger.debug(errorMsg);
|
||||
for(String ip : ipAddrsList){
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_NET_IP_ASSIGN, "Unable to assign public IP " +ip);
|
||||
}
|
||||
throw new CloudRuntimeException(errorMsg);
|
||||
}
|
||||
txn.commit();
|
||||
for(String ip : ipAddrsList){
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_NET_IP_ASSIGN, "Successfully assigned account IP " +ip);
|
||||
}
|
||||
}
|
||||
} catch (CloudRuntimeException iee) {
|
||||
s_logger.error("Associate IP threw an CloudRuntimeException.", iee);
|
||||
|
|
@ -2070,44 +2020,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new InvalidParameterValueException("The IP range can't be deleted because it is being used by a domain router.");
|
||||
}
|
||||
|
||||
Long accountId = null;
|
||||
Long podId = null;
|
||||
List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
|
||||
List<PodVlanMapVO> podVlanMaps = _podVlanMapDao.listPodVlanMapsByVlan(vlanDbId);
|
||||
|
||||
if (accountVlanMaps.size() > 0) {
|
||||
accountId = accountVlanMaps.get(0).getAccountId();
|
||||
}
|
||||
|
||||
if (podVlanMaps.size() > 0) {
|
||||
podId = podVlanMaps.get(0).getPodId();
|
||||
}
|
||||
|
||||
// Delete all public IPs in the VLAN
|
||||
if (!deletePublicIPRange(vlanDbId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the VLAN
|
||||
boolean success = _vlanDao.expunge(vlanDbId);
|
||||
|
||||
if (success) {
|
||||
String[] ipRange = vlan.getIpRange().split("\\-");
|
||||
String startIP = ipRange[0];
|
||||
String endIP = (ipRange.length > 1) ? ipRange[1] : null;
|
||||
String eventMsg = "Successfully deleted IP range (tag = " + vlan.getVlanTag() + ", gateway = " + vlan.getVlanGateway() + ", netmask = " + vlan.getVlanNetmask() + ", start IP = " + startIP;
|
||||
if (endIP != null) {
|
||||
eventMsg += ", end IP = " + endIP;
|
||||
}
|
||||
eventMsg += ".";
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_VLAN_IP_RANGE_DELETE, eventMsg, "vlanType=" + vlan.getVlanType(), "dcId=" + vlan.getDataCenterId(),
|
||||
"accountId=" + accountId, "podId=" + podId,
|
||||
"vlanId=" + vlan.getVlanTag(), "vlanGateway=" + vlan.getVlanGateway(),
|
||||
"vlanNetmask=" + vlan.getVlanNetmask(), "startIP=" + startIP,
|
||||
"endIP=" + endIP);
|
||||
}
|
||||
|
||||
return success;
|
||||
return _vlanDao.expunge(vlanDbId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2523,48 +2442,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long saveConfigurationEvent(long userId, Long accountId, String type, String description, String... paramsList) {
|
||||
UserVO user = _userDao.findById(userId);
|
||||
long accountIdToUse = (accountId != null) ? accountId : user.getAccountId();
|
||||
|
||||
String eventParams = "";
|
||||
String logParams = "";
|
||||
for (int i = 0; i < paramsList.length; i++) {
|
||||
String param = paramsList[i];
|
||||
boolean lastParam = (i == (paramsList.length - 1));
|
||||
|
||||
logParams += param;
|
||||
if (!lastParam) {
|
||||
logParams += ", ";
|
||||
}
|
||||
|
||||
String[] valList = param.split("\\=");
|
||||
String val = (valList.length < 2) ? "null" : valList[1];
|
||||
if (val.equals("null")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
eventParams += param;
|
||||
if (!lastParam) {
|
||||
eventParams += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(userId);
|
||||
event.setAccountId(accountIdToUse);
|
||||
event.setType(type);
|
||||
event.setDescription(description);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
event.setParameters(eventParams);
|
||||
event = _eventDao.persist(event);
|
||||
|
||||
s_logger.debug("User " + user.getUsername() + " performed configuration action: " + type + ", " + description + " | params: " + logParams);
|
||||
|
||||
return event.getId();
|
||||
}
|
||||
|
||||
private String[] getLinkLocalIPRange() throws InvalidParameterValueException {
|
||||
String ipNums = _configDao.getValue("linkLocalIp.nums");
|
||||
int nums = Integer.parseInt(ipNums);
|
||||
|
|
@ -2725,8 +2602,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, false, specifyVlan, networkRate, multicastRate, maxConnections, false, availability, false, false, false, false, false, false, false);
|
||||
|
||||
if ((offering = _networkOfferingDao.persist(offering)) != null) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_CREATE, "Successfully created new network offering with name: " + name + ".", "noId=" + offering.getId(), "name=" + name,
|
||||
"displayText=" + displayText, "tags=" + tags);
|
||||
return offering;
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -2796,7 +2671,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
@Override
|
||||
public boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd) throws InvalidParameterValueException{
|
||||
Long offeringId = cmd.getId();
|
||||
Long userId = UserContext.current().getCallerUserId();
|
||||
|
||||
//Verify network offering id
|
||||
NetworkOfferingVO offering = _networkOfferingDao.findById(offeringId);
|
||||
|
|
@ -2812,8 +2686,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
if (_networkOfferingDao.remove(offeringId)) {
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_DELETE, "Successfully deleted network offering with name: " + offering.getName(), "noId=" + offeringId, "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -340,8 +340,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
long accountId = proxy.getAccountId();
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, accountId, EventTypes.EVENT_PROXY_START, "Starting proxy : " + proxy.getName());
|
||||
proxy = startProxy(proxyVmId);
|
||||
|
||||
if (proxy == null) {
|
||||
|
|
@ -363,7 +361,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Unable to start console proxy, proxy vm Id : " + proxyVmId + " will recycle it and restart a new one");
|
||||
}
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_PROXY_START, "Failed to start console proxy", startEventId);
|
||||
destroyProxy(proxyVmId);
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -371,7 +368,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
s_logger.trace("Console proxy " + proxy.getName() + " is started");
|
||||
}
|
||||
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_PROXY_START, "Started console proxy: "+proxy.getName(), startEventId);
|
||||
// if it is a new assignment or a changed assignment,
|
||||
// update the
|
||||
// record
|
||||
|
|
@ -644,7 +640,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
}
|
||||
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_PROXY_CREATE, "Creating console proxy");
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
|
|
@ -652,14 +647,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Creating proxy instance failed, data center id : " + dataCenterId);
|
||||
}
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_ERROR, EventTypes.EVENT_PROXY_CREATE, "console proxy creation failed", startEventId);
|
||||
return null;
|
||||
}
|
||||
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
// allocProxyStorage(dataCenterId, proxyVmId);
|
||||
if (proxy != null) {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_INFO, EventTypes.EVENT_PROXY_CREATE, "Succesfully created console proxy", startEventId);
|
||||
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
|
||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATED, dataCenterId, proxy.getId(), proxy, null));
|
||||
return proxy;
|
||||
|
|
@ -673,7 +666,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
this,
|
||||
new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE, dataCenterId, proxyVmId, null,
|
||||
"Unable to allocate storage"));
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_ERROR, EventTypes.EVENT_PROXY_CREATE, "console proxy creation failed", startEventId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -1171,8 +1163,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
if (proxy != null) {
|
||||
long proxyVmId = proxy.getId();
|
||||
GlobalLock proxyLock = GlobalLock.getInternLock(getProxyLockName(proxyVmId));
|
||||
long accountId = proxy.getAccountId();
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, accountId, EventTypes.EVENT_PROXY_START, "Starting proxy : " + proxy.getName());
|
||||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
|
|
@ -1195,7 +1185,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
s_logger.info("Unable to start console proxy for standby capacity, proxy vm Id : " + proxyVmId
|
||||
+ ", will recycle it and start a new one");
|
||||
}
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_PROXY_START, "Failed to start console proxy", startEventId);
|
||||
|
||||
if (proxyFromStoppedPool) {
|
||||
destroyProxy(proxyVmId);
|
||||
|
|
@ -1204,8 +1193,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Console proxy " + proxy.getName() + " is started");
|
||||
}
|
||||
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_PROXY_START, "Started console proxy: "+proxy.getName(), startEventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,36 +24,14 @@ import net.sf.cglib.proxy.Callback;
|
|||
import net.sf.cglib.proxy.MethodInterceptor;
|
||||
import net.sf.cglib.proxy.MethodProxy;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.component.AnnotationInterceptor;
|
||||
|
||||
public class ActionEventCallback implements MethodInterceptor, AnnotationInterceptor<EventVO> {
|
||||
boolean create = false;
|
||||
private String eventType = null;
|
||||
private long accountId = Account.ACCOUNT_ID_SYSTEM;
|
||||
private long userId = User.UID_SYSTEM;
|
||||
private String description = null;
|
||||
private long startEventId = 0;
|
||||
|
||||
@Override
|
||||
public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||
ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
|
||||
EventVO event = null;
|
||||
if (actionEvent != null) {
|
||||
create = actionEvent.create();
|
||||
UserContext ctx = UserContext.current();
|
||||
Long userID = ctx.getCallerUserId();
|
||||
userId = (userID == null) ? User.UID_SYSTEM : userID;
|
||||
eventType = actionEvent.eventType();
|
||||
description = actionEvent.eventDescription();
|
||||
startEventId = ctx.getStartEventId();
|
||||
|
||||
if(!create){
|
||||
event = interceptStart(method);
|
||||
}
|
||||
}
|
||||
EventVO event = interceptStart(method);;
|
||||
try {
|
||||
return methodProxy.invokeSuper(object, args);
|
||||
} finally {
|
||||
|
|
@ -70,30 +48,25 @@ public class ActionEventCallback implements MethodInterceptor, AnnotationInterce
|
|||
Method method = (Method)element;
|
||||
ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
|
||||
if (actionEvent != null) {
|
||||
create = actionEvent.create();
|
||||
return true;
|
||||
}
|
||||
|
||||
Class<?> clazz = method.getDeclaringClass();
|
||||
do {
|
||||
actionEvent = clazz.getAnnotation(ActionEvent.class);
|
||||
if (actionEvent != null) {
|
||||
return true;
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
} while (clazz != Object.class && clazz != null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventVO interceptStart(AnnotatedElement element) {
|
||||
EventVO event = null;
|
||||
if(eventType != null){
|
||||
long eventId = EventUtils.saveStartedEvent(userId, accountId, eventType, description, startEventId);
|
||||
if(startEventId == 0){
|
||||
// There was no scheduled event. so Started event Id
|
||||
startEventId = eventId;
|
||||
Method method = (Method)element;
|
||||
ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
|
||||
if (actionEvent != null) {
|
||||
boolean async = actionEvent.async();
|
||||
if(async){
|
||||
UserContext ctx = UserContext.current();
|
||||
long userId = ctx.getCallerUserId();
|
||||
long accountId = ctx.getAccountId();
|
||||
long startEventId = ctx.getStartEventId();
|
||||
EventUtils.saveStartedEvent(userId, accountId, actionEvent.eventType(), actionEvent.eventDescription(), startEventId);
|
||||
}
|
||||
}
|
||||
return event;
|
||||
|
|
@ -101,25 +74,37 @@ public class ActionEventCallback implements MethodInterceptor, AnnotationInterce
|
|||
|
||||
@Override
|
||||
public void interceptComplete(AnnotatedElement element, EventVO event) {
|
||||
if(eventType != null){
|
||||
if(create){
|
||||
Method method = (Method)element;
|
||||
ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
|
||||
if (actionEvent != null) {
|
||||
UserContext ctx = UserContext.current();
|
||||
long userId = ctx.getCallerUserId();
|
||||
long accountId = ctx.getAccountId();
|
||||
long startEventId = ctx.getStartEventId();
|
||||
if(actionEvent.create()){
|
||||
//This start event has to be used for subsequent events of this action
|
||||
startEventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_INFO, eventType, "Successfully created entity for "+description);
|
||||
UserContext ctx = UserContext.current();
|
||||
startEventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for "+actionEvent.eventDescription());
|
||||
ctx.setStartEventId(startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, eventType, "Successfully completed "+description, startEventId);
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed "+actionEvent.eventDescription(), startEventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptException(AnnotatedElement element, EventVO event) {
|
||||
if(eventType != null){
|
||||
if(create){
|
||||
EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_ERROR, eventType, "Error while creating entity for "+description);
|
||||
Method method = (Method)element;
|
||||
ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
|
||||
if (actionEvent != null) {
|
||||
UserContext ctx = UserContext.current();
|
||||
long userId = ctx.getCallerUserId();
|
||||
long accountId = ctx.getAccountId();
|
||||
long startEventId = ctx.getStartEventId();
|
||||
if(actionEvent.create()){
|
||||
long eventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for "+actionEvent.eventDescription());
|
||||
ctx.setStartEventId(eventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, eventType, "Error while "+description, startEventId);
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while "+actionEvent.eventDescription(), startEventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ public class EventUtils {
|
|||
/*
|
||||
* Save event after scheduling an async job
|
||||
*/
|
||||
public static Long saveScheduledEvent(Long userId, Long accountId, String type, String description) {
|
||||
public static Long saveScheduledEvent(Long userId, Long accountId, String type, String description, long startEventId) {
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(userId);
|
||||
event.setAccountId(accountId);
|
||||
event.setType(type);
|
||||
event.setStartId(startEventId);
|
||||
event.setState(Event.State.Scheduled);
|
||||
event.setDescription("Scheduled async job for "+description);
|
||||
event = _eventDao.persist(event);
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ import com.cloud.deploy.DeploymentPlan;
|
|||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
|
|
@ -259,11 +257,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
long dcId = network.getDataCenterId();
|
||||
long ownerId = owner.getId();
|
||||
|
||||
final EventVO event = new EventVO();
|
||||
event.setUserId(callerId); // system user performed the action...
|
||||
event.setAccountId(ownerId);
|
||||
event.setType(EventTypes.EVENT_NET_IP_ASSIGN);
|
||||
|
||||
PublicIp ip = null;
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
@ -297,8 +290,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
// Increment the number of public IPs for this accountId in the database
|
||||
_accountMgr.incrementResourceCount(ownerId, ResourceType.public_ip);
|
||||
event.setDescription("Acquired a public ip: " + ip.getAddress());
|
||||
_eventDao.persist(event);
|
||||
} else {
|
||||
// Account already has ip addresses
|
||||
|
||||
|
|
@ -333,9 +324,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
if (ip == null) {
|
||||
txn.rollback();
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
event.setDescription("Failed to acquire a public ip.");
|
||||
_eventDao.persist(event);
|
||||
s_logger.error("Unable to get source nat ip address for account " + ownerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -524,11 +512,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(userId);
|
||||
event.setAccountId(ownerId);
|
||||
event.setType(EventTypes.EVENT_NET_IP_ASSIGN);
|
||||
|
||||
PublicIp ip = null;
|
||||
boolean success = false;
|
||||
|
||||
|
|
@ -566,9 +549,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
_accountMgr.incrementResourceCount(ownerId, ResourceType.public_ip);
|
||||
|
||||
Ip ipAddress = ip.getAddress();
|
||||
event.setParameters("address=" + ipAddress + "\nsourceNat=" + false + "\ndcId=" + zoneId);
|
||||
event.setDescription("Assigned a public IP address: " + ipAddress);
|
||||
_eventDao.persist(event);
|
||||
|
||||
s_logger.debug("Got " + ipAddress + " to assign for account " + owner.getId() + " in zone " + network.getDataCenterId());
|
||||
|
||||
|
|
@ -604,9 +584,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
_ipAddressDao.unassignIpAddress(ip.getAddress());
|
||||
_accountMgr.decrementResourceCount(ownerId, ResourceType.public_ip);
|
||||
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
event.setDescription("");
|
||||
_eventDao.persist(event);
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
|
|
@ -662,9 +639,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
EventUtils.saveEvent(userId, ip.getAllocatedToAccountId(), EventTypes.EVENT_NET_IP_RELEASE, "released a public ip: " + addr);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -1455,21 +1429,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
txn.commit();
|
||||
|
||||
String eventMsg = "Successfully created network " + name + " (networkOfferingId=" + networkOfferingId + ", isShared=" + isShared + ", ownerId=" + ownerId + ", netmask=" + netmask + ", startIP=" + startIP + ", endIP=" + endIP + ", gateway=" + gateway + ", vlan=" + vlanId + ")";
|
||||
if (networks != null && !networks.isEmpty()) {
|
||||
_configMgr.saveConfigurationEvent(userId, ownerId, EventTypes.EVENT_NETWORK_CREATE, eventMsg,
|
||||
"dcId=" + zoneId,
|
||||
"networkOfferingId=" + networkOfferingId,
|
||||
"name=" + name,
|
||||
"isShared=" + isShared,
|
||||
"ownerId=" + ownerId,
|
||||
"networkGateway=" + gateway,
|
||||
"networkNetmask=" + netmask,
|
||||
"startIP=" + startIP,
|
||||
"endIP=" + endIP,
|
||||
"vlan=" + vlanId);
|
||||
}
|
||||
|
||||
return networks.get(0);
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Unexpected exception while creating network ", ex);
|
||||
|
|
@ -1725,8 +1684,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
_networksDao.update(network.getId(), network);
|
||||
_networksDao.remove(network.getId());
|
||||
txn.commit();
|
||||
String eventMsg = "Successfully deleted network " + network.getName() + " (id=" + networkId + ")";
|
||||
_configMgr.saveConfigurationEvent(callerUserId, network.getAccountId(), EventTypes.EVENT_NETWORK_DELETE, eventMsg, "id=" + networkId, "dcId=" + network.getDataCenterId(), "accountId=" + network.getAccountId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -346,14 +346,14 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
|||
|
||||
newRule = _lbDao.persist(newRule);
|
||||
|
||||
boolean success = false;
|
||||
try {
|
||||
_rulesMgr.detectRulesConflict(newRule, ipAddr);
|
||||
if (!_rulesDao.setStateToAdd(newRule)) {
|
||||
throw new CloudRuntimeException("Unable to update the state to add for " + newRule);
|
||||
}
|
||||
s_logger.debug("Load balancer " + newRule.getId() + " for Ip address " + srcIp + ", public port " + srcPortStart + ", private port " + defPortStart+ " is added successfully.");
|
||||
success = true;
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_LOAD_BALANCER_CREATE, ipAddr.getAllocatedToAccountId(), ipAddr.getDataCenterId(), newRule.getId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
return newRule;
|
||||
} catch (Exception e) {
|
||||
_lbDao.remove(newRule.getId());
|
||||
|
|
@ -361,26 +361,6 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
|
|||
throw (NetworkRuleConflictException) e;
|
||||
}
|
||||
throw new CloudRuntimeException("Unable to add rule for " + newRule.getSourceIpAddress(), e);
|
||||
} finally {
|
||||
long userId = caller.getCallerUserId();
|
||||
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(userId);
|
||||
event.setAccountId(ipAddr.getAllocatedToAccountId());
|
||||
event.setType(EventTypes.EVENT_LOAD_BALANCER_CREATE);
|
||||
|
||||
if (!success) {
|
||||
event.setDescription("Failed to create load balancer " + lb.getName() + " on ip address " + srcIp + "[" + srcPortStart + "->"
|
||||
+ defPortStart + "]");
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
} else {
|
||||
event.setDescription("Successfully created load balancer " + lb.getName() + " on ip address " + srcIp + "[" + srcPortStart + "->"
|
||||
+ defPortStart + "]");
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_LOAD_BALANCER_CREATE, ipAddr.getAllocatedToAccountId(), ipAddr.getDataCenterId(), newRule.getId(), null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -891,7 +891,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
DomainRouterVO router = _routerDao.findByNetworkConfiguration(guestNetwork.getId());
|
||||
if (router == null) {
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_CREATE, "Starting to create router for accountId : " +owner.getAccountId());
|
||||
long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating the router " + id);
|
||||
|
|
@ -933,22 +932,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(),
|
||||
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA(), guestNetwork.getNetworkDomain());
|
||||
router = _itMgr.allocate(router, _template, _offering, networks, plan, null, owner);
|
||||
if(router != null){
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ROUTER_CREATE, "successfully create router : " + router.getName(), startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_CREATE, "router creation failed", startEventId);
|
||||
}
|
||||
}
|
||||
|
||||
State state = router.getState();
|
||||
if (state != State.Starting && state != State.Running) {
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_START, "Starting router : " +router.getName());
|
||||
router = this.start(router, _accountService.getSystemUser(), _accountService.getSystemAccount());
|
||||
if(router != null){
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ROUTER_START, "successfully started router : " + router.getName(), startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_START, "failed to start router", startEventId);
|
||||
}
|
||||
}
|
||||
|
||||
return router;
|
||||
|
|
@ -978,7 +966,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
if (router == null) {
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_CREATE, "Starting to create router for accountId : " +owner.getAccountId());
|
||||
long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating the router " + id);
|
||||
|
|
@ -998,21 +985,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA(), guestNetwork.getNetworkDomain());
|
||||
router.setRole(Role.DHCP_USERDATA);
|
||||
router = _itMgr.allocate(router, _template, _offering, networks, plan, null, owner);
|
||||
if(router != null){
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ROUTER_CREATE, "successfully create router : " + router.getName(), startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_CREATE, "router creation failed", startEventId);
|
||||
}
|
||||
}
|
||||
State state = router.getState();
|
||||
if (state != State.Starting && state != State.Running) {
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_START, "Starting router : " +router.getName());
|
||||
router = this.start(router, _accountService.getSystemUser(), _accountService.getSystemAccount());
|
||||
if(router != null){
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ROUTER_START, "successfully started router : " + router.getName(), startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_START, "failed to start router", startEventId);
|
||||
}
|
||||
}
|
||||
return router;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,20 +237,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
}
|
||||
|
||||
throw new CloudRuntimeException("Unable to add rule for " + newRule.getSourceIpAddress(), e);
|
||||
} finally {
|
||||
// Save and create the event
|
||||
String description;
|
||||
String ruleName = "ip forwarding";
|
||||
String level = EventVO.LEVEL_INFO;
|
||||
|
||||
if (success == true) {
|
||||
description = "created new " + ruleName + " rule [" + newRule.getSourceIpAddress() + ":" + newRule.getSourcePortStart() + "]->["
|
||||
+ newRule.getDestinationIpAddress() + ":" + newRule.getDestinationPortStart() + "]" + " " + newRule.getProtocol();
|
||||
} else {
|
||||
level = EventVO.LEVEL_ERROR;
|
||||
description = "failed to create new " + ruleName + " rule [" + newRule.getSourceIpAddress() + ":" + newRule.getSourcePortStart() + "]->["
|
||||
+ newRule.getDestinationIpAddress() + ":" + newRule.getDestinationPortStart() + "]" + " " + newRule.getProtocol();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
@Override
|
||||
@DB
|
||||
public VpnUser addVpnUser(long vpnOwnerId, String username, String password) {
|
||||
long callerId = UserContext.current().getCallerUserId();
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
if (!username.matches("^[a-zA-Z0-9][a-zA-Z0-9@._-]{2,63}$")) {
|
||||
|
|
@ -272,15 +271,12 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
}
|
||||
|
||||
VpnUser user = _vpnUsersDao.persist(new VpnUserVO(vpnOwnerId, owner.getDomainId(), username, password));
|
||||
EventUtils.saveEvent(callerId, owner.getId(), EventTypes.EVENT_VPN_USER_ADD, "Added a VPN user for account: " + owner.getAccountName()
|
||||
+ " username= " + username);
|
||||
txn.commit();
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVpnUser(long vpnOwnerId, String username) {
|
||||
long callerId = UserContext.current().getCallerUserId();
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
VpnUserVO user = _vpnUsersDao.findByAccountAndUsername(vpnOwnerId, username);
|
||||
|
|
@ -291,7 +287,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
|
||||
user.setState(State.Revoke);
|
||||
_vpnUsersDao.update(user.getId(), user);
|
||||
EventUtils.saveEvent(callerId, vpnOwnerId, EventTypes.EVENT_VPN_USER_REMOVE, "Removed a VPN user username= " + username);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2629,7 +2629,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("User: " + username + " in domain " + domainId + " has successfully logged in");
|
||||
}
|
||||
EventUtils.saveEvent(user.getId(), user.getAccountId(), EventTypes.EVENT_USER_LOGIN, "user has logged in");
|
||||
return user;
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -2901,19 +2900,12 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if ((domains == null) || domains.isEmpty()) {
|
||||
DomainVO domain = new DomainVO(name, ownerId, parentId);
|
||||
try {
|
||||
DomainVO dbDomain = _domainDao.create(domain);
|
||||
EventUtils.saveEvent(new Long(1), ownerId, EventVO.LEVEL_INFO, EventTypes.EVENT_DOMAIN_CREATE, "Domain, " + name + " created with owner id = " + ownerId
|
||||
+ " and parentId " + parentId);
|
||||
return dbDomain;
|
||||
return _domainDao.create(domain);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
s_logger.warn("Failed to create domain ", ex);
|
||||
EventUtils.saveEvent(new Long(1), ownerId, EventVO.LEVEL_ERROR, EventTypes.EVENT_DOMAIN_CREATE, "Domain, " + name + " was not created with owner id = " + ownerId
|
||||
+ " and parentId " + parentId);
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
EventUtils.saveEvent(new Long(1), ownerId, EventVO.LEVEL_ERROR, EventTypes.EVENT_DOMAIN_CREATE, "Domain, " + name + " was not created with owner id = " + ownerId
|
||||
+ " and parentId " + parentId);
|
||||
throw new InvalidParameterValueException("Domain with name " + name + " already exists for the parent id=" + parentId);
|
||||
}
|
||||
}
|
||||
|
|
@ -2976,23 +2968,11 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
List<AccountVO> accounts = _accountDao.search(sc, null);
|
||||
for (AccountVO account : accounts) {
|
||||
success = (success && _accountMgr.cleanupAccount(account, UserContext.current().getCallerUserId(), UserContext.current().getCaller()));
|
||||
String description = "Account:" + account.getAccountId();
|
||||
if(success){
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, account.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ACCOUNT_DELETE, "Successfully deleted " +description);
|
||||
}else{
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, account.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ACCOUNT_DELETE, "Error deleting " +description);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// delete the domain itself
|
||||
boolean deleteDomainSuccess = _domainDao.remove(domainId);
|
||||
if (!deleteDomainSuccess) {
|
||||
EventUtils.saveEvent(new Long(1), ownerId, EventVO.LEVEL_ERROR, EventTypes.EVENT_DOMAIN_DELETE, "Domain with id " + domainId + " was not deleted");
|
||||
} else {
|
||||
EventUtils.saveEvent(new Long(1), ownerId, EventVO.LEVEL_INFO, EventTypes.EVENT_DOMAIN_DELETE, "Domain with id " + domainId + " was deleted");
|
||||
}
|
||||
|
||||
return success && deleteDomainSuccess;
|
||||
}
|
||||
|
|
@ -3030,11 +3010,9 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
String updatedDomainPath = getUpdatedDomainPath(domain.getPath(),domainName);
|
||||
updateDomainChildren(domain,updatedDomainPath);
|
||||
_domainDao.update(domainId, domainName, updatedDomainPath);
|
||||
EventUtils.saveEvent(new Long(1), domain.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_DOMAIN_UPDATE, "Domain, " + domainName + " was updated");
|
||||
return _domainDao.findById(domainId);
|
||||
} else {
|
||||
domain = _domainDao.findById(domainId);
|
||||
EventUtils.saveEvent(new Long(1), domain.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_DOMAIN_UPDATE, "Failed to update domain " + domain.getName() + " with name " + domainName + ", name in use.");
|
||||
s_logger.error("Domain with name " + domainName + " already exists in the system");
|
||||
throw new CloudRuntimeException("Failed to update domain " + domainId);
|
||||
}
|
||||
|
|
@ -4285,7 +4263,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
List<HostVO> storageServers = _hostDao.listByTypeDataCenter(Host.Type.SecondaryStorage, zoneId);
|
||||
HostVO sserver = storageServers.get(0);
|
||||
|
||||
EventUtils.saveStartedEvent(userId, accountId, cmd.getEventType(), "Starting extraction of " +volume.getName()+ " mode:"+mode, cmd.getStartEventId());
|
||||
List<UploadVO> extractURLList = _uploadDao.listByTypeUploadStatus(volumeId, Upload.Type.VOLUME, UploadVO.Status.DOWNLOAD_URL_CREATED);
|
||||
|
||||
if (extractMode == Upload.Mode.HTTP_DOWNLOAD && extractURLList.size() > 0){
|
||||
|
|
@ -4326,7 +4303,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
uploadJob.setLastUpdated(new Date());
|
||||
_uploadDao.update(uploadJob.getId(), uploadJob);
|
||||
|
||||
EventUtils.saveEvent(userId, accountId, EventTypes.EVENT_VOLUME_UPLOAD, errorString);
|
||||
throw new CloudRuntimeException(errorString);
|
||||
}
|
||||
|
||||
|
|
@ -4342,7 +4318,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
return uploadJob.getId();
|
||||
}else{ // Volume is copied now make it visible under apache and create a URL.
|
||||
_uploadMonitor.createVolumeDownloadURL(volumeId, volumeLocalPath, Upload.Type.VOLUME, zoneId, uploadJob.getId());
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, cmd.getEventType(), "Completed extraction of "+volume.getName()+ " in mode:" +mode, null, cmd.getStartEventId() == null ? 0:cmd.getStartEventId());
|
||||
return uploadJob.getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -4576,7 +4551,6 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if(updateCertAns.getResult() == true)
|
||||
{
|
||||
//we have the cert copied over on cpvm
|
||||
long eventId = saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_PROXY_REBOOT, "rebooting console proxy with Id: "+cp.getId());
|
||||
_consoleProxyMgr.rebootProxy(cp.getId());
|
||||
//when cp reboots, the context will be reinit with the new cert
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ import com.cloud.dc.dao.HostPodDao;
|
|||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
|
|
@ -1597,7 +1598,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
|
||||
|
||||
/*Just allocate a volume in the database, don't send the createvolume cmd to hypervisor. The volume will be finally created only when it's attached to a VM.*/
|
||||
@Override
|
||||
@Override @ActionEvent (eventType=EventTypes.EVENT_VOLUME_CREATE, eventDescription="creating volume", create=true)
|
||||
public VolumeVO allocVolume(CreateVolumeCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceAllocationException {
|
||||
// FIXME: some of the scheduled event stuff might be missing here...
|
||||
Account account = UserContext.current().getCaller();
|
||||
|
|
@ -1755,7 +1756,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
return volume;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override @DB @ActionEvent (eventType=EventTypes.EVENT_VOLUME_CREATE, eventDescription="creating volume", async=true)
|
||||
public VolumeVO createVolume(CreateVolumeCmd cmd) {
|
||||
VolumeVO volume = _volsDao.findById(cmd.getEntityId());
|
||||
// VolumeVO createdVolume = null;
|
||||
|
|
@ -2263,18 +2264,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
_storagePoolDao.persist(primaryStorage);
|
||||
}
|
||||
|
||||
private Long saveScheduledEvent(Long userId, Long accountId, String type, String description)
|
||||
{
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(userId);
|
||||
event.setAccountId(accountId);
|
||||
event.setType(type);
|
||||
event.setState(Event.State.Scheduled);
|
||||
event.setDescription("Scheduled async job for "+description);
|
||||
event = _eventDao.persist(event);
|
||||
return event.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public synchronized StoragePoolVO cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd) throws ServerApiException{
|
||||
|
|
@ -2519,7 +2508,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
if(vm instanceof UserVm){
|
||||
long sizeMB = size / (1024 * 1024);
|
||||
|
||||
EventUtils.saveEvent(userId, vol.getAccountId(), EventTypes.EVENT_VOLUME_CREATE, "Created volume: "+ vol.getName() +" with size: " + sizeMB + " MB");
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offering.getId(), null , sizeMB);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
|
||||
|
|
@ -2564,8 +2552,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
if(vm instanceof UserVm){
|
||||
long sizeMB = vol.getSize() / (1024 * 1024);
|
||||
|
||||
EventUtils.saveEvent(userId, vol.getAccountId(), EventTypes.EVENT_VOLUME_CREATE, "Created volume: "+ vol.getName() +" with size: " + sizeMB + " MB");
|
||||
|
||||
Long offeringId = null;
|
||||
|
||||
if(offering.getType() == DiskOfferingVO.Type.Disk){
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ public class DownloadListener implements Listener {
|
|||
|
||||
public void logDisconnect() {
|
||||
s_logger.warn("Unable to monitor download progress of " + template.getName() + " at host " + sserver.getName());
|
||||
downloadMonitor.logEvent(template.getAccountId(), EventTypes.EVENT_TEMPLATE_DOWNLOAD_FAILED, "Storage server " + sserver.getName() + " disconnected during download of template " + template.getName(), EventVO.LEVEL_WARN);
|
||||
}
|
||||
|
||||
public synchronized void updateDatabase(Status state, String errorString) {
|
||||
|
|
@ -368,7 +367,6 @@ public class DownloadListener implements Listener {
|
|||
}
|
||||
|
||||
public void logDownloadStart() {
|
||||
downloadMonitor.logEvent(template.getAccountId(), EventTypes.EVENT_TEMPLATE_DOWNLOAD_START, "Storage server " + sserver.getName() + " started download of template " + template.getName(), EventVO.LEVEL_INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import com.cloud.configuration.dao.ConfigurationDao;
|
|||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
|
|
@ -99,8 +98,6 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
private final DataCenterDao _dcDao = null;
|
||||
@Inject
|
||||
VMTemplateDao _templateDao = null;
|
||||
@Inject
|
||||
private final EventDao _eventDao = null;
|
||||
@Inject
|
||||
private AgentManager _agentMgr;
|
||||
@Inject
|
||||
|
|
@ -124,17 +121,6 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
return _agentMgr.gatherStats(hostId, cmd, listener);
|
||||
}
|
||||
|
||||
public void logEvent(long accountId, String evtType, String description, String level) {
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(1);
|
||||
event.setAccountId(accountId);
|
||||
event.setType(evtType);
|
||||
event.setDescription(description);
|
||||
event.setLevel(level);
|
||||
_eventDao.persist(event);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) {
|
||||
_name = name;
|
||||
|
|
@ -344,15 +330,6 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
_listenerMap.remove(vmTemplateHost);
|
||||
}
|
||||
}
|
||||
if (dnldStatus == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||
logEvent(template.getAccountId(), EventTypes.EVENT_TEMPLATE_DOWNLOAD_SUCCESS, template.getName() + " successfully downloaded to storage server " + host.getName(), EventVO.LEVEL_INFO);
|
||||
}
|
||||
if (dnldStatus == Status.DOWNLOAD_ERROR) {
|
||||
logEvent(template.getAccountId(), EventTypes.EVENT_TEMPLATE_DOWNLOAD_FAILED, template.getName() + " failed to download to storage server " + host.getName(), EventVO.LEVEL_ERROR);
|
||||
}
|
||||
if (dnldStatus == Status.ABANDONED) {
|
||||
logEvent(template.getAccountId(), EventTypes.EVENT_TEMPLATE_DOWNLOAD_FAILED, template.getName() + " :aborted download to storage server " + host.getName(), EventVO.LEVEL_WARN);
|
||||
}
|
||||
|
||||
VMTemplateHostVO vmTemplateHost = _vmTemplateHostDao.findByHostTemplate(host.getId(), template.getId());
|
||||
|
||||
|
|
@ -364,22 +341,11 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
else{
|
||||
s_logger.warn("Failed to get size for template" + template.getName());
|
||||
}
|
||||
String eventParams = "id=" + template.getId() + "\ndcId="+host.getDataCenterId()+"\nsize="+size;
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(1L);
|
||||
event.setAccountId(template.getAccountId());
|
||||
String eventType = EventTypes.EVENT_TEMPLATE_CREATE;
|
||||
if((template.getFormat()).equals(ImageFormat.ISO)){
|
||||
event.setType(EventTypes.EVENT_ISO_CREATE);
|
||||
event.setDescription("Successfully created ISO " + template.getName());
|
||||
eventType = EventTypes.EVENT_ISO_CREATE;
|
||||
}
|
||||
else{
|
||||
event.setType(EventTypes.EVENT_TEMPLATE_CREATE);
|
||||
event.setDescription("Successfully created template " + template.getName());
|
||||
}
|
||||
event.setParameters(eventParams);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
_eventDao.persist(event);
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_TEMPLATE_CREATE, template.getAccountId(), host.getDataCenterId(), template.getId(), template.getName(), null, null , size);
|
||||
UsageEventVO usageEvent = new UsageEventVO(eventType, template.getAccountId(), host.getDataCenterId(), template.getId(), template.getName(), null, null , size);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
|
||||
|
|
@ -517,12 +483,10 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
long result = send(sserverId, dtCommand, null);
|
||||
if (result == -1 ){
|
||||
String description = "Failed to delete " + tInfo.getTemplateName() + " on secondary storage " + sserverId + " which isn't in the database";
|
||||
logEvent(1L, EventTypes.EVENT_TEMPLATE_CLEANUP, description , EventVO.LEVEL_ERROR);
|
||||
s_logger.error(description);
|
||||
return;
|
||||
}
|
||||
String description = "Deleted template " + tInfo.getTemplateName() + " on secondary storage " + sserverId + " since it isn't in the database, result=" + result;
|
||||
logEvent(1L, EventTypes.EVENT_TEMPLATE_CLEANUP, description, EventVO.LEVEL_INFO);
|
||||
s_logger.info(description);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,6 @@ import com.cloud.dc.DataCenterVO;
|
|||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
|
@ -216,12 +213,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
@Override
|
||||
public SecondaryStorageVmVO startSecStorageVm(long secStorageVmId) {
|
||||
boolean started = false;
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_START,
|
||||
"Starting secondary storage Vm with Id: " + secStorageVmId);
|
||||
try {
|
||||
SecondaryStorageVmVO ssvm = start(secStorageVmId);
|
||||
started = true;
|
||||
return ssvm;
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start secondary storage vm", e);
|
||||
|
|
@ -239,15 +232,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
s_logger.warn("Exception while trying to start secondary storage vm", e);
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
if (started) {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_INFO, EventTypes.EVENT_SSVM_START,
|
||||
"Started secondary storage Vm with Id: " + secStorageVmId, startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_ERROR, EventTypes.EVENT_SSVM_START,
|
||||
"Failed to start secondary storage Vm with Id: " + secStorageVmId, startEventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -375,8 +359,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
s_logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId);
|
||||
}
|
||||
|
||||
long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_CREATE,
|
||||
"Creating secondary storage Vm in zone : " + dataCenterId);
|
||||
Map<String, Object> context = createSecStorageVmInstance(dataCenterId);
|
||||
|
||||
long secStorageVmId = (Long) context.get("secStorageVmId");
|
||||
|
|
@ -385,8 +367,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
s_logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId);
|
||||
}
|
||||
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_ERROR, EventTypes.EVENT_SSVM_CREATE,
|
||||
"Failed to create secondary storage Vm in zone : " + dataCenterId, startEventId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -396,8 +376,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
if (secStorageVm != null) {
|
||||
SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
|
||||
new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_CREATED, dataCenterId, secStorageVmId, secStorageVm, null));
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_INFO, EventTypes.EVENT_SSVM_CREATE,
|
||||
"Successfully created secondary storage Vm " + secStorageVm.getName() + " in zone : " + dataCenterId, startEventId);
|
||||
return secStorageVm;
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -410,8 +388,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
this,
|
||||
new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE, dataCenterId, secStorageVmId, null,
|
||||
"Unable to allocate storage"));
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventVO.LEVEL_ERROR, EventTypes.EVENT_SSVM_CREATE,
|
||||
"Failed to create secondary storage Vm in zone : " + dataCenterId, startEventId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ import com.cloud.dc.dao.DataCenterDao;
|
|||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.UsageEventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
|
|
@ -580,12 +578,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
// Excess snapshot. delete it asynchronously
|
||||
//destroySnapshotAsync(userId, volumeId, oldSnapId, policyId);
|
||||
// create the event
|
||||
long startEventId = EventUtils.saveStartedEvent(userId, oldestSnapshot.getAccountId(), EventTypes.EVENT_SNAPSHOT_DELETE, "Deleting snapshot with Id:"+oldSnapId);
|
||||
if(deleteSnapshotInternal(oldSnapId, policyId)){
|
||||
EventUtils.saveEvent(userId, oldestSnapshot.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_SNAPSHOT_DELETE, "Deleted snapshot with Id:"+oldSnapId, startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, oldestSnapshot.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_SNAPSHOT_DELETE, "Failed to delete snapshot with Id:"+oldSnapId, startEventId);
|
||||
}
|
||||
deleteSnapshotInternal(oldSnapId, policyId);
|
||||
snaps.remove(oldestSnapshot);
|
||||
}
|
||||
|
||||
|
|
@ -750,7 +743,6 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
|
||||
}
|
||||
|
|
@ -928,7 +920,6 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
_accountMgr.decrementResourceCount(accountId, ResourceType.snapshot);
|
||||
|
||||
//Log event after successful deletion
|
||||
EventUtils.saveEvent(User.UID_SYSTEM, snapshot.getAccountId(), EventTypes.EVENT_SNAPSHOT_DELETE, "Successfully deleted snapshot " + snapshot.getId() + " for volumeId: " + snapshot.getVolumeId());
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_SNAPSHOT_DELETE, snapshot.getAccountId(), volume.getDataCenterId(), snapshot.getId(), snapshot.getName(), null, null, volume.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
|
|
@ -994,11 +985,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
|
||||
SnapshotPolicyVO policy = new SnapshotPolicyVO(volumeId, cmd.getSchedule(), timezoneId, (short)type.ordinal(), cmd.getMaxSnaps());
|
||||
// Create an event
|
||||
EventVO event = new EventVO();
|
||||
try{
|
||||
policy = _snapshotPolicyDao.persist(policy);
|
||||
event.setType(EventTypes.EVENT_SNAPSHOT_POLICY_CREATE);
|
||||
event.setDescription("Successfully created snapshot policy with Id: "+ policy.getId());
|
||||
} catch (EntityExistsException e ) {
|
||||
policy = _snapshotPolicyDao.findOneByVolume(volumeId);
|
||||
try {
|
||||
|
|
@ -1014,13 +1002,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
_snapshotPolicyDao.releaseFromLockTable(policy.getId());
|
||||
}
|
||||
}
|
||||
event.setType(EventTypes.EVENT_SNAPSHOT_POLICY_UPDATE);
|
||||
event.setDescription("Successfully updated snapshot policy with Id: "+ policy.getId());
|
||||
}
|
||||
event.setAccountId(accountId);
|
||||
event.setUserId(userId);
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
_eventDao.persist(event);
|
||||
_snapSchedMgr.scheduleNextSnapshotJob(policy);
|
||||
return policy;
|
||||
}
|
||||
|
|
@ -1028,22 +1010,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
@Override
|
||||
public boolean deletePolicy(long userId, Long policyId) {
|
||||
SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId);
|
||||
VolumeVO volume = _volsDao.findById(snapshotPolicy.getVolumeId());
|
||||
_snapSchedMgr.removeSchedule(snapshotPolicy.getVolumeId(), snapshotPolicy.getId());
|
||||
EventVO event = new EventVO();
|
||||
event.setAccountId(volume.getAccountId());
|
||||
event.setUserId(userId);
|
||||
event.setType(EventTypes.EVENT_SNAPSHOT_POLICY_DELETE);
|
||||
boolean success = _snapshotPolicyDao.remove(policyId);
|
||||
if(success){
|
||||
event.setLevel(EventVO.LEVEL_INFO);
|
||||
event.setDescription("Successfully deleted snapshot policy with Id: "+policyId);
|
||||
} else {
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
event.setDescription("Failed to delete snapshot policy with Id: "+policyId);
|
||||
}
|
||||
_eventDao.persist(event);
|
||||
return success;
|
||||
return _snapshotPolicyDao.remove(policyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -250,7 +250,6 @@ public class UploadListener implements Listener {
|
|||
}
|
||||
|
||||
public void logUploadStart() {
|
||||
String event = uploadMonitor.getEvent(type);
|
||||
//uploadMonitor.logEvent(accountId, event, "Storage server " + sserver.getName() + " started upload of " +type.toString() + " " + typeName, EventVO.LEVEL_INFO, eventId);
|
||||
}
|
||||
|
||||
|
|
@ -418,9 +417,6 @@ public class UploadListener implements Listener {
|
|||
|
||||
public void logDisconnect() {
|
||||
s_logger.warn("Unable to monitor upload progress of " + typeName + " at host " + sserver.getName());
|
||||
String event;
|
||||
event = uploadMonitor.getEvent(type);
|
||||
uploadMonitor.logEvent(accountId, event, "Storage server " + sserver.getName() + " disconnected during upload of " + typeName, EventVO.LEVEL_WARN, eventId);
|
||||
}
|
||||
|
||||
public void scheduleImmediateStatusCheck(RequestType request) {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ import com.cloud.agent.api.storage.UploadProgressCommand.RequestType;
|
|||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
|
|
@ -75,8 +72,6 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
HostDao _serverDao = null;
|
||||
@Inject
|
||||
VMTemplateDao _templateDao = null;
|
||||
@Inject
|
||||
private final EventDao _eventDao = null;
|
||||
@Inject
|
||||
private AgentManager _agentMgr;
|
||||
@Inject
|
||||
|
|
@ -363,20 +358,6 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
return true;
|
||||
}
|
||||
|
||||
public String getEvent(Type type){
|
||||
|
||||
if(type == Type.TEMPLATE) {
|
||||
return EventTypes.EVENT_TEMPLATE_EXTRACT;
|
||||
}
|
||||
if(type == Type.ISO) {
|
||||
return EventTypes.EVENT_ISO_EXTRACT;
|
||||
}
|
||||
if(type == Type.VOLUME) {
|
||||
return EventTypes.EVENT_VOLUME_EXTRACT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public void handleUploadEvent(HostVO host, Long accountId, String typeName, Type type, Long uploadId, com.cloud.storage.Upload.Status reason, long eventId) {
|
||||
|
||||
if ((reason == Upload.Status.UPLOADED) || (reason==Upload.Status.ABANDONED)){
|
||||
|
|
@ -386,30 +367,9 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
_listenerMap.remove(uploadObj);
|
||||
}
|
||||
}
|
||||
if (reason == Upload.Status.UPLOADED) {
|
||||
logEvent(accountId, getEvent(type), typeName + " successfully uploaded from storage server " + host.getName(), EventVO.LEVEL_INFO, eventId);
|
||||
}
|
||||
if (reason == Upload.Status.UPLOAD_ERROR) {
|
||||
logEvent(accountId, getEvent(type), typeName + " failed to upload from storage server " + host.getName(), EventVO.LEVEL_ERROR, eventId);
|
||||
}
|
||||
if (reason == Upload.Status.ABANDONED) {
|
||||
logEvent(accountId, getEvent(type), typeName + " :aborted upload from storage server " + host.getName(), EventVO.LEVEL_WARN, eventId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void logEvent(long accountId, String evtType, String description, String level, long eventId) {
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(1);
|
||||
event.setAccountId(accountId);
|
||||
event.setType(evtType);
|
||||
event.setDescription(description);
|
||||
event.setLevel(level);
|
||||
event.setStartId(eventId);
|
||||
_eventDao.persist(event);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUploadSync(long sserverId) {
|
||||
|
||||
|
|
|
|||
|
|
@ -549,9 +549,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
extractMode = mode.equals(Upload.Mode.FTP_UPLOAD.toString()) ? Upload.Mode.FTP_UPLOAD : Upload.Mode.HTTP_DOWNLOAD;
|
||||
}
|
||||
|
||||
long userId = UserContext.current().getCallerUserId();
|
||||
long accountId = template.getAccountId();
|
||||
String event = isISO ? EventTypes.EVENT_ISO_EXTRACT : EventTypes.EVENT_TEMPLATE_EXTRACT;
|
||||
if (extractMode == Upload.Mode.FTP_UPLOAD){
|
||||
URI uri = null;
|
||||
try {
|
||||
|
|
@ -580,23 +577,13 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
throw new IllegalArgumentException(template.getName() + " upload is in progress. Please wait for some time to schedule another upload for the same");
|
||||
}
|
||||
|
||||
//long eventId = EventUtils.saveScheduledEvent(userId, accountId, event, "Extraction job");
|
||||
|
||||
// FIXME: scheduled event should've already been saved, we should be saving this started event here...
|
||||
// String event = template.getFormat() == ImageFormat.ISO ? EventTypes.EVENT_ISO_UPLOAD : EventTypes.EVENT_TEMPLATE_UPLOAD;
|
||||
// EventUtils.saveStartedEvent(template.getAccountId(), template.getAccountId(), event, "Starting upload of " +template.getName()+ " to " +url, cmd.getStartEventId());
|
||||
|
||||
EventUtils.saveStartedEvent(userId, accountId, event, "Starting extraction of " +template.getName()+ " mode:" +extractMode.toString(), eventId);
|
||||
return _uploadMonitor.extractTemplate(template, url, tmpltHostRef, zoneId, eventId, job.getId(), mgr);
|
||||
}
|
||||
|
||||
EventUtils.saveStartedEvent(userId, accountId, event, "Starting extraction of " +template.getName()+ " in mode:" +extractMode.toString(), eventId);
|
||||
UploadVO vo = _uploadMonitor.createEntityDownloadURL(template, tmpltHostRef, zoneId, eventId);
|
||||
if (vo!=null){
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, event, "Completed extraction of "+template.getName()+ " in mode:" +mode, null, eventId);
|
||||
return vo.getId();
|
||||
}else{
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, event, "Failed extraction of "+template.getName()+ " in mode:" +mode, null, eventId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -755,25 +742,17 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
}
|
||||
|
||||
// Event details
|
||||
String params = "id=" + templateId + "\ndcId="+destZoneId+"\nsize="+srcTmpltHost.getSize();
|
||||
Account account = _accountDao.findById(vmTemplate.getAccountId());
|
||||
String copyEventType;
|
||||
String copyEventDescription;
|
||||
String createEventType;
|
||||
String createEventDescription;
|
||||
String templateType;
|
||||
if (vmTemplate.getFormat().equals(ImageFormat.ISO)){
|
||||
copyEventType = EventTypes.EVENT_ISO_COPY;
|
||||
createEventType = EventTypes.EVENT_ISO_CREATE;
|
||||
templateType = "ISO ";
|
||||
} else {
|
||||
copyEventType = EventTypes.EVENT_TEMPLATE_COPY;
|
||||
createEventType = EventTypes.EVENT_TEMPLATE_CREATE;
|
||||
templateType = "Template ";
|
||||
}
|
||||
|
||||
copyEventDescription = templateType + vmTemplate.getName() + " started copying to zone: " + destZone.getName() + ".";
|
||||
createEventDescription = templateType + vmTemplate.getName() + " succesfully created in zone: " + destZone.getName() + ".";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
|
@ -790,8 +769,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
dstTmpltHost.setDestroyed(false);
|
||||
_tmpltHostDao.update(dstTmpltHost.getId(), dstTmpltHost);
|
||||
|
||||
saveEvent(userId, account.getId(), account.getDomainId(), copyEventType, copyEventDescription, EventVO.LEVEL_INFO, params);
|
||||
saveEvent(userId, account.getId(), account.getDomainId(), createEventType, createEventDescription, EventVO.LEVEL_INFO, params);
|
||||
return true;
|
||||
}
|
||||
} else if (dstTmpltHost != null && dstTmpltHost.getDownloadState() == Status.DOWNLOAD_ERROR){
|
||||
|
|
@ -815,7 +792,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
|
||||
UsageEventVO usageEvent = new UsageEventVO(copyEventType, account.getId(), destZoneId, templateId, null, null, null, srcTmpltHost.getSize());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
saveEvent(userId, account.getId(), account.getDomainId(), copyEventType, copyEventDescription, EventVO.LEVEL_INFO, params);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -921,17 +897,13 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
}
|
||||
}
|
||||
|
||||
String params = "id=" + template.getId();
|
||||
Account account = _accountDao.findById(template.getAccountId());
|
||||
String eventType = "";
|
||||
String description = "";
|
||||
|
||||
if (template.getFormat().equals(ImageFormat.ISO)){
|
||||
eventType = EventTypes.EVENT_ISO_DELETE;
|
||||
description = "ISO ";
|
||||
} else {
|
||||
eventType = EventTypes.EVENT_TEMPLATE_DELETE;
|
||||
description = "Template ";
|
||||
}
|
||||
|
||||
// Iterate through all necessary secondary storage hosts and mark the template on each host as destroyed
|
||||
|
|
@ -957,8 +929,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
_tmpltZoneDao.remove(templateZone.getId());
|
||||
}
|
||||
|
||||
String zoneParams = params + "\ndcId=" + sZoneId;
|
||||
saveEvent(userId, account.getId(), account.getDomainId(), eventType, description + template.getName() + " succesfully deleted.", EventVO.LEVEL_INFO, zoneParams, 0);
|
||||
UsageEventVO usageEvent = new UsageEventVO(eventType, account.getId(), sZoneId, templateId, null, null, null, null);
|
||||
_usageEventDao.persist(usageEvent);
|
||||
} finally {
|
||||
|
|
@ -1052,33 +1022,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
}
|
||||
}
|
||||
|
||||
private Long saveEvent(long userId, Long accountId, Long domainId, String type, String description, String level, String params, long startEventId) {
|
||||
EventVO event = new EventVO();
|
||||
event.setUserId(userId);
|
||||
event.setAccountId(accountId);
|
||||
event.setType(type);
|
||||
event.setDescription(description);
|
||||
event.setStartId(startEventId);
|
||||
|
||||
if (domainId != null) {
|
||||
event.setDomainId(domainId);
|
||||
}
|
||||
|
||||
if (level != null) {
|
||||
event.setLevel(level);
|
||||
}
|
||||
|
||||
if (params != null) {
|
||||
event.setParameters(params);
|
||||
}
|
||||
|
||||
return _eventDao.persist(event).getId();
|
||||
}
|
||||
|
||||
private Long saveEvent(long userId, Long accountId, Long domainId, String type, String description, String level, String params) {
|
||||
return saveEvent(userId, accountId, domainId, type, description, level, params,0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
|
|
@ -1139,8 +1082,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
|
||||
Long templateId = _tmpltDao.addTemplateToZone(template, zoneId);
|
||||
UserAccount userAccount = _userAccountDao.findById(userId);
|
||||
saveEvent(userId, userAccount.getAccountId(), userAccount.getDomainId(), EventTypes.EVENT_TEMPLATE_DOWNLOAD_START,
|
||||
"Started download of template: " + template.getName(), null, null);
|
||||
|
||||
_downloadMonitor.downloadTemplateToStorage(id, zoneId);
|
||||
|
||||
|
|
@ -1250,12 +1191,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
private boolean attachISOToVM(long vmId, long userId, long isoId, boolean attach) {
|
||||
UserVmVO vm = _userVmDao.findById(vmId);
|
||||
VMTemplateVO iso = _tmpltDao.findById(isoId);
|
||||
long startEventId = 0;
|
||||
if(attach){
|
||||
startEventId = EventUtils.saveStartedEvent(userId, vm.getAccountId(), EventTypes.EVENT_ISO_ATTACH, "Attaching ISO: "+isoId+" to Vm: "+vmId, startEventId);
|
||||
} else {
|
||||
startEventId = EventUtils.saveStartedEvent(userId, vm.getAccountId(), EventTypes.EVENT_ISO_DETACH, "Detaching ISO: "+isoId+" from Vm: "+vmId, startEventId);
|
||||
}
|
||||
|
||||
boolean success = _vmMgr.attachISOToVM(vmId, isoId, attach);
|
||||
|
||||
|
|
@ -1266,21 +1201,6 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
|
|||
}
|
||||
_userVmDao.update(vmId, vm);
|
||||
|
||||
if (success) {
|
||||
if (attach) {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ISO_ATTACH, "Successfully attached ISO: " + iso.getName() + " to VM with ID: " + vmId,
|
||||
null, startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ISO_DETACH, "Successfully detached ISO from VM with ID: " + vmId, null, startEventId);
|
||||
}
|
||||
} else {
|
||||
if (attach) {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ISO_ATTACH, "Failed to attach ISO: " + iso.getName() + " to VM with ID: " + vmId, null, startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ISO_DETACH, "Failed to detach ISO from VM with ID: " + vmId, null, startEventId);
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -840,13 +840,9 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
}
|
||||
|
||||
for (UserVmVO vm : vms) {
|
||||
long startEventId = EventUtils.saveStartedEvent(callerUserId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Destroyed VM instance : " + vm.getName());
|
||||
if (!_vmMgr.expunge(vm, callerUserId, caller)) {
|
||||
s_logger.error("Unable to destroy vm: " + vm.getId());
|
||||
accountCleanupNeeded = true;
|
||||
EventUtils.saveEvent(callerUserId, vm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_DESTROY, "Unable to destroy vm: " + vm.getId(), startEventId);
|
||||
} else {
|
||||
EventUtils.saveEvent(callerUserId, vm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_DESTROY, "Successfully destroyed VM instance : " + vm.getName(), startEventId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1010,12 +1006,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
throw new CloudRuntimeException("The user " + username + " being creating is using a password that is different than what's in the db");
|
||||
}
|
||||
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_USER_CREATE, "User, " + username + " for accountId = " + accountId
|
||||
+ " and domainId = " + domainId + " was created.");
|
||||
return _userAccountDao.findById(dbUser.getId());
|
||||
} catch (Exception e) {
|
||||
EventUtils.saveEvent(new Long(1), new Long(1), EventVO.LEVEL_ERROR, EventTypes.EVENT_USER_CREATE, "Error creating user, " + username + " for accountId = " + accountId
|
||||
+ " and domainId = " + domainId);
|
||||
if (e instanceof CloudRuntimeException) {
|
||||
s_logger.info("unable to create user: " + e);
|
||||
} else {
|
||||
|
|
@ -1069,8 +1061,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
throw new CloudRuntimeException("The user " + userName + " being creating is using a password that is different than what's in the db");
|
||||
}
|
||||
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_USER_CREATE, "User, " + userName + " for accountId = " + accountId
|
||||
+ " and domainId = " + domainId + " was created.");
|
||||
return dbUser;
|
||||
}
|
||||
|
||||
|
|
@ -1152,12 +1142,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
}
|
||||
|
||||
_userDao.update(id, userName, password, firstName, lastName, email, accountId, timeZone, apiKey, secretKey);
|
||||
EventUtils.saveEvent(new Long(1), Long.valueOf(1), EventVO.LEVEL_INFO, EventTypes.EVENT_USER_UPDATE, "User, " + userName + " for accountId = "
|
||||
+ accountId + " domainId = " + userAccount.getDomainId() + " and timezone = "+timeZone + " was updated.");
|
||||
} catch (Throwable th) {
|
||||
s_logger.error("error updating user", th);
|
||||
EventUtils.saveEvent(Long.valueOf(1), Long.valueOf(1), EventVO.LEVEL_ERROR, EventTypes.EVENT_USER_UPDATE, "Error updating user, " + userName
|
||||
+ " for accountId = " + accountId + " and domainId = " + userAccount.getDomainId());
|
||||
throw new CloudRuntimeException("Unable to update user " + id);
|
||||
}
|
||||
return _userAccountDao.findById(id);
|
||||
|
|
@ -1454,15 +1440,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
throw new InvalidParameterValueException("Account id : " + user.getAccountId() + " is a system account, delete for user associated with this account is not allowed");
|
||||
}
|
||||
|
||||
long accountId = user.getAccountId();
|
||||
long userId = UserContext.current().getCallerUserId();
|
||||
boolean success = _userDao.remove(id);
|
||||
if(success){
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_USER_DELETE, "Deleted User, " + user.getUsername() + " for accountId = " + user.getAccountId());
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_USER_DELETE, "Failed to delete User, " + user.getUsername() + " for accountId = " + user.getAccountId());
|
||||
}
|
||||
return success;
|
||||
return _userDao.remove(id);
|
||||
}
|
||||
|
||||
protected class AccountCleanupTask implements Runnable {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ import com.cloud.deploy.DataCenterDeployment;
|
|||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
|
|
@ -325,15 +326,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
if (_routerMgr.savePasswordToRouter(vmInstance.getDomainRouterId(), vmInstance.getPrivateIpAddress(), password)) {
|
||||
// Need to reboot the virtual machine so that the password gets redownloaded from the DomR, and reset on the VM
|
||||
long startId = EventUtils.saveStartedEvent(userId, vmInstance.getAccountId(), EventTypes.EVENT_VM_REBOOT, "Reboot vm with id:"+vmId);
|
||||
if (!rebootVirtualMachine(userId, vmId)) {
|
||||
EventUtils.saveEvent(userId, vmInstance.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_REBOOT, "Failed to reboot vm with id:"+vmId, startId);
|
||||
if (vmInstance.getState() == State.Stopped) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, vmInstance.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_REBOOT, "Successfully rebooted vm with id:"+vmId, startId);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -361,7 +359,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
return true;
|
||||
}
|
||||
|
||||
long startEventId = EventUtils.saveStartedEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_STOP, "stopping Vm with Id: "+vmId);
|
||||
User user = _userDao.findById(userId);
|
||||
Account account = _accountDao.findById(user.getAccountId());
|
||||
|
||||
|
|
@ -373,11 +370,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
if(status){
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_STOP, "Successfully stopped VM instance : " + vmId, startEventId);
|
||||
return status;
|
||||
}
|
||||
else {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_STOP, "Error stopping VM instance : " + vmId, startEventId);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
|
@ -1603,8 +1598,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
_vmDao.updateVM(id, displayName, ha, osTypeId);
|
||||
|
||||
// create a event for the change in HA Enabled flag
|
||||
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_VM_UPDATE, "Successfully updated virtual machine: "+vm.getName()+". "+description);
|
||||
return _vmDao.findById(id);
|
||||
}
|
||||
|
||||
|
|
@ -1852,7 +1845,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
@Override @DB @ActionEvent (eventType=EventTypes.EVENT_VM_CREATE, eventDescription="creating Vm", create=true)
|
||||
public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
|
|
@ -2100,7 +2093,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
return vm;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @ActionEvent (eventType=EventTypes.EVENT_VM_CREATE, eventDescription="starting Vm", async=true)
|
||||
public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
long vmId = cmd.getEntityId();
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue