Search in sources :

Example 1 with OvsProviderResponse

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

the class ListOvsElementsCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    List<? extends OvsProvider> providers = _service.get(0).searchForOvsElement(this);
    ListResponse<OvsProviderResponse> response = new ListResponse<OvsProviderResponse>();
    List<OvsProviderResponse> providerResponses = new ArrayList<OvsProviderResponse>();
    for (OvsProvider provider : providers) {
        OvsProviderResponse providerResponse = _responseGenerator.createOvsProviderResponse(provider);
        providerResponses.add(providerResponse);
    }
    response.setResponses(providerResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) OvsProvider(com.cloud.network.OvsProvider) ArrayList(java.util.ArrayList) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse)

Example 2 with OvsProviderResponse

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

the class ConfigureOvsElementCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Ovs element: " + id);
    OvsProvider result = _service.get(0).configure(this);
    if (result != null) {
        OvsProviderResponse ovsResponse = _responseGenerator.createOvsProviderResponse(result);
        ovsResponse.setResponseName(getCommandName());
        this.setResponseObject(ovsResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the ovs provider");
    }
}
Also used : OvsProvider(com.cloud.network.OvsProvider) ServerApiException(org.apache.cloudstack.api.ServerApiException) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse)

Example 3 with OvsProviderResponse

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

the class ApiResponseHelper method createOvsProviderResponse.

@Override
public OvsProviderResponse createOvsProviderResponse(OvsProvider result) {
    OvsProviderResponse response = new OvsProviderResponse();
    response.setId(result.getUuid());
    PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
    if (nsp != null) {
        response.setNspId(nsp.getUuid());
    }
    response.setEnabled(result.isEnabled());
    response.setObjectName("ovselement");
    return response;
}
Also used : PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse)

Aggregations

OvsProviderResponse (org.apache.cloudstack.api.response.OvsProviderResponse)3 OvsProvider (com.cloud.network.OvsProvider)2 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1