Package org.apache.cloudstack.context

Examples of org.apache.cloudstack.context.CallContext


                    }
                }

                _lastNetworkIdsToFree = stillFree;

                CallContext cctx = CallContext.current();

                for (Long networkId : shutdownList) {

                    // If network is removed, unset gc flag for it
                    if (_networksDao.findById(networkId) == null) {
                        s_logger.debug("Network id=" + networkId + " is removed, so clearing up corresponding gc check");
                        _networksDao.clearCheckForGc(networkId);
                    } else {
                        try {

                            User caller = cctx.getCallingUser();
                            Account owner = cctx.getCallingAccount();

                            ReservationContext context = new ReservationContextImpl(null, null, caller, owner);

                            shutdownNetwork(networkId, context, false);
                        } catch (Exception e) {
View Full Code Here


        //delete the domain shared networks
        boolean networksDeleted = true;
        s_logger.debug("Deleting networks for domain id=" + domainId);
        List<Long> networkIds = _networkDomainDao.listNetworkIdsByDomain(domainId);
        CallContext ctx = CallContext.current();
        ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(ctx.getCallingUserId()), ctx.getCallingAccount());
        for (Long networkId : networkIds) {
            s_logger.debug("Deleting network id=" + networkId + " as a part of domain id=" + domainId + " cleanup");
            if (!_networkMgr.destroyNetwork(networkId, context, false)) {
                s_logger.warn("Unable to destroy network id=" + networkId + " as a part of domain id=" + domainId + " cleanup.");
                networksDeleted = false;
View Full Code Here

        CallContext.setActionEventInfo(eventType, eventDescription);
        onStartedActionEventFromContext(eventType, eventDescription, true);
    }

    public static void onStartedActionEventFromContext(String eventType, String eventDescription, boolean eventDisplayEnabled) {
        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, eventDisplayEnabled, startEventId);
    }
View Full Code Here

        }

        // get the entity details for which ActionEvent is generated
        String entityType = null;
        String entityUuid = null;
        CallContext context = CallContext.current();
        Class entityKey = getEntityKey(eventType);
        if (entityKey != null){
            //FIXME - Remove this since it should be covered by the else if condition below.
            entityUuid = (String)context.getContextParameter(entityKey);
            if (entityUuid != null)
                entityType = entityKey.getName();
        }else if (EventTypes.getEntityClassForEvent(eventType) != null){
            //Get entity Class(Example - VirtualMachine.class) from the event Type eg. - VM.CREATE
            Class entityClass = EventTypes.getEntityClassForEvent(eventType);

            //Get uuid from id
            if(context.getContextParameter(entityClass.getName()) != null){
                try {
                    entityUuid = getEntityUuid(entityClass, context.getContextParameter(entityClass.getName()));
                } catch (Exception e){
                    s_logger.debug("Caught exception while finding entityUUID, moving on");
                }
            }
        }
View Full Code Here

        return account.getDomainId();
    }

    private static void populateFirstClassEntities(Map<String, String> eventDescription){

        CallContext context = CallContext.current();
        Map<Object, Object> contextMap = context.getContextParameters();

        try{
            for(Map.Entry<Object, Object> entry : contextMap.entrySet()){
                Object key = entry.getKey();
                Class clz = Class.forName((String)key);
View Full Code Here

    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;
View Full Code Here

    }

    @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.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()) {
                //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);
            }
        }
View Full Code Here

    }

    @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);
            }
        }
View Full Code Here

    @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_DELETE, eventDescription = "deleting account", async = true)
    // This method deletes the account
        public
        boolean deleteUserAccount(long accountId) {

        CallContext ctx = CallContext.current();
        long callerUserId = ctx.getCallingUserId();
        Account caller = ctx.getCallingAccount();

        // If the user is a System user, return an error. We do not allow this
        AccountVO account = _accountDao.findById(accountId);

        if (account == null || account.getRemoved() != null) {
View Full Code Here

    @Override
    @DB
    @ActionEvent(eventType = EventTypes.EVENT_NET_RULE_ADD, eventDescription = "creating forwarding rule", create = true)
    public PortForwardingRule createPortForwardingRule(final PortForwardingRule rule, final Long vmId, Ip vmIp, final boolean openFirewall, final Boolean forDisplay)
            throws NetworkRuleConflictException {
        CallContext ctx = CallContext.current();
        final Account caller = ctx.getCallingAccount();

        final Long ipAddrId = rule.getSourceIpAddressId();

        IPAddressVO ipAddress = _ipAddressDao.findById(ipAddrId);
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.context.CallContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.