Search in sources :

Example 1 with VpcOfferingResponse

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

the class ApiResponseHelper method createVpcOfferingResponse.

@Override
public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering) {
    VpcOfferingResponse response = new VpcOfferingResponse();
    response.setId(offering.getUuid());
    response.setName(offering.getName());
    response.setDisplayText(offering.getDisplayText());
    response.setIsDefault(offering.isDefault());
    response.setState(offering.getState().name());
    response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
    response.setSupportsRegionLevelVpc(offering.offersRegionLevelVPC());
    Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
    List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
    for (Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet()) {
        Service service = entry.getKey();
        Set<Provider> srvc_providers = entry.getValue();
        ServiceResponse svcRsp = new ServiceResponse();
        // skip gateway service
        if (service == Service.Gateway) {
            continue;
        }
        svcRsp.setName(service.getName());
        List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
        for (Provider provider : srvc_providers) {
            if (provider != null) {
                ProviderResponse providerRsp = new ProviderResponse();
                providerRsp.setName(provider.getName());
                providers.add(providerRsp);
            }
        }
        svcRsp.setProviders(providers);
        serviceResponses.add(svcRsp);
    }
    response.setServices(serviceResponses);
    response.setObjectName("vpcoffering");
    return response;
}
Also used : VpcOfferingResponse(org.apache.cloudstack.api.response.VpcOfferingResponse) EnumSet(java.util.EnumSet) HashSet(java.util.HashSet) Set(java.util.Set) ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse) ArrayList(java.util.ArrayList) Service(com.cloud.network.Network.Service) UsageService(org.apache.cloudstack.usage.UsageService) OvsProvider(com.cloud.network.OvsProvider) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) Provider(com.cloud.network.Network.Provider) ServiceResponse(org.apache.cloudstack.api.response.ServiceResponse) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with VpcOfferingResponse

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

the class CreateVPCOfferingCmd method execute.

@Override
public void execute() {
    VpcOffering vpc = _vpcProvSvc.getVpcOffering(getEntityId());
    if (vpc != null) {
        VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(vpc);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC offering");
    }
}
Also used : VpcOfferingResponse(org.apache.cloudstack.api.response.VpcOfferingResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VpcOffering(com.cloud.network.vpc.VpcOffering)

Example 3 with VpcOfferingResponse

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

the class UpdateVPCOfferingCmd method execute.

@Override
public void execute() {
    VpcOffering result = _vpcProvSvc.updateVpcOffering(getId(), getVpcOfferingName(), getDisplayText(), getState());
    if (result != null) {
        VpcOfferingResponse response = _responseGenerator.createVpcOfferingResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC offering");
    }
}
Also used : VpcOfferingResponse(org.apache.cloudstack.api.response.VpcOfferingResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) VpcOffering(com.cloud.network.vpc.VpcOffering)

Example 4 with VpcOfferingResponse

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

the class ListVPCOfferingsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    Pair<List<? extends VpcOffering>, Integer> offerings = _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(), isDefault, this.getKeyword(), getState(), this.getStartIndex(), this.getPageSizeVal());
    ListResponse<VpcOfferingResponse> response = new ListResponse<VpcOfferingResponse>();
    List<VpcOfferingResponse> offeringResponses = new ArrayList<VpcOfferingResponse>();
    for (VpcOffering offering : offerings.first()) {
        VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
        offeringResponses.add(offeringResponse);
    }
    response.setResponses(offeringResponses, offerings.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : VpcOfferingResponse(org.apache.cloudstack.api.response.VpcOfferingResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) VpcOffering(com.cloud.network.vpc.VpcOffering) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

VpcOfferingResponse (org.apache.cloudstack.api.response.VpcOfferingResponse)4 VpcOffering (com.cloud.network.vpc.VpcOffering)3 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 Provider (com.cloud.network.Network.Provider)1 Service (com.cloud.network.Network.Service)1 OvsProvider (com.cloud.network.OvsProvider)1 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)1 VirtualRouterProvider (com.cloud.network.VirtualRouterProvider)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 OvsProviderResponse (org.apache.cloudstack.api.response.OvsProviderResponse)1 ProviderResponse (org.apache.cloudstack.api.response.ProviderResponse)1 ServiceResponse (org.apache.cloudstack.api.response.ServiceResponse)1 VirtualRouterProviderResponse (org.apache.cloudstack.api.response.VirtualRouterProviderResponse)1