Search in sources :

Example 1 with CheckVirtualMachineAnswer

use of com.cloud.agent.api.CheckVirtualMachineAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

private Answer execute(CheckVirtualMachineCommand cmd) {
    try {
        Connect conn = LibvirtConnection.getConnection();
        final State state = getVmState(conn, cmd.getVmName());
        Integer vncPort = null;
        if (state == State.Running) {
            vncPort = getVncPort(conn, cmd.getVmName());
            synchronized (_vms) {
                _vms.put(cmd.getVmName(), State.Running);
            }
        }
        return new CheckVirtualMachineAnswer(cmd, state, vncPort);
    } catch (LibvirtException e) {
        return new CheckVirtualMachineAnswer(cmd, e.getMessage());
    }
}
Also used : CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) LibvirtException(org.libvirt.LibvirtException) State(com.cloud.vm.VirtualMachine.State) Connect(org.libvirt.Connect)

Example 2 with CheckVirtualMachineAnswer

use of com.cloud.agent.api.CheckVirtualMachineAnswer in project CloudStack-archive by CloudStack-extras.

the class FakeComputingResource method execute.

protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
    VmMgr vmMgr = getVmManager();
    final String vmName = cmd.getVmName();
    final State state = vmMgr.checkVmState(vmName);
    Integer vncPort = null;
    if (state == State.Running) {
        vncPort = vmMgr.getVncPort(vmName);
        synchronized (_vms) {
            _vms.put(vmName, State.Running);
        }
    }
    return new CheckVirtualMachineAnswer(cmd, state, vncPort);
}
Also used : CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) VmState(com.cloud.agent.api.StartupRoutingCommand.VmState) State(com.cloud.vm.VirtualMachine.State) VmMgr(com.cloud.agent.mockvm.VmMgr) MockVmMgr(com.cloud.agent.mockvm.MockVmMgr)

Example 3 with CheckVirtualMachineAnswer

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

the class Ovm3HypervisorSupport method execute.

/* check "the" virtual machine */
public CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
    LOGGER.debug("CheckVirtualMachineCommand: " + cmd.getVmName());
    String vmName = cmd.getVmName();
    try {
        CloudstackPlugin plug = new CloudstackPlugin(c);
        Integer vncPort = Integer.valueOf(plug.getVncPort(vmName));
        if (vncPort == 0) {
            LOGGER.warn("No VNC port for " + vmName);
        }
        /* we already have the state ftw */
        Map<String, State> states = getAllVmStates(vmStateMap);
        State vmState = states.get(vmName);
        if (vmState == null) {
            LOGGER.warn("Check state of " + vmName + " return null in CheckVirtualMachineCommand");
            vmState = State.Stopped;
        }
        synchronized (vmStateMap) {
            vmStateMap.put(vmName, State.Running);
        }
        return new CheckVirtualMachineAnswer(cmd, convertStateToPower(vmState), vncPort);
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("Check migration for " + vmName + " failed", e);
        return new CheckVirtualMachineAnswer(cmd, convertStateToPower(State.Stopped), null);
    }
}
Also used : BigInteger(java.math.BigInteger) CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) PowerState(com.cloud.vm.VirtualMachine.PowerState) State(com.cloud.vm.VirtualMachine.State) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CloudstackPlugin(com.cloud.hypervisor.ovm3.objects.CloudstackPlugin)

Example 4 with CheckVirtualMachineAnswer

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

the class LibvirtCheckVirtualMachineCommandWrapper method execute.

@Override
public Answer execute(final CheckVirtualMachineCommand command, final LibvirtComputingResource libvirtComputingResource) {
    try {
        final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
        final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName());
        final PowerState state = libvirtComputingResource.getVmState(conn, command.getVmName());
        Integer vncPort = null;
        if (state == PowerState.PowerOn) {
            vncPort = libvirtComputingResource.getVncPort(conn, command.getVmName());
        }
        return new CheckVirtualMachineAnswer(command, state, vncPort);
    } catch (final LibvirtException e) {
        return new CheckVirtualMachineAnswer(command, e.getMessage());
    }
}
Also used : CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer) LibvirtException(org.libvirt.LibvirtException) Connect(org.libvirt.Connect) PowerState(com.cloud.vm.VirtualMachine.PowerState)

Example 5 with CheckVirtualMachineAnswer

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

the class AgentRoutingResource method execute.

protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
    final String vmName = cmd.getVmName();
    CheckVirtualMachineAnswer result = (CheckVirtualMachineAnswer) _simMgr.simulate(cmd, hostGuid);
    return result;
}
Also used : CheckVirtualMachineAnswer(com.cloud.agent.api.CheckVirtualMachineAnswer)

Aggregations

CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)19 CheckVirtualMachineCommand (com.cloud.agent.api.CheckVirtualMachineCommand)7 PowerState (com.cloud.vm.VirtualMachine.PowerState)7 Answer (com.cloud.agent.api.Answer)3 PrepareForMigrationAnswer (com.cloud.agent.api.PrepareForMigrationAnswer)3 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)3 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)3 State (com.cloud.vm.VirtualMachine.State)3 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2 ClusterVMMetaDataSyncAnswer (com.cloud.agent.api.ClusterVMMetaDataSyncAnswer)2 MigrateWithStorageAnswer (com.cloud.agent.api.MigrateWithStorageAnswer)2 MigrateWithStorageCommand (com.cloud.agent.api.MigrateWithStorageCommand)2 MigrateWithStorageCompleteAnswer (com.cloud.agent.api.MigrateWithStorageCompleteAnswer)2 MigrateWithStorageCompleteCommand (com.cloud.agent.api.MigrateWithStorageCompleteCommand)2 MigrateWithStorageReceiveAnswer (com.cloud.agent.api.MigrateWithStorageReceiveAnswer)2 MigrateWithStorageReceiveCommand (com.cloud.agent.api.MigrateWithStorageReceiveCommand)2 MigrateWithStorageSendAnswer (com.cloud.agent.api.MigrateWithStorageSendAnswer)2 MigrateWithStorageSendCommand (com.cloud.agent.api.MigrateWithStorageSendCommand)2 PlugNicAnswer (com.cloud.agent.api.PlugNicAnswer)2 PrepareForMigrationCommand (com.cloud.agent.api.PrepareForMigrationCommand)2