use of com.cloud.network.dao.NetworkExternalFirewallVO in project cloudstack by apache.
the class JuniperSRXExternalFirewallElement method configureSrxFirewall.
@Override
public ExternalFirewallDeviceVO configureSrxFirewall(ConfigureSrxFirewallCmd cmd) {
Long fwDeviceId = cmd.getFirewallDeviceId();
Long deviceCapacity = cmd.getFirewallCapacity();
ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
throw new InvalidParameterValueException("No SRX firewall device found with ID: " + fwDeviceId);
}
if (deviceCapacity != null) {
// check if any networks are using this SRX device
List<NetworkExternalFirewallVO> networks = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId);
if ((networks != null) && !networks.isEmpty()) {
if (deviceCapacity < networks.size()) {
throw new CloudRuntimeException("There are more number of networks already using this SRX firewall device than configured capacity");
}
}
if (deviceCapacity != null) {
fwDeviceVO.setCapacity(deviceCapacity);
}
}
fwDeviceVO.setDeviceState(FirewallDeviceState.Enabled);
_fwDevicesDao.update(fwDeviceId, fwDeviceVO);
return fwDeviceVO;
}
use of com.cloud.network.dao.NetworkExternalFirewallVO in project cloudstack by apache.
the class PaloAltoExternalFirewallElement method listNetworks.
@Override
public List<? extends Network> listNetworks(ListPaloAltoFirewallNetworksCmd cmd) {
Long fwDeviceId = cmd.getFirewallDeviceId();
List<NetworkVO> networks = new ArrayList<NetworkVO>();
ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId);
if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) {
throw new InvalidParameterValueException("Could not find Palo Alto firewall device with ID " + fwDeviceId);
}
List<NetworkExternalFirewallVO> networkFirewallMaps = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId);
if (networkFirewallMaps != null && !networkFirewallMaps.isEmpty()) {
for (NetworkExternalFirewallVO networkFirewallMap : networkFirewallMaps) {
NetworkVO network = _networkDao.findById(networkFirewallMap.getNetworkId());
networks.add(network);
}
}
return networks;
}
use of com.cloud.network.dao.NetworkExternalFirewallVO in project cloudstack by apache.
the class ExternalFirewallDeviceManagerImpl method getExternalFirewallForNetwork.
@Override
public ExternalFirewallDeviceVO getExternalFirewallForNetwork(Network network) {
NetworkExternalFirewallVO fwDeviceForNetwork = _networkExternalFirewallDao.findByNetworkId(network.getId());
if (fwDeviceForNetwork != null) {
long fwDeviceId = fwDeviceForNetwork.getExternalFirewallDeviceId();
ExternalFirewallDeviceVO fwDevice = _externalFirewallDeviceDao.findById(fwDeviceId);
assert (fwDevice != null);
return fwDevice;
}
return null;
}
use of com.cloud.network.dao.NetworkExternalFirewallVO in project cloudstack by apache.
the class ExternalFirewallDeviceManagerImpl method findSuitableFirewallForNetwork.
@Override
public ExternalFirewallDeviceVO findSuitableFirewallForNetwork(Network network) throws InsufficientCapacityException {
long physicalNetworkId = network.getPhysicalNetworkId();
List<ExternalFirewallDeviceVO> fwDevices = _externalFirewallDeviceDao.listByPhysicalNetwork(physicalNetworkId);
// loop through the firewall device in the physical network and pick the first-fit
for (ExternalFirewallDeviceVO fwDevice : fwDevices) {
// max number of guest networks that can be mapped to this device
long fullCapacity = fwDevice.getCapacity();
if (fullCapacity == 0) {
// if capacity not configured then use the default
fullCapacity = _defaultFwCapacity;
}
// get the list of guest networks that are mapped to this load balancer
List<NetworkExternalFirewallVO> mappedNetworks = _networkExternalFirewallDao.listByFirewallDeviceId(fwDevice.getId());
long usedCapacity = (mappedNetworks == null) ? 0 : mappedNetworks.size();
if ((fullCapacity - usedCapacity) > 0) {
return fwDevice;
}
}
throw new InsufficientNetworkCapacityException("Unable to find a firewall provider with sufficient capcity " + " to implement the network", DataCenter.class, network.getDataCenterId());
}
use of com.cloud.network.dao.NetworkExternalFirewallVO in project cloudstack by apache.
the class ExternalFirewallDeviceManagerImpl method setExternalFirewallForNetwork.
public void setExternalFirewallForNetwork(Network network, long externalFWDeviceID) {
NetworkExternalFirewallVO fwDeviceForNetwork = new NetworkExternalFirewallVO(network.getId(), externalFWDeviceID);
_networkExternalFirewallDao.persist(fwDeviceForNetwork);
}
Aggregations