Skip to content

Commit d3d49bd

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-4632: updateNetwork with the new network offering - log original and new network offerings' ids in the Action event
1 parent 4f61396 commit d3d49bd

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.cloud.exception.InsufficientCapacityException;
3434
import com.cloud.exception.InvalidParameterValueException;
3535
import com.cloud.network.Network;
36+
import com.cloud.offering.NetworkOffering;
3637
import com.cloud.user.Account;
3738
import com.cloud.user.User;
3839

@@ -152,7 +153,26 @@ public void execute() throws InsufficientCapacityException, ConcurrentOperationE
152153

153154
@Override
154155
public String getEventDescription() {
155-
return "Updating network: " + getId();
156+
157+
158+
StringBuffer eventMsg = new StringBuffer("Updating network: " + getId());
159+
if (getNetworkOfferingId() != null) {
160+
Network network = _networkService.getNetwork(getId());
161+
if (network == null) {
162+
throw new InvalidParameterValueException("Networkd id=" + id + " doesn't exist");
163+
}
164+
if (network.getNetworkOfferingId() != getNetworkOfferingId()) {
165+
NetworkOffering oldOff = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
166+
NetworkOffering newOff = _entityMgr.findById(NetworkOffering.class, getNetworkOfferingId());
167+
if (newOff == null) {
168+
throw new InvalidParameterValueException("Networkd offering id supplied is invalid");
169+
}
170+
171+
eventMsg.append(". Original network offering id: " + oldOff.getUuid() + ", new network offering id: " + newOff.getUuid());
172+
}
173+
}
174+
175+
return eventMsg.toString();
156176
}
157177

158178
@Override

0 commit comments

Comments
 (0)