Search in sources :

Example 1 with PaloAltoFirewallResponse

use of com.cloud.api.response.PaloAltoFirewallResponse 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 2 with PaloAltoFirewallResponse

use of com.cloud.api.response.PaloAltoFirewallResponse in project cloudstack by apache.

the class AddPaloAltoFirewallCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        ExternalFirewallDeviceVO fwDeviceVO = _paFwService.addPaloAltoFirewall(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 add Palo Alto 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) PaloAltoFirewallResponse(com.cloud.api.response.PaloAltoFirewallResponse) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 3 with PaloAltoFirewallResponse

use of com.cloud.api.response.PaloAltoFirewallResponse in project cloudstack by apache.

the class ListPaloAltoFirewallsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<ExternalFirewallDeviceVO> fwDevices = _paFwService.listPaloAltoFirewalls(this);
        ListResponse<PaloAltoFirewallResponse> response = new ListResponse<PaloAltoFirewallResponse>();
        List<PaloAltoFirewallResponse> fwDevicesResponse = new ArrayList<PaloAltoFirewallResponse>();
        if (fwDevices != null && !fwDevices.isEmpty()) {
            for (ExternalFirewallDeviceVO fwDeviceVO : fwDevices) {
                PaloAltoFirewallResponse deviceResponse = _paFwService.createPaloAltoFirewallResponse(fwDeviceVO);
                fwDevicesResponse.add(deviceResponse);
            }
        }
        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) PaloAltoFirewallResponse(com.cloud.api.response.PaloAltoFirewallResponse) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList)

Example 4 with PaloAltoFirewallResponse

use of com.cloud.api.response.PaloAltoFirewallResponse in project cloudstack by apache.

the class PaloAltoExternalFirewallElement method createPaloAltoFirewallResponse.

@Override
public PaloAltoFirewallResponse createPaloAltoFirewallResponse(ExternalFirewallDeviceVO fwDeviceVO) {
    PaloAltoFirewallResponse response = new PaloAltoFirewallResponse();
    Map<String, String> fwDetails = _hostDetailDao.findDetails(fwDeviceVO.getHostId());
    Host fwHost = _hostDao.findById(fwDeviceVO.getHostId());
    response.setId(fwDeviceVO.getUuid());
    PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(fwDeviceVO.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    response.setDeviceName(fwDeviceVO.getDeviceName());
    if (fwDeviceVO.getCapacity() == 0) {
        long defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50);
        response.setDeviceCapacity(defaultFwCapacity);
    } else {
        response.setDeviceCapacity(fwDeviceVO.getCapacity());
    }
    response.setProvider(fwDeviceVO.getProviderName());
    response.setDeviceState(fwDeviceVO.getDeviceState().name());
    response.setIpAddress(fwHost.getPrivateIpAddress());
    response.setPublicInterface(fwDetails.get("publicInterface"));
    response.setUsageInterface(fwDetails.get("usageInterface"));
    response.setPrivateInterface(fwDetails.get("privateInterface"));
    response.setPublicZone(fwDetails.get("publicZone"));
    response.setPrivateZone(fwDetails.get("privateZone"));
    response.setNumRetries(fwDetails.get("numRetries"));
    response.setTimeout(fwDetails.get("timeout"));
    response.setObjectName("paloaltofirewall");
    return response;
}
Also used : PaloAltoFirewallResponse(com.cloud.api.response.PaloAltoFirewallResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) Host(com.cloud.host.Host)

Aggregations

PaloAltoFirewallResponse (com.cloud.api.response.PaloAltoFirewallResponse)4 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)3 ExternalFirewallDeviceVO (com.cloud.network.dao.ExternalFirewallDeviceVO)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)3 Host (com.cloud.host.Host)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1