ofri masad has uploaded a new change for review.

Change subject: webadmin: UI for cpu shares
......................................................................

webadmin: UI for cpu shares

Added UI for CPU shares.
Changed the UI for CPU Pinning topology (was moved to the 'Resource
Allocation' tab and added info icon instead of the example panel)

Change-Id: I5c975cf521f8aa18d3a6836dee31fd249a8815bb
Signed-off-by: Ofri Masad <oma...@redhat.com>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationTemplates.java
16 files changed, 197 insertions(+), 41 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/17668/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 8bd85bb..220e4ba 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
@@ -617,6 +617,9 @@
     @DefaultStringValue("Memory Allocation:")
     String memAllocVmPopup();
 
+    @DefaultStringValue("CPU Allocation:")
+    String cpuAllocVmPopup();
+
     @DefaultStringValue("Storage Allocation:")
     String storageAllocVmPopup();
 
@@ -1560,4 +1563,7 @@
 
     @DefaultStringValue("Memory Balloon Device Enabled")
     String memoryBalloonDeviceEnabled();
+
+    @DefaultStringValue("CPU Shares")
+    String cpuShares();
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java
index 89f4cc4..aace842 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java
@@ -70,4 +70,6 @@
     @Template("<div style='width: 600px'><div style='width: 30%; display: 
inline-block; border-right: 1px solid black; font-weight:bold; padding-right: 
25px; float: left'>{0}</div><div style='display: inline-block; margin-left: 
25px;'>{1}</div></div>")
     SafeHtml typeAheadNameDescription(String name, String description);
 
+    @Template("<div style='width: {0}; font-style: italic;'>{1}</div>")
+    SafeHtml italicFixedWidth(String pxWidth, String text);
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
index be1f361..97cd9f7 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
@@ -70,7 +70,6 @@
 import com.google.gwt.user.cellview.client.CellTable.Resources;
 import com.google.gwt.user.client.ui.ButtonBase;
 import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Panel;
@@ -107,6 +106,10 @@
         String cdImageEditor();
 
         String monitorsStyles();
+
+        String cpuSharesSelectorInner();
+
+        String cpuSharesValueInner();
     }
 
     @UiField
@@ -153,10 +156,6 @@
     @Path(value = "template.selectedItem")
     @WithElementId("template")
     public ListModelTypeAheadListBoxEditor<Object> templateEditor;
-
-    @UiField
-    @Ignore
-    HTML cpuPinningLabel;
 
     @UiField(provided = true)
     @Path(value = "OSType.selectedItem")
@@ -421,9 +420,22 @@
     public EntityModelRadioButtonEditor isAutoAssignEditor;
 
     @UiField(provided = true)
+    InfoIcon cpuPinningInfo;
+
+    @UiField(provided = true)
     @Path(value = "cpuPinning.entity")
     @WithElementId("cpuPinning")
-    public EntityModelTextBoxEditor cpuPinning;
+    public EntityModelTextBoxOnlyEditor cpuPinning;
+
+    @UiField(provided = true)
+    @Path(value = "cpuSharesAmountSelection.selectedItem")
+    @WithElementId("cpuSharesAmountSelection")
+    public ListModelListBoxEditor<Object> cpuSharesAmountSelectionEditor;
+
+    @UiField(provided = true)
+    @Path(value = "cpuSharesAmount.entity")
+    @WithElementId("cpuSharesAmount")
+    public EntityModelTextBoxOnlyEditor cpuSharesAmountEditor;
 
     // ==High Availability Tab==
     @UiField
@@ -602,6 +614,8 @@
         copyTemplatePermissionsEditor = new 
EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
         isMemoryBalloonDeviceEnabled = new 
EntityModelCheckBoxEditor(Align.RIGHT);
         isSingleQxlEnabledEditor = new EntityModelCheckBoxEditor(Align.RIGHT, 
new ModeSwitchingVisibilityRenderer());
+        cpuPinningInfo = new 
InfoIcon(applicationTemplates.italicFixedWidth("465px",  //$NON-NLS-1$
+                constants.cpuPinningLabelExplanation()), resources);
 
         priorityEditor = new EntityModelCellTable<ListModel>(
                 (Resources) GWT.create(ButtonCellTableResources.class));
@@ -639,7 +653,9 @@
         commentEditor = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
         totalvCPUsEditor = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
         numOfVmsEditor = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
-        cpuPinning = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
+        cpuPinning = new EntityModelTextBoxOnlyEditor(new 
ModeSwitchingVisibilityRenderer());
+        cpuSharesAmountEditor = new EntityModelTextBoxOnlyEditor(new 
ModeSwitchingVisibilityRenderer());
+        cpuSharesAmountEditor.asValueBox().setWidth("110px");//$NON-NLS-1$
         kernel_pathEditor = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
         initrd_pathEditor = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
         kernel_parametersEditor = new EntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
@@ -872,6 +888,11 @@
                 return (String) object;
             }
         }, new ModeSwitchingVisibilityRenderer());
+
+        cpuSharesAmountSelectionEditor =
+                new ListModelListBoxEditor<Object>(new EnumRenderer(), new 
ModeSwitchingVisibilityRenderer());
+        cpuSharesAmountSelectionEditor.asListBox().setWidth("110px"); 
//$NON-NLS-1$
+        
cpuSharesAmountSelectionEditor.getContentWidgetContainer().setWidth("110px"); 
//$NON-NLS-1$
     }
 
     private String typeAheadNameDescriptionTemplateNullSafe(String name, 
String description) {
@@ -937,7 +958,6 @@
         // specificHostEditor.setLabel("Specific");
         hostCpuEditor.setLabel(constants.useHostCpu());
         cpuPinning.setLabel(constants.cpuPinningLabel());
-        cpuPinningLabel.setHTML(constants.cpuPinningLabelExplanation());
 
         // High Availability Tab
         isHighlyAvailableEditor.setLabel(constants.highlyAvailableVmPopup());
@@ -951,6 +971,7 @@
         provisioningThinEditor.setLabel(constants.thinVmPopup());
         provisioningCloneEditor.setLabel(constants.cloneVmPopup());
         minAllocatedMemoryEditor.setLabel(constants.physMemGuarVmPopup());
+        cpuSharesAmountSelectionEditor.setLabel(constants.cpuShares());
 
         // Boot Options
         firstBootDeviceEditor.setLabel(constants.firstDeviceVmPopup());
@@ -1207,16 +1228,6 @@
                     specificHost.setValue(true, true);
             }
         });
-
-        changeApplicationLevelVisibility(cpuPinningLabel, 
vm.getCpuPinning().getIsChangable());
-        vm.getCpuPinning().getPropertyChangedEvent().addListener(new 
IEventListener() {
-
-            @Override
-            public void eventRaised(Event ev, Object sender, EventArgs args) {
-                changeApplicationLevelVisibility(cpuPinningLabel, 
vm.getCpuPinning().getIsChangable());
-            }
-        });
-
     }
 
     private void updateDisksWarningByImageStatus(List<DiskModel> disks, 
ImageStatus imageStatus) {
@@ -1331,7 +1342,6 @@
         defaultHostEditor.setTabIndex(nextTabIndex++);
         migrationModeEditor.setTabIndex(nextTabIndex++);
         hostCpuEditor.setTabIndex(nextTabIndex++);
-        cpuPinning.setTabIndex(nextTabIndex++);
 
         // ==High Availability Tab==
         nextTabIndex = highAvailabilityTab.setTabIndexes(nextTabIndex);
@@ -1347,6 +1357,8 @@
         provisioningEditor.setTabIndex(nextTabIndex++);
         provisioningThinEditor.setTabIndex(nextTabIndex++);
         provisioningCloneEditor.setTabIndex(nextTabIndex++);
+        cpuPinning.setTabIndex(nextTabIndex++);
+        cpuSharesAmountEditor.setTabIndex(nextTabIndex++);
         nextTabIndex = disksAllocationView.setTabIndexes(nextTabIndex);
 
         // ==Boot Options Tab==
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
index dd378ca..cf319cd 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
@@ -17,6 +17,10 @@
                        margin-bottom: 20px;
                }
 
+        .sectionPanelTight {
+            margin-bottom: 6px;
+        }
+
                .sectionLabel {
                        font-weight: bold;
                        margin-top: 10px;
@@ -135,14 +139,10 @@
                        bottom: 10px;
                }
 
-               .explanationLabel {
-                       font-style: italic;
-                       margin-left: 40px;
-                       margin-bottom: 10px;
-                       width: 300px;
-               }
+
 
                .cpuPinningStyle {
+            float: left;
                }
 
                .expanderContent,.generalExpanderContent {
@@ -251,6 +251,32 @@
             float: left;
             color: #333333;
             width: 250px;
+        }
+
+        .cpuPinningLabel {
+            float: left;
+            color: #333333;
+            width: 220px;
+            margin: 5px;
+        }
+
+        .cpuSharesSelector {
+            float: left;
+            width: 370px;
+        }
+
+        .cpuSharesSelectorInner {
+            float: left;
+            width: 100px;
+        }
+
+        .cpuSahresValue {
+            width: 120px;
+            float:left;
+        }
+
+        .cpuSharesValueInner {
+            width: 120px;
         }
        </ui:style>
 
@@ -428,8 +454,6 @@
                                                        
<e:ListModelListBoxEditor ui:field="migrationModeEditor" 
addStyleNames="{style.migrationSelect}"/>
                                                        
<e:EntityModelCheckBoxEditor ui:field="hostCpuEditor" 
addStyleNames="{style.checkbox}" />
                                                </g:VerticalPanel>
-                                               <e:EntityModelTextBoxEditor 
ui:field="cpuPinning" addStyleNames="{style.cpuPinningStyle}"/>
-                                               <g:HTML 
ui:field="cpuPinningLabel" 
addStyleNames="{style.explanationLabel},generalDialogComment" />
                                        </g:FlowPanel>
                                </t:content>
                        </t:DialogTab>
@@ -458,12 +482,20 @@
                        <t:DialogTab ui:field="resourceAllocationTab">
                                <t:content>
                                        <g:FlowPanel>
-                                               <g:FlowPanel 
addStyleNames="{style.sectionPanel}">
+                        <g:FlowPanel addStyleNames="{style.sectionPanelTight}">
+                            <g:Label addStyleNames="{style.sectionLabel}" 
text="{constants.cpuAllocVmPopup}" />
+                            <e:ListModelListBoxEditor 
ui:field="cpuSharesAmountSelectionEditor" 
addStyleNames="{style.cpuSharesSelector}"/>
+                            <e:EntityModelTextBoxOnlyEditor 
ui:field="cpuSharesAmountEditor" addStyleNames="{style.cpuSahresValue}"/>
+                            <g:Label text="{constants.cpuPinningLabel}" 
addStyleNames="{style.cpuPinningLabel}"/>
+                            <d:InfoIcon ui:field="cpuPinningInfo" 
addStyleNames="{style.poolNameIcon}" />
+                            <e:EntityModelTextBoxOnlyEditor 
ui:field="cpuPinning" addStyleNames="{style.cpuPinningStyle}"/>
+                        </g:FlowPanel>
+                                               <g:FlowPanel 
addStyleNames="{style.sectionPanelTight}">
                                                        <g:Label 
addStyleNames="{style.sectionLabel}" text="{constants.memAllocVmPopup}" />
                                                        
<e:EntityModelTextBoxEditor ui:field="minAllocatedMemoryEditor" />
                                                        
<e:EntityModelCheckBoxEditor addStyleNames="{style.checkbox}" 
ui:field="isMemoryBalloonDeviceEnabled"/>
                                                </g:FlowPanel>
-                                               <g:FlowPanel 
ui:field="storageAllocationPanel" addStyleNames="{style.sectionPanel}">
+                                               <g:FlowPanel 
ui:field="storageAllocationPanel" addStyleNames="{style.sectionPanelTight}">
                                                        <g:HorizontalPanel>
                                                                <g:Label 
addStyleNames="{style.sectionLabel}" text="{constants.storageAllocVmPopup}" />
                                                                <g:Label 
addStyleNames="{style.sectionComment}" 
text="{constants.availOnlyTemplSelectedVmPopup}" />
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
index 3aeded3..b33403a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
@@ -171,6 +171,8 @@
         getModel().getCustomProperties().setEntity(vm.getCustomProperties());
         
getModel().getCustomPropertySheet().setEntity(vm.getCustomProperties());
         getModel().getCpuPinning().setEntity(vm.getCpuPinning());
+        getModel().getCpuSharesAmount().setEntity(vm.getCpuShares());
+        updateCpuSharesSelection();
 
         Frontend.RunQuery(VdcQueryType.GetWatchdog, new 
IdQueryParameters(getVm().getId()), new AsyncQuery(this,
                 new INewAsyncCallback() {
@@ -251,6 +253,7 @@
         updateCpuPinningVisibility();
         initNetworkInterfaces();
         updateMemoryBalloon();
+        updateCpuSharesAvailability();
     }
 
     private void initNetworkInterfaces() {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
index 3d195cc..a9c7cb7 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
@@ -173,6 +173,7 @@
     {
         updateQuotaByCluster(null, null);
         updateMemoryBalloon();
+        updateCpuSharesAvailability();
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
index 86b162e..c10a426 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
@@ -187,6 +187,7 @@
         updateTemplate();
         initNetworkInterfaces(networkBehavior, null);
         updateMemoryBalloon();
+        updateCpuSharesAvailability();
     }
 
     private void updateNetworkInterfacesByTemplate(VmTemplate template) {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
index 97d5fb3..b275546 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
@@ -198,6 +198,7 @@
             updateQuotaByCluster(template.getQuotaId(), 
template.getQuotaName());
         }
         updateMemoryBalloon();
+        updateCpuSharesAvailability();
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
index 4258839..2c49da7 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
@@ -112,6 +112,7 @@
         updateNumOfSockets();
         updateQuotaByCluster(template.getQuotaId(), template.getQuotaName());
         updateMemoryBalloon();
+        updateCpuSharesAvailability();
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index a141593..cab7529 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -1076,6 +1076,26 @@
         this.cpuPinning = cpuPinning;
     }
 
+    private NotChangableForVmInPoolEntityModel cpuSharesAmount;
+
+    public EntityModel getCpuSharesAmount() {
+        return cpuSharesAmount;
+    }
+
+    public void setCpuSharesAmount(NotChangableForVmInPoolEntityModel 
cpuSharesAmount) {
+        this.cpuSharesAmount = cpuSharesAmount;
+    }
+
+    private NotChangableForVmInPoolListModel cpuSharesAmountSelection;
+
+    public ListModel getCpuSharesAmountSelection() {
+        return cpuSharesAmountSelection;
+    }
+
+    public void setCpuSharesAmountSelection(NotChangableForVmInPoolListModel 
cpuSharesAmountSelection) {
+        this.cpuSharesAmountSelection = cpuSharesAmountSelection;
+    }
+
     private ListModel vncKeyboardLayout;
 
     public ListModel getVncKeyboardLayout() {
@@ -1272,6 +1292,16 @@
         getCpuPinning().setEntity("");
         getCpuPinning().setIsChangable(false);
 
+        setCpuSharesAmount(new NotChangableForVmInPoolEntityModel());
+        getCpuSharesAmount().setEntity("");
+        getCpuSharesAmount().setIsChangable(false);
+
+        setCpuSharesAmountSelection(new NotChangableForVmInPoolListModel());
+        
getCpuSharesAmountSelection().setItems(Arrays.asList(CpuSharesAmount.values()));
+        
getCpuSharesAmountSelection().getEntityChangedEvent().addListener(this);
+        
getCpuSharesAmountSelection().getSelectedItemChangedEvent().addListener(this);
+        getCpuSharesAmountSelection().setSelectedItem(CpuSharesAmount.MEDIUM);
+
         setIsSoundcardEnabled(new NotChangableForVmInPoolEntityModel());
         getIsSoundcardEnabled().setEntity(false);
         getIsSoundcardEnabled().setIsChangable(false);
@@ -1379,6 +1409,10 @@
                 behavior.updateCpuPinningVisibility();
                 behavior.updateHaAvailability();
             }
+            else if (sender == getCpuSharesAmountSelection())
+            {
+                behavior.updateCpuSharesAmountChangeability();
+            }
         }
         else if 
(ev.matchesDefinition(EntityModel.EntityChangedEventDefinition))
         {
@@ -1461,14 +1495,12 @@
 
                         UnitVmModel model = (UnitVmModel) target;
                         Integer oldNumOfMonitors = null;
-                        if (model.getNumOfMonitors().getSelectedItem() != null)
-                        {
+                        if (model.getNumOfMonitors().getSelectedItem() != 
null) {
                             oldNumOfMonitors = (Integer) 
model.getNumOfMonitors().getSelectedItem();
                         }
                         ArrayList<Integer> numOfMonitors = 
(ArrayList<Integer>) returnValue;
                         model.getNumOfMonitors().setItems(numOfMonitors);
-                        if (oldNumOfMonitors != null)
-                        {
+                        if (oldNumOfMonitors != null) {
                             
model.getNumOfMonitors().setSelectedItem(oldNumOfMonitors);
                         }
 
@@ -2098,6 +2130,11 @@
             }
         }
 
+        if (getCpuSharesAmount().getIsAvailable()) {
+            getCpuSharesAmount().validateEntity(new IValidation[] {new 
NotEmptyValidation()
+                    , new IntegerValidation(0, 262144)});
+        }
+
         boolean customPropertySheetValid = getCustomPropertySheet().validate();
 
         setIsBootSequenceTabValid(true);
@@ -2114,7 +2151,8 @@
         setIsFirstRunTabValid(getDomain().getIsValid() && 
getTimeZone().getIsValid());
         setIsDisplayTabValid(getUsbPolicy().getIsValid() && 
getNumOfMonitors().getIsValid());
         setIsHostTabValid(getDefaultHost().getIsValid());
-        setIsAllocationTabValid(getDisksAllocationModel().getIsValid() && 
getMinAllocatedMemory().getIsValid());
+        setIsAllocationTabValid(getDisksAllocationModel().getIsValid() && 
getMinAllocatedMemory().getIsValid()
+                && getCpuSharesAmount().getIsValid());
         setIsBootSequenceTabValid(getCdImage().getIsValid() && 
getKernel_path().getIsValid());
         setIsCustomPropertiesTabValid(customPropertySheetValid);
 
@@ -2126,6 +2164,7 @@
                 && getKernel_path().getIsValid()
                 && getInitrd_path().getIsValid()
                 && getKernel_parameters().getIsValid()
+                && getCpuSharesAmount().getIsValid()
                 && behavior.validate()
                 && customPropertySheetValid && getQuota().getIsValid();
 
@@ -2330,4 +2369,16 @@
 
         return dataCenterWithCluster.getCluster();
     }
+
+    public static enum CpuSharesAmount {
+        LOW(512), MEDIUM(1024), HIGH(2048), CUSTOM(-1);
+
+        private int value;
+        private CpuSharesAmount(int value) {
+            this.value = value;
+        }
+        public int getValue() {
+            return value;
+        }
+    }
 }
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 65cd92a..ea91344 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
@@ -1991,10 +1991,13 @@
         EntityModel prioritySelectedItem = (EntityModel) 
model.getPriority().getSelectedItem();
         getcurrentVm().setPriority((Integer) prioritySelectedItem.getEntity());
 
-        getcurrentVm().setCpuPinning((String) model.getCpuPinning()
-                .getEntity());
+        getcurrentVm().setCpuPinning((String) 
model.getCpuPinning().getEntity());
         getcurrentVm().setVncKeyboardLayout((String) 
model.getVncKeyboardLayout().getSelectedItem());
 
+        if (model.getCpuSharesAmount().getIsAvailable()) {
+            
getcurrentVm().setCpuShares(Integer.parseInt(model.getCpuSharesAmount().getEntity().toString()));
+        }
+
         if ((Boolean) model.getIsAutoAssign().getEntity()) {
             getcurrentVm().setDedicatedVmForVds(null);
         }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
index 9108a07..8da7cb3 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
@@ -661,6 +661,17 @@
         }
     }
 
+
+    protected void updateCpuSharesAvailability() {
+        if (getModel().getSelectedCluster() != null) {
+            VDSGroup cluster = getModel().getSelectedCluster();
+            boolean availableCpuShares = cluster.getcompatibility_version()
+                    .compareTo(Version.v3_3) >= 0;
+            
getModel().getCpuSharesAmountSelection().setIsAvailable(availableCpuShares);
+            getModel().getCpuSharesAmount().setIsAvailable(availableCpuShares);
+        }
+    }
+
     protected void setupTemplate(VM vm, ListModel model) {
         AsyncDataProvider.getTemplateById(new AsyncQuery(getModel(),
                 new INewAsyncCallback() {
@@ -695,11 +706,11 @@
                 hasCpuPinning = false;
             }
 
-            getModel().getCpuPinning()
-                    .setIsChangable(hasCpuPinning);
             if (!hasCpuPinning) {
+                
getModel().getCpuPinning().setChangeProhibitionReason(constants.cpuPinningUnavailable());
                 getModel().getCpuPinning().setEntity("");
             }
+            getModel().getCpuPinning().setIsChangable(hasCpuPinning);
         }
     }
 
@@ -744,6 +755,25 @@
 
     }
 
+    public void updateCpuSharesAmountChangeability() {
+        boolean changeable =
+                getModel().getCpuSharesAmountSelection().getSelectedItem() == 
UnitVmModel.CpuSharesAmount.CUSTOM;
+        getModel().getCpuSharesAmount().setIsChangable(changeable);
+        getModel().getCpuSharesAmount()
+                .setEntity(changeable
+                        ? "" //$NON-NLS-1$
+                        : ((UnitVmModel.CpuSharesAmount) 
getModel().getCpuSharesAmountSelection()
+                        .getSelectedItem()).getValue());
+    }
+
+    public void updateCpuSharesSelection() {
+        for (UnitVmModel.CpuSharesAmount cpuSharesAmount : 
UnitVmModel.CpuSharesAmount.values()) {
+            if (cpuSharesAmount.getValue() == 
(Integer)getModel().getCpuSharesAmount().getEntity()) {
+                
getModel().getCpuSharesAmountSelection().setSelectedItem(cpuSharesAmount);
+            }
+        }
+    }
+
     private boolean isVmMigratable() {
         return getModel().getMigrationMode().getSelectedItem() != 
MigrationSupport.PINNED_TO_HOST;
     }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index 8d49d43..30b1275 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -810,4 +810,13 @@
     String AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED();
 
     String AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED();
+
+    String UnitVmModel$CpuSharesAmount___HIGH();
+
+    String UnitVmModel$CpuSharesAmount___MEDIUM();
+
+    String UnitVmModel$CpuSharesAmount___LOW();
+
+    String UnitVmModel$CpuSharesAmount___CUSTOM();
+
 }
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 494c2b8..8e72e11 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
@@ -1887,6 +1887,9 @@
     @DefaultStringValue("'Use Host CPU' is only available for cluster 
compatible with ver 3.2 or higher, when 'Do not allow migration' is selected or 
'Allow manual migration' is selected and no host is specified) ")
     String hosCPUUnavailable();
 
+    @DefaultStringValue("'CPU Pinning topology' is only available for cluster 
compatible with ver 3.1 or higher, when 'Do not allow migration' is selected 
and host is specified")
+    String cpuPinningUnavailable();
+
     @DefaultStringValue("Low")
     String vmLowPriority();
 
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index d779e0b..2c264e0 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -403,3 +403,7 @@
 AuditLogType___USER_ADD_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED=A trusted 
Template was created from non-trusted VM
 AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED=Template 
moved from trusted cluster to non-trusted cluster
 AuditLogType___USER_UPDATE_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED=Template 
moved from non-trusted cluster to trusted cluster
+UnitVmModel$CpuSharesAmount___HIGH=High
+UnitVmModel$CpuSharesAmount___MEDIUM=Medium
+UnitVmModel$CpuSharesAmount___LOW=Low
+UnitVmModel$CpuSharesAmount___CUSTOM=Custom
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationTemplates.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationTemplates.java
index 77120e8..908a364 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationTemplates.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationTemplates.java
@@ -121,9 +121,6 @@
     @Template("<i>{0}<br />{1}</i>")
     SafeHtml italicTwoLines(String firstLine, String secondLine);
 
-    @Template("<div style='width: {0}; font-style: italic;'>{1}</div>")
-    SafeHtml italicFixedWidth(String pxWidth, String text);
-
     @Template("<div style='background: url({0}) no-repeat; height: {1}px; 
width: {2}px;'></div>")
     SafeHtml image(String url, int height, int width);
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c975cf521f8aa18d3a6836dee31fd249a8815bb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: ofri masad <oma...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to