Search in sources :

Example 1 with ExternalFirewallResponse

use of org.apache.cloudstack.api.response.ExternalFirewallResponse in project cloudstack by apache.

the class AddExternalFirewallCmd method execute.

@SuppressWarnings("deprecation")
@Override
public void execute() {
    try {
        Host externalFirewall = _srxElementService.addExternalFirewall(this);
        ExternalFirewallResponse response = _srxElementService.createExternalFirewallResponse(externalFirewall);
        response.setObjectName("externalfirewall");
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (InvalidParameterValueException ipve) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
    } catch (CloudRuntimeException cre) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Host(com.cloud.host.Host) ExternalFirewallResponse(org.apache.cloudstack.api.response.ExternalFirewallResponse)

Example 2 with ExternalFirewallResponse

use of org.apache.cloudstack.api.response.ExternalFirewallResponse in project cloudstack by apache.

the class ExternalFirewallDeviceManagerImpl method createExternalFirewallResponse.

public ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall) {
    Map<String, String> fwDetails = _hostDetailDao.findDetails(externalFirewall.getId());
    ExternalFirewallResponse response = new ExternalFirewallResponse();
    response.setId(externalFirewall.getUuid());
    response.setIpAddress(externalFirewall.getPrivateIpAddress());
    response.setUsername(fwDetails.get("username"));
    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"));
    return response;
}
Also used : ExternalFirewallResponse(org.apache.cloudstack.api.response.ExternalFirewallResponse)

Example 3 with ExternalFirewallResponse

use of org.apache.cloudstack.api.response.ExternalFirewallResponse in project cloudstack by apache.

the class ListExternalFirewallsCmd method execute.

@SuppressWarnings("deprecation")
@Override
public void execute() {
    List<? extends Host> externalFirewalls = _srxElementService.listExternalFirewalls(this);
    ListResponse<ExternalFirewallResponse> listResponse = new ListResponse<ExternalFirewallResponse>();
    List<ExternalFirewallResponse> responses = new ArrayList<ExternalFirewallResponse>();
    for (Host externalFirewall : externalFirewalls) {
        ExternalFirewallResponse response = _srxElementService.createExternalFirewallResponse(externalFirewall);
        response.setObjectName("externalfirewall");
        response.setResponseName(getCommandName());
        responses.add(response);
    }
    listResponse.setResponses(responses);
    listResponse.setResponseName(getCommandName());
    this.setResponseObject(listResponse);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) ExternalFirewallResponse(org.apache.cloudstack.api.response.ExternalFirewallResponse)

Aggregations

ExternalFirewallResponse (org.apache.cloudstack.api.response.ExternalFirewallResponse)3 Host (com.cloud.host.Host)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1