Examples of CallContext


Examples of org.apache.cloudstack.context.CallContext

        return new VmStateSyncOutcome((VmWorkJobVO)result[0],
                VirtualMachine.PowerState.PowerOn, vm.getId(), null);
    }

    public Outcome<VirtualMachine> stopVmThroughJobQueue(final String vmUuid, final boolean cleanup) {
        final CallContext context = CallContext.current();
        final Account account = context.getCallingAccount();
        final User user = context.getCallingUser();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
            @Override
            public Object[] doInTransaction(TransactionStatus status) {
                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        vm.getType(), vm.getId(),
                        VmWorkStop.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {
                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> rebootVmThroughJobQueue(final String vmUuid,
            final Map<VirtualMachineProfile.Param, Object> params) {

        final CallContext context = CallContext.current();
        final Account account = context.getCallingAccount();
        final User user = context.getCallingUser();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
            @Override
            public Object[] doInTransaction(TransactionStatus status) {
                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkReboot.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {
                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0],
                vm.getId());
    }

    public Outcome<VirtualMachine> migrateVmThroughJobQueue(final String vmUuid, final long srcHostId, final DeployDestination dest) {
        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkMigrate.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    public Outcome<VirtualMachine> migrateVmWithStorageThroughJobQueue(
            final String vmUuid, final long srcHostId, final long destHostId,
            final Map<Volume, StoragePool> volumeToPool) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkMigrateWithStorage.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> migrateVmForScaleThroughJobQueue(
            final String vmUuid, final long srcHostId, final DeployDestination dest, final Long newSvcOfferingId) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkMigrateForScale.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> migrateVmStorageThroughJobQueue(
            final String vmUuid, final StoragePool destPool) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkStorageMigration.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> addVmToNetworkThroughJobQueue(
            final VirtualMachine vm, final Network network, final NicProfile requested) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkAddVmToNetwork.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> removeNicFromVmThroughJobQueue(
            final VirtualMachine vm, final Nic nic) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkRemoveNicFromVm.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> removeVmFromNetworkThroughJobQueue(
            final VirtualMachine vm, final Network network, final URI broadcastUri) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkRemoveVmFromNetwork.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

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

Examples of org.apache.cloudstack.context.CallContext

    }

    public Outcome<VirtualMachine> reconfigureVmThroughJobQueue(
            final String vmUuid, final ServiceOffering newServiceOffering, final boolean reconfiguringOnExistingHost) {

        final CallContext context = CallContext.current();
        final User user = context.getCallingUser();
        final Account account = context.getCallingAccount();

        final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);

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

                _vmDao.lockRow(vm.getId(), true);

                List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
                        VirtualMachine.Type.Instance, vm.getId(),
                        VmWorkReconfigure.class.getName());

                VmWorkJobVO workJob = null;
                if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
                    assert (pendingWorkJobs.size() == 1);
                    workJob = pendingWorkJobs.get(0);
                } else {

                    workJob = new VmWorkJobVO(context.getContextId());

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

                    workJob.setAccountId(account.getId());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.