@Override @ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_ITEM_CREATE, eventDescription = "Applying Network ACL Item", async = true) public boolean applyNetworkACL(final long aclId) throws ResourceUnavailableException { return _networkAclMgr.applyNetworkACL(aclId); }
@Override public void interceptComplete(Method method, Object target, Object event) { ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); if (actionEvent != null) { CallContext ctx = CallContext.current(); if (!actionEvent.create()) { publishOnMessageBus(EventCategory.ACTION_EVENT.getName(), actionEvent.eventType(), ctx.getEventDetails(), com.cloud.event.Event.State.Completed); } } }
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; } }
@Override public void interceptException(Method method, Object target, Object event) { for (ActionEvent actionEvent : getActionEvents(method)) { CallContext ctx = CallContext.current(); long userId = ctx.getCallingUserId(); long accountId = ctx.getCallingAccountId(); long startEventId = ctx.getStartEventId(); String eventDescription = getEventDescription(actionEvent, ctx); String eventType = getEventType(actionEvent, ctx); boolean isEventDisplayEnabled = ctx.isEventDisplayEnabled(); if (eventType.equals("")) return; if (actionEvent.create()) { long eventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, eventType, isEventDisplayEnabled, "Error while creating entity for " + eventDescription); ctx.setStartEventId(eventId); } else { ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, eventType, isEventDisplayEnabled, "Error while " + eventDescription, startEventId); } } }
protected String getEventType(ActionEvent actionEvent, CallContext ctx) { String type = ctx.getEventType(); return type == null ? actionEvent.eventType() : type; }
@Override public Object interceptStart(Method method, Object target) { EventVO event = null; for (ActionEvent actionEvent : getActionEvents(method)) { boolean async = actionEvent.async(); if (async) { CallContext ctx = CallContext.current(); String eventDescription = getEventDescription(actionEvent, ctx); String eventType = getEventType(actionEvent, ctx); boolean isEventDisplayEnabled = ctx.isEventDisplayEnabled(); ActionEventUtils.onStartedActionEventFromContext(eventType, eventDescription, isEventDisplayEnabled); } } return event; }
@Override public void interceptComplete(Method method, Object target, Object event) { for (ActionEvent actionEvent : getActionEvents(method)) { CallContext ctx = CallContext.current(); long userId = ctx.getCallingUserId(); long accountId = ctx.getProject() != null ? ctx.getProject().getProjectAccountId() : ctx.getCallingAccountId(); //This should be the entity owner id rather than the Calling User Account Id. long startEventId = ctx.getStartEventId(); String eventDescription = getEventDescription(actionEvent, ctx); String eventType = getEventType(actionEvent, ctx); boolean isEventDisplayEnabled = ctx.isEventDisplayEnabled(); 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, eventType, isEventDisplayEnabled, "Successfully created entity for " + eventDescription); ctx.setStartEventId(startEventId); } else { ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_INFO, eventType, isEventDisplayEnabled, "Successfully completed " + eventDescription, startEventId); } } }
@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) { return createUser(userName, password, firstName, lastName, email, timeZone, accountName, domainId, userUUID, User.Source.UNKNOWN); }
@Override @ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_ADD, eventDescription = "Adding a new guest OS type", async = true) public GuestOS getAddedGuestOs(final Long guestOsId) { return getGuestOs(guestOsId); }
@Override @ActionEvent(eventType = EventTypes.EVENT_SERVICE_PROVIDER_CREATE, eventDescription = "Creating Physical Network ServiceProvider", async = true) public PhysicalNetworkServiceProvider getCreatedPhysicalNetworkServiceProvider(Long providerId) { return getPhysicalNetworkServiceProvider(providerId); }
@Override @ActionEvent(eventType = EventTypes.EVENT_ENABLE_STATIC_NAT, eventDescription = "enabling static nat") public boolean enableStaticNat(long ipId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException { return enableStaticNat(ipId, vmId, networkId, false, vmGuestIp); }
@Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_START, eventDescription = "starting router Vm", async = true) public VirtualRouter startRouter(final long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException { return startRouter(id, true); }
@Override @ActionEvent(eventType = EventTypes.EVENT_HA_RESOURCE_ENABLE, eventDescription = "enabling HA for resource") public boolean enableHA(final Long resourceId, final HAResource.ResourceType resourceType) { Preconditions.checkArgument(resourceId != null && resourceId > 0L); Preconditions.checkArgument(resourceType != null); return configureHA(resourceId, resourceType, true, null); }
@Override @ActionEvent(eventType = EventTypes.EVENT_NET_IP_RELEASE, eventDescription = "disassociating Ip", async = true) public boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException { return releaseIpAddressInternal(ipAddressId); }
@Override @ActionEvents({@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account"), @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User")}) public UserAccount createUserAccount(final String userName, final String password, final String firstName, final String lastName, final String email, final String timezone, String accountName, final short accountType, final Long roleId, Long domainId, final String networkDomain, final Map<String, String> details, String accountUUID, final String userUUID) { return createUserAccount(userName, password, firstName, lastName, email, timezone, accountName, accountType, roleId, domainId, networkDomain, details, accountUUID, userUUID, User.Source.UNKNOWN); }
@Override @ActionEvent(eventType = EventTypes.EVENT_PHYSICAL_NETWORK_CREATE, eventDescription = "Creating Physical Network", async = true) public PhysicalNetwork getCreatedPhysicalNetwork(Long physicalNetworkId) { return getPhysicalNetwork(physicalNetworkId); }
@Override @ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_CREATE, eventDescription = "Creating Physical Network TrafficType", async = true) public PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id) { return _pNTrafficTypeDao.findById(id); }
@Override @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", async = true) public boolean applyIngressFwRules(long ipId, Account caller) throws ResourceUnavailableException { return applyIngressFirewallRules(ipId, caller); }
@Override @ActionEvent(eventType = EventTypes.EVENT_FIREWALL_CLOSE, eventDescription = "revoking firewall rule", async = true) public boolean revokeIngressFwRule(long ruleId, boolean apply) { return revokeIngressFirewallRule(ruleId, apply); }
@Override @ActionEvent(eventType = EventTypes.EVENT_REMOVE_FROM_LOAD_BALANCER_RULE, eventDescription = "removing from load balancer", async = true) public boolean removeFromLoadBalancer(long loadBalancerId, List<Long> instanceIds, Map<Long, List<String>> vmIdIpsMap) { return removeFromLoadBalancerInternal(loadBalancerId, instanceIds, true, vmIdIpsMap); }