diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main')
5 files changed, 62 insertions, 39 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index 0a60bff875..7ee8654013 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -299,6 +299,11 @@ public class OrchestrationRequests { ir.setVolumeGroupInstanceName(iar.getVolumeGroupName()); if(iar.getRequestorId() != null) ir.setRequestorId(iar.getRequestorId()); + if(iar.getInstanceGroupId() != null) + ir.setInstanceGroupId(iar.getInstanceGroupId()); + if(iar.getInstanceGroupName() != null) + ir.setInstanceGroupName(iar.getInstanceGroupName()); + request.setInstanceReferences(ir); @@ -335,21 +340,24 @@ public class OrchestrationRequests { } if(flowStatusMessage != null){ if(statusMessages != null){ - statusMessages = statusMessages + "/"; + statusMessages = statusMessages + " " + "FLOW STATUS: " + flowStatusMessage; + }else{ + statusMessages = "FLOW STATUS: " + flowStatusMessage; } - statusMessages = statusMessages + "FLOW STATUS: " + flowStatusMessage; } if(retryStatusMessage != null){ if(statusMessages != null){ - statusMessages = statusMessages + "/"; + statusMessages = statusMessages + " " + "RETRY STATUS: " + retryStatusMessage; + }else{ + statusMessages = "RETRY STATUS: " + retryStatusMessage; } - statusMessages = statusMessages + "RETRY STATUS: " + retryStatusMessage; } if(rollbackStatusMessage != null){ if(statusMessages != null){ - statusMessages = statusMessages + "/"; + statusMessages = statusMessages + " " + "ROLLBACK STATUS: " + rollbackStatusMessage; + }else{ + statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; } - statusMessages = statusMessages + "ROLLBACK STATUS: " + rollbackStatusMessage; } if(statusMessages != null){ status.setStatusMessage(statusMessages); @@ -358,6 +366,10 @@ public class OrchestrationRequests { String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT"; status.setFinishTime(endTimeStamp); } + if(iar.getModifyTime() != null){ + String timeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getModifyTime()) + " GMT"; + status.setTimeStamp(timeStamp); + } if(iar.getRequestStatus() != null){ diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 0cd5d8dcb7..676dca101b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -692,7 +692,7 @@ public class ServiceInstances { sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri); String requestScope = deriveRequestScope(action, sir, requestUri); - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, requestJSON, requestScope); + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); if(sir.getRequestDetails().getRequestParameters() != null){ aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte(); } @@ -705,7 +705,6 @@ public class ServiceInstances { String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion); String networkType = msoRequest.getNetworkType(sir,requestScope); String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir); - String serviceInstanceType = msoRequest.getServiceInstanceType(sir,requestScope); String vfModuleType = msoRequest.getVfModuleType(sir,requestScope,action,requestVersion); if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){ @@ -732,7 +731,7 @@ public class ServiceInstances { Boolean isBaseVfModule = false; RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq); - + String serviceInstanceType = getServiceType(requestScope, sir, alaCarteFlag); ModelType modelType; ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { @@ -820,7 +819,7 @@ public class ServiceInstances { .errorInfo(errorLoggerInfo).build(); } - if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ + if(!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance){ aLaCarte = true; }else if(aLaCarte == null){ aLaCarte = false; @@ -864,7 +863,7 @@ public class ServiceInstances { sir.setInstanceGroupId(instanceGroupId); String requestScope = ModelType.instanceGroup.toString(); - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, null, requestScope); + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, null, requestScope); setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); try { validateHeaders(requestContext); @@ -1018,19 +1017,7 @@ public class ServiceInstances { .errorInfo(errorLoggerInfo).build(); updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; - } - - currentActiveReq.setRequestStatus(Status.IN_PROGRESS.name()); - setInstanceId(currentActiveReq, requestScope, jsonResponse.getRequestReferences().getInstanceId(), new HashMap<>()); - - try{ - infraActiveRequestsClient.save(currentActiveReq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.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(); - } - + } return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion()); } } @@ -1869,4 +1856,30 @@ public class ServiceInstances { } } } + protected String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){ + String serviceType = null; + if(requestScope.equalsIgnoreCase(ModelType.service.toString())){ + String defaultServiceModelName = getDefaultModel(sir); + org.onap.so.db.catalog.beans.Service serviceRecord; + if(aLaCarteFlag){ + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if(serviceRecord != null){ + serviceType = serviceRecord.getServiceType(); + } + }else{ + serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId()); + if(serviceRecord != null){ + serviceType = serviceRecord.getServiceType(); + }else{ + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if(serviceRecord != null){ + serviceType = serviceRecord.getServiceType(); + } + } + } + }else{ + serviceType = msoRequest.getServiceInstanceType(sir, requestScope); + } + return serviceType; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java index f83e707258..60a05d74e5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java @@ -32,15 +32,14 @@ import org.springframework.context.ApplicationContext; public class GrmClientPropertiesImpl implements GRMProperties { private String grmEndpoint; - private String grmUsername; - private String grmPassword; + private String grmAuth; + private String grmKey; public GrmClientPropertiesImpl() { - ApplicationContext context = SpringContextHelper.getAppContext(); - + ApplicationContext context = SpringContextHelper.getAppContext(); grmEndpoint = context.getEnvironment().getProperty("mso.grm.endpoint"); - grmUsername = context.getEnvironment().getProperty("mso.grm.username"); - grmPassword = context.getEnvironment().getProperty("mso.grm.password"); + grmAuth = context.getEnvironment().getProperty("mso.grm.auth"); + grmKey = context.getEnvironment().getProperty("mso.msoKey"); } @Override @@ -59,13 +58,13 @@ public class GrmClientPropertiesImpl implements GRMProperties { } @Override - public String getUsername() { - return grmUsername; + public String getAuth() { + return grmAuth; } @Override - public String getPassword() { - return grmPassword; + public String getKey() { + return grmKey; } @Override diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index 8a4d561fbd..4e8e9562ce 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java @@ -21,9 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers; import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; @@ -36,6 +33,7 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.client.HttpClient; +import org.onap.so.client.HttpClientFactory; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.utils.CryptoUtils; @@ -53,6 +51,7 @@ public class SDCClientHelper { private static String MESSAGE_UNDEFINED_ERROR = "Undefined Error Message!"; private static String MESSAGE_UNEXPECTED_FORMAT = "Unexpected response format from SDC."; + private final HttpClientFactory httpClientFactory = new HttpClientFactory(); @Value("${mso.sdc.endpoint}") private String sdcEndpoint; @@ -91,7 +90,7 @@ public class SDCClientHelper { URL url = new URL(urlString); - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDC); + HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC); httpClient.addBasicAuthHeader(sdcClientAuth, msoKey); Response apiResponse = setHttpPostResponse(httpClient, jsonPayload); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java index c4671aed3c..a6fdcc958d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java @@ -133,7 +133,7 @@ public class RelatedInstancesValidation implements ValidationRule{ if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { isSourceVnfPresent = true; } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) && - (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) { + (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf)))) { isDestinationVnfPresent = true; } } |