use of com.cloud.api.response.ProviderResponse 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.api.response.ProviderResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method getServiceResponses.
private List<ServiceResponse> getServiceResponses(final Map<Service, Set<Provider>> serviceProviderMap) {
final List<ServiceResponse> serviceResponses = new ArrayList<>();
for (final Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet()) {
final Service service = entry.getKey();
final Set<Provider> serviceProviders = entry.getValue();
final ServiceResponse svcRsp = new ServiceResponse();
// skip gateway service
if (service == Service.Gateway) {
continue;
}
svcRsp.setName(service.getName());
final List<ProviderResponse> providers = getProviderResponses(serviceProviders);
svcRsp.setProviders(providers);
serviceResponses.add(svcRsp);
}
return serviceResponses;
}
use of com.cloud.api.response.ProviderResponse in project CloudStack-archive by CloudStack-extras.
the class AddNetworkServiceProviderCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Network ServiceProvider Id: " + getEntityId());
PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
if (result != null) {
ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
}
}
use of com.cloud.api.response.ProviderResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createServiceProviderResponse.
private ProviderResponse createServiceProviderResponse(final Provider serviceProvider) {
final ProviderResponse response = new ProviderResponse();
response.setName(serviceProvider.getName());
final boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
response.setCanEnableIndividualServices(canEnableIndividualServices);
return response;
}
use of com.cloud.api.response.ProviderResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createNetworkServiceResponse.
@Override
public ServiceResponse createNetworkServiceResponse(final Service service) {
final ServiceResponse response = new ServiceResponse();
response.setName(service.getName());
// set list of capabilities required for the service
final List<CapabilityResponse> capabilityResponses = new ArrayList<>();
final Capability[] capabilities = service.getCapabilities();
for (final Capability cap : capabilities) {
final CapabilityResponse capabilityResponse = new CapabilityResponse();
capabilityResponse.setName(cap.getName());
capabilityResponse.setObjectName("capability");
if (cap.getName().equals(Capability.SupportedLBIsolation.getName()) || cap.getName().equals(Capability.SupportedSourceNatTypes.getName()) || cap.getName().equals(Capability.RedundantRouter.getName())) {
capabilityResponse.setCanChoose(true);
} else {
capabilityResponse.setCanChoose(false);
}
capabilityResponses.add(capabilityResponse);
}
response.setCapabilities(capabilityResponses);
// set list of providers providing this service
final List<? extends Network.Provider> serviceProviders = ApiDBUtils.getProvidersForService(service);
final List<ProviderResponse> serviceProvidersResponses = new ArrayList<>();
for (final Network.Provider serviceProvider : serviceProviders) {
// return only Virtual Router/JuniperSRX/CiscoVnmc as a provider for the firewall
if (service == Service.Firewall && serviceProvider != Provider.VirtualRouter) {
continue;
}
final ProviderResponse serviceProviderResponse = createServiceProviderResponse(serviceProvider);
serviceProvidersResponses.add(serviceProviderResponse);
}
response.setProviders(serviceProvidersResponses);
response.setObjectName("networkservice");
return response;
}
Aggregations