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());
}
}
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);
}
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);
}
}
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());
}
}
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;
}
Aggregations