Updated Branches:
  refs/heads/master 4f61396c6 -> d3d49bd0a

CLOUDSTACK-4632: updateNetwork with the new network offering - log original and 
new network offerings' ids in the Action event


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d3d49bd0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d3d49bd0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d3d49bd0

Branch: refs/heads/master
Commit: d3d49bd0aaa08899ec07a6708d641d49ca8be3e3
Parents: 4f61396
Author: Alena Prokharchyk <[email protected]>
Authored: Tue Sep 17 17:03:31 2013 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Tue Sep 17 17:11:09 2013 -0700

----------------------------------------------------------------------
 .../command/user/network/UpdateNetworkCmd.java  | 22 +++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d3d49bd0/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
index 885feb8..e0cd713 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
@@ -33,6 +33,7 @@ import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.network.Network;
+import com.cloud.offering.NetworkOffering;
 import com.cloud.user.Account;
 import com.cloud.user.User;
 
@@ -152,7 +153,26 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
 
     @Override
     public String getEventDescription() {
-        return  "Updating network: " + getId();
+        
+        
+        StringBuffer eventMsg = new StringBuffer("Updating network: " + 
getId());
+        if (getNetworkOfferingId() != null) {
+            Network network = _networkService.getNetwork(getId());
+            if (network == null) {
+                throw new InvalidParameterValueException("Networkd id=" + id + 
" doesn't exist");
+            }
+            if (network.getNetworkOfferingId() != getNetworkOfferingId()) {
+                NetworkOffering oldOff = 
_entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
+                NetworkOffering newOff = 
_entityMgr.findById(NetworkOffering.class, getNetworkOfferingId());
+                if (newOff == null) {
+                    throw new InvalidParameterValueException("Networkd 
offering id supplied is invalid");
+                }
+
+                eventMsg.append(". Original network offering id: " + 
oldOff.getUuid() + ", new network offering id: " + newOff.getUuid());
+            }
+        }
+            
+        return eventMsg.toString();
     }
 
     @Override

Reply via email to