use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method onAttach.
public void onAttach() {
ListModel<EntityModel<StorageDomain>> model = (ListModel<EntityModel<StorageDomain>>) getWindow();
List<StorageDomain> selectedDataStorageDomains = new ArrayList<>();
if (getEntity() == null) {
cancel();
return;
}
selectedStorageDomains = new ArrayList<>();
for (EntityModel<StorageDomain> a : model.getItems()) {
if (a.getIsSelected()) {
StorageDomain storageDomain = a.getEntity();
selectedStorageDomains.add(storageDomain);
if (storageDomain.getStorageDomainType() == StorageDomainType.Data) {
selectedDataStorageDomains.add(storageDomain);
}
}
}
if (selectedStorageDomains.isEmpty()) {
cancel();
return;
}
AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
if (!attachedStorageDomains.isEmpty()) {
ConfirmationModel confirmationModel = new ConfirmationModel();
setWindow(null);
setWindow(confirmationModel);
List<String> stoageDomainNames = attachedStorageDomains.stream().map(StorageDomainStatic::getStorageName).collect(Collectors.toList());
confirmationModel.setItems(stoageDomainNames);
confirmationModel.setTitle(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningTitle());
confirmationModel.setMessage(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningMessage());
confirmationModel.setHelpTag(HelpTag.attach_storage_domain_confirmation);
// $NON-NLS-1$
confirmationModel.setHashName("attach_storage_domain_confirmation");
confirmationModel.getLatch().setIsAvailable(true);
confirmationModel.getLatch().setIsChangeable(true);
// $NON-NLS-1$
UICommand onApprove = new UICommand("OnAttachApprove", DataCenterStorageListModel.this);
onApprove.setTitle(ConstantsManager.getInstance().getConstants().ok());
onApprove.setIsDefault(true);
confirmationModel.getCommands().add(onApprove);
// $NON-NLS-1$
UICommand cancel = new UICommand("Cancel", DataCenterStorageListModel.this);
cancel.setTitle(ConstantsManager.getInstance().getConstants().cancel());
cancel.setIsCancel(true);
confirmationModel.getCommands().add(cancel);
} else {
executeAttachStorageDomains();
}
}), getEntity(), selectedDataStorageDomains);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class StorageDomainValidator method isDomainWithinThresholds.
public ValidationResult isDomainWithinThresholds() {
if (storageDomain.getStorageType().isCinderDomain()) {
return ValidationResult.VALID;
}
StorageDomainDynamic dynamicData = storageDomain.getStorageDynamicData();
StorageDomainStatic staticData = storageDomain.getStorageStaticData();
if (dynamicData != null && staticData != null && dynamicData.getAvailableDiskSize() != null && staticData.getCriticalSpaceActionBlocker() != null && dynamicData.getAvailableDiskSize() < staticData.getCriticalSpaceActionBlocker()) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN, storageName());
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testEmptyStorageDomainListQuery.
@Test
public void testEmptyStorageDomainListQuery() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Up);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testAttachedStorageDomainWithStorageDomainsParameterQuery.
@Test
public void testAttachedStorageDomainWithStorageDomainsParameterQuery() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Up);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
storageDomainList.add(storageDomain);
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
returnedStorageDomainList.add(storageDomain.getStorageStaticData());
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class GetStorageDomainsWithAttachedStoragePoolGuidQueryTest method testStoragePoolIsUninitializedButCheckBooleanIsFalse.
@Test
public void testStoragePoolIsUninitializedButCheckBooleanIsFalse() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Uninitialized);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
storageDomainList.add(storageDomain);
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
when(paramsMock.isCheckStoragePoolStatus()).thenReturn(Boolean.FALSE);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
returnedStorageDomainList.add(storageDomain.getStorageStaticData());
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Aggregations