Alona Kaplan has uploaded a new change for review.

Change subject: webadmin: Wrong vnics when creating vm from blank template
......................................................................

webadmin: Wrong vnics when creating vm from blank template

The 'Blank' template belongs to the 'Default' dc/cluster.
If the 'Blank' template has vnics with profiles, when creating a vm in
different cluster than 'Default' the vnic profiles (which don't exist in
the vm's cluster) should be overridden by 'Empty' profile.

This override happens in EditProfileBehavior->initSelectedProfile, but
since it is called before the registration of ProfileInstanceTypeEditor
to SelectedItemChangedEvent of VnicInstanceType the new selection of
'Empty' profile isn't reflected on VnicInstanceType.NetworkInterface.

This patch fixes it by calling syncSelectedItemWithNetworkInterface(..)
also before the registration and not just from the eventRaised(..).

Change-Id: I60be6b21050c43bb004e56688f8e306b5b943d24
Bug-Url: https://bugzilla.redhat.com/1103058
Signed-off-by: Alona Kaplan <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java
1 file changed, 10 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/30637/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java
index 65277ff..45d128d 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java
@@ -71,24 +71,29 @@
     public void edit(final VnicInstanceType model) {
         driver.edit(model);
 
-        final VmNetworkInterface vnic = model.getNetworkInterface();
-        String vnicName = vnic.getName();
+        String vnicName = model.getNetworkInterface().getName();
 
         profileEditor.addLabelStyleName(style.noDisplay());
         profileEditor.addContentWidgetStyleName(style.contentStyle());
         profileEditor.setElementId(ElementIdUtils.createElementId(elementId, 
vnicName));
+        syncSelectedItemWithNetworkInterface(model);
         model.getSelectedItemChangedEvent().addListener(new IEventListener() {
 
             @Override
             public void eventRaised(Event ev, Object sender, EventArgs args) {
-                VnicProfileView profile = model.getSelectedItem();
-                vnic.setVnicProfileId(profile != null ? profile.getId() : 
null);
-                vnic.setNetworkName(profile != null ? profile.getNetworkName() 
: null);
+                syncSelectedItemWithNetworkInterface(model);
                 ValueChangeEvent.fire(ProfileInstanceTypeEditor.this, model);
             }
         });
     }
 
+    private void syncSelectedItemWithNetworkInterface(final VnicInstanceType 
model) {
+        final VmNetworkInterface vnic = model.getNetworkInterface();
+        VnicProfileView profile = model.getSelectedItem();
+        vnic.setVnicProfileId(profile != null ? profile.getId() : null);
+        vnic.setNetworkName(profile != null ? profile.getNetworkName() : null);
+    }
+
     @Override
     public VnicInstanceType flush() {
         return driver.flush();


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

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

Reply via email to