use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.
the class GetInstanceTypeQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
InstanceType instance;
GetVmTemplateParameters params = getParameters();
if (params.getName() != null) {
instance = vmTemplateDao.getInstanceTypeByName(params.getName(), getUserID(), getParameters().isFiltered());
} else {
instance = vmTemplateDao.getInstanceType(getParameters().getId(), getUserID(), getParameters().isFiltered());
}
getQueryReturnValue().setReturnValue(instance);
}
use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.
the class GetVmDataByPoolIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
VM vm = vmPoolDao.getVmDataFromPoolByPoolGuid(getParameters().getId(), getUserID(), getParameters().isFiltered());
if (vm != null) {
boolean isLatestLoad = vm.isUseLatestVersion();
boolean loadTemplateData = false;
Guid vmtGuid = vm.getVmtGuid();
if (vm.isNextRunConfigurationExists()) {
QueryReturnValue nextRunRet = backend.runInternalQuery(QueryType.GetVmNextRunConfiguration, new IdQueryParameters(vm.getId()));
if (nextRunRet != null) {
VM nextRunVm = nextRunRet.getReturnValue();
if (nextRunVm != null) {
// template version was changed -> load data from template
isLatestLoad = nextRunVm.isUseLatestVersion();
vmtGuid = nextRunVm.getVmtGuid();
loadTemplateData = true;
}
}
}
VmTemplate templateData = null;
if (isLatestLoad) {
QueryReturnValue latestRet = backend.runInternalQuery(QueryType.GetLatestTemplateInChain, new IdQueryParameters(vmtGuid));
if (latestRet != null) {
templateData = latestRet.getReturnValue();
}
} else if (loadTemplateData) {
QueryReturnValue templateRet = backend.runInternalQuery(QueryType.GetVmTemplate, new GetVmTemplateParameters(vmtGuid));
if (templateRet != null) {
templateData = templateRet.getReturnValue();
}
}
if (templateData != null) {
VmStatic temp = vm.getStaticData();
temp.setVmtGuid(vmtGuid);
temp.setUseLatestVersion(isLatestLoad);
VmHandler.copyData(templateData, temp);
vm.setStaticData(temp);
}
vmHandler.updateDisksFromDb(vm);
vmHandler.updateVmInitFromDB(vm.getStaticData(), true);
}
getQueryReturnValue().setReturnValue(vm);
}
use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.
the class GetVmTemplateQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
VmTemplate vmt;
GetVmTemplateParameters params = getParameters();
if (params.getName() != null) {
// If no DC info available, the query will return the first
Guid storagePoolId = getStoragePoolId();
// Template with the given name found.
vmt = vmTemplateDao.getByName(params.getName(), storagePoolId, getUserID(), params.isFiltered());
} else {
vmt = vmTemplateDao.get(getParameters().getId(), getUserID(), getParameters().isFiltered());
}
if (vmt != null) {
vmTemplateHandler.updateDisksFromDb(vmt);
vmHandler.updateVmInitFromDB(vmt, true);
}
getQueryReturnValue().setReturnValue(vmt);
}
use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.
the class GetVmTemplateQuery method getStoragePoolId.
// Get the datacenter ID.
private Guid getStoragePoolId() {
Guid result = null;
GetVmTemplateParameters params = getParameters();
if (params.getDataCenterId() != null) {
result = params.getDataCenterId();
} else if (params.getClusterId() != null) {
Cluster cluster = clusterDao.get(params.getClusterId());
if (cluster != null) {
result = cluster.getStoragePoolId();
}
}
return result;
}
use of org.ovirt.engine.core.common.queries.GetVmTemplateParameters in project ovirt-engine by oVirt.
the class BackendInstanceTypeResource method get.
@Override
public InstanceType get() {
InstanceType instanceType = performGet(QueryType.GetInstanceType, new GetVmTemplateParameters(guid));
DisplayHelper.adjustDisplayData(this, instanceType);
return instanceType;
}
Aggregations