use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class CreateOvfVolumeForStorageDomainCommand method createDisk.
public DiskImage createDisk(Guid domainId) {
DiskImage createdDiskImage = new DiskImage();
createdDiskImage.setContentType(DiskContentType.OVF_STORE);
createdDiskImage.setWipeAfterDelete(false);
createdDiskImage.setDiskAlias(OvfInfoFileConstants.OvfStoreDescriptionLabel);
createdDiskImage.setDiskDescription(OvfInfoFileConstants.OvfStoreDescriptionLabel);
createdDiskImage.setShareable(shouldOvfStoreBeShareable());
createdDiskImage.setStorageIds(new ArrayList<>(Collections.singletonList(domainId)));
createdDiskImage.setSize(SizeConverter.BYTES_IN_MB * 128);
createdDiskImage.setVolumeFormat(VolumeFormat.RAW);
createdDiskImage.setVolumeType(VolumeType.Preallocated);
createdDiskImage.setDescription("OVF store for domain " + domainId);
Date creationDate = new Date();
createdDiskImage.setCreationDate(creationDate);
createdDiskImage.setLastModified(creationDate);
return createdDiskImage;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class OvfHelper method readVmFromOvf.
/**
* parses a given ovf to a vm, initialize all the extra data related to it such as images, interfaces, cluster,
* LUNS, etc..
*
* @return FullEntityOvfData that represents the given ovf data
*/
public FullEntityOvfData readVmFromOvf(String ovf) throws OvfReaderException {
VM vm = new VM();
FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
ovfManager.importVm(ovf, vm, fullEntityOvfData);
// add images
vm.setImages((ArrayList) fullEntityOvfData.getDiskImages());
// add interfaces
vm.setInterfaces(fullEntityOvfData.getInterfaces());
// add disk map
Map<Guid, List<DiskImage>> images = ImagesHandler.getImagesLeaf(fullEntityOvfData.getDiskImages());
for (Map.Entry<Guid, List<DiskImage>> entry : images.entrySet()) {
List<DiskImage> list = entry.getValue();
vm.getDiskMap().put(entry.getKey(), list.get(list.size() - 1));
}
fullEntityOvfData.getLunDisks().forEach(lunDisk -> vm.getDiskMap().put(lunDisk.getId(), lunDisk));
return fullEntityOvfData;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class OvfUpdateProcessHelper method getVmImagesFromDb.
public ArrayList<DiskImage> getVmImagesFromDb(VM vm) {
ArrayList<DiskImage> allVmImages = new ArrayList<>();
List<DiskImage> filteredDisks = DisksFilter.filterImageDisks(vm.getDiskList(), ONLY_SNAPABLE, ONLY_ACTIVE);
for (DiskImage diskImage : filteredDisks) {
allVmImages.addAll(diskImageDao.getAllSnapshotsForLeaf(diskImage.getImageId()));
}
for (DiskImage disk : allVmImages) {
DiskVmElement dve = diskVmElementDao.get(new VmDeviceId(disk.getId(), vm.getId()));
disk.setDiskVmElements(Collections.singletonList(dve));
}
return allVmImages;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class ProcessOvfUpdateForStorageDomainCommand method populateStorageDomainOvfData.
private void populateStorageDomainOvfData() {
List<StorageDomainOvfInfo> storageDomainOvfInfos = storageDomainOvfInfoDao.getAllForDomain(getStorageDomainId());
ovfDiskCount = storageDomainOvfInfos.size();
storageDomainOvfInfos.sort(OVF_INFO_COMPARATOR);
for (StorageDomainOvfInfo storageDomainOvfInfo : storageDomainOvfInfos) {
if (storageDomainOvfInfo.getStatus() != StorageDomainOvfInfoStatus.DISABLED) {
DiskImage ovfDisk = (DiskImage) diskDao.get(storageDomainOvfInfo.getOvfDiskId());
domainOvfStoresInfoForUpdate.add(new Pair<>(storageDomainOvfInfo, ovfDisk));
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class ProcessOvfUpdateForStoragePoolCommand method populateVmsMetadataForOvfUpdate.
/**
* Create and returns map contains valid vms metadata
*/
protected Map<Guid, KeyValuePairCompat<String, List<Guid>>> populateVmsMetadataForOvfUpdate(List<Guid> idsToProcess) {
Map<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndTemplateMetadata = new HashMap<>();
List<VM> vms = vmDao.getVmsByIds(idsToProcess);
for (VM vm : vms) {
if (VMStatus.ImageLocked != vm.getStatus()) {
updateVmDisksFromDb(vm);
if (!verifyImagesStatus(vm.getDiskList())) {
continue;
}
ArrayList<DiskImage> vmImages = ovfUpdateProcessHelper.getVmImagesFromDb(vm);
if (!verifyImagesStatus(vmImages)) {
continue;
}
vm.setSnapshots(snapshotDao.getAllWithConfiguration(vm.getId()));
if (!verifySnapshotsStatus(vm.getSnapshots())) {
continue;
}
ovfUpdateProcessHelper.loadVmData(vm);
Long currentDbGeneration = vmStaticDao.getDbGeneration(vm.getId());
if (currentDbGeneration == null) {
log.warn("currentDbGeneration of VM (name: '{}', id: '{}') is null, probably because the VM was deleted during the run of OvfDataUpdater.", vm.getName(), vm.getId());
continue;
}
if (vm.getStaticData().getDbGeneration() == currentDbGeneration) {
List<LunDisk> lunDisks = DisksFilter.filterLunDisks(vm.getDiskMap().values());
for (LunDisk lun : lunDisks) {
lun.getLun().setLunConnections(new ArrayList<>(storageServerConnectionDao.getAllForLun(lun.getLun().getId())));
}
List<AffinityGroup> affinityGroups = affinityGroupDao.getAllAffinityGroupsByVmId(vm.getId());
List<Label> affinityLabels = labelDao.getAllByEntityIds(Collections.singletonList(vm.getId()));
Set<DbUser> dbUsers = new HashSet<>(dbUserDao.getAllForVm(vm.getId()));
FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
fullEntityOvfData.setDiskImages(vmImages);
fullEntityOvfData.setLunDisks(lunDisks);
fullEntityOvfData.setAffinityGroups(affinityGroups);
fullEntityOvfData.setAffinityLabels(affinityLabels);
fullEntityOvfData.setDbUsers(dbUsers);
ovfHelper.populateUserToRoles(fullEntityOvfData, vm.getId());
proccessedOvfConfigurationsInfo.add(ovfUpdateProcessHelper.buildMetadataDictionaryForVm(vm, vmsAndTemplateMetadata, fullEntityOvfData));
proccessedIdsInfo.add(vm.getId());
proccessedOvfGenerationsInfo.add(vm.getStaticData().getDbGeneration());
proccessDisksDomains(vm.getDiskList());
}
}
}
return vmsAndTemplateMetadata;
}
Aggregations