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

This commit is contained in:
Alena Prokharchyk 2013-09-17 17:03:31 -07:00
parent 4f61396c61
commit d3d49bd0aa

View File

@ -33,6 +33,7 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network; import com.cloud.network.Network;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.User; import com.cloud.user.User;
@ -152,7 +153,26 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
@Override @Override
public String getEventDescription() { 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 @Override