Search in sources :

Example 41 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class AddVmTemplateFromSnapshotCommand method init.

@Override
protected void init() {
    if (getParameters().getVm() == null) {
        return;
    }
    setClusterId(getParameters().getVm().getClusterId());
    if (getCluster() == null) {
        return;
    }
    setStoragePoolId(getCluster().getStoragePoolId());
    VM vm = getVmFromConfiguration();
    if (vm == null) {
        return;
    }
    vm.setStaticData(getParameters().getMasterVm());
    setVm(vm);
    setSnapshotName(getSnapshot() != null ? getSnapshot().getDescription() : null);
    super.init();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM)

Example 42 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class ImportVmCommandBase method reportExternalMacs.

private void reportExternalMacs() {
    final VM vm = getVm();
    final Set<String> externalMacAddresses = externalVmMacsFinder.findExternalMacAddresses(vm);
    if (CollectionUtils.isNotEmpty(externalMacAddresses)) {
        auditLog(createExternalMacsAuditLog(vm, externalMacAddresses), AuditLogType.MAC_ADDRESS_IS_EXTERNAL);
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM)

Example 43 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class ImportVmFromConfigurationCommand method init.

@Override
protected void init() {
    VM vmFromConfiguration = getParameters().getVm();
    if (vmFromConfiguration != null) {
        vmFromConfiguration.getStaticData().setClusterId(getParameters().getClusterId());
        if (!isImagesAlreadyOnTarget()) {
            setDisksToBeAttached(vmFromConfiguration);
        }
        getParameters().setContainerId(vmFromConfiguration.getId());
    } else {
        initUnregisteredVM();
    }
    if (Guid.Empty.equals(getParameters().getVmId()) && getParameters().getVm() != null) {
        getParameters().setVmId(getParameters().getVm().getId());
    }
    setClusterId(getParameters().getClusterId());
    if (getCluster() != null) {
        getParameters().setStoragePoolId(getCluster().getStoragePoolId());
    }
    super.init();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM)

Example 44 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class ImportVmFromConfigurationCommand method initUnregisteredVM.

private void initUnregisteredVM() {
    List<OvfEntityData> ovfEntityDataList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(getParameters().getContainerId(), getParameters().getStorageDomainId());
    if (!ovfEntityDataList.isEmpty()) {
        try {
            // We should get only one entity, since we fetched the entity with a specific Storage Domain
            ovfEntityData = ovfEntityDataList.get(0);
            FullEntityOvfData fullEntityOvfData = ovfHelper.readVmFromOvf(ovfEntityData.getOvfData());
            VM vmFromConfiguration = fullEntityOvfData.getVm();
            if (Guid.isNullOrEmpty(getParameters().getClusterId())) {
                Cluster cluster = drMappingHelper.getMappedCluster(fullEntityOvfData.getClusterName(), vmFromConfiguration.getId(), getParameters().getClusterMap());
                if (cluster != null) {
                    getParameters().setClusterId(cluster.getId());
                }
            }
            vmFromConfiguration.setClusterId(getParameters().getClusterId());
            getParameters().setVm(vmFromConfiguration);
            getParameters().setDestDomainId(ovfEntityData.getStorageDomainId());
            getParameters().setSourceDomainId(ovfEntityData.getStorageDomainId());
            getParameters().setUserToRoles(fullEntityOvfData.getUserToRoles());
            // For quota, update disks when required
            if (getParameters().getDiskMap() != null) {
                vmFromConfiguration.setDiskMap(getParameters().getDiskMap());
                vmFromConfiguration.setImages(getDiskImageListFromDiskMap(getParameters().getDiskMap()));
            }
            // Note: The VM's OVF does not preserve the username and password for the LUN's connection.
            // Therefore to achieve a simple VM registration the iSCSI storage server should not use
            // credentials, although if the user will use the mapping attribute, one can set the credentials through
            // there.
            drMappingHelper.mapExternalLunDisks(DisksFilter.filterLunDisks(vmFromConfiguration.getDiskMap().values()), getParameters().getExternalLunMap());
            mapEntities(fullEntityOvfData);
        } catch (OvfReaderException e) {
            log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData());
            log.debug("Exception", e);
        }
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 45 with VM

use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.

the class ImportVmCommand method createMemoryDisk.

private DiskImage createMemoryDisk(Snapshot snapshot) {
    StorageDomainStatic sd = validateStorageDomainExistsInDb(snapshot, memoryDiskDomainMap.get(snapshot.getMemoryDiskId()));
    DiskImage disk = isMemoryDiskAlreadyExistsInDb(snapshot, snapshot.getMemoryDiskId());
    if (sd == null || disk != null) {
        return null;
    }
    VM vm = snapshotVmConfigurationHelper.getVmFromConfiguration(snapshot.getVmConfiguration(), snapshot.getVmId(), snapshot.getId());
    DiskImage memoryDisk = MemoryUtils.createSnapshotMemoryDisk(vm, sd.getStorageType(), vmOverheadCalculator, MemoryUtils.generateMemoryDiskDescription(vm, snapshot.getDescription()));
    memoryDisk.setId(snapshot.getMemoryDiskId());
    memoryDisk.setImageId(getMemoryDiskImageId(snapshot.getMemoryDiskId()));
    memoryDisk.setStorageIds(new ArrayList<>(Collections.singletonList(sd.getId())));
    memoryDisk.setStoragePoolId(getStoragePoolId());
    memoryDisk.setCreationDate(snapshot.getCreationDate());
    memoryDisk.setActive(true);
    memoryDisk.setWipeAfterDelete(vm.getDiskList().stream().anyMatch(DiskImage::isWipeAfterDelete));
    return memoryDisk;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

VM (org.ovirt.engine.core.common.businessentities.VM)591 Test (org.junit.Test)178 Guid (org.ovirt.engine.core.compat.Guid)150 ArrayList (java.util.ArrayList)130 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)82 HashMap (java.util.HashMap)69 List (java.util.List)65 VDS (org.ovirt.engine.core.common.businessentities.VDS)63 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)56 Map (java.util.Map)53 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)53 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)41 QueryType (org.ovirt.engine.core.common.queries.QueryType)36 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)33 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)32 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)32 Collectors (java.util.stream.Collectors)31 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)31