Search in sources :

Example 21 with OvfEntityData

use of org.ovirt.engine.core.common.businessentities.OvfEntityData 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

OvfEntityData (org.ovirt.engine.core.common.businessentities.OvfEntityData)21 ArrayList (java.util.ArrayList)10 VM (org.ovirt.engine.core.common.businessentities.VM)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)4 Guid (org.ovirt.engine.core.compat.Guid)4 OvfReaderException (org.ovirt.engine.core.utils.ovf.OvfReaderException)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 Pair (org.ovirt.engine.core.common.utils.Pair)2 XmlDocument (org.ovirt.engine.core.utils.ovf.xml.XmlDocument)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1