use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.
the class ServiceInstances method getCloudConfigurationOnReplace.
protected CloudConfiguration getCloudConfigurationOnReplace(String requestScope, HashMap<String, String> instanceIdMap, InfraActiveRequests currentActiveReq) throws ApiException {
logger.debug("Replace request is missing cloudConfiguration, autofilling from create.");
CloudConfiguration cloudConfiguration = null;
if (requestScope.equals(ModelType.vfModule.toString())) {
cloudConfiguration = bpmnRequestBuilder.getCloudConfigurationVfModuleReplace(instanceIdMap.get("vnfInstanceId"), instanceIdMap.get("vfModuleInstanceId"));
} else {
cloudConfiguration = bpmnRequestBuilder.mapCloudConfigurationVnf(instanceIdMap.get("vnfInstanceId"));
}
if (cloudConfiguration == null) {
String errorMessage = "CloudConfiguration not found during autofill for replace request.";
logger.error(errorMessage);
updateStatus(currentActiveReq, Status.FAILED, errorMessage);
throw new CloudConfigurationNotFoundException("CloudConfiguration not found during autofill for replace request.");
}
return cloudConfiguration;
}
use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.
the class RequestHandlerUtils method addCloudConfig.
private Optional<CloudConfiguration> addCloudConfig(CloudConfiguration sourceCloudConfiguration) {
CloudConfiguration targetConfiguration = new CloudConfiguration();
if (sourceCloudConfiguration != null) {
targetConfiguration.setAicNodeClli(sourceCloudConfiguration.getAicNodeClli());
targetConfiguration.setTenantId(sourceCloudConfiguration.getTenantId());
targetConfiguration.setLcpCloudRegionId(sourceCloudConfiguration.getLcpCloudRegionId());
targetConfiguration.setCloudOwner(sourceCloudConfiguration.getCloudOwner());
return Optional.of(targetConfiguration);
}
return Optional.empty();
}
use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.
the class RequestHandlerUtils method configureCloudConfig.
protected CloudConfiguration configureCloudConfig(RequestParameters reqParams) throws IOException {
for (Map<String, Object> params : reqParams.getUserParams()) {
if (params.containsKey("service")) {
Service service = serviceMapper(params);
Optional<CloudConfiguration> targetConfiguration = addCloudConfig(service.getCloudConfiguration());
if (targetConfiguration.isPresent()) {
return targetConfiguration.get();
} else {
for (Networks network : service.getResources().getNetworks()) {
targetConfiguration = addCloudConfig(network.getCloudConfiguration());
if (targetConfiguration.isPresent()) {
return targetConfiguration.get();
}
}
for (Vnfs vnf : service.getResources().getVnfs()) {
targetConfiguration = addCloudConfig(vnf.getCloudConfiguration());
if (targetConfiguration.isPresent()) {
return targetConfiguration.get();
}
for (VfModules vfModule : vnf.getVfModules()) {
targetConfiguration = addCloudConfig(vfModule.getCloudConfiguration());
if (targetConfiguration.isPresent()) {
return targetConfiguration.get();
}
}
}
}
}
}
return null;
}
use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.
the class ServiceInstances method serviceInstances.
public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, HashMap<String, String> queryParams) throws ApiException {
String serviceInstanceId;
Boolean aLaCarte = null;
ServiceInstancesRequest sir;
String apiVersion = version.substring(1);
sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri);
action = handleReplaceInstance(action, sir);
String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri);
try {
requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action);
} catch (ApiException e) {
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope, requestJSON, requestHandlerUtils.getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null), sir);
throw e;
}
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
if (sir.getRequestDetails().getRequestParameters() != null) {
aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
}
requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
if ((action == Action.replaceInstance || action == Action.replaceInstanceRetainAssignments) && (requestScope.equals(ModelType.vnf.toString()) || requestScope.equals(ModelType.vfModule.toString())) && sir.getRequestDetails().getCloudConfiguration() == null) {
CloudConfiguration cloudConfiguration = getCloudConfigurationOnReplace(requestScope, instanceIdMap, currentActiveReq);
sir.getRequestDetails().setCloudConfiguration(cloudConfiguration);
setCloudConfigurationCurrentActiveRequest(cloudConfiguration, currentActiveReq);
}
requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
String instanceName = null;
if (sir.getRequestDetails().getRequestInfo() != null) {
instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
}
boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir);
String vnfType = msoRequest.getVnfType(sir, requestScope);
String networkType = msoRequest.getNetworkType(sir, requestScope);
String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir);
String vfModuleType = msoRequest.getVfModuleType(sir, requestScope);
if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null) {
currentActiveReq.setVnfType(vnfType);
} else if (requestScope.equalsIgnoreCase(ModelType.network.name()) && networkType != null) {
currentActiveReq.setNetworkType(networkType);
}
requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, instanceName);
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
RequestReferences referencesResponse = new RequestReferences();
referencesResponse.setRequestId(requestId);
serviceResponse.setRequestReferences(referencesResponse);
RecipeLookupResult recipeLookupResult = requestHandlerUtils.getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq);
String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag);
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
ModelType modelType = requestHandlerUtils.getModelType(action, modelInfo);
Boolean isBaseVfModule = false;
if (modelType.equals(ModelType.vfModule)) {
isBaseVfModule = requestHandlerUtils.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, currentActiveReq);
}
serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
String vnfId = "";
String vfModuleId = "";
String volumeGroupId = "";
String networkId = "";
String pnfCorrelationId = "";
String instanceGroupId = null;
if (sir.getVnfInstanceId() != null) {
vnfId = sir.getVnfInstanceId();
}
if (sir.getVfModuleInstanceId() != null) {
vfModuleId = sir.getVfModuleInstanceId();
}
if (sir.getVolumeGroupInstanceId() != null) {
volumeGroupId = sir.getVolumeGroupInstanceId();
}
if (sir.getNetworkInstanceId() != null) {
networkId = sir.getNetworkInstanceId();
}
if (sir.getInstanceGroupId() != null) {
instanceGroupId = sir.getInstanceGroupId();
}
pnfCorrelationId = getPnfCorrelationId(sir);
try {
infraActiveRequestsClient.save(currentActiveReq);
} catch (Exception e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
}
if (!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance && !requestScope.equalsIgnoreCase(ModelType.vnf.name())) {
aLaCarte = true;
} else if (aLaCarte == null) {
aLaCarte = false;
}
RequestClientParameter requestClientParameter;
try {
requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfCorrelationId).setVnfId(vnfId).setVfModuleId(vfModuleId).setVolumeGroupId(volumeGroupId).setNetworkId(networkId).setServiceType(serviceInstanceType).setVnfType(vnfType).setVfModuleType(vfModuleType).setNetworkType(networkType).setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)).setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).setInstanceGroupId(instanceGroupId).build();
} catch (IOException e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
}
return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.
the class VolumeGroupDeleteValidatorTest method validateFailureVnfTest.
@Test
public void validateFailureVnfTest() {
instanceIdMap.put("volumeGroupInstanceId", "1");
ServiceInstancesRequest request = new ServiceInstancesRequest();
RequestDetails details = new RequestDetails();
details.setCloudConfiguration(new CloudConfiguration());
request.setRequestDetails(details);
when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(true);
Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null);
assertEquals(true, result.isPresent());
}
Aggregations