Arik Hadas has uploaded a new change for review.

Change subject: webadmin: [WIP] introduce WebadminRunOnceModel
......................................................................

webadmin: [WIP] introduce WebadminRunOnceModel

Add WebadminRunOnceModel that extends RunOnceModel for the web-admin.
the code that initializes the run-once-model in the web-admin was moved
from VmListModel to it.

Change-Id: Ic7568c7159f70bb4875a1f5b2f7846b111db094b
Signed-off-by: Arik Hadas <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
A 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java
2 files changed, 239 insertions(+), 255 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/13208/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
index 8aa7d1e..5d7793a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
@@ -40,21 +40,17 @@
 import org.ovirt.engine.core.common.businessentities.UsbPolicy;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
-import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VmOsType;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.businessentities.VmType;
 import org.ovirt.engine.core.common.businessentities.VolumeType;
 import org.ovirt.engine.core.common.businessentities.storage_pool;
-import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
 import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
 import org.ovirt.engine.core.common.queries.GetAllDisksByVmIdParameters;
-import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.SearchParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
-import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.NGuid;
@@ -1369,42 +1365,27 @@
     private void RunOnce()
     {
         VM vm = (VM) getSelectedItem();
-        RunOnceModel model = new WebadminRunOnceModel();
+        RunOnceModel model = new WebadminRunOnceModel(vm,
+                
getCustomPropertiesKeysList().get(vm.getVdsGroupCompatibilityVersion()));
         setWindow(model);
-        
model.setTitle(ConstantsManager.getInstance().getConstants().runVirtualMachinesTitle());
-        model.setHashName("run_virtual_machine"); //$NON-NLS-1$
-        model.getAttachIso().setEntity(false);
-        model.getAttachFloppy().setEntity(false);
-        model.getRunAsStateless().setEntity(vm.isStateless());
-        model.getRunAndPause().setEntity(false);
-        model.setHwAcceleration(true);
 
-        // passing Kernel parameters
-        model.getKernel_parameters().setEntity(vm.getKernelParams());
-        model.getKernel_path().setEntity(vm.getKernelUrl());
-        model.getInitrd_path().setEntity(vm.getInitrdUrl());
+        model.init();
 
-        // Custom Properties
-        model.getCustomPropertySheet()
-                .setKeyValueString(this.getCustomPropertiesKeysList()
-                        .get(vm.getVdsGroupCompatibilityVersion()));
-        model.getCustomPropertySheet().setEntity(vm.getCustomProperties());
-        model.setCustomPropertiesKeysList(this.getCustomPropertiesKeysList()
-                .get(vm.getVdsGroupCompatibilityVersion()));
+        EntityModel tempVar3 = new EntityModel();
+        
tempVar3.setTitle(ConstantsManager.getInstance().getConstants().VNCTitle());
+        tempVar3.setEntity(DisplayType.vnc);
+        EntityModel vncProtocol = tempVar3;
 
-        model.setIsLinuxOS(AsyncDataProvider.IsLinuxOsType(vm.getVmOs()));
-        model.getIsLinuxOptionsAvailable().setEntity(model.getIsLinuxOS());
-        model.setIsWindowsOS(AsyncDataProvider.IsWindowsOsType(vm.getVmOs()));
-        model.getIsVmFirstRun().setEntity(!vm.isInitialized());
-        model.getSysPrepDomainName().setSelectedItem(vm.getVmDomain());
+        EntityModel tempVar5 = new EntityModel();
+        
tempVar5.setTitle(ConstantsManager.getInstance().getConstants().spiceTitle());
+        tempVar5.setEntity(DisplayType.qxl);
+        EntityModel qxlProtocol = tempVar5;
 
-        RunOnceUpdateDisplayProtocols(vm);
-        RunOnceUpdateFloppy(vm, new ArrayList<String>());
-        RunOnceUpdateImages(vm);
-        RunOnceUpdateDomains();
-        updateInterfacesRelatedRunOnceData(vm);
-        updateDisksRelatedRunOnceData(vm);
-        RunOnceLoadHosts(vm);
+        ArrayList<EntityModel> items = new ArrayList<EntityModel>();
+        items.add(vncProtocol);
+        items.add(qxlProtocol);
+        model.getDisplayProtocol().setItems(items);
+        model.getDisplayProtocol().setSelectedItem(vm.getDefaultDisplayType() 
== DisplayType.vnc ? vncProtocol : qxlProtocol);
 
         UICommand tempVar = new UICommand("OnRunOnce", this); //$NON-NLS-1$
         tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
@@ -1414,226 +1395,6 @@
         
tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel());
         tempVar2.setIsCancel(true);
         model.getCommands().add(tempVar2);
-
-        model.getIsAutoAssign().setEntity(true);
-    }
-
-    private void RunOnceUpdateDisplayProtocols(VM vm)
-    {
-        RunOnceModel model = (RunOnceModel) getWindow();
-
-        EntityModel tempVar = new EntityModel();
-        
tempVar.setTitle(ConstantsManager.getInstance().getConstants().VNCTitle());
-        tempVar.setEntity(DisplayType.vnc);
-        EntityModel vncProtocol = tempVar;
-
-        EntityModel tempVar2 = new EntityModel();
-        
tempVar2.setTitle(ConstantsManager.getInstance().getConstants().spiceTitle());
-        tempVar2.setEntity(DisplayType.qxl);
-        EntityModel qxlProtocol = tempVar2;
-
-        boolean isVncSelected = vm.getDefaultDisplayType() == DisplayType.vnc;
-        model.getDisplayConsole_Vnc_IsSelected().setEntity(isVncSelected);
-        model.getDisplayConsole_Spice_IsSelected().setEntity(!isVncSelected);
-
-        ArrayList<EntityModel> items = new ArrayList<EntityModel>();
-        items.add(vncProtocol);
-        items.add(qxlProtocol);
-        model.getDisplayProtocol().setItems(items);
-        model.getDisplayProtocol().setSelectedItem(isVncSelected ? vncProtocol 
: qxlProtocol);
-    }
-
-    private void updateInterfacesRelatedRunOnceData(VM vm)
-    {
-        AsyncQuery _asyncQuery = new AsyncQuery();
-        _asyncQuery.setModel(this);
-
-        _asyncQuery.asyncCallback = new INewAsyncCallback() {
-            @Override
-            public void OnSuccess(Object model, Object ReturnValue)
-            {
-                VmListModel vmListModel = (VmListModel) model;
-                RunOnceModel runOnceModel = (RunOnceModel) 
vmListModel.getWindow();
-                boolean hasNics =
-                        ((ArrayList<VmNetworkInterface>) 
((VdcQueryReturnValue) ReturnValue).getReturnValue()).size() > 0;
-
-                if (!hasNics)
-                {
-                    BootSequenceModel bootSequenceModel = 
runOnceModel.getBootSequence();
-                    bootSequenceModel.getNetworkOption()
-                            
.setChangeProhibitionReason(ConstantsManager.getInstance().getMessages().interfaceIsRequiredToBootFromNetwork());
-                    bootSequenceModel.getNetworkOption().setIsChangable(false);
-                }
-            }
-        };
-
-        Frontend.RunQuery(VdcQueryType.GetVmInterfacesByVmId, new 
IdQueryParameters(vm.getId()), _asyncQuery);
-    }
-
-    private void updateDisksRelatedRunOnceData(VM vm) {
-        AsyncQuery vmDisksQuery = new AsyncQuery();
-        vmDisksQuery.setModel(this);
-
-        vmDisksQuery.asyncCallback = new INewAsyncCallback() {
-            @Override
-            public void OnSuccess(Object model, Object returnValue)
-            {
-                VmListModel vmListModel = (VmListModel) model;
-                ArrayList<Disk> vmDisks = (ArrayList<Disk>) 
((VdcQueryReturnValue) returnValue).getReturnValue();
-                RunOnceModel runOnceModel = (RunOnceModel) 
vmListModel.getWindow();
-
-                if (vmDisks.isEmpty()) {
-                    runOnceModel.getRunAsStateless().setIsChangable(false);
-                    runOnceModel.getRunAsStateless()
-                            
.setChangeProhibitionReason(ConstantsManager.getInstance().getMessages().disklessVmCannotRunAsStateless());
-                    runOnceModel.getRunAsStateless().setEntity(false);
-                }
-
-                boolean hasBootableDisk = false;
-                for (Disk disk : vmDisks) {
-                    if (disk.isBoot()) {
-                        hasBootableDisk = true;
-                        break;
-                    }
-                }
-
-                if (!hasBootableDisk)
-                {
-                    BootSequenceModel bootSequenceModel = 
runOnceModel.getBootSequence();
-                    
bootSequenceModel.getHardDiskOption().setIsChangable(false);
-                    bootSequenceModel.getHardDiskOption()
-                            
.setChangeProhibitionReason(ConstantsManager.getInstance().getMessages().bootableDiskIsRequiredToBootFromDisk());
-                }
-            }
-        };
-
-        Frontend.RunQuery(VdcQueryType.GetAllDisksByVmId, new 
GetAllDisksByVmIdParameters(vm.getId()), vmDisksQuery);
-    }
-
-    private void RunOnceUpdateDomains()
-    {
-        RunOnceModel model = (RunOnceModel) getWindow();
-
-        // Update Domain list
-        AsyncDataProvider.GetDomainList(new AsyncQuery(model,
-                new INewAsyncCallback() {
-                    @Override
-                    public void OnSuccess(Object target, Object returnValue) {
-
-                        RunOnceModel runOnceModel = (RunOnceModel) target;
-                        List<String> domains = (List<String>) returnValue;
-                        String oldDomain = (String) 
runOnceModel.getSysPrepDomainName().getSelectedItem();
-                        if (oldDomain != null && !oldDomain.equals("") && 
!domains.contains(oldDomain)) //$NON-NLS-1$
-                        {
-                            domains.add(0, oldDomain);
-                        }
-                        runOnceModel.getSysPrepDomainName().setItems(domains);
-                        String selectedDomain = (oldDomain != null) ? 
oldDomain : Linq.FirstOrDefault(domains);
-                        if (!StringHelper.stringsEqual(selectedDomain, "")) 
//$NON-NLS-1$
-                        {
-                            
runOnceModel.getSysPrepDomainName().setSelectedItem(selectedDomain);
-                        }
-
-                    }
-                }), true);
-    }
-
-    public void RunOnceUpdateFloppy(VM vm, ArrayList<String> images)
-    {
-        RunOnceModel model = (RunOnceModel) getWindow();
-
-        if (AsyncDataProvider.IsWindowsOsType(vm.getVmOs()))
-        {
-            // Add a pseudo floppy disk image used for Windows' sysprep.
-            if (!vm.isInitialized())
-            {
-                images.add(0, "[sysprep]"); //$NON-NLS-1$
-                model.getAttachFloppy().setEntity(true);
-            }
-            else
-            {
-                images.add("[sysprep]"); //$NON-NLS-1$
-            }
-        }
-
-        model.getFloppyImage().setItems(images);
-
-        if (model.getFloppyImage().getIsChangable() && 
model.getFloppyImage().getSelectedItem() == null)
-        {
-            
model.getFloppyImage().setSelectedItem(Linq.FirstOrDefault(images));
-        }
-    }
-
-    private void RunOnceUpdateImages(VM vm) {
-
-        AsyncQuery _asyncQuery2 = new AsyncQuery();
-        _asyncQuery2.setModel(this);
-
-        _asyncQuery2.asyncCallback = new INewAsyncCallback() {
-            @Override
-            public void OnSuccess(Object model2, Object result)
-            {
-                VmListModel vmListModel2 = (VmListModel) model2;
-                VM selectedVM = (VM) vmListModel2.getSelectedItem();
-                ArrayList<String> images = (ArrayList<String>) result;
-
-                vmListModel2.RunOnceUpdateFloppy(selectedVM, images);
-            }
-        };
-        AsyncDataProvider.GetFloppyImageList(_asyncQuery2, 
vm.getStoragePoolId());
-
-        AsyncQuery getImageListQuery = new AsyncQuery();
-        getImageListQuery.setModel(this);
-
-        getImageListQuery.asyncCallback = new INewAsyncCallback() {
-            @Override
-            public void OnSuccess(Object model1, Object result)
-            {
-                VmListModel vmListModel1 = (VmListModel) model1;
-                RunOnceModel runOnceModel = (RunOnceModel) 
vmListModel1.getWindow();
-                ArrayList<String> images = (ArrayList<String>) result;
-
-                runOnceModel.getIsoImage().setItems(images);
-                if (runOnceModel.getIsoImage().getIsChangable()
-                        && runOnceModel.getIsoImage().getSelectedItem() == 
null)
-                {
-                    
runOnceModel.getIsoImage().setSelectedItem(Linq.FirstOrDefault(images));
-                }
-            }
-        };
-        AsyncDataProvider.GetIrsImageList(getImageListQuery, 
vm.getStoragePoolId());
-
-    }
-
-    /**
-     * Load active hosts bound to active cluster.
-     *
-     */
-    private void RunOnceLoadHosts(VM vm) {
-        RunOnceModel model = (RunOnceModel) getWindow();
-
-        // append just active hosts
-        AsyncDataProvider.GetHostListByCluster(new AsyncQuery(model,
-                new INewAsyncCallback() {
-                    @Override
-                    public void OnSuccess(Object target, Object returnValue) {
-                        final RunOnceModel model = (RunOnceModel) target;
-                        final List<VDS> hosts = (ArrayList<VDS>) returnValue;
-                        final List<VDS> activeHosts = new ArrayList<VDS>();
-                        for(VDS host : hosts) {
-                            if(VDSStatus.Up.equals(host.getStatus())) {
-                                activeHosts.add(host);
-                            }
-                        }
-
-                        model.getDefaultHost().setItems(activeHosts);
-
-                        // hide host tab when no active host is available
-                        if(activeHosts.isEmpty()) {
-                            model.setIsHostTabVisible(false);
-                        }
-                    }
-                }), vm.getVdsGroupName());
     }
 
     private void OnRunOnce()
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java
new file mode 100644
index 0000000..d07f631
--- /dev/null
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java
@@ -0,0 +1,223 @@
+package org.ovirt.engine.ui.uicommonweb.models.vms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ovirt.engine.core.common.businessentities.Disk;
+import org.ovirt.engine.core.common.businessentities.DisplayType;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
+import org.ovirt.engine.core.common.businessentities.VM;
+import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
+import org.ovirt.engine.core.common.queries.GetAllDisksByVmIdParameters;
+import org.ovirt.engine.core.common.queries.IdQueryParameters;
+import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
+import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.compat.StringHelper;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.Frontend;
+import org.ovirt.engine.ui.frontend.INewAsyncCallback;
+import org.ovirt.engine.ui.uicommonweb.Linq;
+import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
+import org.ovirt.engine.ui.uicompat.ConstantsManager;
+
+public class WebadminRunOnceModel extends RunOnceModel {
+
+    private VM vm;
+    private ArrayList<String> customPropertiesKeysList;
+
+    public WebadminRunOnceModel(VM vm, ArrayList<String> 
customPropertiesKeysList) {
+        this.vm = vm;
+        this.customPropertiesKeysList = customPropertiesKeysList;
+    }
+
+    @Override
+    public void init() {
+        
setTitle(ConstantsManager.getInstance().getConstants().runVirtualMachinesTitle());
+        setHashName("run_virtual_machine"); //$NON-NLS-1$
+        getAttachIso().setEntity(false);
+        getAttachFloppy().setEntity(false);
+        getRunAsStateless().setEntity(vm.isStateless());
+        getRunAndPause().setEntity(false);
+        setHwAcceleration(true);
+        getIsAutoAssign().setEntity(true);
+
+        // passing Kernel parameters
+        getKernel_parameters().setEntity(vm.getKernelParams());
+        getKernel_path().setEntity(vm.getKernelUrl());
+        getInitrd_path().setEntity(vm.getInitrdUrl());
+
+        setIsLinuxOS(AsyncDataProvider.IsLinuxOsType(vm.getVmOs()));
+        getIsLinuxOptionsAvailable().setEntity(getIsLinuxOS());
+        setIsWindowsOS(AsyncDataProvider.IsWindowsOsType(vm.getVmOs()));
+        getIsVmFirstRun().setEntity(!vm.isInitialized());
+        getSysPrepDomainName().setSelectedItem(vm.getVmDomain());
+
+        // Custom Properties
+        setCustomPropertiesKeysList(customPropertiesKeysList);
+        getCustomPropertySheet().setKeyValueString(customPropertiesKeysList);
+        getCustomPropertySheet().setEntity(vm.getCustomProperties());
+
+        RunOnceUpdateDisplayProtocols(vm);
+        RunOnceUpdateFloppy(vm, new ArrayList<String>());
+        RunOnceUpdateImages(vm);
+        RunOnceUpdateDomains();
+        updateInterfacesRelatedRunOnceData(vm);
+        updateDisksRelatedRunOnceData(vm);
+        RunOnceLoadHosts(vm);
+    }
+
+    private void RunOnceUpdateDisplayProtocols(VM vm) {
+        boolean isVncSelected = vm.getDefaultDisplayType() == DisplayType.vnc;
+        getDisplayConsole_Vnc_IsSelected().setEntity(isVncSelected);
+        getDisplayConsole_Spice_IsSelected().setEntity(!isVncSelected);
+    }
+
+    private void updateInterfacesRelatedRunOnceData(VM vm) {
+        Frontend.RunQuery(VdcQueryType.GetVmInterfacesByVmId, new 
IdQueryParameters(vm.getId()),
+                new AsyncQuery(this, new INewAsyncCallback() {
+
+                    @Override
+                    public void OnSuccess(Object model, Object returnValue) {
+                        boolean hasNics =
+                                ((ArrayList<VmNetworkInterface>) 
((VdcQueryReturnValue) returnValue).getReturnValue()).size() > 0;
+
+                        if (!hasNics)
+                        {
+                            BootSequenceModel bootSequenceModel = 
getBootSequence();
+                            bootSequenceModel.getNetworkOption()
+                            
.setChangeProhibitionReason(ConstantsManager.getInstance().getMessages().interfaceIsRequiredToBootFromNetwork());
+                            
bootSequenceModel.getNetworkOption().setIsChangable(false);
+                        }
+                    }
+                }));
+    }
+
+    private void updateDisksRelatedRunOnceData(VM vm) {
+        Frontend.RunQuery(VdcQueryType.GetAllDisksByVmId, new 
GetAllDisksByVmIdParameters(vm.getId()),
+                new AsyncQuery(this, new INewAsyncCallback() {
+
+                    @Override
+                    public void OnSuccess(Object model, Object returnValue) {
+                        ArrayList<Disk> vmDisks = (ArrayList<Disk>) 
((VdcQueryReturnValue) returnValue).getReturnValue();
+
+                        if (vmDisks.isEmpty()) {
+                            getRunAsStateless().setIsChangable(false);
+                            getRunAsStateless()
+                            
.setChangeProhibitionReason(ConstantsManager.getInstance().getMessages().disklessVmCannotRunAsStateless());
+                            getRunAsStateless().setEntity(false);
+                        }
+
+                        boolean hasBootableDisk = false;
+                        for (Disk disk : vmDisks) {
+                            if (disk.isBoot()) {
+                                hasBootableDisk = true;
+                                break;
+                            }
+                        }
+
+                        if (!hasBootableDisk)
+                        {
+                            BootSequenceModel bootSequenceModel = 
getBootSequence();
+                            
bootSequenceModel.getHardDiskOption().setIsChangable(false);
+                            bootSequenceModel.getHardDiskOption()
+                            
.setChangeProhibitionReason(ConstantsManager.getInstance().getMessages().bootableDiskIsRequiredToBootFromDisk());
+                        }
+                    }
+                }));
+    }
+
+    private void RunOnceUpdateDomains() {
+        // Update Domain list
+        AsyncDataProvider.GetDomainList(new AsyncQuery(this,
+                new INewAsyncCallback() {
+            @Override
+            public void OnSuccess(Object target, Object returnValue) {
+                List<String> domains = (List<String>) returnValue;
+                String oldDomain = (String) 
getSysPrepDomainName().getSelectedItem();
+                if (oldDomain != null && !oldDomain.equals("") && 
!domains.contains(oldDomain)) { //$NON-NLS-1$
+                    domains.add(0, oldDomain);
+                }
+                getSysPrepDomainName().setItems(domains);
+                String selectedDomain = (oldDomain != null) ? oldDomain : 
Linq.FirstOrDefault(domains);
+                if (!StringHelper.stringsEqual(selectedDomain, "")) { 
//$NON-NLS-1$
+                    getSysPrepDomainName().setSelectedItem(selectedDomain);
+                }
+            }
+        }), true);
+    }
+
+    public void RunOnceUpdateFloppy(VM vm, ArrayList<String> images) {
+        if (AsyncDataProvider.IsWindowsOsType(vm.getVmOs()))
+        {
+            // Add a pseudo floppy disk image used for Windows' sysprep.
+            if (!vm.isInitialized()) {
+                images.add(0, "[sysprep]"); //$NON-NLS-1$
+                getAttachFloppy().setEntity(true);
+            }
+            else {
+                images.add("[sysprep]"); //$NON-NLS-1$
+            }
+        }
+
+        getFloppyImage().setItems(images);
+
+        if (getFloppyImage().getIsChangable() && 
getFloppyImage().getSelectedItem() == null) {
+            getFloppyImage().setSelectedItem(Linq.FirstOrDefault(images));
+        }
+    }
+
+    private void RunOnceUpdateImages(final VM vm) {
+        AsyncDataProvider.GetFloppyImageList(new AsyncQuery(this,
+                new INewAsyncCallback() {
+
+            @Override
+            public void OnSuccess(Object model, Object returnValue) {
+                ArrayList<String> images = (ArrayList<String>) returnValue;
+                RunOnceUpdateFloppy(vm, images);
+            }
+        }), vm.getStoragePoolId());
+
+        AsyncDataProvider.GetIrsImageList(new AsyncQuery(this,
+                new INewAsyncCallback() {
+
+            @Override
+            public void OnSuccess(Object model, Object returnValue) {
+                ArrayList<String> images = (ArrayList<String>) returnValue;
+
+                getIsoImage().setItems(images);
+                if (getIsoImage().getIsChangable()
+                        && getIsoImage().getSelectedItem() == null) {
+                    getIsoImage().setSelectedItem(Linq.FirstOrDefault(images));
+                }
+            }
+        }), vm.getStoragePoolId());
+    }
+
+    /**
+     * Load active hosts bound to active cluster.
+     */
+    private void RunOnceLoadHosts(VM vm) {
+        // append just active hosts
+        AsyncDataProvider.GetHostListByCluster(new AsyncQuery(this,
+                new INewAsyncCallback() {
+            @Override
+            public void OnSuccess(Object target, Object returnValue) {
+                final List<VDS> hosts = (ArrayList<VDS>) returnValue;
+                final List<VDS> activeHosts = new ArrayList<VDS>();
+                for(VDS host : hosts) {
+                    if(VDSStatus.Up.equals(host.getStatus())) {
+                        activeHosts.add(host);
+                    }
+                }
+
+                getDefaultHost().setItems(activeHosts);
+
+                // hide host tab when no active host is available
+                if(activeHosts.isEmpty()) {
+                    setIsHostTabVisible(false);
+                }
+            }
+        }), vm.getVdsGroupName());
+    }
+}


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7568c7159f70bb4875a1f5b2f7846b111db094b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to