}
@Override
@ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_DELETE, eventDescription = "Deleting physical network TrafficType", async = true)
public boolean deletePhysicalNetworkTrafficType(Long id) {
PhysicalNetworkTrafficTypeVO trafficType = _pNTrafficTypeDao.findById(id);
if (trafficType == null) {
throw new InvalidParameterValueException("Traffic Type with id=" + id + "doesn't exist in the system");
}
// check if there are any networks associated to this physical network with this traffic type
if (TrafficType.Guest.equals(trafficType.getTrafficType())) {
if (!_networksDao.listByPhysicalNetworkTrafficType(trafficType.getPhysicalNetworkId(), trafficType.getTrafficType()).isEmpty()) {
throw new CloudRuntimeException("The Traffic Type is not deletable because there are existing networks with this traffic type:" + trafficType.getTrafficType());
}
} else if (TrafficType.Storage.equals(trafficType.getTrafficType())) {
PhysicalNetworkVO pn = _physicalNetworkDao.findById(trafficType.getPhysicalNetworkId());
if (_stnwMgr.isAnyStorageIpInUseInZone(pn.getDataCenterId())) {
throw new CloudRuntimeException("The Traffic Type is not deletable because there are still some storage network ip addresses in use:" + trafficType.getTrafficType());
}
}
return _pNTrafficTypeDao.remove(id);
}