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();
}
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);
}
}
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();
}
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);
}
}
}
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;
}
Aggregations