use of com.cloud.hypervisor.vmware.manager.VmwareManager in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(GetVncPortCommand cmd) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Executing resource GetVncPortCommand: " + _gson.toJson(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) {
if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext();
}
String msg = "GetVncPortCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e);
return new GetVncPortAnswer(cmd, msg);
}
}
use of com.cloud.hypervisor.vmware.manager.VmwareManager in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(CreateVolumeFromSnapshotCommand cmd) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource CreateVolumeFromSnapshotCommand: " + _gson.toJson(cmd));
}
String details = null;
boolean success = false;
String newVolumeName = UUID.randomUUID().toString();
try {
VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) {
if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext();
}
details = "CreateVolumeFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(details, e);
}
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
}
use of com.cloud.hypervisor.vmware.manager.VmwareManager in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(DeleteVMSnapshotCommand cmd) {
try {
VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd);
} catch (Exception e) {
e.printStackTrace();
return new DeleteVMSnapshotAnswer(cmd, false, "");
}
}
use of com.cloud.hypervisor.vmware.manager.VmwareManager in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(CreateVMSnapshotCommand cmd) {
try {
VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd);
} catch (Exception e) {
e.printStackTrace();
return new CreateVMSnapshotAnswer(cmd, false, "");
}
}
use of com.cloud.hypervisor.vmware.manager.VmwareManager in project cloudstack by apache.
the class VmwareResource method fillHostNetworkInfo.
private void fillHostNetworkInfo(VmwareContext serviceContext, StartupRoutingCommand cmd) throws RuntimeFaultFaultMsg, RemoteException {
try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
assert (hyperHost instanceof HostMO);
VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
VmwareHypervisorHostNetworkSummary summary = hyperHost.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost((HostMO) hyperHost));
if (summary == null) {
throw new Exception("No ESX(i) host found");
}
if (s_logger.isInfoEnabled()) {
s_logger.info("Startup report on host network info. " + _gson.toJson(summary));
}
cmd.setPrivateIpAddress(summary.getHostIp());
cmd.setPrivateNetmask(summary.getHostNetmask());
cmd.setPrivateMacAddress(summary.getHostMacAddress());
cmd.setStorageIpAddress(summary.getHostIp());
cmd.setStorageNetmask(summary.getHostNetmask());
cmd.setStorageMacAddress(summary.getHostMacAddress());
} catch (Throwable e) {
String msg = "querying host network info failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e);
throw new CloudRuntimeException(msg);
}
}
Aggregations