diff options
33 files changed, 686 insertions, 215 deletions
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java new file mode 100644 index 0000000000..44f814aa10 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.nssmf.annotation; + + +import java.lang.annotation.*; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RequestLogger { + boolean ignore() default false; +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java index 28789f2a98..84e1eb2acc 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java @@ -159,7 +159,7 @@ public class NssmfAdapterConsts { new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.QUERY_SUB_NET_CAPABILITY), - new NssmfUrlInfo(INTERNAL_QUERY_SUB_NET_CAPABILITY, HttpMethod.POST)); + new NssmfUrlInfo(INTERNAL_QUERY_SUB_NET_CAPABILITY, HttpMethod.GET)); } /** diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java index 02d7468a0c..3732e2c256 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java @@ -1,5 +1,6 @@ package org.onap.so.adapters.nssmf.controller; +import org.onap.so.adapters.nssmf.annotation.RequestLogger; import org.onap.so.adapters.nssmf.service.NssmfManagerService; import org.onap.so.beans.nsmf.*; import org.springframework.beans.factory.annotation.Autowired; @@ -9,6 +10,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; @RestController @RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON}) +@RequestLogger public class NssmfAdapterController { @Autowired diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java index 665b111e03..77662bf272 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java @@ -33,4 +33,7 @@ public interface AaiServiceProvider { void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, String serviceInstanceId); + ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); + + void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index b972517338..1d7c42aafe 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -75,4 +75,24 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); aaiClientProvider.getAaiClient().create(uri, nssiInstance); } + + @Override + public ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, + String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); + + return aaiClientProvider.getAaiClient().get(ServiceInstance.class, uri).orElseGet(() -> { + logger.debug("ServiceInstance " + serviceInstanceId + " not found in AAI"); + return null; + }); + } + + @Override + public void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); + + aaiClientProvider.getAaiClient().delete(uri); + } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java index ea6a1250d9..bca4a12d4b 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java @@ -17,76 +17,39 @@ # limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.so.adapters.nssmf.interceptor; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.onap.so.adapters.nssmf.annotation.ServiceLogger; -import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; +import org.apache.logging.log4j.ThreadContext; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.UUID; -/** - * support to print logger of service method - */ -@Aspect -@Order(100) @Component -public class LoggerInterceptor { - - private static final Logger logger = LoggerFactory.getLogger(LoggerInterceptor.class); +public class LoggerInterceptor implements HandlerInterceptor { - @Pointcut("execution(* org.onap.so.adapters.nssmf.service..*(..))") - public void serviceLogger() { + private final static String TRACE_ID = "traceId"; + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + String traceId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); + ThreadContext.put(TRACE_ID, traceId); + return true; } - @Around("serviceLogger()") - public Object around(ProceedingJoinPoint joinPoint) { - try { - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - Method method = signature.getMethod(); - - Class<?> targetClass = method.getDeclaringClass(); - - StringBuilder classAndMethod = new StringBuilder(); - ServiceLogger classAnnotation = targetClass.getAnnotation(ServiceLogger.class); - ServiceLogger methodAnnotation = method.getAnnotation(ServiceLogger.class); - - if (classAnnotation == null && methodAnnotation == null) { - return joinPoint.proceed(); - } + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { - if (classAnnotation != null) { - if (classAnnotation.ignore()) { - return joinPoint.proceed(); - } - classAndMethod.append(classAnnotation.value()).append("-"); - } - - String target = targetClass.getName() + "#" + method.getName(); - - String params = NssmfAdapterUtil.marshal(joinPoint.getArgs()); - - logger.info("{} Start: Method = {} \nParams = {}", classAndMethod.toString(), target, params); - - long start = System.currentTimeMillis(); - Object result = joinPoint.proceed(); - long timeConsuming = System.currentTimeMillis() - start; - - logger.info("\n{} End: Method = {}, Spend time = {}ms \nResult = {}", classAndMethod.toString(), target, - timeConsuming, NssmfAdapterUtil.marshal(result)); - return result; + } - } catch (Throwable e) { - logger.error(e.getMessage(), e); - } - return null; + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) + throws Exception { + ThreadContext.remove(TRACE_ID); } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java new file mode 100644 index 0000000000..95f26b4ad5 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.nssmf.interceptor; + +import lombok.Data; +import lombok.ToString; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.reflect.MethodSignature; +import org.onap.so.adapters.nssmf.annotation.RequestLogger; +import org.onap.so.adapters.nssmf.annotation.ServiceLogger; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * support to print logger of service method + */ +@Aspect +@Order(100) +@Component +public class RequestLogAspect { + + private static final Logger logger = LoggerFactory.getLogger(RequestLogAspect.class); + + @Pointcut("execution(* org.onap.so.adapters.nssmf.service..*(..))") + public void serviceLogger() { + + } + + @Around("serviceLogger()") + public Object around(ProceedingJoinPoint joinPoint) { + try { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + Class<?> targetClass = method.getDeclaringClass(); + + StringBuilder classAndMethod = new StringBuilder(); + ServiceLogger classAnnotation = targetClass.getAnnotation(ServiceLogger.class); + ServiceLogger methodAnnotation = method.getAnnotation(ServiceLogger.class); + + if (classAnnotation == null && methodAnnotation == null) { + return joinPoint.proceed(); + } + + if (classAnnotation != null) { + if (classAnnotation.ignore()) { + return joinPoint.proceed(); + } + classAndMethod.append(classAnnotation.value()).append("-"); + } + + String target = targetClass.getName() + "#" + method.getName(); + + String params = NssmfAdapterUtil.marshal(joinPoint.getArgs()); + + logger.info("{} Start: Method = {} \nParams = {}", classAndMethod.toString(), target, params); + + long start = System.currentTimeMillis(); + Object result = joinPoint.proceed(); + long timeConsuming = System.currentTimeMillis() - start; + + logger.info("\n{} End: Method = {}, Spend time = {}ms \nResult = {}", classAndMethod.toString(), target, + timeConsuming, NssmfAdapterUtil.marshal(result)); + return result; + + } catch (Throwable e) { + logger.error(e.getMessage(), e); + } + return null; + } + + @Pointcut("execution(* org.onap.so.adapters.nssmf.controller..*(..))") + public void controllerLogger() { + + } + + @Around("controllerLogger()") + public Object doAroundRequest(ProceedingJoinPoint point) throws Throwable { + MethodSignature signature = (MethodSignature) point.getSignature(); + Method method = signature.getMethod(); + Class<?> targetClass = method.getDeclaringClass(); + + RequestLogger classAnnotation = targetClass.getAnnotation(RequestLogger.class); + RequestLogger methodAnnotation = method.getAnnotation(RequestLogger.class); + + if ((classAnnotation == null && methodAnnotation == null) + || (classAnnotation != null && classAnnotation.ignore()) + || (methodAnnotation != null && methodAnnotation.ignore())) { + return point.proceed(); + } + + long start = System.currentTimeMillis(); + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + + assert attributes != null; + HttpServletRequest request = attributes.getRequest(); + Object result = point.proceed(); + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setIp(request.getRemoteAddr()); + requestInfo.setUrl(request.getRequestURL().toString()); + requestInfo.setHttpMethod(request.getMethod()); + requestInfo.setClassMethod(String.format("%s.%s", signature.getDeclaringTypeName(), signature.getName())); + requestInfo.setRequestParams(getRequestParamsByProceedingJoinPoint(point)); + requestInfo.setResult(result); + requestInfo.setTimeCost(System.currentTimeMillis() - start); + logger.info("Request Info : {}", NssmfAdapterUtil.marshal(requestInfo)); + return result; + } + + @AfterThrowing(pointcut = "controllerLogger()", throwing = "e") + public void doAfterRequestThrow(JoinPoint joinPoint, RuntimeException e) { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + Class<?> targetClass = method.getDeclaringClass(); + + RequestLogger classAnnotation = targetClass.getAnnotation(RequestLogger.class); + RequestLogger methodAnnotation = method.getAnnotation(RequestLogger.class); + + if ((classAnnotation == null && methodAnnotation == null) + || (classAnnotation != null && classAnnotation.ignore()) + || (methodAnnotation != null && methodAnnotation.ignore())) { + return; + } + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + assert attributes != null; + HttpServletRequest request = attributes.getRequest(); + RequestErrorInfo requestErrorInfo = new RequestErrorInfo(); + requestErrorInfo.setIp(request.getRemoteAddr()); + requestErrorInfo.setUrl(request.getRequestURL().toString()); + requestErrorInfo.setHttpMethod(request.getMethod()); + requestErrorInfo.setClassMethod(String.format("%s.%s", joinPoint.getSignature().getDeclaringTypeName(), + joinPoint.getSignature().getName())); + requestErrorInfo.setRequestParams(getRequestParamsByJoinPoint(joinPoint)); + requestErrorInfo.setException(e); + String res; + try { + res = NssmfAdapterUtil.marshal(requestErrorInfo); + logger.info("Error Request Info : {}", res); + } catch (ApplicationException ex) { + logger.info("Error Request Info : {}", requestErrorInfo); + } + } + + private Map<String, Object> getRequestParamsByJoinPoint(JoinPoint joinPoint) { + String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames(); + Object[] paramValues = joinPoint.getArgs(); + + return buildRequestParam(paramNames, paramValues); + } + + + private Map<String, Object> getRequestParamsByProceedingJoinPoint(ProceedingJoinPoint proceedingJoinPoint) { + String[] paramNames = ((MethodSignature) proceedingJoinPoint.getSignature()).getParameterNames(); + Object[] paramValues = proceedingJoinPoint.getArgs(); + + return buildRequestParam(paramNames, paramValues); + } + + private Map<String, Object> buildRequestParam(String[] paramNames, Object[] paramValues) { + Map<String, Object> requestParams = new HashMap<>(); + for (int i = 0; i < paramNames.length; i++) { + Object value = paramValues[i]; + + if (value instanceof MultipartFile) { + MultipartFile file = (MultipartFile) value; + value = file.getOriginalFilename(); + } + + requestParams.put(paramNames[i], value); + } + + return requestParams; + } + + @Data + @ToString + private class RequestInfo { + private String ip; + private String url; + private String httpMethod; + private String classMethod; + private Object requestParams; + private Object result; + private Long timeCost; + } + + @Data + @ToString + private class RequestErrorInfo { + private String ip; + private String url; + private String httpMethod; + private String classMethod; + private Object requestParams; + private RuntimeException exception; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java index 2ccd88a358..c4f269c3a0 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -193,7 +193,7 @@ public abstract class BaseNssmfManager implements NssmfManager { return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery()); } - protected abstract RestResponse doQuerySubnetCapability(String req) throws ApplicationException; + protected abstract <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException; /** * send request to nssmf diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index 0d0d896370..bb2b83fd59 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -25,6 +25,7 @@ import org.apache.http.message.BasicHeader; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.so.adapters.nssmf.entity.NssmfInfo; import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.enums.ActionType; import org.onap.so.adapters.nssmf.enums.JobStatus; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; @@ -63,24 +64,32 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { protected void afterQueryJobStatus(ResourceOperationStatus status) { if (Integer.parseInt(status.getProgress()) == 100) { - ServiceInstance nssiInstance = new ServiceInstance(); - nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); - nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); - nssiInstance.setServiceType(serviceInfo.getSST()); + ActionType jobOperType = ActionType.valueOf(status.getOperType()); - nssiInstance.setOrchestrationStatus(initStatus); - nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid()); - nssiInstance.setModelVersionId(serviceInfo.getServiceUuid()); - nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList()); - nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType()); - nssiInstance.setServiceRole("nssi"); + if (ActionType.ALLOCATE.equals(jobOperType)) { + ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); + if (nssiInstance == null) { + nssiInstance = new ServiceInstance(); + } - restUtil.createServiceInstance(nssiInstance, serviceInfo); + nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); + nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); + nssiInstance.setServiceType(serviceInfo.getSST()); + + nssiInstance.setOrchestrationStatus(initStatus); + nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid()); + nssiInstance.setModelVersionId(serviceInfo.getServiceUuid()); + nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList()); + nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType()); + nssiInstance.setServiceRole("nssi"); + + restUtil.createServiceInstance(nssiInstance, serviceInfo); + } else if (ActionType.DEALLOCATE.equals(jobOperType)) { + restUtil.deleteServiceInstance(serviceInfo); + } } } - - @Override protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException { return marshal(actDeActNssi); @@ -157,7 +166,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { } @Override - protected RestResponse doQuerySubnetCapability(String req) throws ApplicationException { + protected <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException { RestResponse response = new RestResponse(); response.setStatus(200); response.setResponseContent(null); diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java index 348bf12bcb..4705e871f3 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java @@ -122,8 +122,8 @@ public abstract class InternalNssmfManager extends BaseNssmfManager { protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; @Override - protected RestResponse doQuerySubnetCapability(String req) throws ApplicationException { + protected <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException { // handler - return sendRequest(req); + return sendRequest(marshal(req)); } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index 491da0aab4..c51b72d61e 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -76,6 +76,7 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { ResourceOperationStatus status = new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid()); status.setResourceInstanceID(nssiId); + status.setOperType(actionType.toString()); updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED, NssmfAdapterUtil.getStatusDesc(actionType)); @@ -128,6 +129,8 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { updateRequestDbJobStatus(responseDescriptor, status, restResponse); + status.setProgress(Integer.toString(responseDescriptor.getProgress())); + return restResponse; } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java index 0c5999b20e..a7adbe116a 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java @@ -77,6 +77,16 @@ public class RestUtil { serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); } + public ServiceInstance getServiceInstance(ServiceInfo serviceInfo) { + return aaiSvcProv.invokeGetServiceInstance(serviceInfo.getGlobalSubscriberId(), + serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); + } + + public void deleteServiceInstance(ServiceInfo serviceInfo) { + aaiSvcProv.invokeDeleteServiceInstance(serviceInfo.getGlobalSubscriberId(), + serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); + } + public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException { EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList(); if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) { @@ -214,7 +224,11 @@ public class RestUtil { break; case GET: - base = new HttpGet(url); + HttpGetWithBody get = new HttpGetWithBody(url); + if (content != null) { + get.setEntity(new StringEntity(content, APPLICATION_JSON)); + } + base = get; break; case PUT: @@ -275,6 +289,29 @@ public class RestUtil { } } + class HttpGetWithBody extends HttpEntityEnclosingRequestBase { + public static final String METHOD_NAME = "GET"; + + public HttpGetWithBody() { + super(); + } + + public HttpGetWithBody(final String uri) { + super(); + setURI(URI.create(uri)); + } + + public HttpGetWithBody(final URI uri) { + super(); + setURI(uri); + } + + @Override + public String getMethod() { + return METHOD_NAME; + } + } + public HttpClient getHttpsClient() { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index 1b5463211c..6497a99e5e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -120,6 +120,10 @@ public class VfResourceStructure extends ResourceStructure { case ASDCConfiguration.OTHER: case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: case ASDCConfiguration.HELM: + if (artifactInfo.getArtifactName().contains("dummy") + && artifactInfo.getArtifactName().contains("ignore")) { + break; + } artifactsMapByUUID.put(artifactInfo.getArtifactUUID(), vfModuleArtifact); break; case ASDCConfiguration.VF_MODULES_METADATA: @@ -143,6 +147,9 @@ public class VfResourceStructure extends ResourceStructure { return; } for (IVfModuleData vfModuleMeta : vfModulesMetadataList) { + if (vfModuleMeta.getVfModuleModelName().contains("dummy") + && vfModuleMeta.getVfModuleModelName().contains("ignore")) + continue; vfModulesStructureList.add(new VfModuleStructure(this, vfModuleMeta)); } setNumberOfResources(vfModulesMetadataList.size()); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy index 644cf5e387..b457bdca46 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DoHandleOofRequest.groovy @@ -83,7 +83,7 @@ class DoHandleOofRequest extends AbstractServiceTaskProcessor { execution.setVariable("oofRequestPayload", requestJson) } - public void callOofAdapter(DelegateExecution execution) { + void callOofAdapter(DelegateExecution execution) { logger.debug("Start callOofAdapter") String requestId = execution.getVariable("msoRequestId") String oofAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.oof.endpoint", execution) @@ -95,7 +95,7 @@ class DoHandleOofRequest extends AbstractServiceTaskProcessor { Response httpResponse = httpClient.post(oofRequest) int responseCode = httpResponse.getStatus() logger.debug("OOF sync response code is: " + responseCode) - if(responseCode != 200){ + if(responseCode < 200 || responseCode >= 300){ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 30cbeaf2d8..ff31c46a3a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -540,10 +540,8 @@ class OofUtils { " \"timeout\": 600,\n" + " \"callbackUrl\": \"${callbackUrl}\"\n" + " },\n") - response.append(" \"serviceProfile\": {\n" + - " \"serviceProfileParameters\": ") - response.append(json); - response.append("\n }\n") + response.append(" \"serviceProfile\":") + response.append(json) response.append("\n}\n") return response.toString() } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 72fd052f31..5f0d412de0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.so.serviceinstancebeans.Service import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError @@ -126,21 +127,22 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { logger.debug("modelInfo: " + serviceModelInfo) - //requestParameters - String subscriptionServiceType = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestParameters.subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - logger.debug("subscriptionServiceType: " + subscriptionServiceType) +// //requestParameters +// String subscriptionServiceType = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestParameters.subscriptionServiceType") +// if (isBlank(subscriptionServiceType)) { +// msg = "Input subscriptionServiceType is null" +// logger.debug(msg) +// exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) +// } else { +// subscriptionServiceType = "5G" +// execution.setVariable("subscriptionServiceType", subscriptionServiceType) +// } +// logger.debug("subscriptionServiceType: " + subscriptionServiceType) /* * Extracting User Parameters from incoming Request and converting into a Map */ - Map reqMap = jsonSlurper.parseText(ssRequest) + Map reqMap = jsonSlurper.parseText(ssRequest) as Map //InputParams def userParamsList = reqMap.requestDetails?.requestParameters?.userParams @@ -168,6 +170,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { execution.setVariable("serviceInputParams", inputMap) execution.setVariable("uuiRequest", uuiRequest) execution.setVariable("serviceProfile", serviceProfile) + execution.setVariable("subscriptionServiceType", serviceObject.get("serviceType")) //TODO //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index 48e1acd523..fc80a9f658 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -101,6 +101,9 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ */ String serviceRole = "service-profile" String serviceType = execution.getVariable("serviceType") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + Map<String, Object> serviceProfile = sliceParams.getServiceProfile() String ssInstanceId = execution.getVariable("serviceInstanceId") try { @@ -121,7 +124,10 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(ssInstanceId)) client.create(uri, ss) } catch (BpmnError e) { throw e @@ -139,8 +145,8 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", ssInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", subscriptionServiceType) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", globalSubscriberId) execution.setVariable("rollbackData", rollbackData) execution.setVariable("RollbackData", rollbackData) logger.debug("RollbackData:" + rollbackData) @@ -156,6 +162,8 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ /** * todo: ServiceProfile params changed */ + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter Map<String, Object> serviceProfileMap = sliceParams.getServiceProfile() @@ -181,11 +189,11 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ serviceProfile.setSurvivalTime("0") serviceProfile.setReliability("") try { - AAIResourceUri uri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")) - .serviceSubscription(execution.getVariable("subscriptionServiceType")) - .serviceInstance(serviceProfileInstanceId) - .serviceProfile(serviceProfileId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceProfileInstanceId) + .serviceProfile(serviceProfileId)) client.create(uri, serviceProfile) execution.setVariable("sliceTaskParams", sliceParams) @@ -206,15 +214,21 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ public void createAllottedResource(DelegateExecution execution) { try { - + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceProfileDecomposition") as ServiceDecomposition + String serviceInstanceId = execution.getVariable("serviceInstanceId") List<org.onap.so.bpmn.core.domain.AllottedResource> allottedResourceList = serviceDecomposition.getAllottedResources() for(org.onap.so.bpmn.core.domain.AllottedResource allottedResource : allottedResourceList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("serviceInstanceId")).allottedResource(allottedResourceId)) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceInstanceId) + .allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String arType = allottedResource.getAllottedResourceType() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 1d5232f3c5..cfdbe98c34 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -371,6 +371,9 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ execution.setVariable("needQuerySliceProfile", true) } else { + if(execution.getVariable("needQuerySliceProfile")){ + execution.setVariable("needQuerySliceProfile", false) + } processNewNSI(solution, sliceTaskParams) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 7beafefc28..f20bca9837 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.SliceProfile import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri @@ -133,7 +134,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { throw e } catch (Exception ex) { String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance: " + ex.getMessage() - logger.info(msg) + logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } @@ -163,6 +164,8 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) getAAIClient().create(allottedResourceUri, resource) + createNetworkPolicyForAllocatedResource(execution, ssInstanceId, allottedResourceId) + String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") createLogicalLinksForAllocatedResource(execution, linkArrayStr, ssInstanceId, allottedResourceId) } @@ -170,7 +173,81 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { throw e } catch (Exception ex) { String msg = "Exception in DoCreateTnNssiInstance.createAllottedResource: " + ex.getMessage() - logger.info(msg) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void createNetworkPolicy(DelegateExecution execution, String ssInstanceId, String networkPolicyId) { + try { + + String sliceProfileStr = execution.getVariable("sliceProfile") + if (sliceProfileStr == null || sliceProfileStr.isEmpty()) { + String msg = "ERROR: createNetworkPolicy: sliceProfile is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId(networkPolicyId) + networkPolicy.setName("TSCi policy") + networkPolicy.setType("SLA") + networkPolicy.setNetworkPolicyFqdn(ssInstanceId) + + String latencyStr = jsonUtil.getJsonValue(sliceProfileStr, "latency") + if (latencyStr != null && !latencyStr.isEmpty()) { + networkPolicy.setLatency(Integer.parseInt(latencyStr)) + } + + String bwStr = jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth") + if (bwStr != null && !bwStr.isEmpty()) { + networkPolicy.setMaxBandwidth(Integer.parseInt(bwStr)) + } else { + log.debug("ERROR: createNetworkPolicy: maxBandwidth is null") + } + + //networkPolicy.setReliability(new Object()) + + AAIResourceUri networkPolicyUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) + getAAIClient().create(networkPolicyUri, networkPolicy) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void createNetworkPolicyForAllocatedResource(DelegateExecution execution, + String ssInstanceId, + String allottedResourceId) { + try { + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId) + .allottedResource(allottedResourceId)) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + + String networkPolicyId = UUID.randomUUID().toString() + createNetworkPolicy(execution, ssInstanceId, networkPolicyId) + + tnNssmfUtils.attachNetworkPolicyToAllottedResource(execution, AAI_VERSION, allottedResourceUri, networkPolicyId); + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } @@ -219,7 +296,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { throw e } catch (Exception ex) { String msg = "Exception in DoCreateTnNssiInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage() - logger.info(msg) + logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index 75ef7d347c..f3bc47e7cf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -151,6 +151,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor serviceInfo.setServiceInvariantUuid(serviceInvariantUuid) serviceInfo.setServiceUuid(serviceUuid) serviceInfo.setNsiId(nsiId) + serviceInfo.setNssiId(nssiId) serviceInfo.setGlobalSubscriberId(globalSubscriberId) serviceInfo.setSubscriptionServiceType(subscriptionServiceType) String serviceInfoString = objectMapper.writeValueAsString(serviceInfo) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index e856522fca..8a276ed330 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -321,7 +321,8 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("sliceServiceInstanceId") + String serviceId = execution.getVariable("dummyServiceId") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") @@ -329,6 +330,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { roStatus.setServiceId(serviceId) roStatus.setOperationId(jobId) roStatus.setResourceTemplateUUID(nsiId) + roStatus.setResourceInstanceID(ssInstanceId) roStatus.setOperType("Allocate") roStatus.setProgress(progress) roStatus.setStatus(status) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index 869b55b5d2..d97f416db9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -118,55 +118,67 @@ class TnNssmfUtils { if (execution.getVariable("vnfParamsExistFlag") == true) { sdncVNFParamsXml = buildSDNCParamsXml(execution) } else { - sdncVNFParamsXml = "" + sdncVNFParamsXml = buildDefaultVnfInputParams(vnfId) } String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" - xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" - xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> - <request-action>${MsoUtils.xmlEscape(reqAction)}</request-action> - <source>${MsoUtils.xmlEscape(source)}</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> - <subscription-service-type>${MsoUtils.xmlEscape(subServiceType)}</subscription-service-type> - ${serviceEcompModelInformation} - <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id> - <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> - </service-information> - <vnf-information> - <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> - <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - ${vnfEcompModelInformation} - </vnf-information> - <vnf-request-input> - ${vnfNameString} - <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant> - <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> - ${sdncVNFParamsXml} - </vnf-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> + <request-action>${MsoUtils.xmlEscape(reqAction)}</request-action> + <source>${MsoUtils.xmlEscape(source)}</source> + <notification-url/> + <order-number/> + <order-version/> + </request-information> + <service-information> + <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> + <subscription-service-type>${MsoUtils.xmlEscape(subServiceType)}</subscription-service-type> + ${serviceEcompModelInformation} + <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id> + <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> + </service-information> + <vnf-information> + <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> + <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> + ${vnfEcompModelInformation} + </vnf-information> + <vnf-request-input> + ${vnfNameString} + <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant> + <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> + ${sdncVNFParamsXml} + </vnf-request-input> + </sdncadapterworkflow:SDNCRequestData> + </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" logger.debug("sdncRequest: " + sdncRequest) return sdncRequest } + + String buildDefaultVnfInputParams(String vnfName) { + String res = + """<vnf-input-parameters> + <param> + <name>${MsoUtils.xmlEscape(vnfName)}</name> + </param> + </vnf-input-parameters>""" + + return res + } + String buildSDNCParamsXml(DelegateExecution execution) { String params = "" StringBuilder sb = new StringBuilder() @@ -241,19 +253,19 @@ class TnNssmfUtils { } String getExecutionInputParams(DelegateExecution execution) { - String res = "msoRequestId=" + execution.getVariable("msoRequestId") + - ", modelInvariantUuid=" + execution.getVariable("modelInvariantUuid") + - ", modelUuid=" + execution.getVariable("modelUuid") + - ", serviceInstanceID=" + execution.getVariable("serviceInstanceID") + - ", operationType=" + execution.getVariable("operationType") + - ", globalSubscriberId=" + execution.getVariable("globalSubscriberId") + - ", dummyServiceId=" + execution.getVariable("dummyServiceId") + - ", nsiId=" + execution.getVariable("nsiId") + - ", networkType=" + execution.getVariable("networkType") + - ", subscriptionServiceType=" + execution.getVariable("subscriptionServiceType") + - ", jobId=" + execution.getVariable("jobId") + - ", sliceParams=" + execution.getVariable("sliceParams") + - ", servicename=" + execution.getVariable("servicename") + String res = "\n msoRequestId=" + execution.getVariable("msoRequestId") + + "\n modelInvariantUuid=" + execution.getVariable("modelInvariantUuid") + + "\n modelUuid=" + execution.getVariable("modelUuid") + + "\n serviceInstanceID=" + execution.getVariable("serviceInstanceID") + + "\n operationType=" + execution.getVariable("operationType") + + "\n globalSubscriberId=" + execution.getVariable("globalSubscriberId") + + "\n dummyServiceId=" + execution.getVariable("dummyServiceId") + + "\n nsiId=" + execution.getVariable("nsiId") + + "\n networkType=" + execution.getVariable("networkType") + + "\n subscriptionServiceType=" + execution.getVariable("subscriptionServiceType") + + "\n jobId=" + execution.getVariable("jobId") + + "\n sliceParams=" + execution.getVariable("sliceParams") + + "\n servicename=" + execution.getVariable("servicename") return res } @@ -297,7 +309,6 @@ class TnNssmfUtils { void attachLogicalLinkToAllottedResource(DelegateExecution execution, String aaiVersion, AAIResourceUri arUri, String logicalLinkId) { - String toLink = "aai/${aaiVersion}/network/logical-links/logical-link/${logicalLinkId}" Relationship relationship = new Relationship() @@ -307,4 +318,18 @@ class TnNssmfUtils { createRelationShipInAAI(execution, arUri, relationship) } + + void attachNetworkPolicyToAllottedResource(DelegateExecution execution, String aaiVersion, + AAIResourceUri aaiResourceUri, String networkPolicyId) { + + String toLink = "aai/${aaiVersion}/network/network-policies/network-policy/${networkPolicyId}" + + Relationship relationship = new Relationship() + relationship.setRelatedLink(toLink) + relationship.setRelatedTo("network-policy") + relationship.setRelationshipLabel("org.onap.relationships.inventory.Uses") + + createRelationShipInAAI(execution, aaiResourceUri, relationship) + + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn index 2aa7da2cd2..f2d4d7c701 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn @@ -44,7 +44,7 @@ dcsi.createAllottedResource(execution)</bpmn:script> <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1wafqwa</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcsi= new CreateSliceService() +def dcsi = new DoCreateSliceServiceInstance() dcsi.prepareDecomposeService(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="CallActivity_0svmkxh" name="Call Decompose Service" calledElement="DecomposeService"> @@ -135,4 +135,4 @@ dcsi.prepareDecomposeService(execution)</bpmn:script> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn index 55adbe3698..fefa022bb9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateTnNssiInstance.bpmn @@ -21,9 +21,9 @@ def dcsi = new DoCreateTnNssiInstance() dcsi.createServiceInstance(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_1uiz85h" sourceRef="Activity_16luyg1" targetRef="Event_1rsf7yb" /> - <bpmn:sequenceFlow id="SequenceFlow_0g5bwvl" sourceRef="instantiate_NSTask" targetRef="Activity_08tw2di" /> + <bpmn:sequenceFlow id="SequenceFlow_0g5bwvl" sourceRef="instantiate_NSTask" targetRef="ScriptTask_18rzwzb" /> <bpmn:scriptTask id="ScriptTask_18rzwzb" name="Create Allottedsource in AAI" scriptFormat="groovy"> - <bpmn:incoming>Flow_106ei42</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0g5bwvl</bpmn:incoming> <bpmn:outgoing>SequenceFlow_17u69c4</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcsi = new DoCreateTnNssiInstance() @@ -74,14 +74,6 @@ dcsi.validateSDNCResponse(execution, response, "allocate")</bpmn:script> <bpmn:incoming>SequenceFlow_17u69c4</bpmn:incoming> <bpmn:linkEventDefinition id="LinkEventDefinition_1skl6p7" name="SdncOperation" /> </bpmn:intermediateThrowEvent> - <bpmn:scriptTask id="Activity_08tw2di" name="create Slice Profile in AAI" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0g5bwvl</bpmn:incoming> - <bpmn:outgoing>Flow_106ei42</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcsi = new DoCreateTnNssiInstance() -dcsi.createSliceProfile(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="Flow_106ei42" sourceRef="Activity_08tw2di" targetRef="ScriptTask_18rzwzb" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateTnNssiInstance"> @@ -98,12 +90,12 @@ dcsi.createSliceProfile(execution)</bpmn:script> <di:waypoint x="299" y="375" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_17u69c4_di" bpmnElement="SequenceFlow_17u69c4"> - <di:waypoint x="930" y="129" /> - <di:waypoint x="1102" y="129" /> + <di:waypoint x="830" y="129" /> + <di:waypoint x="982" y="129" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0g5bwvl_di" bpmnElement="SequenceFlow_0g5bwvl"> - <di:waypoint x="574" y="129" /> - <di:waypoint x="650" y="129" /> + <di:waypoint x="600" y="129" /> + <di:waypoint x="730" y="129" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1uiz85h_di" bpmnElement="SequenceFlow_1uiz85h"> <di:waypoint x="840" y="375" /> @@ -113,37 +105,25 @@ dcsi.createSliceProfile(execution)</bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> - <di:waypoint x="393" y="129" /> - <di:waypoint x="474" y="129" /> + <di:waypoint x="410" y="129" /> + <di:waypoint x="500" y="129" /> <bpmndi:BPMNLabel> <dc:Bounds x="436" y="108" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> <di:waypoint x="211" y="129" /> - <di:waypoint x="251" y="129" /> - <di:waypoint x="251" y="129" /> - <di:waypoint x="293" y="129" /> + <di:waypoint x="310" y="129" /> <bpmndi:BPMNLabel> <dc:Bounds x="266" y="123" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_106ei42_di" bpmnElement="Flow_106ei42"> - <di:waypoint x="750" y="129" /> - <di:waypoint x="830" y="129" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateTnNssi_StartEvent"> <dc:Bounds x="175" y="111" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="153" y="147" width="86" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> - <dc:Bounds x="293" y="89" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask"> - <dc:Bounds x="474" y="89" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_0l9vk9p_di" bpmnElement="Event_0l9vk9p"> <dc:Bounds x="175" y="357" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -163,16 +143,19 @@ dcsi.createSliceProfile(execution)</bpmn:script> <dc:Bounds x="972" y="357" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_1a9swwa_di" bpmnElement="Event_1a9swwa"> - <dc:Bounds x="1102" y="111" width="36" height="36" /> + <dc:Bounds x="982" y="111" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1093" y="154" width="59" height="27" /> + <dc:Bounds x="973" y="154" width="59" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_18rzwzb_di" bpmnElement="ScriptTask_18rzwzb"> - <dc:Bounds x="830" y="89" width="100" height="80" /> + <dc:Bounds x="730" y="89" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_08tw2di_di" bpmnElement="Activity_08tw2di"> - <dc:Bounds x="650" y="89" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask"> + <dc:Bounds x="500" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="310" y="89" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index d9ad245e76..7c4f735577 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Optional; @@ -1663,8 +1664,11 @@ public class WorkflowAction { execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); } List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList(); - if (flows == null) + if (flows == null) { flows = new ArrayList<>(); + } else { + flows.sort(Comparator.comparingInt(OrchestrationFlow::getSequenceNumber)); + } for (OrchestrationFlow flow : flows) { if (!flow.getFlowName().contains("BB") && !flow.getFlowName().contains("Activity")) { List<OrchestrationFlow> macroQueryFlows = diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 53d1bea1f2..50ff074866 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -3110,9 +3110,11 @@ public class WorkflowActionTest extends BaseTaskTest { private List<OrchestrationFlow> createFlowList(String... flowNames) { List<OrchestrationFlow> result = new ArrayList<>(); + int sequenceNumber = 1; for (String flowName : flowNames) { OrchestrationFlow orchFlow = new OrchestrationFlow(); orchFlow.setFlowName(flowName); + orchFlow.setSequenceNumber(sequenceNumber++); result.add(orchFlow); } return result; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java index a44dbd636f..e4989059a3 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java @@ -44,7 +44,7 @@ public class NssmfAdapterNBIRequest implements Serializable { private DeAllocateNssi deAllocateNssi; - private String subnetCapabilityQuery; + private Object subnetCapabilityQuery; private String responseId; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java index 8ea0eb6587..e97aa704eb 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java @@ -48,23 +48,23 @@ public class SliceTaskParamsAdapter implements Serializable { private String nstName; - private Map<String, Object> serviceProfile; + private Map<String, Object> serviceProfile = new HashMap<>(); private String suggestNsiId; private String suggestNsiName; - private TemplateInfo NSTInfo; + private TemplateInfo NSTInfo = new TemplateInfo(); - private SliceTaskInfo<TnSliceProfile> tnBHSliceTaskInfo; + private SliceTaskInfo<TnSliceProfile> tnBHSliceTaskInfo = new SliceTaskInfo<>(); - private SliceTaskInfo<TnSliceProfile> tnMHSliceTaskInfo; + private SliceTaskInfo<TnSliceProfile> tnMHSliceTaskInfo = new SliceTaskInfo<>(); - private SliceTaskInfo<TnSliceProfile> tnFHSliceTaskInfo; + private SliceTaskInfo<TnSliceProfile> tnFHSliceTaskInfo = new SliceTaskInfo<>(); - private SliceTaskInfo<CnSliceProfile> cnSliceTaskInfo; + private SliceTaskInfo<CnSliceProfile> cnSliceTaskInfo = new SliceTaskInfo<>(); - private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo; + private SliceTaskInfo<AnSliceProfile> anSliceTaskInfo = new SliceTaskInfo<>(); @SuppressWarnings("unchecked") public void convertFromJson(String jsonString) throws IOException { @@ -226,6 +226,10 @@ public class SliceTaskParamsAdapter implements Serializable { */ private <T> Map<String, Object> bean2Map(T t) { Map<String, Object> resMap = new HashMap<>(); + if (t == null) { + return resMap; + } + try { Field[] fields = t.getClass().getDeclaredFields(); for (Field field : fields) { diff --git a/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java b/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java index 6c2c76e87c..b17b1fe0fe 100644 --- a/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java +++ b/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java @@ -38,15 +38,18 @@ public class HttpClientConnectionConfiguration { @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}") private int socketTimeOutInSeconds; - @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}") + @Value(value = "${rest.http.client.configuration.timeToLiveInSeconds:600}") private int timeToLiveInSeconds; - @Value(value = "${rest.http.client.configuration.maxConnections:10}") + @Value(value = "${rest.http.client.configuration.maxConnections:100}") private int maxConnections; - @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}") + @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:20}") private int maxConnectionsPerRoute; + @Value(value = "${rest.http.client.configuration.evictIdleConnectionsTimeInSec:5}") + private int evictIdleConnectionsTimeInSec; + /** * @return the socket connection time out in milliseconds */ @@ -82,4 +85,8 @@ public class HttpClientConnectionConfiguration { return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds); } + public long getEvictIdleConnectionsTimeInSec() { + return evictIdleConnectionsTimeInSec; + } + } diff --git a/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java b/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java index 882ed95cfc..aef2ed165e 100644 --- a/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java +++ b/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java @@ -22,6 +22,7 @@ package org.onap.so.configuration.rest; import java.util.concurrent.TimeUnit; import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.NoConnectionReuseStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; @@ -55,7 +56,10 @@ public class HttpComponentsClientConfiguration { return HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager()) .setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute()) .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections()) - .setDefaultRequestConfig(requestConfig()).build(); + .setDefaultRequestConfig(requestConfig()).setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE) + .evictExpiredConnections().evictIdleConnections( + clientConnectionConfiguration.getEvictIdleConnectionsTimeInSec(), TimeUnit.SECONDS) + .build(); } @Bean diff --git a/releases/1.7.6-nslcm-adapter.yaml b/releases/1.7.6-nslcm-adapter.yaml new file mode 100644 index 0000000000..0f78b9f1db --- /dev/null +++ b/releases/1.7.6-nslcm-adapter.yaml @@ -0,0 +1,9 @@ +--- +distribution_type: 'container' +container_release_tag: '1.7.7' +project: 'so' +log_dir: 'so-maven-docker-stage-master/510/' +ref: '1757b2f9727591fd5907f43834dbe9f0b8261740' +containers: + - name: 'so/so-etsi-nfvo-ns-lcm' + version: '1.7.6-20201102T0420'
\ No newline at end of file diff --git a/releases/1.7.7.yaml b/releases/1.7.7.yaml new file mode 100644 index 0000000000..d19c9742ef --- /dev/null +++ b/releases/1.7.7.yaml @@ -0,0 +1,33 @@ +--- +distribution_type: 'container' +container_release_tag: '1.7.7' +project: 'so' +log_dir: 'so-maven-docker-stage-master/504/' +ref: 'deb4f1d1292d661b08f8969a117b7b979551158a' +containers: + - name: 'so/vnfm-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/catalog-db-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/request-db-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/openstack-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/sdnc-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/vfc-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/sdc-controller' + version: '1.7.6-20201027T1345' + - name: 'so/bpmn-infra' + version: '1.7.6-20201027T1345' + - name: 'so/so-monitoring' + version: '1.7.6-20201027T1345' + - name: 'so/api-handler-infra' + version: '1.7.6-20201027T1345' + - name: 'so/nssmf-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/mso-cnf-adapter' + version: '1.7.6-20201027T1345' + - name: 'so/so-oof-adapter' + version: '1.7.6-20201027T1345'
\ No newline at end of file diff --git a/version.properties b/version.properties index ae46bac616..10c959331e 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=7 -patch=5 +patch=6 base_version=${major}.${minor}.${patch} |