Skip to content

Commit

Permalink
Correct Data Center for the "Upload Image" dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Ermakov <sermakov@orionsoft.ru>

This PR fixes the following issue: incorrect Data Center is displayed when uploading a disk image from "Storage Domain Disks" UI.

Steps to reproduce:

    1. Create a Storage Domain at non-Default Data Center.
    2. Open the Storage -> Domains -> <The created Storage Domain> -> Disks page.
    3. Select the Upload -> Start menu item. The "Upload image" dialog is displayed.

Expected behavior:
    The Data Center filed is disabled and displays the name of the non-Default Data Center.
Current behavior:
    The Data Center field is disabled and display the name of the Default Data Center.

Fixed in the following way: when "Upload image" dialog is displayed then query the Storage Domain details with information about its Data Center and select the Storage Domain's Data Center in the "Data Center" field
  • Loading branch information
sermakov-orion committed Feb 19, 2024
1 parent af1e3c1 commit 58256c2
Showing 1 changed file with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.ovirt.engine.core.common.action.AddDiskParameters;
import org.ovirt.engine.core.common.action.TransferDiskImageParameters;
import org.ovirt.engine.core.common.action.TransferImageStatusParameters;
import org.ovirt.engine.core.common.businessentities.StorageDomain;
import org.ovirt.engine.core.common.businessentities.StorageFormatType;
import org.ovirt.engine.core.common.businessentities.StoragePool;
import org.ovirt.engine.core.common.businessentities.storage.Disk;
Expand All @@ -21,6 +22,9 @@
import org.ovirt.engine.core.common.businessentities.storage.TransferClientType;
import org.ovirt.engine.core.common.businessentities.storage.TransferType;
import org.ovirt.engine.core.common.businessentities.storage.VolumeFormat;
import org.ovirt.engine.core.common.queries.IdQueryParameters;
import org.ovirt.engine.core.common.queries.QueryReturnValue;
import org.ovirt.engine.core.common.queries.QueryType;
import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.compat.StringHelper;
import org.ovirt.engine.ui.frontend.Frontend;
Expand All @@ -30,6 +34,7 @@
import org.ovirt.engine.ui.uicommonweb.help.HelpTag;
import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel;
import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
import org.ovirt.engine.ui.uicommonweb.models.ListModel;
import org.ovirt.engine.ui.uicommonweb.models.Model;
import org.ovirt.engine.ui.uicommonweb.models.vms.AbstractDiskModel;
import org.ovirt.engine.ui.uicommonweb.models.vms.NewDiskModel;
Expand Down Expand Up @@ -169,11 +174,26 @@ public void initialize() {

getDataCenter().setIsChangeable(isChangeable);
if (!isChangeable) {
// Set the selected item on the storage domains list.
AsyncDataProvider.getInstance().getStorageDomainById(
new AsyncQuery<>(storageDomain -> {
getStorageDomain().setItems(Collections.singletonList(storageDomain));
}), limitToStorageDomainId);
// Set the selected item on the storage domains and data centers lists.
Frontend.getInstance().runQuery(
QueryType.GetStorageDomainListById,
new IdQueryParameters(limitToStorageDomainId),
new AsyncQuery<QueryReturnValue>(returnValue -> {
ArrayList<StorageDomain> domains = returnValue.getReturnValue();
if (!domains.isEmpty()) {
StorageDomain storageDomain = domains.get(0);
// Set the selected item on the storage domains list.
getStorageDomain().setItems(Collections.singletonList(storageDomain));
Guid dcId = storageDomain.getStoragePoolId();
if (dcId != null) {
// Set selected data center if the list of data centers is populated.
selectDataCenter(dcId);
// Or listen to the data centers list change to update selected data center.
getDataCenter().getItemsChangedEvent()
.addListener((ev, sender, args) -> selectDataCenter(dcId));
}
}
}));
}
getStorageDomain().setIsChangeable(isChangeable);
getStorageType().setIsChangeable(false);
Expand All @@ -196,6 +216,13 @@ public int getMinimumDiskSize() {
protected boolean performUpdateHosts() {
return true;
}

private void selectDataCenter(Guid dcId) {
ListModel<StoragePool> dcList = getDataCenter();
dcList.getItems().stream()
.filter(dc -> dcId.equals(dc.getId())).findFirst()
.ifPresent(dcList::setSelectedItem);
}
});
} else {
setDiskModel(new ReadOnlyDiskModel() {
Expand Down

0 comments on commit 58256c2

Please sign in to comment.