Search in sources :

Example 6 with StartCommand

use of com.cloud.agent.api.StartCommand in project cloudstack by apache.

the class LibvirtComputingResourceTest method testStartCommandInternalError.

@Test
public void testStartCommandInternalError() {
    final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
    final com.cloud.host.Host host = Mockito.mock(com.cloud.host.Host.class);
    final boolean executeInSequence = false;
    final StartCommand command = new StartCommand(vmSpec, host, executeInSequence);
    final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class);
    final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
    final Connect conn = Mockito.mock(Connect.class);
    final LibvirtVMDef vmDef = Mockito.mock(LibvirtVMDef.class);
    final NicTO nic = Mockito.mock(NicTO.class);
    final NicTO[] nics = new NicTO[] { nic };
    final String vmName = "Test";
    when(libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
    when(vmSpec.getNics()).thenReturn(nics);
    when(vmSpec.getType()).thenReturn(VirtualMachine.Type.DomainRouter);
    when(vmSpec.getName()).thenReturn(vmName);
    when(libvirtComputingResource.createVMFromSpec(vmSpec)).thenReturn(vmDef);
    when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
    try {
        when(libvirtUtilitiesHelper.getConnectionByType(vmDef.getHvsType())).thenReturn(conn);
        doThrow(InternalErrorException.class).when(libvirtComputingResource).createVbd(conn, vmSpec, vmName, vmDef);
    } catch (final LibvirtException e) {
        fail(e.getMessage());
    } catch (final InternalErrorException e) {
        fail(e.getMessage());
    } catch (final URISyntaxException e) {
        fail(e.getMessage());
    }
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertFalse(answer.getResult());
    verify(libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
    try {
        verify(libvirtUtilitiesHelper, times(1)).getConnectionByType(vmDef.getHvsType());
    } catch (final LibvirtException e) {
        fail(e.getMessage());
    }
}
Also used : KVMStoragePoolManager(com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager) LibvirtException(org.libvirt.LibvirtException) StartCommand(com.cloud.agent.api.StartCommand) Connect(org.libvirt.Connect) InternalErrorException(com.cloud.exception.InternalErrorException) URISyntaxException(java.net.URISyntaxException) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) LibvirtUtilitiesHelper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper) AttachAnswer(org.apache.cloudstack.storage.command.AttachAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) LibvirtRequestWrapper(com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper) NicTO(com.cloud.agent.api.to.NicTO) Test(org.junit.Test)

Example 7 with StartCommand

use of com.cloud.agent.api.StartCommand in project cloudstack by apache.

the class HypervDirectConnectResource method executeRequest.

// TODO: Is it valid to return NULL, or should we throw on error?
@Override
public final Answer executeRequest(final Command cmd) {
    // Set HTTP POST destination URI
    // Using java.net.URI, see
    // http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URI.html
    URI agentUri = null;
    final Class<? extends Command> clazz = cmd.getClass();
    Answer answer = null;
    try {
        final String cmdName = cmd.getClass().getName();
        agentUri = new URI("https", null, _agentIp, _port, "/api/HypervResource/" + cmdName, null, null);
    } catch (final URISyntaxException e) {
        // TODO add proper logging
        final String errMsg = "Could not generate URI for Hyper-V agent";
        s_logger.error(errMsg, e);
        return null;
    }
    if (cmd instanceof NetworkElementCommand) {
        return _vrResource.executeRequest((NetworkElementCommand) cmd);
    }
    if (clazz == CheckSshCommand.class) {
        answer = execute((CheckSshCommand) cmd);
    } else if (clazz == GetDomRVersionCmd.class) {
        answer = execute((GetDomRVersionCmd) cmd);
    } else if (cmd instanceof NetworkUsageCommand) {
        answer = execute((NetworkUsageCommand) cmd);
    } else if (clazz == IpAssocCommand.class) {
        answer = execute((IpAssocCommand) cmd);
    } else if (clazz == DnsMasqConfigCommand.class) {
        return execute((DnsMasqConfigCommand) cmd);
    } else if (clazz == CreateIpAliasCommand.class) {
        return execute((CreateIpAliasCommand) cmd);
    } else if (clazz == DhcpEntryCommand.class) {
        answer = execute((DhcpEntryCommand) cmd);
    } else if (clazz == VmDataCommand.class) {
        answer = execute((VmDataCommand) cmd);
    } else if (clazz == SavePasswordCommand.class) {
        answer = execute((SavePasswordCommand) cmd);
    } else if (clazz == SetFirewallRulesCommand.class) {
        answer = execute((SetFirewallRulesCommand) cmd);
    } else if (clazz == LoadBalancerConfigCommand.class) {
        answer = execute((LoadBalancerConfigCommand) cmd);
    } else if (clazz == DeleteIpAliasCommand.class) {
        return execute((DeleteIpAliasCommand) cmd);
    } else if (clazz == PingTestCommand.class) {
        answer = execute((PingTestCommand) cmd);
    } else if (clazz == SetStaticNatRulesCommand.class) {
        answer = execute((SetStaticNatRulesCommand) cmd);
    } else if (clazz == CheckRouterCommand.class) {
        answer = execute((CheckRouterCommand) cmd);
    } else if (clazz == SetPortForwardingRulesCommand.class) {
        answer = execute((SetPortForwardingRulesCommand) cmd);
    } else if (clazz == SetSourceNatCommand.class) {
        answer = execute((SetSourceNatCommand) cmd);
    } else if (clazz == Site2SiteVpnCfgCommand.class) {
        answer = execute((Site2SiteVpnCfgCommand) cmd);
    } else if (clazz == CheckS2SVpnConnectionsCommand.class) {
        answer = execute((CheckS2SVpnConnectionsCommand) cmd);
    } else if (clazz == RemoteAccessVpnCfgCommand.class) {
        answer = execute((RemoteAccessVpnCfgCommand) cmd);
    } else if (clazz == VpnUsersCfgCommand.class) {
        answer = execute((VpnUsersCfgCommand) cmd);
    } else if (clazz == SetStaticRouteCommand.class) {
        answer = execute((SetStaticRouteCommand) cmd);
    } else if (clazz == SetMonitorServiceCommand.class) {
        answer = execute((SetMonitorServiceCommand) cmd);
    } else if (clazz == PlugNicCommand.class) {
        answer = execute((PlugNicCommand) cmd);
    } else if (clazz == UnPlugNicCommand.class) {
        answer = execute((UnPlugNicCommand) cmd);
    } else if (clazz == CopyCommand.class) {
        answer = execute((CopyCommand) cmd);
    } else {
        if (clazz == StartCommand.class) {
            final VirtualMachineTO vmSpec = ((StartCommand) cmd).getVirtualMachine();
            if (vmSpec.getType() != VirtualMachine.Type.User) {
                if (s_hypervMgr != null) {
                    final String secondary = s_hypervMgr.prepareSecondaryStorageStore(Long.parseLong(_zoneId));
                    if (secondary != null) {
                        ((StartCommand) cmd).setSecondaryStorage(secondary);
                    }
                } else {
                    s_logger.error("Hyperv manager isn't available. Couldn't check and copy the systemvm iso.");
                }
            }
        }
        // Send the cmd to hyperv agent.
        final String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri);
        if (ansStr == null) {
            return Answer.createUnsupportedCommandAnswer(cmd);
        }
        // Only Answer instances are returned by remote agents.
        // E.g. see Response.getAnswers()
        final Answer[] result = s_gson.fromJson(ansStr, Answer[].class);
        final String logResult = cleanPassword(s_gson.toJson(result));
        s_logger.debug("executeRequest received response " + logResult);
        if (result.length > 0) {
            return result[0];
        }
    }
    return answer;
}
Also used : CheckRouterCommand(com.cloud.agent.api.CheckRouterCommand) VpnUsersCfgCommand(com.cloud.agent.api.routing.VpnUsersCfgCommand) CheckSshCommand(com.cloud.agent.api.check.CheckSshCommand) Site2SiteVpnCfgCommand(com.cloud.agent.api.routing.Site2SiteVpnCfgCommand) StartCommand(com.cloud.agent.api.StartCommand) GetDomRVersionCmd(com.cloud.agent.api.GetDomRVersionCmd) SavePasswordCommand(com.cloud.agent.api.routing.SavePasswordCommand) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) DhcpEntryCommand(com.cloud.agent.api.routing.DhcpEntryCommand) VmDataCommand(com.cloud.agent.api.routing.VmDataCommand) URISyntaxException(java.net.URISyntaxException) NetworkElementCommand(com.cloud.agent.api.routing.NetworkElementCommand) SetSourceNatCommand(com.cloud.agent.api.routing.SetSourceNatCommand) URI(java.net.URI) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) UnPlugNicCommand(com.cloud.agent.api.UnPlugNicCommand) SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) CreateIpAliasCommand(com.cloud.agent.api.routing.CreateIpAliasCommand) SetPortForwardingRulesCommand(com.cloud.agent.api.routing.SetPortForwardingRulesCommand) IpAssocCommand(com.cloud.agent.api.routing.IpAssocCommand) CheckS2SVpnConnectionsCommand(com.cloud.agent.api.CheckS2SVpnConnectionsCommand) PlugNicCommand(com.cloud.agent.api.PlugNicCommand) UnPlugNicCommand(com.cloud.agent.api.UnPlugNicCommand) LoadBalancerConfigCommand(com.cloud.agent.api.routing.LoadBalancerConfigCommand) PingTestCommand(com.cloud.agent.api.PingTestCommand) SetStaticNatRulesCommand(com.cloud.agent.api.routing.SetStaticNatRulesCommand) DeleteIpAliasCommand(com.cloud.agent.api.routing.DeleteIpAliasCommand) SetStaticRouteCommand(com.cloud.agent.api.routing.SetStaticRouteCommand) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) SetFirewallRulesCommand(com.cloud.agent.api.routing.SetFirewallRulesCommand) UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) SetPortForwardingRulesAnswer(com.cloud.agent.api.routing.SetPortForwardingRulesAnswer) SetSourceNatAnswer(com.cloud.agent.api.routing.SetSourceNatAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) GetVmConfigAnswer(com.cloud.agent.api.GetVmConfigAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) SetStaticNatRulesAnswer(com.cloud.agent.api.routing.SetStaticNatRulesAnswer) IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) SetFirewallRulesAnswer(com.cloud.agent.api.routing.SetFirewallRulesAnswer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) SetStaticRouteAnswer(com.cloud.agent.api.routing.SetStaticRouteAnswer) RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand)

Example 8 with StartCommand

use of com.cloud.agent.api.StartCommand in project cloudstack by apache.

the class VirtualMachineManagerImpl method orchestrateStart.

@Override
public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params, final DeploymentPlan planToDeploy, final DeploymentPlanner planner) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
    final CallContext cctxt = CallContext.current();
    final Account account = cctxt.getCallingAccount();
    final User caller = cctxt.getCallingUser();
    VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
    final VirtualMachineGuru vmGuru = getVmGuru(vm);
    final Ternary<VMInstanceVO, ReservationContext, ItWorkVO> start = changeToStartState(vmGuru, vm, caller, account);
    if (start == null) {
        return;
    }
    vm = start.first();
    final ReservationContext ctx = start.second();
    ItWorkVO work = start.third();
    VMInstanceVO startedVm = null;
    final ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
    final VirtualMachineTemplate template = _entityMgr.findByIdIncludingRemoved(VirtualMachineTemplate.class, vm.getTemplateId());
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Trying to deploy VM, vm has dcId: " + vm.getDataCenterId() + " and podId: " + vm.getPodIdToDeployIn());
    }
    DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodIdToDeployIn(), null, null, null, null, ctx);
    if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("advanceStart: DeploymentPlan is provided, using dcId:" + planToDeploy.getDataCenterId() + ", podId: " + planToDeploy.getPodId() + ", clusterId: " + planToDeploy.getClusterId() + ", hostId: " + planToDeploy.getHostId() + ", poolId: " + planToDeploy.getPoolId());
        }
        plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId(), ctx);
    }
    final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
    boolean canRetry = true;
    ExcludeList avoids = null;
    try {
        final Journal journal = start.second().getJournal();
        if (planToDeploy != null) {
            avoids = planToDeploy.getAvoids();
        }
        if (avoids == null) {
            avoids = new ExcludeList();
        }
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Deploy avoids pods: " + avoids.getPodsToAvoid() + ", clusters: " + avoids.getClustersToAvoid() + ", hosts: " + avoids.getHostsToAvoid());
        }
        boolean planChangedByVolume = false;
        boolean reuseVolume = true;
        final DataCenterDeployment originalPlan = plan;
        int retry = StartRetry.value();
        while (retry-- != 0) {
            if (reuseVolume) {
                // edit plan if this vm's ROOT volume is in READY state already
                final List<VolumeVO> vols = _volsDao.findReadyRootVolumesByInstance(vm.getId());
                for (final VolumeVO vol : vols) {
                    // make sure if the templateId is unchanged. If it is changed,
                    // let planner
                    // reassign pool for the volume even if it ready.
                    final Long volTemplateId = vol.getTemplateId();
                    if (volTemplateId != null && volTemplateId.longValue() != template.getId()) {
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug(vol + " of " + vm + " is READY, but template ids don't match, let the planner reassign a new pool");
                        }
                        continue;
                    }
                    final StoragePool pool = (StoragePool) dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
                    if (!pool.isInMaintenance()) {
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug("Root volume is ready, need to place VM in volume's cluster");
                        }
                        final long rootVolDcId = pool.getDataCenterId();
                        final Long rootVolPodId = pool.getPodId();
                        final Long rootVolClusterId = pool.getClusterId();
                        if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) {
                            final Long clusterIdSpecified = planToDeploy.getClusterId();
                            if (clusterIdSpecified != null && rootVolClusterId != null) {
                                if (rootVolClusterId.longValue() != clusterIdSpecified.longValue()) {
                                    // planner
                                    if (s_logger.isDebugEnabled()) {
                                        s_logger.debug("Cannot satisfy the deployment plan passed in since the ready Root volume is in different cluster. volume's cluster: " + rootVolClusterId + ", cluster specified: " + clusterIdSpecified);
                                    }
                                    throw new ResourceUnavailableException("Root volume is ready in different cluster, Deployment plan provided cannot be satisfied, unable to create a deployment for " + vm, Cluster.class, clusterIdSpecified);
                                }
                            }
                            plan = new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), vol.getPoolId(), null, ctx);
                        } else {
                            plan = new DataCenterDeployment(rootVolDcId, rootVolPodId, rootVolClusterId, null, vol.getPoolId(), null, ctx);
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug(vol + " is READY, changing deployment plan to use this pool's dcId: " + rootVolDcId + " , podId: " + rootVolPodId + " , and clusterId: " + rootVolClusterId);
                            }
                            planChangedByVolume = true;
                        }
                    }
                }
            }
            final Account owner = _entityMgr.findById(Account.class, vm.getAccountId());
            final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, offering, owner, params);
            DeployDestination dest = null;
            try {
                dest = _dpMgr.planDeployment(vmProfile, plan, avoids, planner);
            } catch (final AffinityConflictException e2) {
                s_logger.warn("Unable to create deployment, affinity rules associted to the VM conflict", e2);
                throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict");
            }
            if (dest == null) {
                if (planChangedByVolume) {
                    plan = originalPlan;
                    planChangedByVolume = false;
                    //do not enter volume reuse for next retry, since we want to look for resources outside the volume's cluster
                    reuseVolume = false;
                    continue;
                }
                throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId(), areAffinityGroupsAssociated(vmProfile));
            }
            if (dest != null) {
                avoids.addHost(dest.getHost().getId());
                journal.record("Deployment found ", vmProfile, dest);
            }
            long destHostId = dest.getHost().getId();
            vm.setPodIdToDeployIn(dest.getPod().getId());
            final Long cluster_id = dest.getCluster().getId();
            final ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, "cpuOvercommitRatio");
            final ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, "memoryOvercommitRatio");
            //storing the value of overcommit in the vm_details table for doing a capacity check in case the cluster overcommit ratio is changed.
            if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") == null && (Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f)) {
                _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true);
                _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true);
            } else if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") != null) {
                _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true);
                _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true);
            }
            vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue()));
            vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue()));
            StartAnswer startAnswer = null;
            try {
                if (!changeState(vm, Event.OperationRetry, destHostId, work, Step.Prepare)) {
                    throw new ConcurrentOperationException("Unable to update the state of the Virtual Machine " + vm.getUuid() + " oldstate: " + vm.getState() + "Event :" + Event.OperationRetry);
                }
            } catch (final NoTransitionException e1) {
                throw new ConcurrentOperationException(e1.getMessage());
            }
            try {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("VM is being created in podId: " + vm.getPodIdToDeployIn());
                }
                _networkMgr.prepare(vmProfile, new DeployDestination(dest.getDataCenter(), dest.getPod(), null, null), ctx);
                if (vm.getHypervisorType() != HypervisorType.BareMetal) {
                    volumeMgr.prepare(vmProfile, dest);
                }
                //since StorageMgr succeeded in volume creation, reuse Volume for further tries until current cluster has capacity
                if (!reuseVolume) {
                    reuseVolume = true;
                }
                Commands cmds = null;
                vmGuru.finalizeVirtualMachineProfile(vmProfile, dest, ctx);
                final VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
                handlePath(vmTO.getDisks(), vm.getHypervisorType());
                cmds = new Commands(Command.OnError.Stop);
                cmds.addCommand(new StartCommand(vmTO, dest.getHost(), getExecuteInSequence(vm.getHypervisorType())));
                vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx);
                work = _workDao.findById(work.getId());
                if (work == null || work.getStep() != Step.Prepare) {
                    throw new ConcurrentOperationException("Work steps have been changed: " + work);
                }
                _workDao.updateStep(work, Step.Starting);
                _agentMgr.send(destHostId, cmds);
                _workDao.updateStep(work, Step.Started);
                startAnswer = cmds.getAnswer(StartAnswer.class);
                if (startAnswer != null && startAnswer.getResult()) {
                    handlePath(vmTO.getDisks(), startAnswer.getIqnToPath());
                    final String host_guid = startAnswer.getHost_guid();
                    if (host_guid != null) {
                        final HostVO finalHost = _resourceMgr.findHostByGuid(host_guid);
                        if (finalHost == null) {
                            throw new CloudRuntimeException("Host Guid " + host_guid + " doesn't exist in DB, something went wrong while processing start answer: " + startAnswer);
                        }
                        destHostId = finalHost.getId();
                    }
                    if (vmGuru.finalizeStart(vmProfile, destHostId, cmds, ctx)) {
                        syncDiskChainChange(startAnswer);
                        if (!changeState(vm, Event.OperationSucceeded, destHostId, work, Step.Done)) {
                            s_logger.error("Unable to transition to a new state. VM uuid: " + vm.getUuid() + "VM oldstate:" + vm.getState() + "Event:" + Event.OperationSucceeded);
                            throw new ConcurrentOperationException("Failed to deploy VM" + vm.getUuid());
                        }
                        // Update GPU device capacity
                        final GPUDeviceTO gpuDevice = startAnswer.getVirtualMachine().getGpuDevice();
                        if (gpuDevice != null) {
                            _resourceMgr.updateGPUDetails(destHostId, gpuDevice.getGroupDetails());
                        }
                        // information isn't set,
                        if (_uservmDetailsDao.findDetail(vm.getId(), "deployvm") != null) {
                            _uservmDetailsDao.removeDetail(vm.getId(), "deployvm");
                        }
                        startedVm = vm;
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug("Start completed for VM " + vm);
                        }
                        return;
                    } else {
                        if (s_logger.isDebugEnabled()) {
                            s_logger.info("The guru did not like the answers so stopping " + vm);
                        }
                        StopCommand stopCmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType()), false);
                        stopCmd.setControlIp(getControlNicIpForVM(vm));
                        final StopCommand cmd = stopCmd;
                        final Answer answer = _agentMgr.easySend(destHostId, cmd);
                        if (answer != null && answer instanceof StopAnswer) {
                            final StopAnswer stopAns = (StopAnswer) answer;
                            if (vm.getType() == VirtualMachine.Type.User) {
                                final String platform = stopAns.getPlatform();
                                if (platform != null) {
                                    final Map<String, String> vmmetadata = new HashMap<String, String>();
                                    vmmetadata.put(vm.getInstanceName(), platform);
                                    syncVMMetaData(vmmetadata);
                                }
                            }
                        }
                        if (answer == null || !answer.getResult()) {
                            s_logger.warn("Unable to stop " + vm + " due to " + (answer != null ? answer.getDetails() : "no answers"));
                            _haMgr.scheduleStop(vm, destHostId, WorkType.ForceStop);
                            throw new ExecutionException("Unable to stop this VM, " + vm.getUuid() + " so we are unable to retry the start operation");
                        }
                        throw new ExecutionException("Unable to start  VM:" + vm.getUuid() + " due to error in finalizeStart, not retrying");
                    }
                }
                s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + (startAnswer == null ? " no start answer" : startAnswer.getDetails()));
                if (startAnswer != null && startAnswer.getContextParam("stopRetry") != null) {
                    break;
                }
            } catch (OperationTimedoutException e) {
                s_logger.debug("Unable to send the start command to host " + dest.getHost() + " failed to start VM: " + vm.getUuid());
                if (e.isActive()) {
                    _haMgr.scheduleStop(vm, destHostId, WorkType.CheckStop);
                }
                canRetry = false;
                throw new AgentUnavailableException("Unable to start " + vm.getHostName(), destHostId, e);
            } catch (final ResourceUnavailableException e) {
                s_logger.info("Unable to contact resource.", e);
                if (!avoids.add(e)) {
                    if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
                        throw e;
                    } else {
                        s_logger.warn("unexpected ResourceUnavailableException : " + e.getScope().getName(), e);
                        throw e;
                    }
                }
            } catch (final InsufficientCapacityException e) {
                s_logger.info("Insufficient capacity ", e);
                if (!avoids.add(e)) {
                    if (e.getScope() == Volume.class || e.getScope() == Nic.class) {
                        throw e;
                    } else {
                        s_logger.warn("unexpected InsufficientCapacityException : " + e.getScope().getName(), e);
                    }
                }
            } catch (final ExecutionException e) {
                s_logger.error("Failed to start instance " + vm, e);
                throw new AgentUnavailableException("Unable to start instance due to " + e.getMessage(), destHostId, e);
            } catch (final NoTransitionException e) {
                s_logger.error("Failed to start instance " + vm, e);
                throw new AgentUnavailableException("Unable to start instance due to " + e.getMessage(), destHostId, e);
            } finally {
                if (startedVm == null && canRetry) {
                    final Step prevStep = work.getStep();
                    _workDao.updateStep(work, Step.Release);
                    // If previous step was started/ing && we got a valid answer
                    if ((prevStep == Step.Started || prevStep == Step.Starting) && startAnswer != null && startAnswer.getResult()) {
                        //TODO check the response of cleanup and record it in DB for retry
                        cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false);
                    } else {
                        //if step is not starting/started, send cleanup command with force=true
                        cleanup(vmGuru, vmProfile, work, Event.OperationFailed, true);
                    }
                }
            }
        }
    } finally {
        if (startedVm == null) {
            if (canRetry) {
                try {
                    changeState(vm, Event.OperationFailed, null, work, Step.Done);
                } catch (final NoTransitionException e) {
                    throw new ConcurrentOperationException(e.getMessage());
                }
            }
        }
        if (planToDeploy != null) {
            planToDeploy.setAvoids(avoids);
        }
    }
    if (startedVm == null) {
        throw new CloudRuntimeException("Unable to start instance '" + vm.getHostName() + "' (" + vm.getUuid() + "), see management server log for details");
    }
}
Also used : Account(com.cloud.user.Account) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) User(com.cloud.user.User) StoragePool(com.cloud.storage.StoragePool) StartAnswer(com.cloud.agent.api.StartAnswer) StartCommand(com.cloud.agent.api.StartCommand) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Journal(com.cloud.utils.Journal) Step(com.cloud.vm.ItWorkVO.Step) AffinityConflictException(com.cloud.exception.AffinityConflictException) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) HypervisorGuru(com.cloud.hypervisor.HypervisorGuru) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) Commands(com.cloud.agent.manager.Commands) ExecutionException(com.cloud.utils.exception.ExecutionException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) StopAnswer(com.cloud.agent.api.StopAnswer) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) InsufficientServerCapacityException(com.cloud.exception.InsufficientServerCapacityException) GPUDeviceTO(com.cloud.agent.api.to.GPUDeviceTO) CallContext(org.apache.cloudstack.context.CallContext) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) HostVO(com.cloud.host.HostVO) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) RestoreVMSnapshotAnswer(com.cloud.agent.api.RestoreVMSnapshotAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) StopAnswer(com.cloud.agent.api.StopAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) ClusterVMMetaDataSyncAnswer(com.cloud.agent.api.ClusterVMMetaDataSyncAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) StopCommand(com.cloud.agent.api.StopCommand) DeployDestination(com.cloud.deploy.DeployDestination) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ClusterDetailsVO(com.cloud.dc.ClusterDetailsVO)

Example 9 with StartCommand

use of com.cloud.agent.api.StartCommand in project cloudstack by apache.

the class VmwareResource method executeRequest.

@Override
public Answer executeRequest(Command cmd) {
    if (s_logger.isTraceEnabled())
        s_logger.trace("Begin executeRequest(), cmd: " + cmd.getClass().getSimpleName());
    Answer answer = null;
    NDC.push(getCommandLogTitle(cmd));
    try {
        long cmdSequence = _cmdSequence++;
        Date startTime = DateUtil.currentGMTTime();
        PropertyMapDynamicBean mbean = new PropertyMapDynamicBean();
        mbean.addProp("StartTime", DateUtil.getDateDisplayString(TimeZone.getDefault(), startTime));
        mbean.addProp("Command", _gson.toJson(cmd));
        mbean.addProp("Sequence", String.valueOf(cmdSequence));
        mbean.addProp("Name", cmd.getClass().getSimpleName());
        Class<? extends Command> clz = cmd.getClass();
        if (cmd instanceof NetworkElementCommand) {
            return _vrResource.executeRequest((NetworkElementCommand) cmd);
        } else if (clz == ReadyCommand.class) {
            answer = execute((ReadyCommand) cmd);
        } else if (clz == GetHostStatsCommand.class) {
            answer = execute((GetHostStatsCommand) cmd);
        } else if (clz == GetVmStatsCommand.class) {
            answer = execute((GetVmStatsCommand) cmd);
        } else if (clz == GetVmDiskStatsCommand.class) {
            answer = execute((GetVmDiskStatsCommand) cmd);
        } else if (clz == CheckHealthCommand.class) {
            answer = execute((CheckHealthCommand) cmd);
        } else if (clz == StopCommand.class) {
            answer = execute((StopCommand) cmd);
        } else if (clz == RebootRouterCommand.class) {
            answer = execute((RebootRouterCommand) cmd);
        } else if (clz == RebootCommand.class) {
            answer = execute((RebootCommand) cmd);
        } else if (clz == CheckVirtualMachineCommand.class) {
            answer = execute((CheckVirtualMachineCommand) cmd);
        } else if (clz == PrepareForMigrationCommand.class) {
            answer = execute((PrepareForMigrationCommand) cmd);
        } else if (clz == MigrateCommand.class) {
            answer = execute((MigrateCommand) cmd);
        } else if (clz == MigrateWithStorageCommand.class) {
            answer = execute((MigrateWithStorageCommand) cmd);
        } else if (clz == MigrateVolumeCommand.class) {
            answer = execute((MigrateVolumeCommand) cmd);
        } else if (clz == DestroyCommand.class) {
            answer = execute((DestroyCommand) cmd);
        } else if (clz == CreateStoragePoolCommand.class) {
            return execute((CreateStoragePoolCommand) cmd);
        } else if (clz == ModifyTargetsCommand.class) {
            answer = execute((ModifyTargetsCommand) cmd);
        } else if (clz == ModifyStoragePoolCommand.class) {
            answer = execute((ModifyStoragePoolCommand) cmd);
        } else if (clz == DeleteStoragePoolCommand.class) {
            answer = execute((DeleteStoragePoolCommand) cmd);
        } else if (clz == CopyVolumeCommand.class) {
            answer = execute((CopyVolumeCommand) cmd);
        } else if (clz == AttachIsoCommand.class) {
            answer = execute((AttachIsoCommand) cmd);
        } else if (clz == ValidateSnapshotCommand.class) {
            answer = execute((ValidateSnapshotCommand) cmd);
        } else if (clz == ManageSnapshotCommand.class) {
            answer = execute((ManageSnapshotCommand) cmd);
        } else if (clz == BackupSnapshotCommand.class) {
            answer = execute((BackupSnapshotCommand) cmd);
        } else if (clz == CreateVolumeFromSnapshotCommand.class) {
            answer = execute((CreateVolumeFromSnapshotCommand) cmd);
        } else if (clz == CreatePrivateTemplateFromVolumeCommand.class) {
            answer = execute((CreatePrivateTemplateFromVolumeCommand) cmd);
        } else if (clz == CreatePrivateTemplateFromSnapshotCommand.class) {
            answer = execute((CreatePrivateTemplateFromSnapshotCommand) cmd);
        } else if (clz == UpgradeSnapshotCommand.class) {
            answer = execute((UpgradeSnapshotCommand) cmd);
        } else if (clz == GetStorageStatsCommand.class) {
            answer = execute((GetStorageStatsCommand) cmd);
        } else if (clz == PrimaryStorageDownloadCommand.class) {
            answer = execute((PrimaryStorageDownloadCommand) cmd);
        } else if (clz == GetVncPortCommand.class) {
            answer = execute((GetVncPortCommand) cmd);
        } else if (clz == SetupCommand.class) {
            answer = execute((SetupCommand) cmd);
        } else if (clz == MaintainCommand.class) {
            answer = execute((MaintainCommand) cmd);
        } else if (clz == PingTestCommand.class) {
            answer = execute((PingTestCommand) cmd);
        } else if (clz == CheckOnHostCommand.class) {
            answer = execute((CheckOnHostCommand) cmd);
        } else if (clz == ModifySshKeysCommand.class) {
            answer = execute((ModifySshKeysCommand) cmd);
        } else if (clz == NetworkUsageCommand.class) {
            answer = execute((NetworkUsageCommand) cmd);
        } else if (clz == StartCommand.class) {
            answer = execute((StartCommand) cmd);
        } else if (clz == CheckSshCommand.class) {
            answer = execute((CheckSshCommand) cmd);
        } else if (clz == CheckNetworkCommand.class) {
            answer = execute((CheckNetworkCommand) cmd);
        } else if (clz == PlugNicCommand.class) {
            answer = execute((PlugNicCommand) cmd);
        } else if (clz == UnPlugNicCommand.class) {
            answer = execute((UnPlugNicCommand) cmd);
        } else if (cmd instanceof CreateVMSnapshotCommand) {
            return execute((CreateVMSnapshotCommand) cmd);
        } else if (cmd instanceof DeleteVMSnapshotCommand) {
            return execute((DeleteVMSnapshotCommand) cmd);
        } else if (cmd instanceof RevertToVMSnapshotCommand) {
            return execute((RevertToVMSnapshotCommand) cmd);
        } else if (clz == ResizeVolumeCommand.class) {
            return execute((ResizeVolumeCommand) cmd);
        } else if (clz == UnregisterVMCommand.class) {
            return execute((UnregisterVMCommand) cmd);
        } else if (cmd instanceof StorageSubSystemCommand) {
            checkStorageProcessorAndHandlerNfsVersionAttribute((StorageSubSystemCommand) cmd);
            return storageHandler.handleStorageCommands((StorageSubSystemCommand) cmd);
        } else if (clz == ScaleVmCommand.class) {
            return execute((ScaleVmCommand) cmd);
        } else if (clz == PvlanSetupCommand.class) {
            return execute((PvlanSetupCommand) cmd);
        } else if (clz == GetVmIpAddressCommand.class) {
            return execute((GetVmIpAddressCommand) cmd);
        } else if (clz == UnregisterNicCommand.class) {
            answer = execute((UnregisterNicCommand) cmd);
        } else {
            answer = Answer.createUnsupportedCommandAnswer(cmd);
        }
        if (cmd.getContextParam("checkpoint") != null) {
            answer.setContextParam("checkpoint", cmd.getContextParam("checkpoint"));
        }
        Date doneTime = DateUtil.currentGMTTime();
        mbean.addProp("DoneTime", DateUtil.getDateDisplayString(TimeZone.getDefault(), doneTime));
        mbean.addProp("Answer", _gson.toJson(answer));
        synchronized (this) {
            try {
                JmxUtil.registerMBean("VMware " + _morHyperHost.getValue(), "Command " + cmdSequence + "-" + cmd.getClass().getSimpleName(), mbean);
                _cmdMBeans.add(mbean);
                if (_cmdMBeans.size() >= MazCmdMBean) {
                    PropertyMapDynamicBean mbeanToRemove = _cmdMBeans.get(0);
                    _cmdMBeans.remove(0);
                    JmxUtil.unregisterMBean("VMware " + _morHyperHost.getValue(), "Command " + mbeanToRemove.getProp("Sequence") + "-" + mbeanToRemove.getProp("Name"));
                }
            } catch (Exception e) {
                if (s_logger.isTraceEnabled())
                    s_logger.trace("Unable to register JMX monitoring due to exception " + ExceptionUtil.toString(e));
            }
        }
    } finally {
        recycleServiceContext();
        NDC.pop();
    }
    if (s_logger.isTraceEnabled())
        s_logger.trace("End executeRequest(), cmd: " + cmd.getClass().getSimpleName());
    return answer;
}
Also used : MigrateVolumeCommand(com.cloud.agent.api.storage.MigrateVolumeCommand) RebootRouterCommand(com.cloud.agent.api.RebootRouterCommand) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) ManageSnapshotCommand(com.cloud.agent.api.ManageSnapshotCommand) MigrateCommand(com.cloud.agent.api.MigrateCommand) UnPlugNicCommand(com.cloud.agent.api.UnPlugNicCommand) GetVmDiskStatsCommand(com.cloud.agent.api.GetVmDiskStatsCommand) CreateVolumeFromSnapshotCommand(com.cloud.agent.api.CreateVolumeFromSnapshotCommand) ResizeVolumeCommand(com.cloud.agent.api.storage.ResizeVolumeCommand) PvlanSetupCommand(com.cloud.agent.api.PvlanSetupCommand) CheckNetworkCommand(com.cloud.agent.api.CheckNetworkCommand) PingTestCommand(com.cloud.agent.api.PingTestCommand) BackupSnapshotCommand(com.cloud.agent.api.BackupSnapshotCommand) DestroyCommand(com.cloud.agent.api.storage.DestroyCommand) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) AttachIsoCommand(com.cloud.agent.api.AttachIsoCommand) GetVmStatsCommand(com.cloud.agent.api.GetVmStatsCommand) StopCommand(com.cloud.agent.api.StopCommand) DeleteVMSnapshotCommand(com.cloud.agent.api.DeleteVMSnapshotCommand) StorageSubSystemCommand(org.apache.cloudstack.storage.command.StorageSubSystemCommand) PrepareForMigrationCommand(com.cloud.agent.api.PrepareForMigrationCommand) ReadyCommand(com.cloud.agent.api.ReadyCommand) UpgradeSnapshotCommand(com.cloud.agent.api.UpgradeSnapshotCommand) PropertyMapDynamicBean(com.cloud.utils.mgmt.PropertyMapDynamicBean) CheckOnHostCommand(com.cloud.agent.api.CheckOnHostCommand) RebootCommand(com.cloud.agent.api.RebootCommand) MigrateWithStorageCommand(com.cloud.agent.api.MigrateWithStorageCommand) CheckSshCommand(com.cloud.agent.api.check.CheckSshCommand) StartCommand(com.cloud.agent.api.StartCommand) RevertToVMSnapshotCommand(com.cloud.agent.api.RevertToVMSnapshotCommand) PrimaryStorageDownloadCommand(com.cloud.agent.api.storage.PrimaryStorageDownloadCommand) CopyVolumeCommand(com.cloud.agent.api.storage.CopyVolumeCommand) NetworkElementCommand(com.cloud.agent.api.routing.NetworkElementCommand) GetHostStatsCommand(com.cloud.agent.api.GetHostStatsCommand) CreateVMSnapshotCommand(com.cloud.agent.api.CreateVMSnapshotCommand) ModifySshKeysCommand(com.cloud.agent.api.ModifySshKeysCommand) CreatePrivateTemplateFromSnapshotCommand(com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand) ValidateSnapshotCommand(com.cloud.agent.api.ValidateSnapshotCommand) UnPlugNicCommand(com.cloud.agent.api.UnPlugNicCommand) PlugNicCommand(com.cloud.agent.api.PlugNicCommand) MaintainCommand(com.cloud.agent.api.MaintainCommand) PvlanSetupCommand(com.cloud.agent.api.PvlanSetupCommand) SetupCommand(com.cloud.agent.api.SetupCommand) Date(java.util.Date) ModifyStoragePoolCommand(com.cloud.agent.api.ModifyStoragePoolCommand) GetStorageStatsCommand(com.cloud.agent.api.GetStorageStatsCommand) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException) UnregisterNicCommand(com.cloud.agent.api.UnregisterNicCommand) ModifyTargetsAnswer(com.cloud.agent.api.ModifyTargetsAnswer) GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) ManageSnapshotAnswer(com.cloud.agent.api.ManageSnapshotAnswer) CreatePrivateTemplateAnswer(com.cloud.agent.api.storage.CreatePrivateTemplateAnswer) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) MigrateVolumeAnswer(com.cloud.agent.api.storage.MigrateVolumeAnswer) SetupAnswer(com.cloud.agent.api.SetupAnswer) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) StopAnswer(com.cloud.agent.api.StopAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) UnPlugNicAnswer(com.cloud.agent.api.UnPlugNicAnswer) CheckOnHostAnswer(com.cloud.agent.api.CheckOnHostAnswer) CheckHealthAnswer(com.cloud.agent.api.CheckHealthAnswer) RevertToVMSnapshotAnswer(com.cloud.agent.api.RevertToVMSnapshotAnswer) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer) CreateVMSnapshotAnswer(com.cloud.agent.api.CreateVMSnapshotAnswer) DeleteVMSnapshotAnswer(com.cloud.agent.api.DeleteVMSnapshotAnswer) MaintainAnswer(com.cloud.agent.api.MaintainAnswer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) CheckSshAnswer(com.cloud.agent.api.check.CheckSshAnswer) RebootAnswer(com.cloud.agent.api.RebootAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) StartAnswer(com.cloud.agent.api.StartAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) MigrateAnswer(com.cloud.agent.api.MigrateAnswer) CreateVolumeFromSnapshotAnswer(com.cloud.agent.api.CreateVolumeFromSnapshotAnswer) CheckNetworkAnswer(com.cloud.agent.api.CheckNetworkAnswer) PlugNicAnswer(com.cloud.agent.api.PlugNicAnswer) ScaleVmAnswer(com.cloud.agent.api.ScaleVmAnswer) MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) ResizeVolumeAnswer(com.cloud.agent.api.storage.ResizeVolumeAnswer) BackupSnapshotAnswer(com.cloud.agent.api.BackupSnapshotAnswer) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) ValidateSnapshotAnswer(com.cloud.agent.api.ValidateSnapshotAnswer) ReadyAnswer(com.cloud.agent.api.ReadyAnswer) PrepareForMigrationAnswer(com.cloud.agent.api.PrepareForMigrationAnswer) GetVmDiskStatsAnswer(com.cloud.agent.api.GetVmDiskStatsAnswer) GetVncPortCommand(com.cloud.agent.api.GetVncPortCommand) ModifyTargetsCommand(com.cloud.agent.api.ModifyTargetsCommand) CreatePrivateTemplateFromVolumeCommand(com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand) CheckVirtualMachineCommand(com.cloud.agent.api.CheckVirtualMachineCommand) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand) CheckHealthCommand(com.cloud.agent.api.CheckHealthCommand)

Example 10 with StartCommand

use of com.cloud.agent.api.StartCommand in project cloudstack by apache.

the class HypervDirectConnectResourceTest method simpleVmStart.

private StartAnswer simpleVmStart(final String sample) {
    StartCommand cmd = s_gson.fromJson(sample, StartCommand.class);
    s_logger.info("StartCommand sample " + s_gson.toJson(cmd));
    StartAnswer ans = (StartAnswer) s_hypervresource.executeRequest(cmd);
    return ans;
}
Also used : StartAnswer(com.cloud.agent.api.StartAnswer) StartCommand(com.cloud.agent.api.StartCommand)

Aggregations

StartCommand (com.cloud.agent.api.StartCommand)17 Answer (com.cloud.agent.api.Answer)15 VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)12 Test (org.junit.Test)11 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)8 AttachAnswer (org.apache.cloudstack.storage.command.AttachAnswer)8 NicTO (com.cloud.agent.api.to.NicTO)7 InternalErrorException (com.cloud.exception.InternalErrorException)7 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)7 LibvirtUtilitiesHelper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper)7 KVMStoragePoolManager (com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager)7 URISyntaxException (java.net.URISyntaxException)7 LibvirtException (org.libvirt.LibvirtException)7 Connect (org.libvirt.Connect)6 NetworkUsageCommand (com.cloud.agent.api.NetworkUsageCommand)4 PingTestCommand (com.cloud.agent.api.PingTestCommand)4 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)3 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)3 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)3 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)3