Martin Betak has uploaded a new change for review.

Change subject: webadmin: Add Reboot VM action button
......................................................................

webadmin: Add Reboot VM action button

Added new button for Reboot VM to webadmin and userportal.

This command should be enabled only when the GuestAgent is
present because that is currently the only supported means
of reboot in VDSM.

Change-Id: I4a30dad6f2d3b909457e39ac15510f0468c2b1a1
Signed-off-by: Martin Betak <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
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/userportal/UserPortalItemModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/VmItemBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/presenter/tab/basic/MainTabBasicListItemPresenterWidget.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.ui.xml
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedVirtualMachineView.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/extended/vm/BorderedCompositeCell.java
A 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-24X24.png
A 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-disabled-24X24.png
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationResources.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
A 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-13X13.png
A 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-disabled-13X13.png
19 files changed, 270 insertions(+), 124 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/22746/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index 38964bb..63f421f 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -351,6 +351,9 @@
     @DefaultStringValue("Shutdown")
     String shutDownVm();
 
+    @DefaultStringValue("Reboot")
+    String rebootVm();
+
     @DefaultStringValue("Name")
     String nameVm();
 
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 c215a46..5a71ad4 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
@@ -17,6 +17,7 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.EventNotificationEntity;
 import org.ovirt.engine.core.common.TimeZoneType;
+import org.ovirt.engine.core.common.VdcActionUtils;
 import org.ovirt.engine.core.common.VdcEventNotificationUtils;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.VdcActionType;
@@ -3524,4 +3525,26 @@
         return (Integer) 
getConfigValuePreConverted(ConfigurationValues.SchedulerOverBookingThreshold,
                 getDefaultConfigurationVersion());
     }
+
+    public static boolean isRebootCommandExecutionAllowed(List<VM> vms) {
+        if (vms.isEmpty() || !VdcActionUtils.canExecute(vms, VM.class, 
VdcActionType.RebootVm)) {
+            return false;
+        }
+
+        for (VM vm : vms) {
+            Version version = vm.getVdsGroupCompatibilityVersion();
+            // we pass the same value as StoragePool compatibility version
+            // because the reboot command only depends on the cluster version 
(the SP version doesn't matter)
+            // and getting the actual SP version would be too expensive
+            //
+            // also currently on VDSM side reboot is supported only when the 
guest agent is present and responsive
+            // so we need to check for that
+            // TODO: better guest agent detection
+            // right now we check if the vmIp is set because for some reason 
vm.getHasAgent() returns false even when GA is present
+            if (!isCommandCompatible(VdcActionType.RebootVm, version, version) 
|| StringHelper.isNullOrEmpty(vm.getVmIp())) {
+                return false;
+            }
+        }
+        return true;
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalItemModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalItemModel.java
index 59b275a..4cbe298 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalItemModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalItemModel.java
@@ -105,6 +105,18 @@
         returnVmCommand = value;
     }
 
+    private UICommand rebootCommand;
+
+    public UICommand getRebootCommand() {
+        return rebootCommand;
+    }
+
+    public void setRebootCommand(UICommand value) {
+        getCommands().remove(rebootCommand);
+        getCommands().add(value);
+        rebootCommand = value;
+    }
+
     private String name;
 
     public String getName()
@@ -255,6 +267,7 @@
         setShutdownCommand(new UICommand("Shutdown", this)); //$NON-NLS-1$
         setTakeVmCommand(new UICommand("TakeVm", this)); //$NON-NLS-1$
         setReturnVmCommand(new UICommand("ReturnVm", this)); //$NON-NLS-1$
+        setRebootCommand(new UICommand("RebootVm", this)); //$NON-NLS-1$
 
         ChangeCDModel tempVar = new ChangeCDModel();
         
tempVar.setTitle(ConstantsManager.getInstance().getConstants().retrievingCDsTitle());
@@ -307,6 +320,8 @@
         stopCommand = null;
         takeVmCommand.setTarget(null);
         takeVmCommand = null;
+        rebootCommand.setTarget(null);
+        rebootCommand = null;
         setCommands(null);
     }
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/VmItemBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/VmItemBehavior.java
index 705244c..83c035a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/VmItemBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/VmItemBehavior.java
@@ -69,6 +69,10 @@
         {
             returnVm();
         }
+        else if (command == getItem().getRebootCommand())
+        {
+            reboot();
+        }
     }
 
     @Override
@@ -108,6 +112,11 @@
     {
         VM entity = (VM) getItem().getEntity();
         Frontend.getInstance().runAction(VdcActionType.ShutdownVm, new 
ShutdownVmParameters(entity.getId(), true));
+    }
+
+    private void reboot() {
+        VM entity = (VM) getItem().getEntity();
+        Frontend.getInstance().runAction(VdcActionType.RebootVm, new 
VmOperationParameterBase(entity.getId()));
     }
 
     private void stop() {
@@ -158,6 +167,7 @@
         
getItem().getStopCommand().setIsExecutionAllowed(VdcActionUtils.canExecute(entities,
                 VM.class,
                 VdcActionType.StopVm));
+        
getItem().getRebootCommand().setIsExecutionAllowed(AsyncDataProvider.isRebootCommandExecutionAllowed(entities));
 
         // Check whether a VM is from the manual pool.
         if (entity.getVmPoolId() != null)
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 51d6158..d11dedc 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
@@ -87,6 +87,7 @@
 import org.ovirt.engine.ui.uicompat.IFrontendMultipleQueryAsyncCallback;
 import org.ovirt.engine.ui.uicompat.ObservableCollection;
 import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs;
+import org.ovirt.engine.ui.uicompat.UIConstants;
 
 public class VmListModel extends VmBaseListModel<VM> implements 
ISupportSystemTreeContext {
 
@@ -172,6 +173,16 @@
     private void setShutdownCommand(UICommand value)
     {
         privateShutdownCommand = value;
+    }
+
+    private UICommand privateRebootCommand;
+
+    public UICommand getRebootCommand() {
+        return privateRebootCommand;
+    }
+
+    public void setRebootCommand(UICommand value) {
+        privateRebootCommand = value;
     }
 
     private UICommand privateCancelMigrateCommand;
@@ -387,6 +398,7 @@
         setPauseCommand(new UICommand("Pause", this)); //$NON-NLS-1$
         setStopCommand(new UICommand("Stop", this)); //$NON-NLS-1$
         setShutdownCommand(new UICommand("Shutdown", this)); //$NON-NLS-1$
+        setRebootCommand(new UICommand("Reboot", this)); //$NON-NLS-1$
         setEditConsoleCommand(new UICommand("EditConsoleCommand", this)); 
//$NON-NLS-1$
         setConsoleConnectCommand(new UICommand("ConsoleConnectCommand", 
this)); //$NON-NLS-1$
         setMigrateCommand(new UICommand("Migrate", this)); //$NON-NLS-1$
@@ -1114,14 +1126,14 @@
             model.startProgress(null);
 
             Frontend.getInstance().runMultipleAction(VdcActionType.ExportVm, 
parameters,
-                    new IFrontendMultipleActionAsyncCallback() {
-                        @Override
-                        public void executed(FrontendMultipleActionAsyncResult 
result) {
-                            ExportVmModel localModel = (ExportVmModel) 
result.getState();
-                            localModel.stopProgress();
-                            cancel();
-                        }
-                    }, model);
+                                                     new 
IFrontendMultipleActionAsyncCallback() {
+                                                         @Override
+                                                         public void 
executed(FrontendMultipleActionAsyncResult result) {
+                                                             ExportVmModel 
localModel = (ExportVmModel) result.getState();
+                                                             
localModel.stopProgress();
+                                                             cancel();
+                                                         }
+                                                     }, model);
         }
     }
 
@@ -1163,34 +1175,34 @@
         model.startProgress(null);
 
         Frontend.getInstance().runMultipleAction(VdcActionType.ExportVm, list,
-                new IFrontendMultipleActionAsyncCallback() {
-                    @Override
-                    public void executed(FrontendMultipleActionAsyncResult 
result) {
+                                                 new 
IFrontendMultipleActionAsyncCallback() {
+                                                     @Override
+                                                     public void 
executed(FrontendMultipleActionAsyncResult result) {
 
-                        ExportVmModel localModel = (ExportVmModel) 
result.getState();
-                        localModel.stopProgress();
-                        cancel();
+                                                         ExportVmModel 
localModel = (ExportVmModel) result.getState();
+                                                         
localModel.stopProgress();
+                                                         cancel();
 
-                    }
-                }, model);
+                                                     }
+                                                 }, model);
     }
 
     @Override
     protected void sendWarningForNonExportableDisks(VM entity) {
         // load VM disks and check if there is one which doesn't allow snapshot
         AsyncDataProvider.getVmDiskList(new AsyncQuery(getWindow(),
-                new INewAsyncCallback() {
-                    @Override
-                    public void onSuccess(Object target, Object returnValue) {
-                        final ExportVmModel model = (ExportVmModel) target;
-                        @SuppressWarnings("unchecked")
-                        final ArrayList<Disk> vmDisks = (ArrayList<Disk>) 
returnValue;
-                        VmModelHelper.sendWarningForNonExportableDisks(model,
-                                vmDisks,
-                                VmModelHelper.WarningType.VM_EXPORT);
-                    }
-                }),
-                entity.getId());
+                                                       new INewAsyncCallback() 
{
+                                                           @Override
+                                                           public void 
onSuccess(Object target, Object returnValue) {
+                                                               final 
ExportVmModel model = (ExportVmModel) target;
+                                                               
@SuppressWarnings("unchecked")
+                                                               final 
ArrayList<Disk> vmDisks = (ArrayList<Disk>) returnValue;
+                                                               
VmModelHelper.sendWarningForNonExportableDisks(model,
+                                                                               
                               vmDisks,
+                                                                               
                               VmModelHelper.WarningType.VM_EXPORT);
+                                                           }
+                                                       }),
+                                        entity.getId());
     }
 
     private void runOnce()
@@ -1410,12 +1422,12 @@
         }
 
         
Frontend.getInstance().runMultipleAction(VdcActionType.CancelMigrateVm, list,
-                new IFrontendMultipleActionAsyncCallback() {
-                    @Override
-                    public void executed(
-                            FrontendMultipleActionAsyncResult result) {
-                    }
-                }, null);
+                                                 new 
IFrontendMultipleActionAsyncCallback() {
+                                                     @Override
+                                                     public void executed(
+                                                             
FrontendMultipleActionAsyncResult result) {
+                                                     }
+                                                 }, null);
     }
 
     private void postMigrateGetUpHosts(ArrayList<VDS> hosts)
@@ -1535,28 +1547,25 @@
             }
 
             
Frontend.getInstance().runMultipleAction(VdcActionType.MigrateVmToServer, list,
-                    new IFrontendMultipleActionAsyncCallback() {
-                        @Override
-                        public void executed(FrontendMultipleActionAsyncResult 
result) {
+                                                     new 
IFrontendMultipleActionAsyncCallback() {
+                                                         @Override
+                                                         public void 
executed(FrontendMultipleActionAsyncResult result) {
 
-                            MigrateModel localModel = (MigrateModel) 
result.getState();
-                            localModel.stopProgress();
-                            cancel();
+                                                     MigrateModel localModel = 
(MigrateModel) result.getState();
+                                                             
localModel.stopProgress();
+                                                             cancel();
 
-                        }
-                    }, model);
+                                                         }
+                                                     }, model);
         }
     }
 
-    private void shutdown()
-    {
+    private void powerAction(String actionName, String title, String message) {
         ConfirmationModel model = new ConfirmationModel();
         setWindow(model);
-        
model.setTitle(ConstantsManager.getInstance().getConstants().shutdownVirtualMachinesTitle());
-        model.setHashName("shut_down_virtual_machine"); //$NON-NLS-1$
-        model.setMessage(ConstantsManager.getInstance()
-                .getConstants()
-                .areYouSureYouWantToShutDownTheFollowingVirtualMachinesMsg());
+        model.setTitle(title);
+        model.setHashName(actionName + "_virtual_machine"); //$NON-NLS-1$
+        model.setMessage(message);
         // model.Items = SelectedItems.Cast<VM>().Select(a => a.vm_name);
         ArrayList<String> items = new ArrayList<String>();
         for (Object item : getSelectedItems())
@@ -1566,7 +1575,7 @@
         }
         model.setItems(items);
 
-        UICommand tempVar = new UICommand("OnShutdown", this); //$NON-NLS-1$
+        UICommand tempVar = new UICommand("On" + actionName, this); 
//$NON-NLS-1$
         tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
         tempVar.setIsDefault(true);
         model.getCommands().add(tempVar);
@@ -1576,94 +1585,86 @@
         model.getCommands().add(tempVar2);
     }
 
-    private void onShutdown()
-    {
+    private interface PowerActionParametersFactory<P extends 
VdcActionParametersBase> {
+        P createActionParameters(VM vm);
+    }
+
+    private void onPowerAction(VdcActionType actionType, 
PowerActionParametersFactory<?> parametersFactory) {
         ConfirmationModel model = (ConfirmationModel) getWindow();
 
-        if (model.getProgress() != null)
-        {
+        if (model.getProgress() != null) {
             return;
         }
 
+
         ArrayList<VdcActionParametersBase> list = new 
ArrayList<VdcActionParametersBase>();
-        for (Object item : getSelectedItems())
-        {
-            VM a = (VM) item;
-            list.add(new ShutdownVmParameters(a.getId(), true));
+        for (Object item : getSelectedItems()) {
+            VM vm = (VM) item;
+            list.add(parametersFactory.createActionParameters(vm));
         }
 
         model.startProgress(null);
 
-        Frontend.getInstance().runMultipleAction(VdcActionType.ShutdownVm, 
list,
-                new IFrontendMultipleActionAsyncCallback() {
-                    @Override
-                    public void executed(FrontendMultipleActionAsyncResult 
result) {
+        Frontend.getInstance().runMultipleAction(actionType, list,
+                                                 new 
IFrontendMultipleActionAsyncCallback() {
+                                                     @Override
+                                                     public void 
executed(FrontendMultipleActionAsyncResult result) {
 
-                        ConfirmationModel localModel = (ConfirmationModel) 
result.getState();
-                        localModel.stopProgress();
-                        cancel();
+                                                         ConfirmationModel 
localModel = (ConfirmationModel) result.getState();
+                                                         
localModel.stopProgress();
+                                                         cancel();
 
-                    }
-                }, model);
+                                                     }
+                                                 }, model);
+
     }
 
-    private void stop()
-    {
-        ConfirmationModel model = new ConfirmationModel();
-        setWindow(model);
-        
model.setTitle(ConstantsManager.getInstance().getConstants().stopVirtualMachinesTitle());
-        model.setHashName("stop_virtual_machine"); //$NON-NLS-1$
-        model.setMessage(ConstantsManager.getInstance()
-                .getConstants()
-                .areYouSureYouWantToStopTheFollowingVirtualMachinesMsg());
-        // model.Items = SelectedItems.Cast<VM>().Select(a => a.vm_name);
-        ArrayList<String> items = new ArrayList<String>();
-        for (Object item : getSelectedItems())
-        {
-            VM a = (VM) item;
-            items.add(a.getName());
-        }
-        model.setItems(items);
-
-        UICommand tempVar = new UICommand("OnStop", this); //$NON-NLS-1$
-        tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
-        tempVar.setIsDefault(true);
-        model.getCommands().add(tempVar);
-        UICommand tempVar2 = new UICommand("Cancel", this); //$NON-NLS-1$
-        
tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel());
-        tempVar2.setIsCancel(true);
-        model.getCommands().add(tempVar2);
+    private void shutdown() {
+        UIConstants constants = ConstantsManager.getInstance().getConstants();
+        powerAction("Shutdown", //$NON-NLS-1$
+                    constants.shutdownVirtualMachinesTitle(),
+                    
constants.areYouSureYouWantToShutDownTheFollowingVirtualMachinesMsg());
     }
 
-    private void onStop()
-    {
-        ConfirmationModel model = (ConfirmationModel) getWindow();
+    private void onShutdown() {
+        onPowerAction(VdcActionType.ShutdownVm, new 
PowerActionParametersFactory<VdcActionParametersBase>() {
+            @Override
+            public VdcActionParametersBase createActionParameters(VM vm) {
+                return new ShutdownVmParameters(vm.getId(), true);
+            }
+        });
+    }
 
-        if (model.getProgress() != null)
-        {
-            return;
-        }
+    private void stop() {
+        UIConstants constants = ConstantsManager.getInstance().getConstants();
+        powerAction("Stop", //$NON-NLS-1$
+                    constants.stopVirtualMachinesTitle(),
+                    
constants.areYouSureYouWantToStopTheFollowingVirtualMachinesMsg());
+    }
 
-        ArrayList<VdcActionParametersBase> list = new 
ArrayList<VdcActionParametersBase>();
-        for (Object item : getSelectedItems())
-        {
-            VM a = (VM) item;
-            list.add(new StopVmParameters(a.getId(), StopVmTypeEnum.NORMAL));
-        }
+    private void onStop() {
+        onPowerAction(VdcActionType.StopVm, new 
PowerActionParametersFactory<VdcActionParametersBase>() {
+            @Override
+            public VdcActionParametersBase createActionParameters(VM vm) {
+                return new StopVmParameters(vm.getId(), StopVmTypeEnum.NORMAL);
+            }
+        });
+    }
 
-        model.startProgress(null);
+    private void reboot() {
+        UIConstants constants = ConstantsManager.getInstance().getConstants();
+        powerAction("Reboot", //$NON-NLS-1$
+                    constants.rebootVirtualMachinesTitle(),
+                    
constants.areYouSureYouWantToRebootTheFollowingVirtualMachinesMsg());
+    }
 
-        Frontend.getInstance().runMultipleAction(VdcActionType.StopVm, list,
-                new IFrontendMultipleActionAsyncCallback() {
-                    @Override
-                    public void executed(FrontendMultipleActionAsyncResult 
result) {
-
-                        ConfirmationModel localModel = (ConfirmationModel) 
result.getState();
-                        localModel.stopProgress();
-                        cancel();
-
-                    }
-                }, model);
+    private void onReboot() {
+        onPowerAction(VdcActionType.RebootVm, new 
PowerActionParametersFactory<VdcActionParametersBase>() {
+            @Override
+            public VdcActionParametersBase createActionParameters(VM vm) {
+                return new VmOperationParameterBase(vm.getId());
+            }
+        });
     }
 
     private void pause()
@@ -2246,6 +2247,7 @@
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.ShutdownVm));
         getStopCommand().setIsExecutionAllowed(items.size() > 0
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.StopVm));
+        
getRebootCommand().setIsExecutionAllowed(AsyncDataProvider.isRebootCommandExecutionAllowed(items));
         getMigrateCommand().setIsExecutionAllowed(items.size() > 0
                 && VdcActionUtils.canExecute(items, VM.class, 
VdcActionType.MigrateVm));
         getCancelMigrateCommand().setIsExecutionAllowed(items.size() > 0
@@ -2356,6 +2358,9 @@
         {
             shutdown();
         }
+        else if (command == getRebootCommand()) {
+            reboot();
+        }
         else if (command == getMigrateCommand())
         {
             migrate();
@@ -2444,6 +2449,10 @@
         {
             onStop();
         }
+        else if (StringHelper.stringsEqual(command.getName(), "OnReboot")) 
//$NON-NLS-1$
+        {
+            onReboot();
+        }
         else if (StringHelper.stringsEqual(command.getName(), "OnChangeCD")) 
//$NON-NLS-1$
         {
             onChangeCD();
@@ -2512,5 +2521,4 @@
     protected Guid extractStoragePoolIdNullSafe(VM entity) {
         return entity.getStoragePoolId();
     }
-
 }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index 4a5dd7b..f9fa9ed 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -643,6 +643,9 @@
     @DefaultStringValue("Power Off Virtual Machine(s)")
     String stopVirtualMachinesTitle();
 
+    @DefaultStringValue("Reboot Virtual Machine(s)")
+    String rebootVirtualMachinesTitle();
+
     @DefaultStringValue("Change CD")
     String changeCDTitle();
 
@@ -822,6 +825,9 @@
     @DefaultStringValue("Are you sure you want to Power Off the following 
Virtual Machines?")
     String areYouSureYouWantToStopTheFollowingVirtualMachinesMsg();
 
+    @DefaultStringValue("Are you sure you want to Reboot the following Virtual 
Machines?")
+    String areYouSureYouWantToRebootTheFollowingVirtualMachinesMsg();
+
     @DefaultStringValue("This field must contain an IP address in format 
xxx.xxx.xxx.xxx")
     String thisFieldMustContainIPaddressInFormatMsg();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java
index f761744..74e1264 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java
@@ -314,6 +314,9 @@
     @DefaultStringValue("Run VM")
     String runVm();
 
+    @DefaultStringValue("Reboot VM")
+    String rebootVm();
+
     @DefaultStringValue("Double Click for Console")
     String doubleClickForConsole();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
index d9e2819..9d4d76f 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
@@ -54,6 +54,13 @@
     @Source("images/actions/power_Disabled.png")
     ImageResource powerDisabledIcon();
 
+    @Source("images/actions/Reboot-24X24.png")
+    ImageResource rebootIcon();
+
+    @Source("images/actions/Reboot-disabled-24X24.png")
+    ImageResource rebootDisabledIcon();
+
+
     // status images
     @Source("images/status/suspendedOverlay.png")
     ImageResource suspendedIcon();
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/presenter/tab/basic/MainTabBasicListItemPresenterWidget.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/presenter/tab/basic/MainTabBasicListItemPresenterWidget.java
index 0cbaf0e..ee282ee 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/presenter/tab/basic/MainTabBasicListItemPresenterWidget.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/presenter/tab/basic/MainTabBasicListItemPresenterWidget.java
@@ -64,6 +64,10 @@
 
         void updateSuspendButton(UICommand command);
 
+        HasClickHandlers addRebootButton();
+
+        void updateRebootButton(UICommand command);
+
     }
 
     private final UserPortalBasicListProvider listModelProvider;
@@ -148,6 +152,12 @@
                 executeCommand(getSuspendCommand());
             }
         }));
+        registerHandler(getView().addRebootButton().addClickHandler(new 
ClickHandler() {
+            @Override
+            public void onClick(ClickEvent clickEvent) {
+                executeCommand(getRebootCommand());
+            }
+        }));
     }
 
     @Override
@@ -174,6 +184,10 @@
         return model.getPauseCommand();
     }
 
+    UICommand getRebootCommand() {
+        return model.getRebootCommand();
+    }
+
     /**
      * Updates the item presenter widget with new data.
      */
@@ -185,6 +199,7 @@
         getView().updateRunButton(getRunCommand(), model.isPool());
         getView().updateShutdownButton(getShutdownCommand());
         getView().updateSuspendButton(getSuspendCommand());
+        getView().updateRebootButton(getRebootCommand());
 
         getView().edit(model);
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.java
index 0d401ae..596f3b4 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.java
@@ -73,6 +73,7 @@
 
         String suspendButtonAdditionalStyle();
 
+        String rebootButtonAdditionalStyle();
     }
 
     private final Driver driver = GWT.create(Driver.class);
@@ -119,6 +120,7 @@
     private MainTabBasicListItemActionButton runButton;
     private MainTabBasicListItemActionButton shutdownButton;
     private MainTabBasicListItemActionButton suspendButton;
+    private MainTabBasicListItemActionButton rebootButton;
 
     @Inject
     public MainTabBasicListItemView(
@@ -188,6 +190,23 @@
     @Override
     public void updateSuspendButton(UICommand command) {
         updateButton(suspendButton, command);
+    }
+
+    @Override
+    public HasClickHandlers addRebootButton() {
+        MainTabBasicListItemActionButton button = new 
MainTabBasicListItemActionButton(
+                constants.rebootVm(),
+                resources.rebootIcon(),
+                resources.rebootDisabledIcon(),
+                style.rebootButtonAdditionalStyle());
+        this.rebootButton = button;
+        addButtonToPanel(button);
+        return button;
+    }
+
+    @Override
+    public void updateRebootButton(UICommand command) {
+        updateButton(rebootButton, command);
     }
 
     void addButtonToPanel(MainTabBasicListItemActionButton button) {
@@ -294,6 +313,8 @@
                 ElementIdUtils.createElementId(elementId, "shutdownButton")); 
//$NON-NLS-1$
         suspendButton.setElementId(
                 ElementIdUtils.createElementId(elementId, "suspendButton")); 
//$NON-NLS-1$
+        rebootButton.setElementId(
+                ElementIdUtils.createElementId(elementId, "rebootButton")); 
//$NON-NLS-1$
     }
 
 }
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.ui.xml
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.ui.xml
index c923890..22856ae 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.ui.xml
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/basic/MainTabBasicListItemView.ui.xml
@@ -108,8 +108,8 @@
                }
 
                .buttonsPanel {
-                       margin-left: 40px;
-                       width: 78px;
+                       margin-left: 29px;
+                       width: 104px;
                        height: 30px;
                        float: left;
                }
@@ -125,6 +125,10 @@
         .suspendButtonAdditionalStyle {
                float: right;
         }
+
+    .rebootButtonAdditionalStyle {
+      float: right;
+    }
                
        </ui:style>
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedVirtualMachineView.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedVirtualMachineView.java
index 1413df4..93bff7a 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedVirtualMachineView.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedVirtualMachineView.java
@@ -175,7 +175,7 @@
             public UserPortalItemModel getValue(UserPortalItemModel object) {
                 return object;
             }
-        }, constants.empty(), "130px"); //$NON-NLS-1$
+        }, constants.empty(), "154px"); //$NON-NLS-1$
 
         ConsoleButtonCell openConsoleCell = new ConsoleButtonCell(
                 
applicationResources.sideTabExtendedVmStyle().enabledConsoleButton(),
@@ -354,12 +354,30 @@
         };
         stopCell.setElementIdPrefix(elementIdPrefix);
         stopCell.setColumnId("stopButton"); //$NON-NLS-1$
+
+        ImageButtonCell<UserPortalItemModel> rebootCell = new 
VmButtonsImageButtonCell(
+                applicationResources.rebootIcon(), 
applicationResources.rebootDisabledIcon()) {
+
+            @Override
+            protected String getTitle(UserPortalItemModel value) {
+                return constants.rebootVm();
+            }
+
+            @Override
+            protected UICommand resolveCommand(UserPortalItemModel value) {
+                return value.getRebootCommand();
+            }
+        };
+        rebootCell.setElementIdPrefix(elementIdPrefix);
+        rebootCell.setColumnId("rebootColumn"); //$NON-NLS-1$
+
         CompositeCell<UserPortalItemModel> compositeCell = new 
BorderedCompositeCell<UserPortalItemModel>(
                 new ArrayList<HasCell<UserPortalItemModel, ?>>(Arrays.asList(
                         new UserPortalItemSimpleColumn(runCell),
                         new UserPortalItemSimpleColumn(shutdownCell),
                         new UserPortalItemSimpleColumn(suspendCell),
-                        new UserPortalItemSimpleColumn(stopCell))));
+                        new UserPortalItemSimpleColumn(stopCell),
+                        new UserPortalItemSimpleColumn(rebootCell))));
 
         return compositeCell;
     }
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/extended/vm/BorderedCompositeCell.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/extended/vm/BorderedCompositeCell.java
index c9e8ed5..93423d7 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/extended/vm/BorderedCompositeCell.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/extended/vm/BorderedCompositeCell.java
@@ -24,7 +24,7 @@
 
     @Override
     public void render(Context context, T value, SafeHtmlBuilder sb) {
-        sb.appendHtmlConstant("<div style=\"border-radius: 7px; border: 1px 
solid #c6c6c6; width: 100px; padding-top: 3px; padding-left: 3px\">"); 
//$NON-NLS-1$
+        sb.appendHtmlConstant("<div style=\"border-radius: 7px; border: 1px 
solid #c6c6c6; width: 124px; padding-top: 3px; padding-left: 3px\">"); 
//$NON-NLS-1$
         for (HasCell<T, ?> hasCell : hasCells) {
             render(context, value, sb, hasCell);
         }
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-24X24.png
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-24X24.png
new file mode 100644
index 0000000..3116a7d
--- /dev/null
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-24X24.png
Binary files differ
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-disabled-24X24.png
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-disabled-24X24.png
new file mode 100644
index 0000000..48e9ab3
--- /dev/null
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/actions/Reboot-disabled-24X24.png
Binary files differ
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationResources.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationResources.java
index ffd5da1..d765243 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationResources.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationResources.java
@@ -169,6 +169,12 @@
     @Source("images/icn_stop.png")
     ImageResource stopVmImage();
 
+    @Source("images/Reboot-13X13.png")
+    ImageResource rebootImage();
+
+    @Source("images/Reboot-disabled-13X13.png")
+    ImageResource rebootDisabledImage();
+
     @Source("images/storages.png")
     ImageResource storagesImage();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
index 547b040..1176613 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVirtualMachineView.java
@@ -223,6 +223,13 @@
                 return getMainModel().getStopCommand();
             }
         });
+        getTable().addActionButton(new 
WebAdminImageButtonDefinition<VM>(constants.rebootVm(),
+                resources.rebootImage(), resources.rebootDisabledImage()) {
+            @Override
+            protected UICommand resolveCommand() {
+                return getMainModel().getRebootCommand();
+            }
+        });
         // TODO: separator
         getTable().addActionButton(new 
WebAdminImageButtonDefinition<VM>(constants.consoleVm(),
                 resources.consoleImage(), resources.consoleDisabledImage()) {
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-13X13.png
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-13X13.png
new file mode 100644
index 0000000..09b9a94
--- /dev/null
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-13X13.png
Binary files differ
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-disabled-13X13.png
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-disabled-13X13.png
new file mode 100644
index 0000000..7129dc1
--- /dev/null
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/webadmin/images/Reboot-disabled-13X13.png
Binary files differ


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

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

Reply via email to