Updated Branches: refs/heads/master 37f4a120f -> 832db1b39
Apply https://reviews.apache.org/r/14084/ Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/832db1b3 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/832db1b3 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/832db1b3 Branch: refs/heads/master Commit: 832db1b3980e3aa95f5529396009dd04f52d0b68 Parents: 37f4a12 Author: Kelven Yang <[email protected]> Authored: Tue Sep 17 16:29:48 2013 -0700 Committer: Kelven Yang <[email protected]> Committed: Tue Sep 17 16:29:48 2013 -0700 ---------------------------------------------------------------------- api/src/com/cloud/event/ActionEvents.java | 31 ++++++ .../apache/cloudstack/context/CallContext.java | 26 +++++ .../configuration/ConfigurationManager.java | 104 +++++++++---------- .../cloud/network/rules/FirewallManager.java | 32 +++--- .../configuration/ConfigurationManagerImpl.java | 10 +- .../com/cloud/event/ActionEventInterceptor.java | 98 +++++++++++------ .../src/com/cloud/event/ActionEventUtils.java | 16 ++- .../network/firewall/FirewallManagerImpl.java | 16 +-- .../com/cloud/server/ManagementServerImpl.java | 27 ++--- .../src/com/cloud/user/AccountManagerImpl.java | 9 +- server/src/com/cloud/vm/UserVmManagerImpl.java | 5 +- .../cloud/network/MockFirewallManagerImpl.java | 17 --- .../cloud/vpc/MockConfigurationManagerImpl.java | 22 ---- 13 files changed, 248 insertions(+), 165 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/api/src/com/cloud/event/ActionEvents.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/event/ActionEvents.java b/api/src/com/cloud/event/ActionEvents.java new file mode 100644 index 0000000..9560920 --- /dev/null +++ b/api/src/com/cloud/event/ActionEvents.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.cloud.event; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Target({ TYPE, METHOD }) +@Retention(RUNTIME) +public @interface ActionEvents { + ActionEvent[] value(); +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/api/src/org/apache/cloudstack/context/CallContext.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/context/CallContext.java b/api/src/org/apache/cloudstack/context/CallContext.java index e3c1bf2..a62a3da 100644 --- a/api/src/org/apache/cloudstack/context/CallContext.java +++ b/api/src/org/apache/cloudstack/context/CallContext.java @@ -42,7 +42,9 @@ public class CallContext { private String contextId; private Account account; private long startEventId = 0; + private String eventDescription; private String eventDetails; + private String eventType; private User user; private final Map<Object, Object> context = new HashMap<Object, Object>(); @@ -211,6 +213,30 @@ public class CallContext { public String getEventDetails() { return eventDetails; } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getEventDescription() { + return eventDescription; + } + + public void setEventDescription(String eventDescription) { + this.eventDescription = eventDescription; + } + + public static void setActionEventInfo(String eventType, String description) { + CallContext context = CallContext.current(); + if ( context != null ) { + context.setEventType(eventType); + context.setEventDescription(description); + } + } @Override public String toString() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java index 6e76b6f..5e1b9b5 100755 --- a/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java +++ b/engine/components-api/src/com/cloud/configuration/ConfigurationManager.java @@ -69,58 +69,58 @@ public interface ConfigurationManager { */ String updateConfiguration(long userId, String name, String category, String value, String scope, Long id); - /** - * Creates a new service offering - * - * @param name - * @param cpu - * @param ramSize - * @param speed - * @param displayText - * @param localStorageRequired - * @param offerHA - * @param domainId - * @param volatileVm - * @param hostTag - * @param networkRate - * TODO - * @param id - * @param useVirtualNetwork - * @param deploymentPlanner - * @param details - * @param bytesReadRate - * @param bytesWriteRate - * @param iopsReadRate - * @param iopsWriteRate - * @return ID - */ - ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, - boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details, - Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate); - - /** - * Creates a new disk offering - * - * @param domainId - * @param name - * @param description - * @param numGibibytes - * @param tags - * @param isCustomized - * @param localStorageRequired - * @param isDisplayOfferingEnabled - * @param isCustomizedIops (is admin allowing users to set custom iops?) - * @param minIops - * @param maxIops - * @param bytesReadRate - * @param bytesWriteRate - * @param iopsReadRate - * @param iopsWriteRate - * @return newly created disk offering - */ - DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, - boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops, - Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate); +// /** +// * Creates a new service offering +// * +// * @param name +// * @param cpu +// * @param ramSize +// * @param speed +// * @param displayText +// * @param localStorageRequired +// * @param offerHA +// * @param domainId +// * @param volatileVm +// * @param hostTag +// * @param networkRate +// * TODO +// * @param id +// * @param useVirtualNetwork +// * @param deploymentPlanner +// * @param details +// * @param bytesReadRate +// * @param bytesWriteRate +// * @param iopsReadRate +// * @param iopsWriteRate +// * @return ID +// */ +// ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, +// boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details, +// Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate); + +// /** +// * Creates a new disk offering +// * +// * @param domainId +// * @param name +// * @param description +// * @param numGibibytes +// * @param tags +// * @param isCustomized +// * @param localStorageRequired +// * @param isDisplayOfferingEnabled +// * @param isCustomizedIops (is admin allowing users to set custom iops?) +// * @param minIops +// * @param maxIops +// * @param bytesReadRate +// * @param bytesWriteRate +// * @param iopsReadRate +// * @param iopsWriteRate +// * @return newly created disk offering +// */ +// DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, +// boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops, +// Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate); /** * Creates a new pod http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/engine/components-api/src/com/cloud/network/rules/FirewallManager.java ---------------------------------------------------------------------- diff --git a/engine/components-api/src/com/cloud/network/rules/FirewallManager.java b/engine/components-api/src/com/cloud/network/rules/FirewallManager.java index fa12cd8..57ea88f 100644 --- a/engine/components-api/src/com/cloud/network/rules/FirewallManager.java +++ b/engine/components-api/src/com/cloud/network/rules/FirewallManager.java @@ -55,22 +55,22 @@ public interface FirewallManager extends FirewallService { boolean revokeFirewallRulesForIp(long ipId, long userId, Account caller) throws ResourceUnavailableException; - /** - * Revokes a firewall rule - * - * @param ruleId - * the id of the rule to revoke. - * @param caller - * TODO - * @param userId - * TODO - * @return - */ - boolean revokeFirewallRule(long ruleId, boolean apply, Account caller, long userId); - - FirewallRule createFirewallRule(Long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId, - FirewallRule.FirewallRuleType type, Long networkId, FirewallRule.TrafficType traffictype) - throws NetworkRuleConflictException; +// /** +// * Revokes a firewall rule +// * +// * @param ruleId +// * the id of the rule to revoke. +// * @param caller +// * TODO +// * @param userId +// * TODO +// * @return +// */ +// boolean revokeFirewallRule(long ruleId, boolean apply, Account caller, long userId); + +// FirewallRule createFirewallRule(Long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId, +// FirewallRule.FirewallRuleType type, Long networkId, FirewallRule.TrafficType traffictype) +// throws NetworkRuleConflictException; FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId, long networkId) throws NetworkRuleConflictException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index fb727a1..17ef6bf 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1979,6 +1979,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } @Override + @ActionEvent(eventType = EventTypes.EVENT_SERVICE_OFFERING_CREATE, eventDescription = "creating service offering") public ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd) { Long userId = CallContext.current().getCallingUserId(); @@ -2079,9 +2080,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate()); } - @Override - @ActionEvent(eventType = EventTypes.EVENT_SERVICE_OFFERING_CREATE, eventDescription = "creating service offering") - public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_type, + protected ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_type, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details, Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) { @@ -2182,9 +2181,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } - @Override - @ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CREATE, eventDescription = "creating disk offering") - public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, + protected DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops, Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) { long diskSize = 0;// special case for custom disk offerings @@ -2263,6 +2260,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } @Override + @ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CREATE, eventDescription = "creating disk offering") public DiskOffering createDiskOffering(CreateDiskOfferingCmd cmd) { String name = cmd.getOfferingName(); String description = cmd.getDisplayText(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/event/ActionEventInterceptor.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/event/ActionEventInterceptor.java b/server/src/com/cloud/event/ActionEventInterceptor.java index ba7e270..8396512 100644 --- a/server/src/com/cloud/event/ActionEventInterceptor.java +++ b/server/src/com/cloud/event/ActionEventInterceptor.java @@ -17,15 +17,14 @@ package com.cloud.event; import java.lang.reflect.Method; - -import org.apache.log4j.Logger; +import java.util.ArrayList; +import java.util.List; import org.apache.cloudstack.context.CallContext; import com.cloud.utils.component.ComponentMethodInterceptor; public class ActionEventInterceptor implements ComponentMethodInterceptor { - private static final Logger s_logger = Logger.getLogger(ActionEventInterceptor.class); public ActionEventInterceptor() { } @@ -33,19 +32,15 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor { @Override public Object interceptStart(Method method, Object target) { EventVO event = null; - ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); - if (actionEvent != null) { + for ( ActionEvent actionEvent : getActionEvents(method) ) { boolean async = actionEvent.async(); if(async){ CallContext ctx = CallContext.current(); - long userId = ctx.getCallingUserId(); - long accountId = ctx.getCallingAccountId(); - long startEventId = ctx.getStartEventId(); - String eventDescription = actionEvent.eventDescription(); - if(ctx.getEventDetails() != null){ - eventDescription += ". "+ctx.getEventDetails(); - } - ActionEventUtils.onStartedActionEvent(userId, accountId, actionEvent.eventType(), eventDescription, startEventId); + + String eventDescription = getEventDescription(actionEvent, ctx); + String eventType = getEventType(actionEvent, ctx); + + ActionEventUtils.onStartedActionEventFromContext(eventType, eventDescription); } } return event; @@ -53,43 +48,45 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor { @Override public void interceptComplete(Method method, Object target, Object event) { - ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); - if (actionEvent != null) { + for ( ActionEvent actionEvent : getActionEvents(method) ) { CallContext ctx = CallContext.current(); long userId = ctx.getCallingUserId(); long accountId = ctx.getCallingAccountId(); long startEventId = ctx.getStartEventId(); - String eventDescription = actionEvent.eventDescription(); - if(ctx.getEventDetails() != null){ - eventDescription += ". "+ctx.getEventDetails(); - } + String eventDescription = getEventDescription(actionEvent, ctx); + String eventType = getEventType(actionEvent, ctx); + + if ( eventType.equals("") ) + return; + if(actionEvent.create()){ //This start event has to be used for subsequent events of this action - startEventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for "+eventDescription); + startEventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_INFO, eventType, "Successfully created entity for "+eventDescription); ctx.setStartEventId(startEventId); } else { - ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed "+eventDescription, startEventId); + ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_INFO, eventType, "Successfully completed "+eventDescription, startEventId); } } } @Override public void interceptException(Method method, Object target, Object event) { - ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); - if (actionEvent != null) { + for ( ActionEvent actionEvent : getActionEvents(method) ) { CallContext ctx = CallContext.current(); long userId = ctx.getCallingUserId(); long accountId = ctx.getCallingAccountId(); long startEventId = ctx.getStartEventId(); - String eventDescription = actionEvent.eventDescription(); - if(ctx.getEventDetails() != null){ - eventDescription += ". "+ctx.getEventDetails(); - } + String eventDescription = getEventDescription(actionEvent, ctx); + String eventType = getEventType(actionEvent, ctx); + + if ( eventType.equals("") ) + return; + if(actionEvent.create()){ - long eventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for "+eventDescription); + long eventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, eventType, "Error while creating entity for "+eventDescription); ctx.setStartEventId(eventId); } else { - ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while "+eventDescription, startEventId); + ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, eventType, "Error while "+eventDescription, startEventId); } } } @@ -101,6 +98,49 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor { return true; } + ActionEvents events = method.getAnnotation(ActionEvents.class); + if ( events != null ) { + return true; + } + return false; } + + protected List<ActionEvent> getActionEvents(Method m) { + List<ActionEvent> result = new ArrayList<ActionEvent>(); + + ActionEvents events = m.getAnnotation(ActionEvents.class); + + if ( events != null ) { + for ( ActionEvent e : events.value() ) { + result.add(e); + } + } + + ActionEvent e = m.getAnnotation(ActionEvent.class); + + if ( e != null ) { + result.add(e); + } + + return result; + } + protected String getEventType(ActionEvent actionEvent, CallContext ctx) { + String type = ctx.getEventType(); + + return type == null ? actionEvent.eventType() : type; + } + + protected String getEventDescription(ActionEvent actionEvent, CallContext ctx) { + String eventDescription = ctx.getEventDescription(); + if ( eventDescription == null ) { + eventDescription = actionEvent.eventDescription(); + } + + if(ctx.getEventDetails() != null){ + eventDescription += ". "+ctx.getEventDetails(); + } + + return eventDescription; + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/event/ActionEventUtils.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java index 60f5633..00122de 100755 --- a/server/src/com/cloud/event/ActionEventUtils.java +++ b/server/src/com/cloud/event/ActionEventUtils.java @@ -27,7 +27,6 @@ import javax.inject.Inject; import org.apache.log4j.Logger; import org.springframework.beans.factory.NoSuchBeanDefinitionException; - import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.events.EventBus; import org.apache.cloudstack.framework.events.EventBusException; @@ -94,7 +93,22 @@ public class ActionEventUtils { return event.getId(); } + + public static void startNestedActionEvent(String eventType, String eventDescription) { + CallContext.setActionEventInfo(eventType, eventDescription); + onStartedActionEventFromContext(eventType, eventDescription); + } + public static void onStartedActionEventFromContext(String eventType, String eventDescription) { + CallContext ctx = CallContext.current(); + long userId = ctx.getCallingUserId(); + long accountId = ctx.getCallingAccountId(); + long startEventId = ctx.getStartEventId(); + + if ( ! eventType.equals("") ) + ActionEventUtils.onStartedActionEvent(userId, accountId, eventType, eventDescription, startEventId); + } + /* * Save event after starting execution of an async job */ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/network/firewall/FirewallManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java index cd83c4e..773c2c8 100644 --- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java +++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java @@ -155,6 +155,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true) public FirewallRule createEgressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException { Account caller = CallContext.current().getCallingAccount(); @@ -169,6 +170,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true) public FirewallRule createIngressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException { Account caller = CallContext.current().getCallingAccount(); Long sourceIpAddressId = rule.getSourceIpAddressId(); @@ -179,9 +181,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @DB - @Override - @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true) - public FirewallRule createFirewallRule(Long ipAddrId, Account caller, String xId, Integer portStart, + protected FirewallRule createFirewallRule(Long ipAddrId, Account caller, String xId, Integer portStart, Integer portEnd, String protocol, List<String> sourceCidrList, Integer icmpCode, Integer icmpType, Long relatedRuleId, FirewallRule.FirewallRuleType type, Long networkId, FirewallRule.TrafficType trafficType) throws NetworkRuleConflictException { @@ -688,9 +688,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, return true; } - @Override - @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_CLOSE, eventDescription = "revoking firewall rule", async = true) - public boolean revokeFirewallRule(long ruleId, boolean apply, Account caller, long userId) { + protected boolean revokeFirewallRule(long ruleId, boolean apply, Account caller, long userId) { FirewallRuleVO rule = _firewallDao.findById(ruleId); if (rule == null || rule.getPurpose() != Purpose.Firewall) { @@ -727,6 +725,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_CLOSE, eventDescription = "revoking firewall rule", async = true) public boolean revokeFirewallRule(long ruleId, boolean apply) { Account caller = CallContext.current().getCallingAccount(); long userId = CallContext.current().getCallingUserId(); @@ -770,6 +769,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_CLOSE, eventDescription = "revoking firewall rule", async = true) public boolean revokeFirewallRulesForIp(long ipId, long userId, Account caller) throws ResourceUnavailableException { List<FirewallRule> rules = new ArrayList<FirewallRule>(); @@ -799,6 +799,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true) public FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId, long networkId) throws NetworkRuleConflictException { @@ -817,6 +818,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_CLOSE, eventDescription = "revoking firewall rule", async = true) public boolean revokeAllFirewallRulesForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException { List<FirewallRule> rules = new ArrayList<FirewallRule>(); @@ -860,6 +862,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_CLOSE, eventDescription = "revoking firewall rule", async = true) public boolean revokeFirewallRulesForVm(long vmId) { boolean success = true; UserVmVO vm = _vmDao.findByIdIncludingRemoved(vmId); @@ -916,6 +919,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService, } @Override + @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true) public boolean addSystemFirewallRules(IPAddressVO ip, Account acct) { List<FirewallRuleVO> systemRules = _firewallDao.listSystemRules(); for (FirewallRuleVO rule : systemRules) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index a3efd21..c0a52f7 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2107,12 +2107,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return _consoleProxyMgr.assignProxy(dataCenterId, userVmId); } - @ActionEvent(eventType = EventTypes.EVENT_PROXY_START, eventDescription = "starting console proxy Vm", async = true) private ConsoleProxyVO startConsoleProxy(long instanceId) { return _consoleProxyMgr.startProxy(instanceId); } - @ActionEvent(eventType = EventTypes.EVENT_PROXY_STOP, eventDescription = "stopping console proxy Vm", async = true) private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { @@ -2120,14 +2118,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return _consoleProxyDao.findById(systemVm.getId()); } - @ActionEvent(eventType = EventTypes.EVENT_PROXY_REBOOT, eventDescription = "rebooting console proxy Vm", async = true) private ConsoleProxyVO rebootConsoleProxy(long instanceId) { _consoleProxyMgr.rebootProxy(instanceId); return _consoleProxyDao.findById(instanceId); } - @ActionEvent(eventType = EventTypes.EVENT_PROXY_DESTROY, eventDescription = "destroying console proxy Vm", async = true) - public ConsoleProxyVO destroyConsoleProxy(long instanceId) { + protected ConsoleProxyVO destroyConsoleProxy(long instanceId) { ConsoleProxyVO proxy = _consoleProxyDao.findById(instanceId); if (_consoleProxyMgr.destroyProxy(instanceId)) { @@ -2168,7 +2164,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } @Override - @ActionEvent(eventType = EventTypes.EVENT_DOMAIN_UPDATE, eventDescription = "updating Domain") @DB public DomainVO updateDomain(UpdateDomainCmd cmd) { Long domainId = cmd.getId(); @@ -2988,12 +2983,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return _poolDao.searchAndCount(sc, searchFilter); } - @ActionEvent(eventType = EventTypes.EVENT_SSVM_START, eventDescription = "starting secondary storage Vm", async = true) - public SecondaryStorageVmVO startSecondaryStorageVm(long instanceId) { + private SecondaryStorageVmVO startSecondaryStorageVm(long instanceId) { return _secStorageVmMgr.startSecStorageVm(instanceId); } - @ActionEvent(eventType = EventTypes.EVENT_SSVM_STOP, eventDescription = "stopping secondary storage Vm", async = true) private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { @@ -3001,14 +2994,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return _secStorageVmDao.findById(systemVm.getId()); } - @ActionEvent(eventType = EventTypes.EVENT_SSVM_REBOOT, eventDescription = "rebooting secondary storage Vm", async = true) public SecondaryStorageVmVO rebootSecondaryStorageVm(long instanceId) { _secStorageVmMgr.rebootSecStorageVm(instanceId); return _secStorageVmDao.findById(instanceId); } - @ActionEvent(eventType = EventTypes.EVENT_SSVM_DESTROY, eventDescription = "destroying secondary storage Vm", async = true) - public SecondaryStorageVmVO destroySecondaryStorageVm(long instanceId) { + protected SecondaryStorageVmVO destroySecondaryStorageVm(long instanceId) { SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(instanceId); if (_secStorageVmMgr.destroySecStorageVm(instanceId)) { return secStorageVm; @@ -3102,6 +3093,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } @Override + @ActionEvent(eventType = "", eventDescription = "", async = true) public VirtualMachine startSystemVM(long vmId) { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); @@ -3112,8 +3104,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_START, "starting console proxy Vm"); return startConsoleProxy(vmId); } else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_START, "starting secondary storage Vm"); return startSecondaryStorageVm(vmId); } else { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm with specified vmId"); @@ -3123,6 +3117,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } @Override + @ActionEvent(eventType = "", eventDescription = "", async = true) public VMInstanceVO stopSystemVM(StopSystemVmCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException { Long id = cmd.getId(); @@ -3136,8 +3131,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe try { if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_STOP, "stopping console proxy Vm"); return stopConsoleProxy(systemVm, cmd.isForced()); } else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm"); return stopSecondaryStorageVm(systemVm, cmd.isForced()); } return null; @@ -3147,6 +3144,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } @Override + @ActionEvent(eventType = EventTypes.EVENT_PROXY_REBOOT, eventDescription = "", async = true) public VMInstanceVO rebootSystemVM(RebootSystemVmCmd cmd) { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); @@ -3157,13 +3155,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)) { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_REBOOT, "rebooting console proxy Vm"); return rebootConsoleProxy(cmd.getId()); } else { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_REBOOT, "rebooting secondary storage Vm"); return rebootSecondaryStorageVm(cmd.getId()); } } @Override + @ActionEvent(eventType = "", eventDescription = "", async = true) public VMInstanceVO destroySystemVM(DestroySystemVmCmd cmd) { VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(cmd.getId(), VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); @@ -3174,8 +3175,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } if (systemVm.getType().equals(VirtualMachine.Type.ConsoleProxy)) { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_DESTROY, "destroying console proxy Vm"); return destroyConsoleProxy(cmd.getId()); } else { + ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_DESTROY, "destroying secondary storage Vm"); return destroySecondaryStorageVm(cmd.getId()); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/user/AccountManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 0602514..9a03590 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -39,7 +39,6 @@ import javax.naming.ConfigurationException; import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; - import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.acl.SecurityChecker; @@ -75,6 +74,7 @@ import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.event.ActionEvent; import com.cloud.event.ActionEventUtils; +import com.cloud.event.ActionEvents; import com.cloud.event.EventTypes; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.CloudAuthenticationException; @@ -855,7 +855,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @Override @DB - @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account") + @ActionEvents({ + @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account"), + @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User"), + }) public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID) { @@ -927,6 +930,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } @Override + @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User") public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID) { // default domain to ROOT if not specified @@ -1777,7 +1781,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M return account; } - @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User") protected UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID) { if (s_logger.isDebugEnabled()) { s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index c3a718a..ea9c540 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2152,6 +2152,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } @Override + @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true) public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, @@ -2212,6 +2213,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } @Override + @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true) public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, @@ -2328,6 +2330,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } @Override + @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true) public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, @@ -2449,7 +2452,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } - @DB @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true) + @DB protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, String hostName, String displayName, Account owner, Long diskOfferingId, Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, HTTPMethod httpmethod, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, IpAddresses> requestedIps, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/test/com/cloud/network/MockFirewallManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/network/MockFirewallManagerImpl.java b/server/test/com/cloud/network/MockFirewallManagerImpl.java index c50459e..1f3e1b1 100644 --- a/server/test/com/cloud/network/MockFirewallManagerImpl.java +++ b/server/test/com/cloud/network/MockFirewallManagerImpl.java @@ -128,13 +128,6 @@ public class MockFirewallManagerImpl extends ManagerBase implements FirewallMana } @Override - public boolean revokeFirewallRule(long ruleId, boolean apply, - Account caller, long userId) { - // TODO Auto-generated method stub - return false; - } - - @Override public FirewallRule createRuleForAllCidrs(long ipAddrId, Account caller, Integer startPort, Integer endPort, String protocol, Integer icmpCode, Integer icmpType, Long relatedRuleId, @@ -174,16 +167,6 @@ public class MockFirewallManagerImpl extends ManagerBase implements FirewallMana } @Override - public FirewallRule createFirewallRule(Long ipAddrId, Account caller, - String xId, Integer portStart, Integer portEnd, String protocol, - List<String> sourceCidrList, Integer icmpCode, Integer icmpType, - Long relatedRuleId, FirewallRuleType type, Long networkId, - TrafficType traffictype) throws NetworkRuleConflictException { - // TODO Auto-generated method stub - return null; - } - - @Override public void validateFirewallRule(Account caller, IPAddressVO ipAddress, Integer portStart, Integer portEnd, String proto, Purpose purpose, FirewallRuleType type, Long networkid, TrafficType trafficType) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/832db1b3/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index 3ec146b..c9a0480 100755 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -391,17 +391,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu } /* (non-Javadoc) - * @see com.cloud.configuration.ConfigurationManager#createServiceOffering(long, boolean, com.cloud.vm.VirtualMachine.Type, java.lang.String, int, int, int, java.lang.String, boolean, boolean, boolean, java.lang.String, java.lang.Long, java.lang.String, java.lang.Integer) - */ - @Override - public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, - boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details, - Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) * @see com.cloud.configuration.ConfigurationManager#createPod(long, java.lang.String, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) */ @Override @@ -513,17 +502,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu } /* (non-Javadoc) - * @see com.cloud.configuration.ConfigurationManager#createDiskOffering(java.lang.Long, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, boolean, boolean, boolean) - */ - @Override - public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, - boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops, - Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) * @see com.cloud.configuration.ConfigurationManager#createZone(long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Long, com.cloud.dc.DataCenter.NetworkType, java.lang.String, java.lang.String, boolean, boolean) */ @Override
