From d3d49bd0aaa08899ec07a6708d641d49ca8be3e3 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 17 Sep 2013 17:03:31 -0700 Subject: [PATCH] CLOUDSTACK-4632: updateNetwork with the new network offering - log original and new network offerings' ids in the Action event --- .../user/network/UpdateNetworkCmd.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 885feb8cd9a..e0cd7133e11 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