Search in sources :

Example 6 with OvfReaderException

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;
}
Also used : Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 7 with OvfReaderException

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;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 8 with OvfReaderException

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);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 9 with OvfReaderException

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);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Aggregations

OvfReaderException (org.ovirt.engine.core.utils.ovf.OvfReaderException)9 VM (org.ovirt.engine.core.common.businessentities.VM)6 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)5 ArrayList (java.util.ArrayList)4 OvfEntityData (org.ovirt.engine.core.common.businessentities.OvfEntityData)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 Version (org.ovirt.engine.core.compat.Version)2 HashMap (java.util.HashMap)1 List (java.util.List)1 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 VMStaticOvfLogHandler (org.ovirt.engine.core.utils.ovf.VMStaticOvfLogHandler)1