Search in sources :

Example 16 with ExternalFirewallDeviceVO

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

the class ListSrxFirewallsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<ExternalFirewallDeviceVO> fwDevices = _srxFwService.listSrxFirewalls(this);
        ListResponse<SrxFirewallResponse> response = new ListResponse<SrxFirewallResponse>();
        List<SrxFirewallResponse> fwDevicesResponse = new ArrayList<SrxFirewallResponse>();
        if (fwDevices != null && !fwDevices.isEmpty()) {
            for (ExternalFirewallDeviceVO fwDeviceVO : fwDevices) {
                SrxFirewallResponse lbdeviceResponse = _srxFwService.createSrxFirewallResponse(fwDeviceVO);
                fwDevicesResponse.add(lbdeviceResponse);
            }
        }
        response.setResponses(fwDevicesResponse);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } 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) ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SrxFirewallResponse(com.cloud.api.response.SrxFirewallResponse) ArrayList(java.util.ArrayList)

Example 17 with ExternalFirewallDeviceVO

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

the class JuniperSRXExternalFirewallElement method addExternalFirewall.

@Override
@Deprecated
public Host addExternalFirewall(AddExternalFirewallCmd cmd) {
    Long zoneId = cmd.getZoneId();
    DataCenterVO zone = null;
    PhysicalNetworkVO pNetwork = null;
    HostVO fwHost = null;
    zone = _dcDao.findById(zoneId);
    if (zone == null) {
        throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
    }
    List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
    if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
        throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: " + zoneId + " to add this device.");
    }
    pNetwork = physicalNetworks.get(0);
    String deviceType = NetworkDevice.JuniperSRXFirewall.getName();
    ExternalFirewallDeviceVO fwDeviceVO = addExternalFirewall(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceType, new JuniperSrxResource());
    if (fwDeviceVO != null) {
        fwHost = _hostDao.findById(fwDeviceVO.getHostId());
    }
    return fwHost;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) JuniperSrxResource(com.cloud.network.resource.JuniperSrxResource) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) HostVO(com.cloud.host.HostVO)

Example 18 with ExternalFirewallDeviceVO

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

the class JuniperSRXExternalFirewallElement method deleteSrxFirewall.

@Override
public boolean deleteSrxFirewall(DeleteSrxFirewallCmd cmd) {
    Long fwDeviceId = cmd.getFirewallDeviceId();
    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);
    }
    return deleteExternalFirewall(fwDeviceVO.getHostId());
}
Also used : ExternalFirewallDeviceVO(com.cloud.network.dao.ExternalFirewallDeviceVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException)

Example 19 with ExternalFirewallDeviceVO

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

the class JuniperSRXExternalFirewallElement method listNetworks.

@Override
public List<? extends Network> listNetworks(ListSrxFirewallNetworksCmd cmd) {
    Long fwDeviceId = cmd.getFirewallDeviceId();
    List<NetworkVO> networks = new ArrayList<NetworkVO>();
    ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId);
    if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.JuniperSRXFirewall.getName())) {
        throw new InvalidParameterValueException("Could not find SRX 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 20 with ExternalFirewallDeviceVO

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

the class ConfigureSrxFirewallCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        ExternalFirewallDeviceVO fwDeviceVO = _srxFwService.configureSrxFirewall(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 configure SRX 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) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SrxFirewallResponse(com.cloud.api.response.SrxFirewallResponse)

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