Search in sources :

Example 1 with NetworkExternalFirewallVO

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;
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) NetworkExternalFirewallVO(com.cloud.network.dao.NetworkExternalFirewallVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 2 with NetworkExternalFirewallVO

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;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) NetworkExternalFirewallVO(com.cloud.network.dao.NetworkExternalFirewallVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList)

Example 3 with NetworkExternalFirewallVO

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;
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) NetworkExternalFirewallVO(com.cloud.network.dao.NetworkExternalFirewallVO)

Example 4 with NetworkExternalFirewallVO

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());
}
Also used : InsufficientNetworkCapacityException(com.cloud.exception.InsufficientNetworkCapacityException) ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) NetworkExternalFirewallVO(com.cloud.network.dao.NetworkExternalFirewallVO)

Example 5 with NetworkExternalFirewallVO

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);
}
Also used : NetworkExternalFirewallVO(com.cloud.network.dao.NetworkExternalFirewallVO)

Aggregations

NetworkExternalFirewallVO (com.cloud.network.dao.NetworkExternalFirewallVO)10 ExternalFirewallDeviceVO (com.cloud.network.dao.ExternalFirewallDeviceVO)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 InsufficientNetworkCapacityException (com.cloud.exception.InsufficientNetworkCapacityException)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 HostVO (com.cloud.host.HostVO)2 NetworkVO (com.cloud.network.dao.NetworkVO)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 ArrayList (java.util.ArrayList)2 Answer (com.cloud.agent.api.Answer)1 IpAssocCommand (com.cloud.agent.api.routing.IpAssocCommand)1 IpAddressTO (com.cloud.agent.api.to.IpAddressTO)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 VlanVO (com.cloud.dc.VlanVO)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 DetailVO (com.cloud.host.DetailVO)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 InlineLoadBalancerNicMapVO (com.cloud.network.dao.InlineLoadBalancerNicMapVO)1 NetworkOffering (com.cloud.offering.NetworkOffering)1