use of com.cloud.agent.api.GetVncPortAnswer in project CloudStack-archive by CloudStack-extras.
the class LibvirtComputingResource method execute.
protected GetVncPortAnswer execute(GetVncPortCommand cmd) {
try {
Connect conn = LibvirtConnection.getConnection();
Integer vncPort = getVncPort(conn, cmd.getName());
return new GetVncPortAnswer(cmd, _privateIp, 5900 + vncPort);
} catch (Exception e) {
return new GetVncPortAnswer(cmd, e.toString());
}
}
use of com.cloud.agent.api.GetVncPortAnswer in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(GetVncPortCommand cmd) {
try {
VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context);
assert (hyperHost instanceof HostMO);
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getName());
if (vmMo == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find the owner VM for GetVncPortCommand on host " + hyperHost.getHyperHostName() + ", try within datacenter");
}
vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getName());
if (vmMo == null) {
throw new Exception("Unable to find VM in vSphere, vm: " + cmd.getName());
}
}
Pair<String, Integer> portInfo = vmMo.getVncPort(mgr.getManagementPortGroupByHost((HostMO) hyperHost));
if (s_logger.isTraceEnabled()) {
s_logger.trace("Found vnc port info. vm: " + cmd.getName() + " host: " + portInfo.first() + ", vnc port: " + portInfo.second());
}
return new GetVncPortAnswer(cmd, portInfo.first(), portInfo.second());
} catch (Throwable e) {
return new GetVncPortAnswer(cmd, createLogMessageException(e, cmd));
}
}
use of com.cloud.agent.api.GetVncPortAnswer in project cloudstack by apache.
the class LibvirtGetVncPortCommandWrapper method execute.
@Override
public Answer execute(final GetVncPortCommand command, final LibvirtComputingResource libvirtComputingResource) {
try {
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(command.getName());
final Integer vncPort = libvirtComputingResource.getVncPort(conn, command.getName());
return new GetVncPortAnswer(command, libvirtComputingResource.getPrivateIp(), 5900 + vncPort);
} catch (final LibvirtException e) {
return new GetVncPortAnswer(command, e.toString());
}
}
use of com.cloud.agent.api.GetVncPortAnswer in project cloudstack by apache.
the class ResourceManagerImpl method setKVMVncAccess.
/**
* Add VNC details as user VM details for each VM in 'vms' (KVM hosts only)
*/
protected void setKVMVncAccess(long hostId, List<VMInstanceVO> vms) {
for (VMInstanceVO vm : vms) {
GetVncPortAnswer vmVncPortAnswer = (GetVncPortAnswer) _agentMgr.easySend(hostId, new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
if (vmVncPortAnswer != null) {
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.KVM_VNC_ADDRESS, vmVncPortAnswer.getAddress(), true);
userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.KVM_VNC_PORT, String.valueOf(vmVncPortAnswer.getPort()), true);
}
}
}
use of com.cloud.agent.api.GetVncPortAnswer in project cosmic by MissionCriticalCloud.
the class LibvirtGetVncPortCommandWrapper method execute.
@Override
public Answer execute(final GetVncPortCommand command, final LibvirtComputingResource libvirtComputingResource) {
try {
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(command.getName());
final Integer vncPort = libvirtComputingResource.getVncPort(conn, command.getName());
return new GetVncPortAnswer(command, libvirtComputingResource.getPrivateIp(), 5900 + vncPort);
} catch (final LibvirtException e) {
return new GetVncPortAnswer(command, e.toString());
}
}
Aggregations