Shahar Havivi has uploaded a new change for review.

Change subject: Engine: RFE: add hostname attribute for windows sysprep
......................................................................

Engine: RFE: add hostname attribute for windows sysprep

Change-Id: I9a787c7436f53a521835ff3a86abc9ef60251003
Bug-Url: https://bugzilla.redhat.com/906243
Signed-off-by: Shahar Havivi <shah...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/CreateVmVDSCommand.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
4 files changed, 41 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/24578/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/CreateVmVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/CreateVmVDSCommand.java
index 3eb7131..70020fc 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/CreateVmVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/CreateVmVDSCommand.java
@@ -75,12 +75,14 @@
         if (vm.isSysprepUsed()) {
             String domain = (vm.getVmInit() != null && 
vm.getVmInit().getDomain() != null) ?
                     vm.getVmInit().getDomain() : "";
+            String hostName = (vm.getVmInit() != null && 
vm.getVmInit().getHostname() != null) ?
+                    vm.getVmInit().getHostname() : "";
             // use answer file to run after sysprep.
             CreateVmFromSysPrepVDSCommandParameters createVmFromSysPrepParam =
                     new CreateVmFromSysPrepVDSCommandParameters(
                             getVdsId(),
                             vm,
-                            vm.getName(),
+                            hostName,
                             domain);
             
createVmFromSysPrepParam.setSysPrepParams(getParameters().getSysPrepParams());
             return new 
CreateVmFromSysPrepVDSCommand<CreateVmFromSysPrepVDSCommandParameters>(createVmFromSysPrepParam);
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 7434ea6..39cef26 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
@@ -107,6 +107,11 @@
     FlowPanel cloudInitOptionsContent;
 
     @UiField
+    @Path(value = "windowsHostname.entity")
+    @WithElementId
+    EntityModelTextBoxEditor windowsHostnameEditor;
+
+    @UiField
     @Path(value = "hostname.entity")
     @WithElementId
     EntityModelTextBoxEditor hostnameEditor;
@@ -323,6 +328,7 @@
 
     void localize() {
         hostnameEditor.setLabel(constants.cloudInitHostnameLabel());
+        windowsHostnameEditor.setLabel(constants.cloudInitHostnameLabel());
         
authorizedKeysEditor.setLabel(constants.cloudInitAuthorizedKeysLabel());
         passwordSetEditor.setLabel(constants.vmInitPasswordSetLabel());
         
regenerateKeysEnabledEditor.setLabel(constants.cloudInitRegenerateKeysLabel());
@@ -353,6 +359,7 @@
         dnsSearchDomains.setLabel(constants.cloudInitDnsSearchDomainsLabel());
 
         hostnameEditor.setTitle(constants.cloudInitHostnameToolTip());
+        windowsHostnameEditor.setTitle(constants.cloudInitHostnameToolTip());
         
authorizedKeysEditor.setTitle(constants.cloudInitAuthorizedKeysToolTip());
         passwordSetEditor.setTitle(constants.vmInitPasswordSetToolTip());
         customScriptEditor.setTitle(constants.customScriptToolTip());
@@ -391,6 +398,7 @@
         networkDhcpEditor.addStyleName(customizableStyle.primaryOption());
         
windowsSysprepTimeZoneEditor.addStyleName(customizableStyle.primaryOption());
         hostnameEditor.addStyleName(customizableStyle.primaryOption());
+        windowsHostnameEditor.addStyleName(customizableStyle.primaryOption());
         domainEditor.addStyleName(customizableStyle.primaryOption());
         timeZoneEnabledEditor.addStyleName(customizableStyle.primaryOption());
         timeZoneEditor.addStyleName(customizableStyle.primaryOption());
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 28d01c3..8c3abf1 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
@@ -58,13 +58,14 @@
        <g:FlowPanel addStyleNames="{style.verticalPanel}" ui:field="mainPanel">
         <g:FlowPanel ui:field="syspreptOptionsContent">
             <e:EntityModelCheckBoxEditor 
ui:field="windowsSyspreptimeZoneEnabledEditor" />
+            <e:EntityModelTextBoxEditor ui:field="windowsHostnameEditor" />
             <e:ListModelListBoxEditor ui:field="windowsSysprepTimeZoneEditor" 
/>
         </g:FlowPanel>
 
         <g:FlowPanel ui:field="cloudInitOptionsContent">
             <g:FlowPanel>
-                <e:EntityModelTextBoxEditor ui:field="hostnameEditor" />
                 <e:EntityModelTextBoxEditor ui:field="domainEditor" />
+                <e:EntityModelTextBoxEditor ui:field="hostnameEditor" />
                 <e:EntityModelCheckBoxEditor ui:field="timeZoneEnabledEditor" 
/>
                 <e:ListModelListBoxEditor ui:field="timeZoneEditor" />
             </g:FlowPanel>
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 2c4df39..97bdf12 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
@@ -34,8 +34,13 @@
 
 public class VmInitModel extends Model {
 
+    private boolean isWindowsOS = false;
     public boolean getHostnameEnabled() {
-        return !StringHelper.isNullOrEmpty((String) getHostname().getEntity());
+        if (isWindowsOS) {
+            return !StringHelper.isNullOrEmpty((String) 
getWindowsHostname().getEntity());
+        } else {
+            return !StringHelper.isNullOrEmpty((String) 
getHostname().getEntity());
+        }
     }
 
     private ListModel windowsSysprepTimeZone;
@@ -56,6 +61,14 @@
 
     public void setWindowsSysprepTimeZoneEnabled(EntityModel 
windowsSysprepTimeZoneEnabled) {
         this.windowsSysprepTimeZoneEnabled = windowsSysprepTimeZoneEnabled;
+    }
+
+    private EntityModel privateWindowsHostname;
+    public EntityModel getWindowsHostname() {
+        return privateWindowsHostname;
+    }
+    private void setWindowsHostname(EntityModel value) {
+        privateWindowsHostname = value;
     }
 
     private EntityModel privateHostname;
@@ -329,6 +342,7 @@
 
         setWindowsSysprepTimeZone(new ListModel());
         setWindowsSysprepTimeZoneEnabled(new EntityModel());
+        setWindowsHostname(new EntityModel());
 
         setHostname(new EntityModel());
         setDomain(new EntityModel());
@@ -389,6 +403,7 @@
         getPasswordSet().setEntity(false);
         getPasswordSet().setIsChangable(false);
 
+        getWindowsHostname().setEntity("");
         getHostname().setEntity("");
         getDomain().setEntity("");
         getRootPassword().setEntity("");
@@ -418,13 +433,14 @@
                 }));
 
         // if not proven to be hidden, show it
-        boolean isWindows = vm != null ? 
AsyncDataProvider.isWindowsOsType(vm.getOsId()) : true;
-        getDomain().setIsAvailable(isWindows);
+        isWindowsOS = vm != null ? 
AsyncDataProvider.isWindowsOsType(vm.getOsId()) : true;
+        getDomain().setIsAvailable(isWindowsOS);
 
         VmInit vmInit = (vm != null) ? vm.getVmInit() : null;
         if (vmInit != null) {
             if (!StringHelper.isNullOrEmpty(vmInit.getHostname())) {
                 getHostname().setEntity(vmInit.getHostname());
+                getWindowsHostname().setEntity(vmInit.getHostname());
             }
             getDomain().setEntity(vmInit.getDomain());
             final String tz = vmInit.getTimeZone();
@@ -522,7 +538,11 @@
     public boolean validate() {
         getHostname().setIsValid(true);
         if (getHostnameEnabled()) {
-            getHostname().validateEntity(new IValidation[] { new 
HostnameValidation() });
+            if (this.isWindowsOS) {
+                getWindowsHostname().validateEntity(new IValidation[] { new 
HostnameValidation() });
+            } else {
+                getHostname().validateEntity(new IValidation[] { new 
HostnameValidation() });
+            }
         }
         getDomain().setIsValid(true);
 
@@ -674,7 +694,8 @@
         VmInit vmInit = new VmInit();
 
         if (getHostnameEnabled()) {
-            vmInit.setHostname((String) getHostname().getEntity());
+            vmInit.setHostname(isWindowsOS ? (String) 
getWindowsHostname().getEntity() :
+                (String) getHostname().getEntity());
         }
 
         if (getRootPasswordEnabled()) {
@@ -837,6 +858,7 @@
     }
 
     public void osTypeChanged(Integer selectedItem) {
-        getDomain().setIsAvailable(selectedItem != null && 
AsyncDataProvider.isWindowsOsType(selectedItem));
+        isWindowsOS = AsyncDataProvider.isWindowsOsType(selectedItem);
+        getDomain().setIsAvailable(selectedItem != null && isWindowsOS);
     }
 }


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

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

Reply via email to