use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.
the class EditDiskModel method validate.
@Override
public boolean validate() {
StorageType storageType = getStorageDomain().getSelectedItem() == null ? StorageType.UNKNOWN : getStorageDomain().getSelectedItem().getStorageType();
IntegerValidation sizeValidation = new IntegerValidation();
if (storageType.isBlockDomain()) {
Integer maxBlockDiskSize = (Integer) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.MaxBlockDiskSize);
sizeValidation.setMaximum(maxBlockDiskSize - getSize().getEntity());
}
getSizeExtend().validateEntity(new IValidation[] { new NotEmptyValidation(), new NonNegativeLongNumberValidation(), sizeValidation });
return super.validate() && getSizeExtend().getIsValid();
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method attachInternal.
private void attachInternal(ListModel listModel, StorageDomainType storageType) {
if (getWindow() != null) {
return;
}
this.setStorageDomainType(storageType);
setWindow(listModel);
if (storageType == StorageDomainType.ISO) {
AsyncDataProvider.getInstance().getISOStorageDomainList(new AsyncQuery<>(list -> {
Collection<StorageDomain> currItems = getItems() != null ? getItems() : new ArrayList<>();
List<EntityModel> models = list.stream().filter(a -> currItems.stream().noneMatch(new Linq.IdPredicate<>(a.getId()))).map(EntityModel::new).collect(Collectors.toList());
postAttachInternal(models);
}));
} else {
AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(list -> {
List<EntityModel> models = new ArrayList<>();
boolean addToList;
Collection<StorageDomain> items1 = getItems() != null ? getItems() : new ArrayList<>();
for (StorageDomain a : list) {
addToList = false;
if (a.getStorageDomainSharedStatus() != StorageDomainSharedStatus.Unattached || items1.stream().anyMatch(new Linq.IdPredicate<>(a.getId()))) {
continue;
}
if (a.getStorageDomainType() == StorageDomainType.Volume) {
addToList = true;
} else if (a.getStorageDomainType() == getStorageDomainType()) {
if (getStorageDomainType() == StorageDomainType.Data) {
if (getEntity().getStoragePoolFormatType() == null) {
addToList = true;
} else if (getEntity().getStoragePoolFormatType().compareTo(a.getStorageStaticData().getStorageFormat()) >= 0) {
addToList = true;
} else {
if (a.getStorageStaticData().getStorageFormat() == StorageFormatType.V1 || a.getStorageStaticData().getStorageFormat() == StorageFormatType.V2) {
addToList = true;
}
}
} else if (getStorageDomainType() == StorageDomainType.ImportExport) {
addToList = true;
}
}
if (addToList) {
EntityModel tempVar2 = new EntityModel();
tempVar2.setEntity(a);
models.add(tempVar2);
}
}
postAttachInternal(models);
}));
}
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.
the class ImportVmCommand method validateLunDisk.
private List<EngineMessage> validateLunDisk(LunDisk lunDisk) {
DiskValidator diskValidator = getDiskValidator(lunDisk);
LUNs lun = lunDisk.getLun();
StorageType storageType;
if (lun.getLunConnections() != null && !lun.getLunConnections().isEmpty()) {
// We set the storage type based on the first connection since connections should be with the same
// storage type
storageType = lun.getLunConnections().get(0).getStorageType();
} else {
storageType = StorageType.FCP;
}
if (storageType == StorageType.ISCSI) {
ValidationResult connectionsInLunResult = diskValidator.validateConnectionsInLun(storageType);
if (!connectionsInLunResult.isValid()) {
return connectionsInLunResult.getMessages();
}
}
ValidationResult lunAlreadyInUseResult = diskValidator.validateLunAlreadyInUse();
if (!lunAlreadyInUseResult.isValid()) {
return lunAlreadyInUseResult.getMessages();
}
DiskVmElementValidator diskVmElementValidator = new DiskVmElementValidator(lunDisk, lunDisk.getDiskVmElementForVm(getVmId()));
ValidationResult virtIoScsiResult = isVirtIoScsiValid(getVm(), diskVmElementValidator);
if (!virtIoScsiResult.isValid()) {
return virtIoScsiResult.getMessages();
}
ValidationResult diskInterfaceResult = diskVmElementValidator.isDiskInterfaceSupported(getVm());
if (!diskInterfaceResult.isValid()) {
return diskInterfaceResult.getMessages();
}
Guid vdsId = vdsCommandsHelper.getHostForExecution(getStoragePoolId());
if (vdsId == null || !validateLunExistsAndInitDeviceData(lun, storageType, vdsId)) {
return Arrays.asList(EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_INVALID);
}
ValidationResult usingScsiReservationResult = diskValidator.isUsingScsiReservationValid(getVm(), lunDisk.getDiskVmElementForVm(getVmId()), lunDisk);
if (!usingScsiReservationResult.isValid()) {
return usingScsiReservationResult.getMessages();
}
return Collections.emptyList();
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.
the class BackendHostResource method unregisteredStorageDomainsDiscover.
@Override
public Response unregisteredStorageDomainsDiscover(Action action) {
StorageType storageType = ((action.getIscsi() != null) && (action.getIscsi().getAddress() != null)) ? StorageType.ISCSI : StorageType.FCP;
// Validate if the Host exists.
getEntity();
List<StorageServerConnections> storageServerConnections = new ArrayList<>();
if (storageType == StorageType.ISCSI) {
Action.IscsiTargetsList iscsiTargets = action.getIscsiTargets();
if (iscsiTargets != null) {
for (String iscsiTarget : iscsiTargets.getIscsiTargets()) {
StorageServerConnections connectionDetails = getInitializedConnectionIscsiDetails(action);
connectionDetails.setIqn(iscsiTarget);
storageServerConnections.add(connectionDetails);
}
}
} else {
// For FC we don't need to do anything.
}
GetUnregisteredBlockStorageDomainsParameters unregisteredBlockStorageDomainsParameters = new GetUnregisteredBlockStorageDomainsParameters(guid, storageType, storageServerConnections);
try {
Pair<List<StorageDomain>, List<StorageServerConnections>> pair = getEntity(Pair.class, QueryType.GetUnregisteredBlockStorageDomains, unregisteredBlockStorageDomainsParameters, "GetUnregisteredBlockStorageDomains", true);
List<StorageDomain> storageDomains = pair.getFirst();
return actionSuccess(mapToStorageDomains(action, storageDomains));
} catch (Exception e) {
return handleError(e, false);
}
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageType in project ovirt-engine by oVirt.
the class VmDiskPopupWidget method revealStorageView.
private void revealStorageView(final AbstractDiskModel diskModel) {
if (!diskModel.getIsNew()) {
return;
}
StorageType storageType = diskModel.getStorageType().getSelectedItem();
// Set view and model by storage type
if (storageType == StorageType.ISCSI) {
storageView = iscsiStorageView;
sanStorageModelBase = iscsiStorageModel;
} else if (storageType == StorageType.FCP) {
storageView = fcpStorageView;
sanStorageModelBase = fcpStorageModel;
}
storageModel.setCurrentStorageItem(sanStorageModelBase);
diskModel.setSanStorageModelBase(sanStorageModelBase);
// Execute 'UpdateCommand' to call 'GetDeviceList'
sanStorageModelBase.getUpdateCommand().execute();
sanStorageModelBase.setWidgetModel(diskModel);
externalDiskPanel.clear();
externalDiskPanel.add(storageView);
}
Aggregations