use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.
the class ApiResponseHelper method createInternalLbElementResponse.
@Override
public InternalLoadBalancerElementResponse createInternalLbElementResponse(VirtualRouterProvider result) {
if (result.getType() != VirtualRouterProvider.Type.InternalLbVm) {
return null;
}
InternalLoadBalancerElementResponse response = new InternalLoadBalancerElementResponse();
response.setId(result.getUuid());
PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
if (nsp != null) {
response.setNspId(nsp.getUuid());
}
response.setEnabled(result.isEnabled());
response.setObjectName("internalloadbalancerelement");
return response;
}
use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.
the class ConfigureInternalLoadBalancerElementCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
CallContext.current().setEventDetails("Internal load balancer element: " + id);
VirtualRouterProvider result = _service.get(0).configureInternalLoadBalancerElement(getId(), getEnabled());
if (result != null) {
InternalLoadBalancerElementResponse routerResponse = _responseGenerator.createInternalLbElementResponse(result);
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the internal load balancer element");
}
}
use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.
the class CreateInternalLoadBalancerElementCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Virtual router element Id: " + getEntityId());
VirtualRouterProvider result = _service.get(0).getInternalLoadBalancerElement(getEntityId());
if (result != null) {
InternalLoadBalancerElementResponse response = _responseGenerator.createInternalLbElementResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
}
}
use of org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse in project cloudstack by apache.
the class ListInternalLoadBalancerElementsCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
List<? extends VirtualRouterProvider> providers = _service.searchForInternalLoadBalancerElements(getId(), getNspId(), getEnabled());
ListResponse<InternalLoadBalancerElementResponse> response = new ListResponse<InternalLoadBalancerElementResponse>();
List<InternalLoadBalancerElementResponse> providerResponses = new ArrayList<InternalLoadBalancerElementResponse>();
for (VirtualRouterProvider provider : providers) {
InternalLoadBalancerElementResponse providerResponse = _responseGenerator.createInternalLbElementResponse(provider);
providerResponses.add(providerResponse);
}
response.setResponses(providerResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations