use of org.apache.cloudstack.api.response.NetworkOfferingResponse in project cloudstack by apache.
the class ListNetworkOfferingsCmd method execute.
@Override
public void execute() {
Pair<List<? extends NetworkOffering>, Integer> offerings = _configService.searchForNetworkOfferings(this);
ListResponse<NetworkOfferingResponse> response = new ListResponse<NetworkOfferingResponse>();
List<NetworkOfferingResponse> offeringResponses = new ArrayList<NetworkOfferingResponse>();
for (NetworkOffering offering : offerings.first()) {
NetworkOfferingResponse offeringResponse = _responseGenerator.createNetworkOfferingResponse(offering);
offeringResponses.add(offeringResponse);
}
response.setResponses(offeringResponses, offerings.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.NetworkOfferingResponse in project cloudstack by apache.
the class NetworkOfferingJoinDaoImpl method newNetworkOfferingResponse.
@Override
public NetworkOfferingResponse newNetworkOfferingResponse(NetworkOffering offering) {
NetworkOfferingResponse networkOfferingResponse = new NetworkOfferingResponse();
networkOfferingResponse.setId(offering.getUuid());
networkOfferingResponse.setName(offering.getName());
networkOfferingResponse.setDisplayText(offering.getDisplayText());
networkOfferingResponse.setTags(offering.getTags());
networkOfferingResponse.setTrafficType(offering.getTrafficType().toString());
networkOfferingResponse.setIsDefault(offering.isDefault());
networkOfferingResponse.setSpecifyVlan(offering.isSpecifyVlan());
networkOfferingResponse.setConserveMode(offering.isConserveMode());
networkOfferingResponse.setSpecifyIpRanges(offering.isSpecifyIpRanges());
networkOfferingResponse.setAvailability(offering.getAvailability().toString());
networkOfferingResponse.setIsPersistent(offering.isPersistent());
networkOfferingResponse.setEgressDefaultPolicy(offering.isEgressDefaultPolicy());
networkOfferingResponse.setConcurrentConnections(offering.getConcurrentConnections());
networkOfferingResponse.setSupportsStrechedL2Subnet(offering.isSupportingStrechedL2());
networkOfferingResponse.setSupportsPublicAccess(offering.isSupportingPublicAccess());
networkOfferingResponse.setCreated(offering.getCreated());
if (offering.getGuestType() != null) {
networkOfferingResponse.setGuestIpType(offering.getGuestType().toString());
}
networkOfferingResponse.setState(offering.getState().name());
if (offering instanceof NetworkOfferingJoinVO) {
networkOfferingResponse.setDomainId(((NetworkOfferingJoinVO) offering).getDomainUuid());
networkOfferingResponse.setDomain(((NetworkOfferingJoinVO) offering).getDomainPath());
networkOfferingResponse.setZoneId(((NetworkOfferingJoinVO) offering).getZoneUuid());
networkOfferingResponse.setZone(((NetworkOfferingJoinVO) offering).getZoneName());
}
networkOfferingResponse.setObjectName("networkoffering");
return networkOfferingResponse;
}
use of org.apache.cloudstack.api.response.NetworkOfferingResponse in project cloudstack by apache.
the class UpdateNetworkOfferingCmd method execute.
@Override
public void execute() {
NetworkOffering result = _configService.updateNetworkOffering(this);
if (result != null) {
NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network offering");
}
}
use of org.apache.cloudstack.api.response.NetworkOfferingResponse in project cloudstack by apache.
the class ApiResponseHelper method createNetworkOfferingResponse.
@Override
public NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering offering) {
if (!(offering instanceof NetworkOfferingJoinVO)) {
offering = ApiDBUtils.newNetworkOfferingView(offering);
}
NetworkOfferingResponse response = ApiDBUtils.newNetworkOfferingResponse(offering);
response.setNetworkRate(ApiDBUtils.getNetworkRate(offering.getId()));
Long so = null;
if (offering.getServiceOfferingId() != null) {
so = offering.getServiceOfferingId();
} else {
so = ApiDBUtils.findDefaultRouterServiceOffering();
}
if (so != null) {
ServiceOffering soffering = ApiDBUtils.findServiceOfferingById(so);
if (soffering != null) {
response.setServiceOfferingId(soffering.getUuid());
}
}
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(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);
if (Service.Lb == service) {
List<CapabilityResponse> lbCapResponse = new ArrayList<CapabilityResponse>();
CapabilityResponse lbIsoaltion = new CapabilityResponse();
lbIsoaltion.setName(Capability.SupportedLBIsolation.getName());
lbIsoaltion.setValue(offering.isDedicatedLB() ? "dedicated" : "shared");
lbCapResponse.add(lbIsoaltion);
CapabilityResponse eLb = new CapabilityResponse();
eLb.setName(Capability.ElasticLb.getName());
eLb.setValue(offering.isElasticLb() ? "true" : "false");
lbCapResponse.add(eLb);
CapabilityResponse inline = new CapabilityResponse();
inline.setName(Capability.InlineMode.getName());
inline.setValue(offering.isInline() ? "true" : "false");
lbCapResponse.add(inline);
svcRsp.setCapabilities(lbCapResponse);
} else if (Service.SourceNat == service) {
List<CapabilityResponse> capabilities = new ArrayList<CapabilityResponse>();
CapabilityResponse sharedSourceNat = new CapabilityResponse();
sharedSourceNat.setName(Capability.SupportedSourceNatTypes.getName());
sharedSourceNat.setValue(offering.isSharedSourceNat() ? "perzone" : "peraccount");
capabilities.add(sharedSourceNat);
CapabilityResponse redundantRouter = new CapabilityResponse();
redundantRouter.setName(Capability.RedundantRouter.getName());
redundantRouter.setValue(offering.isRedundantRouter() ? "true" : "false");
capabilities.add(redundantRouter);
svcRsp.setCapabilities(capabilities);
} else if (service == Service.StaticNat) {
List<CapabilityResponse> staticNatCapResponse = new ArrayList<CapabilityResponse>();
CapabilityResponse eIp = new CapabilityResponse();
eIp.setName(Capability.ElasticIp.getName());
eIp.setValue(offering.isElasticIp() ? "true" : "false");
staticNatCapResponse.add(eIp);
CapabilityResponse associatePublicIp = new CapabilityResponse();
associatePublicIp.setName(Capability.AssociatePublicIP.getName());
associatePublicIp.setValue(offering.isAssociatePublicIP() ? "true" : "false");
staticNatCapResponse.add(associatePublicIp);
svcRsp.setCapabilities(staticNatCapResponse);
}
serviceResponses.add(svcRsp);
}
response.setForVpc(_configMgr.isOfferingForVpc(offering));
response.setServices(serviceResponses);
// set network offering details
Map<Detail, String> details = _ntwkModel.getNtwkOffDetails(offering.getId());
if (details != null && !details.isEmpty()) {
response.setDetails(details);
}
response.setHasAnnotation(annotationDao.hasAnnotations(offering.getUuid(), AnnotationService.EntityType.NETWORK_OFFERING.name(), _accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
return response;
}
use of org.apache.cloudstack.api.response.NetworkOfferingResponse in project cloudstack by apache.
the class CreateNetworkOfferingCmd method execute.
@Override
public void execute() {
NetworkOffering result = _configService.createNetworkOffering(this);
if (result != null) {
NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network offering");
}
}
Aggregations