Search in sources :

Example 11 with KeyValuePairCompat

use of org.ovirt.engine.core.compat.KeyValuePairCompat in project ovirt-engine by oVirt.

the class ProcessOvfUpdateForStoragePoolCommand method populateTemplatesMetadataForOvfUpdate.

/**
 * Creates and returns a map containing valid templates metadata
 */
protected Map<Guid, KeyValuePairCompat<String, List<Guid>>> populateTemplatesMetadataForOvfUpdate(List<Guid> idsToProcess) {
    Map<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndTemplateMetadata = new HashMap<>();
    List<VmTemplate> templates = vmTemplateDao.getVmTemplatesByIds(idsToProcess);
    for (VmTemplate template : templates) {
        if (VmTemplateStatus.Locked != template.getStatus()) {
            updateTemplateDisksFromDb(template);
            boolean verifyDisksNotLocked = verifyImagesStatus(template.getDiskList());
            if (verifyDisksNotLocked) {
                ovfUpdateProcessHelper.loadTemplateData(template);
                Long currentDbGeneration = vmStaticDao.getDbGeneration(template.getId());
                // currentDbGeneration can be null in case that the template was deleted during the run of OvfDataUpdater.
                if (currentDbGeneration != null && template.getDbGeneration() == currentDbGeneration) {
                    proccessedOvfConfigurationsInfo.add(ovfUpdateProcessHelper.buildMetadataDictionaryForTemplate(template, vmsAndTemplateMetadata));
                    proccessedIdsInfo.add(template.getId());
                    proccessedOvfGenerationsInfo.add(template.getDbGeneration());
                    proccessDisksDomains(template.getDiskList());
                }
            }
        }
    }
    return vmsAndTemplateMetadata;
}
Also used : KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) HashMap(java.util.HashMap) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with KeyValuePairCompat

use of org.ovirt.engine.core.compat.KeyValuePairCompat in project ovirt-engine by oVirt.

the class ExportVmCommand method updateVmInSpm.

protected void updateVmInSpm() {
    Map<Guid, KeyValuePairCompat<String, List<Guid>>> metaDictionary = new HashMap<>();
    ovfUpdateProcessHelper.loadVmData(getVm());
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(getVm());
    fullEntityOvfData.setClusterName(getVm().getClusterName());
    fullEntityOvfData.setDiskImages(ovfUpdateProcessHelper.getVmImagesFromDb(getVm()));
    ovfUpdateProcessHelper.buildMetadataDictionaryForVm(getVm(), metaDictionary, fullEntityOvfData);
    ovfUpdateProcessHelper.executeUpdateVmInSpmCommand(getVm().getStoragePoolId(), metaDictionary, getParameters().getStorageDomainId());
}
Also used : KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)

Aggregations

KeyValuePairCompat (org.ovirt.engine.core.compat.KeyValuePairCompat)12 Guid (org.ovirt.engine.core.compat.Guid)10 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)4 List (java.util.List)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)2 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2