Search in sources :

Example 11 with ExternalFirewallDeviceVO

use of com.cloud.network.dao.ExternalFirewallDeviceVO in project cloudstack by apache.

the class ConfigurePaloAltoFirewallCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        ExternalFirewallDeviceVO fwDeviceVO = _paFwService.configurePaloAltoFirewall(this);
        if (fwDeviceVO != null) {
            PaloAltoFirewallResponse response = _paFwService.createPaloAltoFirewallResponse(fwDeviceVO);
            response.setObjectName("pafirewall");
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure Palo Alto firewall device due to internal error.");
        }
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PaloAltoFirewallResponse(com.cloud.api.response.PaloAltoFirewallResponse) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 12 with ExternalFirewallDeviceVO

use of com.cloud.network.dao.ExternalFirewallDeviceVO in project cloudstack by apache.

the class AddSrxFirewallCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        ExternalFirewallDeviceVO fwDeviceVO = _srxFwService.addSrxFirewall(this);
        if (fwDeviceVO != null) {
            SrxFirewallResponse response = _srxFwService.createSrxFirewallResponse(fwDeviceVO);
            response.setObjectName("srxfirewall");
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add SRX firewall due to internal error.");
        }
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SrxFirewallResponse(com.cloud.api.response.SrxFirewallResponse)

Example 13 with ExternalFirewallDeviceVO

use of com.cloud.network.dao.ExternalFirewallDeviceVO in project cloudstack by apache.

the class PaloAltoExternalFirewallElement method deletePaloAltoFirewall.

@Override
public boolean deletePaloAltoFirewall(DeletePaloAltoFirewallCmd cmd) {
    Long fwDeviceId = cmd.getFirewallDeviceId();
    ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
    if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) {
        throw new InvalidParameterValueException("No Palo Alto firewall device found with ID: " + fwDeviceId);
    }
    return deleteExternalFirewall(fwDeviceVO.getHostId());
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 14 with ExternalFirewallDeviceVO

use of com.cloud.network.dao.ExternalFirewallDeviceVO in project cloudstack by apache.

the class PaloAltoExternalFirewallElement method listPaloAltoFirewalls.

@Override
public List<ExternalFirewallDeviceVO> listPaloAltoFirewalls(ListPaloAltoFirewallsCmd cmd) {
    Long physcialNetworkId = cmd.getPhysicalNetworkId();
    Long fwDeviceId = cmd.getFirewallDeviceId();
    PhysicalNetworkVO pNetwork = null;
    List<ExternalFirewallDeviceVO> fwDevices = new ArrayList<ExternalFirewallDeviceVO>();
    if (physcialNetworkId == null && fwDeviceId == null) {
        throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
    }
    if (fwDeviceId != null) {
        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);
        }
        fwDevices.add(fwDeviceVo);
    }
    if (physcialNetworkId != null) {
        pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
        if (pNetwork == null) {
            throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
        }
        fwDevices = _fwDevicesDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.PaloAlto.getName());
    }
    return fwDevices;
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) ArrayList(java.util.ArrayList)

Example 15 with ExternalFirewallDeviceVO

use of com.cloud.network.dao.ExternalFirewallDeviceVO in project cloudstack by apache.

the class PaloAltoExternalFirewallElement method configurePaloAltoFirewall.

@Override
public ExternalFirewallDeviceVO configurePaloAltoFirewall(ConfigurePaloAltoFirewallCmd cmd) {
    Long fwDeviceId = cmd.getFirewallDeviceId();
    Long deviceCapacity = cmd.getFirewallCapacity();
    ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId);
    if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) {
        throw new InvalidParameterValueException("No Palo Alto firewall device found with ID: " + fwDeviceId);
    }
    if (deviceCapacity != null) {
        // check if any networks are using this Palo Alto 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 Palo Alto 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)

Aggregations

ExternalFirewallDeviceVO (com.cloud.network.dao.ExternalFirewallDeviceVO)26 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)17 ArrayList (java.util.ArrayList)11 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 NetworkExternalFirewallVO (com.cloud.network.dao.NetworkExternalFirewallVO)8 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)8 DataCenterVO (com.cloud.dc.DataCenterVO)7 HostVO (com.cloud.host.HostVO)7 ServerApiException (org.apache.cloudstack.api.ServerApiException)6 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)4 Answer (com.cloud.agent.api.Answer)3 PaloAltoFirewallResponse (com.cloud.api.response.PaloAltoFirewallResponse)3 SrxFirewallResponse (com.cloud.api.response.SrxFirewallResponse)3 Vlan (com.cloud.dc.Vlan)3 NetworkVO (com.cloud.network.dao.NetworkVO)3 InsufficientNetworkCapacityException (com.cloud.exception.InsufficientNetworkCapacityException)2 Host (com.cloud.host.Host)2 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)2 NetworkDevice (org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice)2 IpAssocCommand (com.cloud.agent.api.routing.IpAssocCommand)1