Package org.apache.cloudstack.context

Examples of org.apache.cloudstack.context.CallContext



    @Override
    @ActionEvent(eventType = EventTypes.EVENT_PROJECT_DELETE, eventDescription = "deleting project", async = true)
    public boolean deleteProject(long projectId) {
        CallContext ctx = CallContext.current();

        ProjectVO project= getProject(projectId);
        //verify input parameters
        if (project == null) {
            throw new InvalidParameterValueException("Unable to find project by id " + projectId);
        }

        _accountMgr.checkAccess(ctx.getCallingAccount(),AccessType.ModifyProject, true, _accountMgr.getAccount(project.getProjectAccountId()));

        return deleteProject(ctx.getCallingAccount(), ctx.getCallingUserId(), project);
    }
View Full Code Here


    }


  @Override
  public void execute() throws ServerApiException {
    final CallContext callContext = getCurrentContext();
        String finalAccountName = getAccountName();
        Long finalDomainId = getDomainId();
    callContext.setEventDetails("Account Name: " + finalAccountName
        + ", Domain Id:" + finalDomainId);
    try {
      final LdapUser user = _ldapManager.getUser(username);
      validateUser(user);
      final UserAccount userAccount = createCloudstackUserAccount(user, finalAccountName, finalDomainId);
View Full Code Here

        });
    }

    @Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_STOP, eventDescription = "stopping router Vm", async = true)
    public VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
        CallContext context = CallContext.current();
        Account account = context.getCallingAccount();

        // verify parameters
        DomainRouterVO router = _routerDao.findById(routerId);
        if (router == null) {
            throw new InvalidParameterValueException("Unable to find router by id " + routerId + ".");
View Full Code Here

    @Override
    @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.getRemoved() != null) {
View Full Code Here

    @Override
    public void finalizeStop(VirtualMachineProfile profile, Answer answer) {
        //release elastic IP here if assigned
        IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());
        if (ip != null && ip.getSystem()) {
            CallContext ctx = CallContext.current();
            try {
                _rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true);
            } catch (Exception ex) {
                s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
            }
        }
    }
View Full Code Here

        }
    }

    public Outcome<VMSnapshot> createVMSnapshotThroughJobQueue(final Long vmId, final Long vmSnapshotId, final boolean quiesceVm) {

        final CallContext context = CallContext.current();
        final User callingUser = context.getCallingUser();
        final Account callingAccount = context.getCallingAccount();

        final VMInstanceVO vm = _vmInstanceDao.findById(vmId);

        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
            @Override
            public Object[] doInTransaction(TransactionStatus status) {
                VmWorkJobVO workJob = null;

                _vmInstanceDao.lockRow(vm.getId(), true);
                workJob = new VmWorkJobVO(context.getContextId());

                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
                workJob.setCmd(VmWorkCreateVMSnapshot.class.getName());

                workJob.setAccountId(callingAccount.getId());
View Full Code Here

                vmSnapshotId);
    }

    public Outcome<VMSnapshot> deleteVMSnapshotThroughJobQueue(final Long vmId, final Long vmSnapshotId) {

        final CallContext context = CallContext.current();
        final User callingUser = context.getCallingUser();
        final Account callingAccount = context.getCallingAccount();

        final VMInstanceVO vm = _vmInstanceDao.findById(vmId);

        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
            @Override
            public Object[] doInTransaction(TransactionStatus status) {
                VmWorkJobVO workJob = null;

                _vmInstanceDao.lockRow(vm.getId(), true);
                workJob = new VmWorkJobVO(context.getContextId());

                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
                workJob.setCmd(VmWorkDeleteVMSnapshot.class.getName());

                workJob.setAccountId(callingAccount.getId());
View Full Code Here

                vmSnapshotId);
    }

    public Outcome<VMSnapshot> revertToVMSnapshotThroughJobQueue(final Long vmId, final Long vmSnapshotId) {

        final CallContext context = CallContext.current();
        final User callingUser = context.getCallingUser();
        final Account callingAccount = context.getCallingAccount();

        final VMInstanceVO vm = _vmInstanceDao.findById(vmId);

        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
            @Override
            public Object[] doInTransaction(TransactionStatus status) {
                VmWorkJobVO workJob = null;

                _vmInstanceDao.lockRow(vm.getId(), true);
                workJob = new VmWorkJobVO(context.getContextId());

                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
                workJob.setCmd(VmWorkRevertToVMSnapshot.class.getName());

                workJob.setAccountId(callingAccount.getId());
View Full Code Here

                vmSnapshotId);
    }

    public Outcome<VirtualMachine> deleteAllVMSnapshotsThroughJobQueue(final Long vmId, final VMSnapshot.Type type) {

        final CallContext context = CallContext.current();
        final User callingUser = context.getCallingUser();
        final Account callingAccount = context.getCallingAccount();

        final VMInstanceVO vm = _vmInstanceDao.findById(vmId);

        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
            @Override
            public Object[] doInTransaction(TransactionStatus status) {
                VmWorkJobVO workJob = null;

                _vmInstanceDao.lockRow(vm.getId(), true);
                workJob = new VmWorkJobVO(context.getContextId());

                workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
                workJob.setCmd(VmWorkDeleteAllVMSnapshots.class.getName());

                workJob.setAccountId(callingAccount.getId());
View Full Code Here

    @Override
    public void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner)
            throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {

        CallContext cctxt = CallContext.current();
        Account account = cctxt.getCallingAccount();
        User caller = cctxt.getCallingUser();

        VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

        VirtualMachineGuru vmGuru = getVmGuru(vm);
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.