Alona Kaplan has uploaded a new change for review.

Change subject: webadmin: Edit vNic Profile- disable pm if the profile is used 
by a vm
......................................................................

webadmin: Edit vNic Profile- disable pm if the profile is used by a vm

Port mirroring checkbox should be disabled if the VNIC profile
is used by a VM.

Bug-Url: https://bugzilla.redhat.com/1031553
Change-Id: I06b851dcfbae9cd1ba48fda20aa0d0db6c3cb6cc
Signed-off-by: Alona Kaplan <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
2 files changed, 39 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/25387/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
index 7187a3c..f87b0c3 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
@@ -1,9 +1,18 @@
 package org.ovirt.engine.ui.uicommonweb.models.profiles;
 
+import java.util.Collection;
+
 import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
+import org.ovirt.engine.core.common.queries.IdQueryParameters;
+import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
+import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.Version;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.Frontend;
+import org.ovirt.engine.ui.frontend.INewAsyncCallback;
 import org.ovirt.engine.ui.uicommonweb.help.HelpTag;
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
@@ -27,6 +36,8 @@
         getDescription().setEntity(profile.getDescription());
         getPortMirroring().setEntity(getProfile().isPortMirroring());
         getPublicUse().setIsAvailable(false);
+
+        updatePortMirroringChangability();
     }
 
     public EditVnicProfileModel(EntityModel sourceModel, Version 
dcCompatibilityVersion, VnicProfile profile, Guid dcId) {
@@ -47,4 +58,29 @@
     protected VdcActionType getVdcActionType() {
         return VdcActionType.UpdateVnicProfile;
     }
+
+    private void updatePortMirroringChangability() {
+        AsyncQuery asyncQuery = new AsyncQuery();
+        asyncQuery.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object ReturnValue)
+            {
+                Collection<VM> vms = (Collection<VM>) ((VdcQueryReturnValue) 
ReturnValue).getReturnValue();
+                if (vms != null && !vms.isEmpty()) {
+                    
getPortMirroring().setChangeProhibitionReason(ConstantsManager.getInstance()
+                            .getConstants()
+                            .portMirroringNotChangedIfUsedByVms());
+                    getPortMirroring().setIsChangable(false);
+                }
+                stopProgress();
+            }
+        };
+
+        IdQueryParameters params =
+                new IdQueryParameters(getProfile().getId());
+        startProgress(null);
+        Frontend.getInstance().runQuery(VdcQueryType.GetVmsByVnicProfileId,
+                params,
+                asyncQuery);
+    }
 }
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 bc04564..9b11bab 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
@@ -1937,6 +1937,9 @@
     @DefaultStringValue("'Port Mirroring' is not supported for 
externally-provided networks")
     String portMirroringNotSupportedExternalNetworks();
 
+    @DefaultStringValue("'Port Mirroring' cannot be changed if the vNIC 
Profile is used by a VM")
+    String portMirroringNotChangedIfUsedByVms();
+
     @DefaultStringValue("Low")
     String vmLowPriority();
 


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

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

Reply via email to