Vitor de Lima has uploaded a new change for review.

Change subject: webadmin: Show only supported disk interfaces
......................................................................

webadmin: Show only supported disk interfaces

This change uses information from the osinfo to avoid the selection of
disk interfaces that are not supported by the chosen operating system.
This was created in order to avoid the use of IDE interfaces on POWER
hosts.

Change-Id: I2b674a3481b3e7503b3a224fdda0f9071b9a0619
Signed-off-by: Vitor de Lima <vitor.l...@eldorado.org.br>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java
4 files changed, 74 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/17964/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index d1b2769..d9f03d5 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -2863,20 +2863,37 @@
         }));
     }
 
-    public static ArrayList<DiskInterface> getDiskInterfaceList(Version 
clusterVersion)
+    public static void getDiskInterfaceList(int osId, Version clusterVersion, 
AsyncQuery asyncQuery)
+    {
+        final INewAsyncCallback chainedCallback = asyncQuery.asyncCallback;
+        asyncQuery.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object returnValue) {
+                ArrayList<String> interfaces = (ArrayList<String>) 
((VdcQueryReturnValue) returnValue).getReturnValue();
+                List<DiskInterface> interfaceTypes = new 
ArrayList<DiskInterface>();
+                for (String diskIfs : interfaces) {
+                    try {
+                        interfaceTypes.add(DiskInterface.valueOf(diskIfs));
+                    } catch (IllegalArgumentException e) {
+                        // ignore if we can't find the enum value.
+                    }
+                }
+                chainedCallback.onSuccess(model, interfaceTypes);
+            }
+        };
+        Frontend.RunQuery(VdcQueryType.OsRepository,
+                new OsQueryParameters(OsRepositoryVerb.GetDiskInterfaces, 
osId, clusterVersion),
+                asyncQuery);
+    }
+
+    public static ArrayList<DiskInterface> getDiskInterfaceList()
     {
         ArrayList<DiskInterface> diskInterfaces = new ArrayList<DiskInterface>(
                 Arrays.asList(new DiskInterface[] {
                         DiskInterface.IDE,
-                        DiskInterface.VirtIO
+                        DiskInterface.VirtIO,
+                        DiskInterface.VirtIO_SCSI
                 }));
-
-        boolean isVirtIOScsiEnabled = clusterVersion != null ? (Boolean) 
AsyncDataProvider.getConfigValuePreConverted(
-                ConfigurationValues.VirtIoScsiEnabled, 
clusterVersion.getValue()) : true;
-
-        if (isVirtIOScsiEnabled) {
-            diskInterfaces.add(DiskInterface.VirtIO_SCSI);
-        }
 
         return diskInterfaces;
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
index c815998..19bc6cb 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
+import java.util.List;
 
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.Disk;
@@ -502,9 +503,28 @@
         volumeType_SelectedItemChanged();
     }
 
-    public void updateInterface(Version clusterVersion) {
-        
getDiskInterface().setItems(AsyncDataProvider.getDiskInterfaceList(clusterVersion));
+    public void updateInterface(int osId, Version clusterVersion, AsyncQuery 
chainedAsyncQuery) {
+        final INewAsyncCallback chainedCallback = 
chainedAsyncQuery.asyncCallback;
+
+        if (clusterVersion == null) {
+            ArrayList<DiskInterface> diskInterfaces = 
AsyncDataProvider.getDiskInterfaceList();
+            getDiskInterface().setItems(diskInterfaces);
+            chainedCallback.onSuccess(this, null);
+        } else {
+            AsyncQuery asyncQuery = new AsyncQuery();
+            asyncQuery.asyncCallback = new INewAsyncCallback() {
+                @Override
+                public void onSuccess(Object model, Object returnValue) {
+                    getDiskInterface().setItems((List<DiskInterface>) 
returnValue);
+                    chainedCallback.onSuccess(model, returnValue);
+                }
+            };
+
+            AsyncDataProvider.getDiskInterfaceList(osId, clusterVersion, 
asyncQuery);
+        }
     }
+
+    public abstract void updateInterface(int osId, Version clusterVersion);
 
     private void updateQuota(StoragePool datacenter) {
         if 
(datacenter.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED)
@@ -651,7 +671,12 @@
         updateVolumeType(datacenter.getStorageType());
         updateShareableDiskEnabled(datacenter);
         updateDirectLunDiskEnabled(datacenter);
-        updateInterface(isInVm ? getVm().getVdsGroupCompatibilityVersion() : 
null);
+
+        if (isInVm) {
+            updateInterface(getVm().getOs(), 
getVm().getVdsGroupCompatibilityVersion());
+        } else {
+            updateInterface(0, null);
+        }
 
         if (isInternal) {
             updateStorageDomains(datacenter);
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java
index f299147..a07b33b 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java
@@ -94,9 +94,16 @@
     }
 
     @Override
-    public void updateInterface(Version clusterVersion) {
-        super.updateInterface(clusterVersion);
-        getDiskInterface().setSelectedItem(getDisk().getDiskInterface());
+    public void updateInterface(int osId, Version clusterVersion) {
+        AsyncQuery asyncQuery = new AsyncQuery();
+        asyncQuery.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object returnValue) {
+                
getDiskInterface().setSelectedItem(getDisk().getDiskInterface());
+            }
+        };
+
+        updateInterface(osId, clusterVersion, asyncQuery);
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java
index 65f504f..c71db42 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewDiskModel.java
@@ -135,9 +135,16 @@
     }
 
     @Override
-    public void updateInterface(Version clusterVersion) {
-        super.updateInterface(clusterVersion);
-        getDiskInterface().setSelectedItem(DiskInterface.VirtIO);
+    public void updateInterface(int osId, Version clusterVersion) {
+        AsyncQuery asyncQuery = new AsyncQuery();
+        asyncQuery.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object returnValue) {
+                getDiskInterface().setSelectedItem(DiskInterface.VirtIO);
+            }
+        };
+
+        updateInterface(osId, clusterVersion, asyncQuery);
     }
 
     @Override


-- 
To view, visit http://gerrit.ovirt.org/17964
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b674a3481b3e7503b3a224fdda0f9071b9a0619
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vitor de Lima <vitor.l...@eldorado.org.br>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to