use of org.ovirt.engine.core.utils.ovf.OvfReaderException in project ovirt-engine by oVirt.
the class TryBackToAllSnapshotsOfVmCommand method validateMemoryTakenInSupportedVersion.
private boolean validateMemoryTakenInSupportedVersion() {
VM vmFromSnapshot = null;
try {
vmFromSnapshot = ovfHelper.readVmFromOvf(getDstSnapshot().getVmConfiguration()).getVm();
} catch (OvfReaderException e) {
// should never happen since the OVF was created by us
log.error("Failed to parse a given ovf configuration: {}", e.getMessage());
return false;
}
Version originalClusterVersion = vmFromSnapshot.getClusterCompatibilityVersionOrigin();
if (Version.getLowest().greater(originalClusterVersion)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_MEMORY_TOO_OLD, String.format("$Cv %s", originalClusterVersion != null ? originalClusterVersion : "N/A"));
}
return true;
}
use of org.ovirt.engine.core.utils.ovf.OvfReaderException in project ovirt-engine by oVirt.
the class GetTemplatesFromExportDomainQuery method buildFromOVFs.
@Override
protected Map<VmTemplate, List<DiskImage>> buildFromOVFs(List<String> ovfList) {
Map<VmTemplate, List<DiskImage>> templateDisksMap = new HashMap<>();
for (String ovf : ovfList) {
try {
if (ovfHelper.isOvfTemplate(ovf)) {
VmTemplate vmTemplate = ovfHelper.readVmTemplateFromOvf(ovf).getVmTemplate();
List<DiskImage> templateDisks = new ArrayList<>(vmTemplate.getDiskTemplateMap().values());
templateDisksMap.put(vmTemplate, templateDisks);
}
} catch (OvfReaderException ex) {
auditLogOvfLoadError(ex.getName(), ex.getMessage());
}
}
return templateDisksMap;
}
use of org.ovirt.engine.core.utils.ovf.OvfReaderException in project ovirt-engine by oVirt.
the class GetUnregisteredVmTemplatesQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<OvfEntityData> entityList = getOvfEntityList(VmEntityType.TEMPLATE);
List<VmTemplate> vmTemplates = new ArrayList<>();
for (OvfEntityData ovf : entityList) {
try {
vmTemplates.add(ovfHelper.readVmTemplateFromOvf(ovf.getOvfData()).getVmTemplate());
} catch (OvfReaderException e) {
log.debug("failed to parse a given ovf configuration: \n" + ovf.getOvfData(), e);
getQueryReturnValue().setExceptionString("failed to parse a given ovf configuration " + e.getMessage());
}
}
getQueryReturnValue().setSucceeded(true);
getQueryReturnValue().setReturnValue(vmTemplates);
}
use of org.ovirt.engine.core.utils.ovf.OvfReaderException in project ovirt-engine by oVirt.
the class GetUnregisteredVmsQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<OvfEntityData> entityList = getOvfEntityList(VmEntityType.VM);
List<VM> vmList = new ArrayList<>();
for (OvfEntityData ovf : entityList) {
try {
VM vm = ovfHelper.readVmFromOvf(ovf.getOvfData()).getVm();
// Setting the rest of the VM attributes which are not in the OVF.
vm.setClusterCompatibilityVersion(ovf.getLowestCompVersion());
vm.setClusterArch(ovf.getArchitecture());
vm.setStatus(ovf.getStatus());
vmList.add(vm);
} catch (OvfReaderException e) {
log.debug("failed to parse a given ovf configuration: \n" + ovf.getOvfData(), e);
getQueryReturnValue().setExceptionString("failed to parse a given ovf configuration " + e.getMessage());
}
}
getQueryReturnValue().setSucceeded(true);
getQueryReturnValue().setReturnValue(vmList);
}
Aggregations