use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createVpcOfferingResponse.
@Override
public VpcOfferingResponse createVpcOfferingResponse(final VpcOffering offering) {
final 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());
final ServiceOffering serviceOffering = this._serviceOfferingDao.findById(offering.getServiceOfferingId());
if (serviceOffering != null) {
response.setServiceOfferingId(serviceOffering.getUuid());
response.setServiceOfferingName(serviceOffering.getName());
}
final ServiceOffering secondaryServiceOffering = this._serviceOfferingDao.findById(offering.getSecondaryServiceOfferingId());
if (secondaryServiceOffering != null) {
response.setSecondaryServiceOfferingId(secondaryServiceOffering.getUuid());
response.setSecondaryServiceOfferingName(secondaryServiceOffering.getName());
}
final Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
final List<ServiceResponse> serviceResponses = getServiceResponses(serviceProviderMap);
response.setServices(serviceResponses);
response.setObjectName("vpcoffering");
return response;
}
use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createNetworkServiceProviderResponse.
@Override
public ProviderResponse createNetworkServiceProviderResponse(final PhysicalNetworkServiceProvider result) {
final ProviderResponse response = new ProviderResponse();
response.setId(result.getUuid());
response.setName(result.getProviderName());
final PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
final PhysicalNetwork dnw = ApiDBUtils.findPhysicalNetworkById(result.getDestinationPhysicalNetworkId());
if (dnw != null) {
response.setDestinationPhysicalNetworkId(dnw.getUuid());
}
response.setState(result.getState().toString());
// set enabled services
final List<String> services = new ArrayList<>();
for (final Service service : result.getEnabledServices()) {
services.add(service.getName());
}
response.setServices(services);
final Provider serviceProvider = Provider.getProvider(result.getProviderName());
final boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
response.setCanEnableIndividualServices(canEnableIndividualServices);
response.setObjectName("networkserviceprovider");
return response;
}
use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.
the class LoadBalancingRulesManagerImpl method getLBCapability.
// Will return a string. For LB Stickiness this will be a json
@Override
public String getLBCapability(final long networkid, final String capabilityName) {
final Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkModel.getNetworkCapabilities(networkid);
if (serviceCapabilitiesMap != null) {
for (final Service service : serviceCapabilitiesMap.keySet()) {
final ServiceResponse serviceResponse = new ServiceResponse();
serviceResponse.setName(service.getName());
if ("Lb".equalsIgnoreCase(service.getName())) {
final Map<Capability, String> serviceCapabilities = serviceCapabilitiesMap.get(service);
if (serviceCapabilities != null) {
for (final Capability capability : serviceCapabilities.keySet()) {
if (capabilityName.equals(capability.getName())) {
return serviceCapabilities.get(capability);
}
}
}
}
}
}
return null;
}
use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.
the class ListSupportedNetworkServicesCmd method execute.
@Override
public void execute() {
final List<? extends Network.Service> services;
if (getServiceName() != null) {
Network.Service service = null;
if (serviceName != null) {
service = Network.Service.getService(serviceName);
if (service == null) {
throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
}
}
final List<Network.Service> serviceList = new ArrayList<>();
serviceList.add(service);
services = serviceList;
} else {
services = _networkService.listNetworkServices(getProviderName());
}
final ListResponse<ServiceResponse> response = new ListResponse<>();
final List<ServiceResponse> servicesResponses = new ArrayList<>();
for (final Network.Service service : services) {
// skip gateway service
if (service == Service.Gateway) {
continue;
}
final ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
servicesResponses.add(serviceResponse);
}
response.setResponses(servicesResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.legacymodel.network.Network.Service in project cosmic by MissionCriticalCloud.
the class NetworkOfferingServiceMapDaoImpl method areServicesSupportedByNetworkOffering.
@Override
public boolean areServicesSupportedByNetworkOffering(final long networkOfferingId, final Service... services) {
final SearchCriteria<NetworkOfferingServiceMapVO> sc = MultipleServicesSearch.create();
sc.setParameters("networkOfferingId", networkOfferingId);
if (services != null) {
final String[] servicesStr = new String[services.length];
int i = 0;
for (final Service service : services) {
servicesStr[i] = service.getName();
i++;
}
sc.setParameters("service", (Object[]) servicesStr);
}
final List<NetworkOfferingServiceMapVO> offeringServices = listBy(sc);
if (services != null) {
if (offeringServices.size() == services.length) {
return true;
}
} else if (!offeringServices.isEmpty()) {
return true;
}
return false;
}
Aggregations