Shahar Havivi has uploaded a new change for review.

Change subject: core: Enable user defined Windows Sysprep file
......................................................................

core: Enable user defined Windows Sysprep file

Change-Id: I7d257f70784a11f2e1e678d5fc4cd13bb4337a76
Bug-Url: https://bugzilla.redhat.com/1080002
Signed-off-by: Shahar Havivi <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java
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/widget/uicommon/popup/vm/VmInitWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
5 files changed, 54 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/26040/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java
index aa4a416..7068105 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java
@@ -62,7 +62,11 @@
 
     public static String getSysPrep(VM vm, SysPrepParams sysPrepParams) {
         String sysPrepContent = "";
-        sysPrepContent = LoadFile(osRepository.getSysprepPath(vm.getVmOsId(), 
null));
+        if (vm.getVmInit() != null && 
!StringUtils.isEmpty(vm.getVmInit().getCustomScript())) {
+            sysPrepContent = vm.getVmInit().getCustomScript();
+        } else {
+            sysPrepContent = 
LoadFile(osRepository.getSysprepPath(vm.getVmOsId(), null));
+        }
         sysPrepContent = replace(sysPrepContent, "$ProductKey$", 
osRepository.getProductKey(vm.getVmOsId(), null));
 
         String domain = (vm.getVmInit() != null && vm.getVmInit().getDomain() 
!= null) ?
@@ -88,16 +92,16 @@
             String userLocale = Config.<String> 
getValue(ConfigValues.DefaultSysprepLocale);
 
             if (vm.getVmInit() != null) {
-                if (vm.getVmInit().getInputLocale() != null) {
+                if (!StringUtils.isEmpty(vm.getVmInit().getInputLocale())) {
                     inputLocale = vm.getVmInit().getInputLocale();
                 }
-                if (vm.getVmInit().getUiLanguage() != null) {
+                if (!StringUtils.isEmpty(vm.getVmInit().getUiLanguage())) {
                     uiLanguage = vm.getVmInit().getUiLanguage();
                 }
-                if (vm.getVmInit().getSystemLocale() != null) {
+                if (!StringUtils.isEmpty(vm.getVmInit().getSystemLocale())) {
                     systemLocale = vm.getVmInit().getSystemLocale();
                 }
-                if (vm.getVmInit().getUserLocale() != null) {
+                if (!StringUtils.isEmpty(vm.getVmInit().getUserLocale())) {
                     userLocale = vm.getVmInit().getUserLocale();
                 }
             }
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 1c3a40c..f568437 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
@@ -169,6 +169,9 @@
     @DefaultStringValue("User Locale")
     String userLocaleLabel();
 
+    @DefaultStringValue("Sysprep")
+    String sysprepLabel();
+
     @DefaultStringValue("User Name")
     String cloudInitUserNameLabel();
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java
index fd2a0a1..fe2ba9b 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java
@@ -131,6 +131,11 @@
     EntityModelTextBoxEditor userLocaleEditor;
 
     @UiField
+    @Path(value = "sysprepScript.entity")
+    @WithElementId
+    EntityModelTextAreaEditor sysprepScriptEditor;
+
+    @UiField
     @Path(value = "userName.entity")
     @WithElementId
     EntityModelTextBoxEditor userNameEditor;
@@ -248,6 +253,14 @@
 
     @UiField
     @Ignore
+    AdvancedParametersExpander sysprepScriptExpander;
+
+    @UiField
+    @Ignore
+    FlowPanel sysprepScriptExpanderContent;
+
+    @UiField
+    @Ignore
     Label networkLabelSepAddRemove;
 
     @UiField
@@ -322,6 +335,7 @@
         
authenticationExpander.initWithContent(authenticationExpanderContent.getElement());
         networkExpander.initWithContent(networkExpanderContent.getElement());
         
customScriptExpander.initWithContent(customScriptExpanderContent.getElement());
+        
sysprepScriptExpander.initWithContent(sysprepScriptExpanderContent.getElement());
     }
 
     void initCheckBoxEditors() {
@@ -355,6 +369,7 @@
         windowsHostnameEditor.setLabel(constants.cloudInitHostnameLabel());
         inputLocaleEditor.setLabel(constants.inputLocaleLabel());
         uiLanguageEditor.setLabel(constants.uiLanguageLabel());
+        sysprepScriptEditor.setTitle(constants.sysprepLabel());
         systemLocaleEditor.setLabel(constants.systemLocaleLabel());
         userLocaleEditor.setLabel(constants.userLocaleLabel());
         userNameEditor.setLabel(constants.cloudInitUserNameLabel());
@@ -415,6 +430,9 @@
 
         
customScriptExpander.setTitleWhenExpended(constants.customScriptLabel());
         
customScriptExpander.setTitleWhenCollapsed(constants.customScriptLabel());
+
+        sysprepScriptExpander.setTitleWhenExpended(constants.sysprepLabel());
+        sysprepScriptExpander.setTitleWhenCollapsed(constants.sysprepLabel());
     }
 
     void addStyles() {
@@ -428,6 +446,7 @@
         
windowsSysprepTimeZoneEditor.addStyleName(customizableStyle.primaryOption());
         inputLocaleEditor.addStyleName(customizableStyle.primaryOption());
         uiLanguageEditor.addStyleName(customizableStyle.primaryOption());
+        
sysprepScriptEditor.setContentWidgetStyleName(customizableStyle.customScript());
         systemLocaleEditor.addStyleName(customizableStyle.primaryOption());
         userLocaleEditor.addStyleName(customizableStyle.primaryOption());
         userNameEditor.addStyleName(customizableStyle.primaryOption());
@@ -448,6 +467,7 @@
 
         
authenticationExpanderContent.addStyleName(customizableStyle.expanderContent());
         
customScriptExpanderContent.addStyleName(customizableStyle.expanderContent());
+        
sysprepScriptExpanderContent.addStyleName(customizableStyle.expanderContent());
     }
 
     /* Controls style for network options based on network selection */
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml
index eced546..95716e0 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml
@@ -64,6 +64,10 @@
             <e:EntityModelTextBoxEditor ui:field="uiLanguageEditor" />
             <e:EntityModelTextBoxEditor ui:field="systemLocaleEditor" />
             <e:EntityModelTextBoxEditor ui:field="userLocaleEditor" />
+            <d:AdvancedParametersExpander ui:field="sysprepScriptExpander" 
addStyleNames="{style.verticalPanel}"/>
+            <g:FlowPanel ui:field="sysprepScriptExpanderContent" >
+                <e:EntityModelTextAreaEditor ui:field="sysprepScriptEditor" 
labelStyleName="{style.displayNone}" />
+            </g:FlowPanel>
         </g:FlowPanel>
 
         <g:FlowPanel ui:field="cloudInitOptionsContent">
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
index 701cb6f..85752f2 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
@@ -127,6 +127,14 @@
         privateDomain = value;
     }
 
+    private EntityModel privateSysprepScript;
+    public EntityModel getSysprepScript() {
+        return privateSysprepScript;
+    }
+    private void setSysprepScript(EntityModel value) {
+        privateSysprepScript = value;
+    }
+
     private EntityModel privateCustomScript;
     public EntityModel getCustomScript() {
         return privateCustomScript;
@@ -387,6 +395,7 @@
         setUiLanguage(new EntityModel());
         setSystemLocale(new EntityModel());
         setUserLocale(new EntityModel());
+        setSysprepScript(new EntityModel());
 
         setHostname(new EntityModel());
         setDomain(new EntityModel());
@@ -453,6 +462,7 @@
         getUiLanguage().setEntity("");
         getSystemLocale().setEntity("");
         getUserLocale().setEntity("");
+        getSysprepScript().setEntity("");
         getHostname().setEntity("");
         getDomain().setEntity("");
         getUserName().setEntity("");
@@ -533,7 +543,11 @@
             }
 
             if (!StringHelper.isNullOrEmpty(vmInit.getCustomScript())) {
-                getCustomScript().setEntity(vmInit.getCustomScript());
+                if (isWindowsOS) {
+                    getSysprepScript().setEntity(vmInit.getCustomScript());
+                } else {
+                    getCustomScript().setEntity(vmInit.getCustomScript());
+                }
             }
 
             initNetworks(vmInit);
@@ -769,6 +783,9 @@
             vmInit.setUiLanguage((String)getUiLanguage().getEntity());
             vmInit.setSystemLocale((String)getSystemLocale().getEntity());
             vmInit.setUserLocale((String)getUserLocale().getEntity());
+            vmInit.setCustomScript((String) getSysprepScript().getEntity());
+        } else {
+            vmInit.setCustomScript((String) getCustomScript().getEntity());
         }
 
         vmInit.setUserName((String) getUserName().getEntity());
@@ -798,7 +815,6 @@
         }
         vmInit.setDnsServers((String) getDnsServers().getEntity());
         vmInit.setDnsSearch((String) getDnsSearchDomains().getEntity());
-        vmInit.setCustomScript((String) getCustomScript().getEntity());
         vmInit.setPasswordAlreadyStored((Boolean) 
getPasswordSet().getEntity());
 
         return vmInit;


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

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

Reply via email to