diff options
73 files changed, 1147 insertions, 3178 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/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java deleted file mode 100644 index 4e5e880f80..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.inventory.delete; - -import javax.annotation.PostConstruct; -import org.onap.so.utils.ExternalTaskServiceUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -@Profile("!test") -public class DeleteInventoryService { - - @Autowired - public Environment env; - - @Autowired - private DeleteInventoryTask deleteInventory; - - @Autowired - private ExternalTaskServiceUtils externalTaskServiceUtils; - - @PostConstruct - public void auditAAIInventory() throws Exception { - for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { - externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") - .lockDuration(externalTaskServiceUtils.getLockDurationMedium()) - .handler(deleteInventory::executeExternalTask).open(); - } - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java index d4a4bb792f..b176892192 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java @@ -22,10 +22,8 @@ package org.onap.so.adapters.tasks; import javax.annotation.PostConstruct; import org.camunda.bpm.client.ExternalTaskClient; -import org.onap.so.adapters.tasks.audit.AuditCreateStackService; -import org.onap.so.adapters.tasks.audit.AuditDeleteStackService; -import org.onap.so.adapters.tasks.audit.AuditQueryStackService; import org.onap.so.adapters.tasks.inventory.CreateInventoryTask; +import org.onap.so.adapters.tasks.inventory.DeleteInventoryTask; import org.onap.so.adapters.tasks.orchestration.PollService; import org.onap.so.adapters.tasks.orchestration.RollbackService; import org.onap.so.adapters.tasks.orchestration.StackService; @@ -46,15 +44,6 @@ public class TaskServices { private ExternalTaskServiceUtils externalTaskServiceUtils; @Autowired - private AuditCreateStackService auditCreateStack; - - @Autowired - private AuditDeleteStackService auditDeleteStack; - - @Autowired - private AuditQueryStackService auditQueryStack; - - @Autowired private CreateInventoryTask createInventory; @Autowired @@ -66,39 +55,24 @@ public class TaskServices { @Autowired private RollbackService rollbackService; - @PostConstruct - public void auditAddAAIInventory() throws Exception { - for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { - ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) - .handler(auditCreateStack::executeExternalTask).open(); - } - } - - @PostConstruct - public void auditDeleteAAIInventory() throws Exception { - for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { - ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) - .handler(auditDeleteStack::executeExternalTask).open(); - } - } + @Autowired + private DeleteInventoryTask deleteInventory; @PostConstruct - public void auditQueryInventory() throws Exception { + public void createtAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryQueryAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) - .handler(auditQueryStack::executeExternalTask).open(); + client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration()) + .handler(createInventory::executeExternalTask).open(); } } @PostConstruct - public void createtAAIInventory() throws Exception { + public void auditAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { - ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration()) - .handler(createInventory::executeExternalTask).open(); + externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") + .lockDuration(externalTaskServiceUtils.getLockDurationMedium()) + .handler(deleteInventory::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java deleted file mode 100644 index 0c6bb6f387..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.tasks.audit; - -import org.onap.aaiclient.client.aai.AAIResourcesClient; - -public class AbstractAudit { - - private AAIResourcesClient aaiClient; - - protected AAIResourcesClient getAaiClient() { - if (aaiClient == null) - return new AAIResourcesClient(); - else - return aaiClient; - } - - protected void setAaiClient(AAIResourcesClient aaiResource) { - aaiClient = aaiResource; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java deleted file mode 100644 index 8cdd37d43f..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.tasks.audit; - -import org.onap.so.objects.audit.AAIObjectAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.onap.so.utils.ExternalTaskUtils; -import org.onap.so.utils.RetrySequenceLevel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -public abstract class AbstractAuditService extends ExternalTaskUtils { - - private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class); - - protected static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = - "Unable to find all VServers and L-Interaces in A&AI"; - - protected static final String UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK = "Unable to find VServers in Openstack"; - - @Autowired - public Environment env; - - public AbstractAuditService() { - super(RetrySequenceLevel.LONG); - } - - /** - * @param auditList - * @return - */ - protected boolean didCreateAuditFail(AAIObjectAuditList auditList) { - if (isAuditListNotNullAndNotEmpty(auditList)) { - if (logger.isInfoEnabled()) { - logger.info("Audit Results: {}", auditList.toString()); - } - return auditList.getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst() - .map(v -> true).orElse(false); - } else { - return false; - } - } - - /** - * @param auditList - * @return - */ - protected boolean didDeleteAuditFail(AAIObjectAuditList auditList) { - if (isAuditListNotNullAndNotEmpty(auditList)) { - if (logger.isInfoEnabled()) { - logger.info("Audit Results: {}", auditList.toString()); - } - return auditList.getAuditList().stream().filter(AAIObjectAudit::isDoesObjectExist).findFirst() - .map(v -> true).orElse(false); - } else { - return false; - } - } - - private boolean isAuditListNotNullAndNotEmpty(AAIObjectAuditList auditList) { - return auditList != null && auditList.getAuditList() != null && !auditList.getAuditList().isEmpty(); - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java deleted file mode 100644 index a4afcf1378..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.tasks.audit; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.ExternalTaskService; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.audit.beans.AuditInventory; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.logging.tasks.AuditMDCSetup; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class AuditCreateStackService extends AbstractAuditService { - - private static final Logger logger = LoggerFactory.getLogger(AuditCreateStackService.class); - - @Autowired - public HeatStackAudit heatStackAudit; - - @Autowired - public AuditMDCSetup mdcSetup; - - public AuditCreateStackService() { - super(); - } - - public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { - mdcSetup.setupMDC(externalTask); - AuditInventory auditInventory = externalTask.getVariable("auditInventory"); - Map<String, Object> variables = new HashMap<>(); - boolean success = false; - try { - Integer retryCount = externalTask.getRetries(); - logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", retryCount, auditInventory); - Optional<AAIObjectAuditList> auditListOpt = heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), - auditInventory.getCloudOwner(), auditInventory.getTenantId(), auditInventory.getHeatStackName()); - if (auditListOpt.isPresent()) { - auditListOpt.get().setAuditType("create"); - auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName()); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get())); - success = !didCreateAuditFail(auditListOpt.get()); - } - } catch (Exception e) { - logger.error("Error during audit of stack", e); - } - variables.put("auditIsSuccessful", success); - mdcSetup.setElapsedTime(); - String externalTaskId = externalTask.getId(); - if (success) { - externalTaskService.complete(externalTask, variables); - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - logger.debug("The External Task Id: {} Successful", externalTaskId); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); - mdcSetup.clearClientMDCs(); - } else { - Integer retryCount = externalTask.getRetries(); - if (retryCount == null) { - logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", - externalTaskId, getRetrySequence().length); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, - UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, getRetrySequence().length, 10000); - } else if (retryCount == 1) { - externalTaskService.complete(externalTask, variables); - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); - mdcSetup.clearClientMDCs(); - } else { - logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", - externalTaskId, retryCount - 1, calculateRetryDelay(retryCount)); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, - UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, retryCount - 1, - calculateRetryDelay(retryCount)); - } - logger.debug("The External Task Id: {} Failed", externalTaskId); - } - } - - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java deleted file mode 100644 index 200f6375ea..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.onap.so.adapters.tasks.audit; - -import java.io.IOException; -import java.util.List; -import java.util.Optional; -import org.onap.so.audit.beans.AuditInventory; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.db.request.beans.RequestProcessingData; -import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; - -@Component -public class AuditDataService { - - private static final String AUDIT_STACK_DATA = "AuditStackData"; - - @Autowired - private RequestsDbClient requestsDbClient; - - /** - * Checks to see if an entry already exist for the given heat stack and writes audit stack data to the request - * database if it doesn't. - * - * @throws JsonProcessingException - */ - public void writeStackDataToRequestDb(AuditInventory auditInventory, AAIObjectAuditList auditList) - throws JsonProcessingException { - List<RequestProcessingData> requestProcessingDataList = - requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), AUDIT_STACK_DATA); - if (requestProcessingDataList.isEmpty()) { - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; - - RequestProcessingData requestProcessingData = new RequestProcessingData(); - requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); - requestProcessingData.setGroupingId(auditInventory.getVfModuleId()); - requestProcessingData.setName(auditInventory.getHeatStackName()); - requestProcessingData.setTag(AUDIT_STACK_DATA); - requestProcessingData.setValue(auditListString); - - requestsDbClient.saveRequestProcessingData(requestProcessingData); - } - } - - /** - * Retrieves audit stack data from the request database. - * - * @throws IOException - * @throws JsonMappingException - * @throws JsonParseException - */ - public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) throws IOException { - - List<RequestProcessingData> requestProcessingDataList = - requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), AUDIT_STACK_DATA); - if (!requestProcessingDataList.isEmpty()) { - RequestProcessingData requestProcessingData = requestProcessingDataList.get(0); - String auditListString = requestProcessingData.getValue(); - - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - AAIObjectAuditList auditList = - objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class); - - return Optional.of(auditList); - } else { - return Optional.empty(); - } - } - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java deleted file mode 100644 index a7fdc352cd..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.tasks.audit; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.ExternalTaskService; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.audit.beans.AuditInventory; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.logging.tasks.AuditMDCSetup; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -public class AuditDeleteStackService extends AbstractAuditService { - - private static final Logger logger = LoggerFactory.getLogger(AuditDeleteStackService.class); - - @Autowired - protected HeatStackAudit heatStackAudit; - - @Autowired - protected AuditVServer auditVservers; - - @Autowired - protected AuditDataService auditDataService; - - @Autowired - protected Environment env; - - @Autowired - public AuditMDCSetup mdcSetup; - - public AuditDeleteStackService() { - super(); - } - - public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { - - mdcSetup.setupMDC(externalTask); - AuditInventory auditInventory = externalTask.getVariable("auditInventory"); - Map<String, Object> variables = new HashMap<>(); - boolean success = false; - try { - Integer retryCount = externalTask.getRetries(); - logger.info("Executing External Task Delete Audit Inventory. Retry Number: {}", retryCount); - Optional<AAIObjectAuditList> auditListOpt = auditDataService.getStackDataFromRequestDb(auditInventory); - if (auditListOpt.isPresent()) { - auditVservers.auditVservers(auditListOpt.get()); - } else { - logger.debug("Auditing Vservers based on vf module relationships"); - auditListOpt = auditVservers.auditVserversThroughRelationships(auditInventory.getGenericVnfId(), - auditInventory.getHeatStackName()); - } - auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName()); - auditListOpt.get().setAuditType("delete"); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get())); - success = !didDeleteAuditFail(auditListOpt.get()); - - } catch (Exception e) { - logger.error("Error during audit of stack", e); - } - variables.put("auditIsSuccessful", success); - mdcSetup.setElapsedTime(); - String externalTaskId = externalTask.getId(); - if (success) { - externalTaskService.complete(externalTask, variables); - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - logger.debug("The External Task Id: {} Successful", externalTaskId); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); - mdcSetup.clearClientMDCs(); - } else { - Integer retryCount = externalTask.getRetries(); - if (retryCount == null) { - logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", - externalTaskId, getRetrySequence().length); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, - UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, getRetrySequence().length, 10000); - } else if (retryCount == 1) { - externalTaskService.complete(externalTask, variables); - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); - mdcSetup.clearClientMDCs(); - } else { - logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", - externalTaskId, retryCount - 1, calculateRetryDelay(retryCount)); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, - UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, retryCount - 1, - calculateRetryDelay(retryCount)); - } - logger.debug("The External Task Id: {} Failed", externalTaskId); - } - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java deleted file mode 100644 index ebef4425eb..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.onap.so.adapters.tasks.audit; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.ExternalTaskService; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.audit.beans.AuditInventory; -import org.onap.so.logging.tasks.AuditMDCSetup; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class AuditQueryStackService extends AbstractAuditService { - - private static final Logger logger = LoggerFactory.getLogger(AuditQueryStackService.class); - - @Autowired - protected HeatStackAudit heatStackAudit; - - @Autowired - protected AuditDataService auditDataService; - - @Autowired - public AuditMDCSetup mdcSetup; - - public AuditQueryStackService() { - super(); - } - - public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { - mdcSetup.setupMDC(externalTask); - AuditInventory auditInventory = externalTask.getVariable("auditInventory"); - boolean success = false; - Map<String, Object> variables = new HashMap<>(); - try { - Integer retryCount = externalTask.getRetries(); - logger.info("Executing External Task Query Audit Inventory. Audit Inventory: {} \n Retry Number: {}", - auditInventory.toString(), retryCount); - - Optional<AAIObjectAuditList> auditList = heatStackAudit.queryHeatStack(auditInventory.getCloudOwner(), - auditInventory.getCloudRegion(), auditInventory.getTenantId(), auditInventory.getHeatStackName()); - - if (auditList.isPresent()) { - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - success = true; - auditDataService.writeStackDataToRequestDb(auditInventory, auditList.get()); - } - mdcSetup.setElapsedTime(); - String externalTaskId = externalTask.getId(); - if (success) { - externalTaskService.complete(externalTask, variables); - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - logger.debug("The External Task {} was Successful", externalTaskId); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); - mdcSetup.clearClientMDCs(); - } else { - if (retryCount == null) { - logger.debug("The External Task {} Failed. Setting Retries to Default Start Value: {}", - externalTaskId, getRetrySequence().length); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK, - UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK, getRetrySequence().length, 10000); - } else if (retryCount == 1) { - externalTaskService.complete(externalTask, variables); - mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.debug("The External Task {} Failed. All Retries Exhausted", externalTaskId); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); - mdcSetup.clearClientMDCs(); - } else { - logger.debug("The External Task {} Failed. Decrementing Retries to {} , Retry Delay: ", - externalTaskId, retryCount - 1, calculateRetryDelay(retryCount)); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK, - UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK, retryCount - 1, calculateRetryDelay(retryCount)); - } - logger.debug("The External Task {} Failed", externalTaskId); - } - } catch (Exception e) { - logger.error("Error during audit query of stack", e); - } - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java deleted file mode 100644 index 6f87b6b309..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.tasks.audit; - -import java.util.List; -import java.util.Optional; -import java.util.Set; -import org.onap.aai.domain.yang.LInterface; -import org.onap.aai.domain.yang.VfModule; -import org.onap.aai.domain.yang.VfModules; -import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.objects.audit.AAIObjectAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; - -@Component -public class AuditVServer extends AbstractAudit { - private static final Logger logger = LoggerFactory.getLogger(AuditVServer.class); - - public void auditVservers(AAIObjectAuditList aaiObjectAuditList) { - - aaiObjectAuditList.getAuditList().forEach(aaiObjectAudit -> { - boolean vserverExist = getAaiClient().exists( - AAIUriFactory.createResourceFromExistingURI(Types.VSERVER, aaiObjectAudit.getResourceURI())); - aaiObjectAudit.setDoesObjectExist(vserverExist); - }); - } - - public Optional<AAIObjectAuditList> auditVserversThroughRelationships(String genericVnfId, String vfModuleName) { - AAIObjectAuditList auditList = new AAIObjectAuditList(); - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModules()) - .queryParam("vf-module-name", vfModuleName); - Optional<AAIResultWrapper> wrapper = getAaiClient().getFirstWrapper(VfModules.class, VfModule.class, uri); - if (wrapper.isPresent() && wrapper.get().getRelationships().isPresent()) { - List<AAIResourceUri> relatedVservers = wrapper.get().getRelationships().get().getRelatedUris(Types.VSERVER); - if (!relatedVservers.isEmpty()) { - relatedVservers.forEach(vserverUri -> { - Optional<Vserver> vserver = getAaiClient().get(vserverUri).asBean(Vserver.class); - Vserver vServerShallow = new Vserver(); - BeanUtils.copyProperties(vserver, vServerShallow); - AAIObjectAudit vServerAudit = new AAIObjectAudit(); - vServerAudit.setAaiObject(vServerShallow); - vServerAudit.setAaiObjectType(Types.VSERVER.typeName()); - vServerAudit.setDoesObjectExist(true); - auditList.getAuditList().add(vServerAudit); - }); - } - } - return Optional.of(auditList); - } - - public Optional<AAIObjectAuditList> auditVservers(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, - String cloudRegion) { - if (vServersToAudit == null || vServersToAudit.isEmpty()) { - return Optional.empty(); - } - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - vServersToAudit.stream().forEach(vserver -> { - try { - logger.debug("Vserver to Audit: {}", objectMapper.getMapper().writeValueAsString(vserver)); - } catch (JsonProcessingException e) { - logger.error("Json parse exception: ", e); - } - - }); - AAIObjectAuditList auditList = new AAIObjectAuditList(); - vServersToAudit.stream().forEach(vServer -> auditList.getAuditList() - .addAll(doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion).getAuditList())); - return Optional.of(auditList); - } - - private AAIObjectAuditList doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, - String cloudRegion) { - AAIObjectAuditList auditList = new AAIObjectAuditList(); - AAIObjectAudit vServerAudit = new AAIObjectAudit(); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId())); - Vserver vServerShallow = new Vserver(); - BeanUtils.copyProperties(vServer, vServerShallow, "LInterfaces"); - boolean vServerExists = getAaiClient().exists(vserverURI); - logger.info("v-server {} exists: {}", vServer.getVserverId(), vServerExists); - vServerAudit.setAaiObject(vServerShallow); - vServerAudit.setDoesObjectExist(vServerExists); - vServerAudit.setResourceURI(vserverURI.build()); - vServerAudit.setAaiObjectType(Types.VSERVER.typeName()); - auditList.getAuditList().add(vServerAudit); - if (vServer.getLInterfaces() != null) { - vServer.getLInterfaces().getLInterface().stream().forEach(lInterface -> auditList.getAuditList().addAll( - doesLinterfaceExistinAAI(lInterface, vServer.getVserverId(), tenantId, cloudOwner, cloudRegion) - .getAuditList())); - } - return auditList; - } - - private AAIObjectAuditList doesLinterfaceExistinAAI(LInterface lInterface, String vServerId, String tenantId, - String cloudOwner, String cloudRegion) { - AAIObjectAuditList auditList = new AAIObjectAuditList(); - AAIObjectAudit lInterfaceAudit = new AAIObjectAudit(); - AAIResourceUri linterfaceURI = AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) - .tenant(tenantId).vserver(vServerId).lInterface(lInterface.getInterfaceName())); - Optional<LInterface> queriedLInterface = getAaiClient().get(LInterface.class, linterfaceURI); - if (queriedLInterface.isPresent()) { - lInterfaceAudit.setDoesObjectExist(true); - lInterface.setInterfaceName(lInterface.getInterfaceName()); - } - lInterfaceAudit.setAaiObject(lInterface); - lInterfaceAudit.setResourceURI(linterfaceURI.build()); - lInterfaceAudit.setAaiObjectType(Types.L_INTERFACE.typeName()); - auditList.getAuditList().add(lInterfaceAudit); - logger.info("l-interface id:{} name: {} exists: {} ", lInterface.getInterfaceId(), - lInterface.getInterfaceName(), lInterfaceAudit.isDoesObjectExist()); - - if (lInterface.getLInterfaces() != null) { - lInterface.getLInterfaces().getLInterface().stream() - .forEach(subInterface -> auditList.getAuditList().add(doesSubInterfaceExistinAAI(subInterface, - lInterface.getInterfaceName(), vServerId, tenantId, cloudOwner, cloudRegion))); - } - logger.debug("l-interface {} does not contain any sub-iterfaces, skipping audit of sub-interfaces", - lInterface.getInterfaceId()); - - return auditList; - } - - private AAIObjectAudit doesSubInterfaceExistinAAI(LInterface subInterface, String linterfaceName, String vServerId, - String tenantId, String cloudOwner, String cloudRegion) { - logger.info("checking if sub-l-interface {} , linterfaceName: {} vserverId: {} exists", - subInterface.getInterfaceName(), linterfaceName, vServerId); - AAIObjectAudit subInterfaceAudit = new AAIObjectAudit(); - - - AAIResourceUri subInterfaceURI = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, - cloudRegion, tenantId, vServerId, linterfaceName, subInterface.getInterfaceName()); - subInterfaceAudit.setResourceURI(subInterfaceURI.build()); - boolean doesExist = getAaiClient().exists(subInterfaceURI); - logger.info("sub-l-interface-id:{} exists: {}", subInterface.getInterfaceId(), doesExist); - subInterfaceAudit.setAaiObject(subInterface); - subInterfaceAudit.setDoesObjectExist(doesExist); - subInterfaceAudit.setAaiObjectType(AAIObjectType.SUB_L_INTERFACE.typeName()); - return subInterfaceAudit; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java deleted file mode 100644 index c58e568ea4..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java +++ /dev/null @@ -1,330 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * - * Modifications Copyright (C) 2019 IBM. - * ================================================================================ - * 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.tasks.audit; - -import java.net.URI; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.onap.aai.domain.yang.LInterface; -import org.onap.aai.domain.yang.LInterfaces; -import org.onap.aai.domain.yang.Vlan; -import org.onap.aai.domain.yang.Vlans; -import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; -import org.onap.so.objects.audit.AAIObjectAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.onap.so.openstack.utils.MsoHeatUtils; -import org.onap.so.openstack.utils.MsoNeutronUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import com.woorea.openstack.heat.model.Link; -import com.woorea.openstack.heat.model.Resource; -import com.woorea.openstack.heat.model.Resources; -import com.woorea.openstack.heat.model.Stack; -import com.woorea.openstack.quantum.model.Port; - -@Component -public class HeatStackAudit { - - private static final String RESOURCES = "/resources"; - - protected static final Logger logger = LoggerFactory.getLogger(HeatStackAudit.class); - - private static final String EXCEPTION_MSG = "Error finding Path from Self Link"; - - @Autowired - protected MsoHeatUtils heat; - - @Autowired - protected MsoNeutronUtils neutron; - - @Autowired - protected AuditVServer auditVservers; - - public Optional<AAIObjectAuditList> queryHeatStack(String cloudOwner, String cloudRegion, String tenantId, - String heatStackName) { - try { - logger.debug("Fetching Top Level Stack Information"); - Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName, 3); - List<Resource> novaResources = resources.getList().stream() - .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); - if (novaResources.isEmpty()) - return Optional.of(new AAIObjectAuditList()); - else { - Set<Vserver> vserversToAudit = createVserverSet(novaResources); - AAIObjectAuditList aaiObjectAuditList = new AAIObjectAuditList(); - vserversToAudit.stream().forEach(vServer -> aaiObjectAuditList.getAuditList() - .add(createAAIObjectAudit(cloudOwner, cloudRegion, tenantId, vServer))); - return Optional.of(aaiObjectAuditList); - } - } catch (Exception e) { - logger.error("Error during query stack resources", e); - return Optional.of(new AAIObjectAuditList()); - } - } - - public Optional<AAIObjectAuditList> auditHeatStack(String cloudRegion, String cloudOwner, String tenantId, - String heatStackName) { - try { - logger.debug("Fetching Top Level Stack Information"); - Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName, 3); - List<Resource> novaResources = resources.getList().stream() - .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); - List<Resource> resourceGroups = resources.getList().stream() - .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")) - .collect(Collectors.toList()); - List<Optional<Port>> neutronPortDetails = retrieveNeutronPortDetails(resources, cloudRegion, tenantId); - if (novaResources.isEmpty()) - return Optional.of(new AAIObjectAuditList()); - else { - Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources, neutronPortDetails); - Set<Vserver> vserversWithSubInterfaces = - processSubInterfaces(cloudRegion, tenantId, resourceGroups, vserversToAudit); - return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); - } - } catch (Exception e) { - logger.error("Error during auditing stack resources", e); - return Optional.empty(); - } - } - - protected Set<Vserver> processSubInterfaces(String cloudRegion, String tenantId, List<Resource> resourceGroups, - Set<Vserver> vServersToAudit) throws Exception { - for (Resource resourceGroup : resourceGroups) { - processResourceGroups(cloudRegion, tenantId, vServersToAudit, resourceGroup); - } - return vServersToAudit; - } - - protected void processResourceGroups(String cloudRegion, String tenantId, Set<Vserver> vServersWithLInterface, - Resource resourceGroup) throws Exception { - Optional<Link> stackLink = - resourceGroup.getLinks().stream().filter(link -> "nested".equals(link.getRel())).findAny(); - if (stackLink.isPresent()) { - try { - Optional<String> path = extractResourcePathFromHref(stackLink.get().getHref()); - if (path.isPresent()) { - logger.debug("Fetching nested Resource Stack Information"); - Resources nestedResourceGroupResources = - heat.executeHeatClientRequest(path.get(), cloudRegion, tenantId, Resources.class); - processNestedResourceGroup(cloudRegion, tenantId, vServersWithLInterface, - nestedResourceGroupResources); - } else - throw new Exception(EXCEPTION_MSG); - } catch (Exception e) { - logger.error("Error Parsing Link to obtain Path", e); - throw new Exception(EXCEPTION_MSG); - } - } - } - - protected void processNestedResourceGroup(String cloudRegion, String tenantId, Set<Vserver> vServersWithLInterface, - Resources nestedResourceGroupResources) throws Exception { - for (Resource resourceGroupNested : nestedResourceGroupResources) { - Optional<Link> subInterfaceStackLink = - resourceGroupNested.getLinks().stream().filter(link -> "nested".equals(link.getRel())).findAny(); - if (subInterfaceStackLink.isPresent()) { - addSubInterface(cloudRegion, tenantId, vServersWithLInterface, subInterfaceStackLink.get()); - } - } - } - - protected void addSubInterface(String cloudRegion, String tenantId, Set<Vserver> vServersWithLInterface, - Link subInterfaceStackLink) throws Exception { - Optional<String> resourcePath = extractResourcePathFromHref(subInterfaceStackLink.getHref()); - Optional<String> stackPath = extractStackPathFromHref(subInterfaceStackLink.getHref()); - if (resourcePath.isPresent() && stackPath.isPresent()) { - logger.debug("Fetching nested Sub-Interface Stack Information"); - Stack subinterfaceStack = - heat.executeHeatClientRequest(stackPath.get(), cloudRegion, tenantId, Stack.class); - Resources subinterfaceResources = - heat.executeHeatClientRequest(resourcePath.get(), cloudRegion, tenantId, Resources.class); - if (subinterfaceStack != null) { - addSubInterfaceToVserver(vServersWithLInterface, subinterfaceStack, subinterfaceResources); - } - } else - throw new Exception(EXCEPTION_MSG); - - } - - protected void addSubInterfaceToVserver(Set<Vserver> vServersWithLInterface, Stack subinterfaceStack, - Resources subinterfaceResources) throws Exception { - String parentNeutronPortId = (String) subinterfaceStack.getParameters().get("port_interface"); - logger.debug("Parent neutron Port: {} on SubInterface: {}", parentNeutronPortId, subinterfaceStack.getId()); - for (Vserver auditVserver : vServersWithLInterface) - for (LInterface lInterface : auditVserver.getLInterfaces().getLInterface()) - - if (parentNeutronPortId.equals(lInterface.getInterfaceId())) { - logger.debug("Found Parent Port on VServer: {} on Port: {}", auditVserver.getVserverId(), - lInterface.getInterfaceId()); - Resource contrailVm = subinterfaceResources.getList().stream() - .filter(resource -> "OS::ContrailV2::VirtualMachineInterface".equals(resource.getType())) - .findAny().orElse(null); - if (contrailVm == null) { - throw new Exception("Cannnot find Contrail Virtual Machine Interface on Stack: " - + subinterfaceStack.getId()); - } - LInterface subInterface = new LInterface(); - subInterface.setInterfaceId(contrailVm.getPhysicalResourceId()); - subInterface.setIsPortMirrored(false); - subInterface.setInMaint(false); - subInterface.setIsIpUnnumbered(false); - String macAddr = (String) subinterfaceStack.getParameters().get("mac_address"); - subInterface.setMacaddr(macAddr); - - String namePrefix = (String) subinterfaceStack.getParameters().get("subinterface_name_prefix"); - Integer vlanIndex = Integer.parseInt((String) subinterfaceStack.getParameters().get("counter")); - String vlanTagList = (String) subinterfaceStack.getParameters().get("vlan_tag"); - List<String> subInterfaceVlanTagList = Arrays.asList(vlanTagList.split(",")); - subInterface.setInterfaceName(namePrefix + "_" + subInterfaceVlanTagList.get(vlanIndex)); - subInterface.setVlans(new Vlans()); - Vlan vlan = new Vlan(); - vlan.setInMaint(false); - vlan.setIsIpUnnumbered(false); - vlan.setVlanIdInner(Long.parseLong(subInterfaceVlanTagList.get(vlanIndex))); - vlan.setVlanInterface(namePrefix + "_" + subInterfaceVlanTagList.get(vlanIndex)); - subInterface.getVlans().getVlan().add(vlan); - if (lInterface.getLInterfaces() == null) - lInterface.setLInterfaces(new LInterfaces()); - - lInterface.getLInterfaces().getLInterface().add(subInterface); - } else - logger.debug("Did Not Find Parent Port on VServer: {} Parent Port: SubInterface: {}", - auditVserver.getVserverId(), lInterface.getInterfaceId(), subinterfaceStack.getId()); - } - - protected Set<Vserver> createVserverSet(Resources resources, List<Resource> novaResources, - List<Optional<Port>> neutronPortDetails) { - Set<Vserver> vserversToAudit = new HashSet<>(); - for (Resource novaResource : novaResources) { - Vserver auditVserver = new Vserver(); - auditVserver.setLInterfaces(new LInterfaces()); - auditVserver.setVserverId(novaResource.getPhysicalResourceId()); - Stream<Port> filteredNeutronPorts = filterNeutronPorts(novaResource, neutronPortDetails); - filteredNeutronPorts.forEach(port -> { - LInterface lInterface = new LInterface(); - lInterface.setInterfaceId(port.getId()); - lInterface.setInterfaceName(port.getName()); - auditVserver.getLInterfaces().getLInterface().add(lInterface); - }); - vserversToAudit.add(auditVserver); - } - return vserversToAudit; - } - - protected Set<Vserver> createVserverSet(List<Resource> novaResources) { - Set<Vserver> vserversToAudit = new HashSet<>(); - for (Resource novaResource : novaResources) { - Vserver auditVserver = new Vserver(); - auditVserver.setLInterfaces(new LInterfaces()); - auditVserver.setVserverId(novaResource.getPhysicalResourceId()); - vserversToAudit.add(auditVserver); - } - return vserversToAudit; - } - - protected AAIObjectAudit createAAIObjectAudit(String cloudOwner, String cloudRegion, String tenantId, - Vserver vServer) { - AAIObjectAudit aaiObjectAudit = new AAIObjectAudit(); - Vserver vServerShallow = new Vserver(); - BeanUtils.copyProperties(vServer, vServerShallow); - aaiObjectAudit.setAaiObject(vServerShallow); - aaiObjectAudit.setAaiObjectType(Types.VSERVER.typeName()); - aaiObjectAudit - .setResourceURI(AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId())) - .build()); - - return aaiObjectAudit; - } - - /** - * @param novaResource Single openstack resource that is of type Nova - * @param neutronPorts List of Neutron ports created within the stack - * @return Filtered list of neutron ports taht relate to the nova server in openstack - */ - protected Stream<Port> filterNeutronPorts(Resource novaResource, List<Optional<Port>> neutronPorts) { - List<Port> filteredNeutronPorts = - neutronPorts.stream().filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()); - return filteredNeutronPorts.stream() - .filter(port -> port.getDeviceId().equalsIgnoreCase(novaResource.getPhysicalResourceId())); - } - - /** - * @param resources Resource stream created by the stack in openstack - * @param cloudSiteId Unique site id to identify which openstack we talk to - * @param tenantId The tenant within the cloud we are talking to where resouces exist - * @return List of optional neutron ports found within the cloud site and tenant - */ - protected List<Optional<Port>> retrieveNeutronPortDetails(Resources resources, String cloudSiteId, - String tenantId) { - return resources.getList().stream().filter(resource -> "OS::Neutron::Port".equals(resource.getType())) - .map(resource -> neutron.getNeutronPort(resource.getPhysicalResourceId(), tenantId, cloudSiteId)) - .collect(Collectors.toList()); - - } - - protected Optional<String> extractResourcePathFromHref(String href) { - try { - Optional<String> stackPath = extractStackPathFromHref(href); - if (stackPath.isPresent()) { - return Optional.of(stackPath.get() + RESOURCES); - } else - return Optional.empty(); - } catch (Exception e) { - logger.error("Error parsing URI", e); - } - return Optional.empty(); - } - - protected Optional<String> extractStackPathFromHref(String href) { - try { - URI uri = new URI(href); - Pattern p = Pattern.compile("/stacks.*"); - Matcher m = p.matcher(uri.getPath()); - if (m.find()) { - return Optional.of(m.group()); - } else - return Optional.empty(); - } catch (Exception e) { - logger.error("Error parsing URI", e); - } - return Optional.empty(); - } - - -} - diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java index 3f79c43bf8..a6194517c2 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java @@ -29,6 +29,7 @@ import org.onap.so.cloud.resource.beans.CloudInformation; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.heatbridge.HeatBridgeApi; +import org.onap.so.heatbridge.HeatBridgeException; import org.onap.so.heatbridge.HeatBridgeImpl; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.openstack4j.model.compute.Flavor; @@ -55,75 +56,70 @@ public class CreateAAIInventory { @Autowired protected Environment env; - public void heatbridge(CloudInformation cloudInformation) { - try { - CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) - .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - String heatStackId = cloudInformation.getTemplateInstanceId().split("/")[1]; - - List<String> oobMgtNetNames = new ArrayList<>(); - - HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, - cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), - cloudInformation.getTenantId(), cloudInformation.getNodeType()); - - heatBridgeClient.authenticate(); - - List<Resource> stackResources = - heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId()); - - List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources); - heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), - osNetworks); - - List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources); - - heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources); - - List<Image> osImages = heatBridgeClient.extractOpenstackImagesFromServers(osServers); - - List<Flavor> osFlavors = heatBridgeClient.extractOpenstackFlavorsFromServers(osServers); - - logger.debug("Successfully queried heat stack{} for resources.", heatStackId); - // os images - if (osImages != null && !osImages.isEmpty()) { - heatBridgeClient.buildAddImagesToAaiAction(osImages); - logger.debug("Successfully built AAI actions to add images."); - } else { - logger.debug("No images to update to AAI."); - } - // flavors - if (osFlavors != null && !osFlavors.isEmpty()) { - heatBridgeClient.buildAddFlavorsToAaiAction(osFlavors); - logger.debug("Successfully built AAI actions to add flavors."); - } else { - logger.debug("No flavors to update to AAI."); - } - - // compute resources - heatBridgeClient.buildAddVserversToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), - osServers); - logger.debug("Successfully queried compute resources and built AAI vserver actions."); - - // neutron resources - List<String> oobMgtNetIds = new ArrayList<>(); - - // if no network-id list is provided, however network-name list is - if (!CollectionUtils.isEmpty(oobMgtNetNames)) { - oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames); - } - heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, - cloudInformation.getOwner()); - logger.debug( - "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); - - // Update AAI - logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, false)); - heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false)); - } catch (Exception ex) { - logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex); + public void heatbridge(CloudInformation cloudInformation) throws HeatBridgeException, MsoCloudSiteNotFound { + CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) + .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + String heatStackId = cloudInformation.getTemplateInstanceId().split("/")[1]; + + List<String> oobMgtNetNames = new ArrayList<>(); + + HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, + cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), + cloudInformation.getTenantId(), cloudInformation.getNodeType()); + + heatBridgeClient.authenticate(); + + List<Resource> stackResources = + heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId()); + + List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources); + heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), + osNetworks); + + List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources); + + heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources); + + List<Image> osImages = heatBridgeClient.extractOpenstackImagesFromServers(osServers); + + List<Flavor> osFlavors = heatBridgeClient.extractOpenstackFlavorsFromServers(osServers); + + logger.debug("Successfully queried heat stack{} for resources.", heatStackId); + // os images + if (osImages != null && !osImages.isEmpty()) { + heatBridgeClient.buildAddImagesToAaiAction(osImages); + logger.debug("Successfully built AAI actions to add images."); + } else { + logger.debug("No images to update to AAI."); + } + // flavors + if (osFlavors != null && !osFlavors.isEmpty()) { + heatBridgeClient.buildAddFlavorsToAaiAction(osFlavors); + logger.debug("Successfully built AAI actions to add flavors."); + } else { + logger.debug("No flavors to update to AAI."); + } + + // compute resources + heatBridgeClient.buildAddVserversToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), + osServers); + logger.debug("Successfully queried compute resources and built AAI vserver actions."); + + // neutron resources + List<String> oobMgtNetIds = new ArrayList<>(); + + // if no network-id list is provided, however network-name list is + if (!CollectionUtils.isEmpty(oobMgtNetNames)) { + oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames); } + heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, + cloudInformation.getOwner()); + logger.debug("Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); + + // Update AAI + logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, false)); + heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false)); } protected AAIResourcesClient getAaiClient() { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java index 2202e97e71..3c9a4833ae 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java @@ -57,7 +57,6 @@ public class CreateInventoryTask extends ExternalTaskUtils { public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); - boolean inventoryException = false; String externalTaskId = externalTask.getId(); CloudInformation cloudInformation = externalTask.getVariable("cloudInformation"); boolean success = true; @@ -75,30 +74,29 @@ public class CreateInventoryTask extends ExternalTaskUtils { if (success) { externalTaskService.complete(externalTask); mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - logger.debug("The External Task Id: {} Successful", externalTaskId); + logger.debug("The External Task {} was successful", externalTaskId); logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); mdcSetup.clearClientMDCs(); } else { if (retryCount == null) { - logger.error("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", + logger.error("The External Task {} Failed, Setting Retries to Default Start Value: {}", externalTaskId, getRetrySequence().length); externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, getRetrySequence().length, 10000); } else if (retryCount != null && retryCount - 1 == 0) { externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE); mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.error("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId); + logger.error("The External Task {} Failed, All Retries Exhausted", externalTaskId); logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { - logger.error("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", + logger.error("The External Task {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTaskId, retryCount - 1, calculateRetryDelay(retryCount)); externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, retryCount - 1, calculateRetryDelay(retryCount)); } - logger.error("The External Task Id: {} Failed", externalTaskId); } } else { - logger.error("The External Task Id: {} Failed, No Cloud Information Provided", externalTaskId); + logger.error("The External Task {} Failed, No Cloud Information Provided", externalTaskId); externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java index 22e6b1fc22..f5a6355529 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.inventory.delete; +package org.onap.so.adapters.tasks.inventory; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.so.cloud.CloudConfig; @@ -26,6 +26,7 @@ import org.onap.so.cloud.resource.beans.CloudInformation; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.heatbridge.HeatBridgeApi; +import org.onap.so.heatbridge.HeatBridgeException; import org.onap.so.heatbridge.HeatBridgeImpl; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.slf4j.Logger; @@ -47,22 +48,16 @@ public class DeleteAAIInventory { @Autowired protected Environment env; - public void heatbridge(CloudInformation cloudInformation) { - try { - logger.debug("Heatbridge delete executing"); - - CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) - .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, - cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), - cloudInformation.getTenantId(), cloudInformation.getNodeType()); - heatBridgeClient.authenticate(); - heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - - } catch (Exception ex) { - logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex); - } + public void heatbridge(CloudInformation cloudInformation) throws MsoCloudSiteNotFound, HeatBridgeException { + logger.debug("Heatbridge delete executing"); + CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) + .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, + cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), + cloudInformation.getTenantId(), cloudInformation.getNodeType()); + heatBridgeClient.authenticate(); + heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); } protected AAIResourcesClient getAaiClient() { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteInventoryTask.java index 10faa2b08f..08361bdbbf 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteInventoryTask.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.inventory.delete; +package org.onap.so.adapters.tasks.inventory; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; @@ -32,7 +32,6 @@ import org.onap.so.utils.RetrySequenceLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -49,16 +48,13 @@ public class DeleteInventoryTask extends ExternalTaskUtils { private DeleteAAIInventory deleteInventory; @Autowired - private Environment env; - - @Autowired private AuditMDCSetup mdcSetup; public DeleteInventoryTask() { super(RetrySequenceLevel.SHORT); } - protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { + public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); String externalTaskId = externalTask.getId(); CloudInformation cloudInformation = externalTask.getVariable("cloudInformation"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 45b29244d1..1264727f35 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -324,10 +324,23 @@ public class HeatBridgeImpl implements HeatBridgeApi { // Build vserver relationships to: image, flavor, pserver, vf-module vserver.setRelationshipList( aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server)); - transaction.createIfNotExists( - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId())), - Optional.of(vserver)); + AAIResourceUri vserverUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId())); + if (resourcesClient.exists(vserverUri)) { + AAIResultWrapper existingVserver = resourcesClient.get(vserverUri); + if (!existingVserver.hasRelationshipsTo(Types.VF_MODULE)) { + AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId)); + transaction.connect(vserverUri, vfModuleUri); + } + if (!existingVserver.hasRelationshipsTo(Types.PSERVER)) { + AAIResourceUri pServerUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(server.getHypervisorHostname())); + transaction.connect(vserverUri, pServerUri); + } + } else { + transaction.create(vserverUri, vserver); + } }); } @@ -380,10 +393,9 @@ public class HeatBridgeImpl implements HeatBridgeApi { if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) { Server server = getOpenstackServerById(port.getDeviceId()); - updateLInterfaceVlan(port, lIf, server.getHypervisorHostname()); + createVlanAndSriovVF(port, lIf, server.getHypervisorHostname()); + updateSriovPfToSriovVF(port, lIf); } - - updateSriovPfToPserver(port, lIf); } } @@ -464,7 +476,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { resourcesClient.createIfNotExists(uri, Optional.of(pInterface)); } - protected void updateLInterfaceVlan(final Port port, final LInterface lIf, final String hostName) + protected void createVlanAndSriovVF(final Port port, final LInterface lIf, final String hostName) throws HeatBridgeException { // add back all vlan logic Vlan vlan = new Vlan(); @@ -582,7 +594,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { * @param lIf AAI l-interface object * @throws HeatBridgeException */ - protected void updateSriovPfToPserver(final Port port, final LInterface lIf) throws HeatBridgeException { + protected void updateSriovPfToSriovVF(final Port port, final LInterface lIf) throws HeatBridgeException { if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { AAIResourceUri sriovVfUri = AAIUriFactory diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index c1a97cefc4..8e6f8cc69b 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -92,13 +92,6 @@ public class AaiHelper { AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId))); relationships.add(genericVnfRelationship); - // vserver to vnfc relationship - if (!StringUtils.isEmpty(server.getName())) { - Relationship vnfcRelationship = buildRelationship( - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(server.getName()))); - relationships.add(vnfcRelationship); - } - // vserver to vf-module relationship Relationship vfModuleRelationship = buildRelationship(AAIUriFactory .createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId))); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java deleted file mode 100644 index c70e60e9d3..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.onap.so.adapters.tasks.audit; - -import org.junit.Test; -import org.onap.so.objects.audit.AAIObjectAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class AbstractAuditServiceTest extends AbstractAuditService { - - private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) { - AAIObjectAudit auditObject = new AAIObjectAudit(); - AAIObjectAuditList auditList = new AAIObjectAuditList(); - - auditObject.setDoesObjectExist(existenceState); - auditList.getAuditList().add(auditObject); - - return auditList; - } - - @Test - public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() { - assertFalse(didCreateAuditFail(null)); - } - - @Test - public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() { - assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false))); - } - - @Test - public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() { - assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true))); - } - - @Test - public void didDeleteAuditFail_shouldReturnFalse_whenGivenNull() { - assertFalse(didDeleteAuditFail(null)); - } - - @Test - public void didDeleteAuditFail_shouldReturnTrue_whenGivenExistingObject() { - assertTrue(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(true))); - } - - @Test - public void didDeleteAuditFail_shouldReturnFalse_whenGivenNotExistingObject() { - assertFalse(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(false))); - } - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java deleted file mode 100644 index 76e5bbc47f..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.onap.so.adapters.tasks.audit; - -import static org.assertj.core.api.Assertions.assertThat; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aai.domain.yang.Vserver; -import org.onap.so.audit.beans.AuditInventory; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.db.request.beans.RequestProcessingData; -import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.objects.audit.AAIObjectAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import com.fasterxml.jackson.core.JsonProcessingException; - - -@RunWith(MockitoJUnitRunner.Silent.class) -public class AuditDataServiceTest { - - @InjectMocks - AuditDataService auditDataService = new AuditDataService(); - - @Mock - protected RequestsDbClient requestsDbClient; - - AuditInventory auditInventory = new AuditInventory(); - - @Before - public void before() throws JsonProcessingException { - auditInventory.setCloudOwner("testCloudOwner"); - auditInventory.setCloudRegion("testLcpCloudRegionId"); - auditInventory.setHeatStackName("testVfModuleName1"); - auditInventory.setVfModuleId("testVnfModuleId"); - auditInventory.setTenantId("testTenantId"); - auditInventory.setGenericVnfId("testVnfId1"); - } - - @Test - public void testWriteStackDataToRequestDb() throws Exception { - Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient) - .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); - Mockito.doNothing().when(requestsDbClient).saveRequestProcessingData(Mockito.any()); - - AAIObjectAuditList auditList = new AAIObjectAuditList(); - auditList.setHeatStackName("testHeatStackName"); - AAIObjectAudit audit = new AAIObjectAudit(); - Vserver vserver = new Vserver(); - vserver.setVserverId("testVserverId"); - audit.setAaiObject(vserver); - auditList.getAuditList().add(audit); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(auditList); - - RequestProcessingData requestProcessingData = new RequestProcessingData(); - requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); - requestProcessingData.setGroupingId(auditInventory.getVfModuleId()); - requestProcessingData.setName(auditInventory.getHeatStackName()); - requestProcessingData.setTag("AuditStackData"); - requestProcessingData.setValue(auditListString); - - auditDataService.writeStackDataToRequestDb(auditInventory, auditList); - Mockito.verify(requestsDbClient, Mockito.times(1)).saveRequestProcessingData(requestProcessingData); - } - - @Test - public void testGetStackDataToRequestDb() throws Exception { - AAIObjectAuditList auditList = new AAIObjectAuditList(); - auditList.setHeatStackName("testHeatStackName"); - AAIObjectAudit audit = new AAIObjectAudit(); - Vserver vserver = new Vserver(); - vserver.setVserverId("testVserverId"); - audit.setAaiObject(vserver); - auditList.getAuditList().add(audit); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(audit); - - List<RequestProcessingData> list = new ArrayList(); - RequestProcessingData requestProcessingData = new RequestProcessingData(); - requestProcessingData.setId(234321432); - requestProcessingData.setGroupingId("testVfModuleId"); - requestProcessingData.setName("heatStackName"); - requestProcessingData.setTag("AuditStackData"); - requestProcessingData.setValue(auditListString); - list.add(requestProcessingData); - - Mockito.doReturn(list).when(requestsDbClient).getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), - Mockito.any(), Mockito.any()); - auditDataService.getStackDataFromRequestDb(auditInventory); - Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( - "testVnfModuleId", "testVfModuleName1", "AuditStackData"); - } - - @Test - public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception { - - Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient) - .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); - Optional<AAIObjectAuditList> result = auditDataService.getStackDataFromRequestDb(auditInventory); - Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( - "testVnfModuleId", "testVfModuleName1", "AuditStackData"); - assertThat(result).isEmpty(); - - } - - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java deleted file mode 100644 index 78dbcd94c2..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.tasks.audit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.doReturn; -import java.io.File; -import java.io.IOException; -import java.util.Map; -import java.util.Optional; -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.ExternalTaskService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.so.adapters.tasks.audit.AuditCreateStackService; -import org.onap.so.adapters.tasks.audit.AuditDataService; -import org.onap.so.adapters.tasks.audit.AuditQueryStackService; -import org.onap.so.adapters.tasks.audit.HeatStackAudit; -import org.onap.so.audit.beans.AuditInventory; -import org.onap.so.logging.tasks.AuditMDCSetup; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.springframework.core.env.Environment; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AuditStackServiceDataTest extends AuditCreateStackService { - - @InjectMocks - private AuditCreateStackService auditStackService = new AuditCreateStackService(); - - @InjectMocks - private AuditQueryStackService auditQueryStackService = new AuditQueryStackService(); - - @Mock - private HeatStackAudit heatStackAuditMock; - - @Mock - private Environment mockEnv; - - @Mock - private ExternalTask mockExternalTask; - - @Mock - private ExternalTaskService mockExternalTaskService; - - @Mock - private AuditDataService auditDataService; - - @Mock - private AuditMDCSetup mdcSetup; - - private ObjectMapper objectMapper = new ObjectMapper(); - - private AuditInventory auditInventory = new AuditInventory(); - - Optional<AAIObjectAuditList> auditListOptSuccess; - - Optional<AAIObjectAuditList> auditListOptFailure; - - @Before - public void setup() throws JsonParseException, JsonMappingException, IOException { - auditInventory.setCloudOwner("cloudOwner"); - auditInventory.setCloudRegion("cloudRegion"); - auditInventory.setTenantId("tenantId"); - auditInventory.setHeatStackName("stackName"); - MockitoAnnotations.initMocks(this); - - AAIObjectAuditList auditListSuccess = objectMapper - .readValue(new File("src/test/resources/ExpectedVServerFound.json"), AAIObjectAuditList.class); - auditListOptSuccess = Optional.of(auditListSuccess); - - AAIObjectAuditList auditListFailure = objectMapper.readValue( - new File("src/test/resources/Vserver2_Found_VServer1_Not_Found.json"), AAIObjectAuditList.class); - auditListOptFailure = Optional.of(auditListFailure); - String[] retrySequence = new String[8]; - retrySequence[0] = "1"; - retrySequence[1] = "1"; - retrySequence[2] = "2"; - retrySequence[3] = "3"; - retrySequence[4] = "5"; - retrySequence[5] = "8"; - retrySequence[6] = "13"; - retrySequence[7] = "20"; - doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory"); - doReturn("6000").when(mockEnv).getProperty("mso.workflow.topics.retryMultiplier", "6000"); - doReturn(retrySequence).when(mockEnv).getProperty("mso.workflow.topics.retrySequence", String[].class); - doReturn("aasdfasdf").when(mockExternalTask).getId(); - } - - @Test - public void execute_external_task_audit_success_Test() { - doReturn(auditListOptSuccess).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", - "stackName"); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); - ArgumentCaptor<ExternalTask> taskCaptor = ArgumentCaptor.forClass(ExternalTask.class); - Mockito.verify(mockExternalTaskService).complete(taskCaptor.capture(), captor.capture()); - Map actualMap = captor.getValue(); - assertEquals(true, actualMap.get("auditIsSuccessful")); - assertNotNull(actualMap.get("auditInventoryResult")); - } - - @Test - public void executeExternalTaskQueryAuditTest() throws JsonProcessingException { - doReturn(auditListOptSuccess).when(heatStackAuditMock).queryHeatStack("cloudOwner", "cloudRegion", "tenantId", - "stackName"); - Mockito.doNothing().when(auditDataService).writeStackDataToRequestDb(Mockito.any(AuditInventory.class), - Mockito.any(AAIObjectAuditList.class)); - auditQueryStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); - ArgumentCaptor<ExternalTask> taskCaptor = ArgumentCaptor.forClass(ExternalTask.class); - Mockito.verify(mockExternalTaskService).complete(taskCaptor.capture(), captor.capture()); - Mockito.verify(auditDataService).writeStackDataToRequestDb(Mockito.any(AuditInventory.class), - Mockito.any(AAIObjectAuditList.class)); - } - - @Test - public void execute_external_task_audit_first_failure_Test() { - doReturn(auditListOptFailure).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", - "stackName"); - doReturn(null).when(mockExternalTask).getRetries(); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, - "Unable to find all VServers and L-Interaces in A&AI", - "Unable to find all VServers and L-Interaces in A&AI", 8, 10000L); - } - - @Test - public void execute_external_task_audit_intermediate_failure_Test() { - doReturn(auditListOptFailure).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", - "stackName"); - doReturn(6).when(mockExternalTask).getRetries(); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, - "Unable to find all VServers and L-Interaces in A&AI", - "Unable to find all VServers and L-Interaces in A&AI", 5, 12000L); - - } - - @Test - public void execute_external_task_audit_final_failure_Test() { - doReturn(auditListOptFailure).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", - "stackName"); - doReturn(1).when(mockExternalTask).getRetries(); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); - ArgumentCaptor<ExternalTask> taskCaptor = ArgumentCaptor.forClass(ExternalTask.class); - Mockito.verify(mockExternalTaskService).complete(taskCaptor.capture(), captor.capture()); - Map actualMap = captor.getValue(); - assertEquals(false, actualMap.get("auditIsSuccessful")); - assertNotNull(actualMap.get("auditInventoryResult")); - } - - @Test - public void determineAuditResult_Test() throws Exception { - boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess.get()); - assertEquals(false, actual); - } - - @Test - public void determineAuditResult_Failure_Test() throws Exception { - boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure.get()); - assertEquals(true, actual); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java deleted file mode 100644 index 2e496c50cd..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java +++ /dev/null @@ -1,444 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 perservice2sions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tasks.audit; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doReturn; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aai.domain.yang.LInterface; -import org.onap.aai.domain.yang.LInterfaces; -import org.onap.aai.domain.yang.VfModule; -import org.onap.aai.domain.yang.VfModules; -import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; -import org.onap.so.objects.audit.AAIObjectAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.skyscreamer.jsonassert.JSONAssert; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@RunWith(MockitoJUnitRunner.Silent.class) -public class AuditVServerTest extends AuditVServer { - - private ObjectMapper objectMapper = new ObjectMapper(); - - @InjectMocks - private AuditVServer auditNova = new AuditVServer(); - - @Mock - private AAIResourcesClient aaiResourcesMock; - - private String cloudOwner = "cloudOwner"; - private String cloudRegion = "cloudRegion"; - private String tenantId = "tenantId"; - - private AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db")); - - private AAIResourceUri vserverURI2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz")); - - private AAIResourceUri ssc_1_trusted_port_0_uri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) - .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_trusted_port_0")); - - private AAIResourceUri ssc_1_service1_port_0_uri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) - .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_service1_port_0")); - - private AAIResourceUri ssc_1_mgmt_port_1_uri = AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) - .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_mgmt_port_1")); - - private AAIResourceUri ssc_1_mgmt_port_0_uri = AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) - .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_mgmt_port_0")); - - private AAIResourceUri ssc_1_service2_port_0_uri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) - .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_service2_port_0")); - - private AAIResourceUri ssc_1_int_ha_port_0_uri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) - .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_int_ha_port_0")); - - private AAIResourceUri test_port_1_uri = AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) - .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz").lInterface("test_port_1")); - - private AAIResourceUri test_port_2_uri = AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) - .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz").lInterface("test_port_2")); - - private AAIResourceUri service2_sub_1_uri = - AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId, - "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service2_port_0", "service2_sub_interface_1"); - - private AAIResourceUri service1_sub_0_uri = - AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId, - "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service1_port_0", "service1_sub_interface_1"); - - private AAIResourceUri service1_sub_1_uri = - AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId, - "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service1_port_0", "service1_sub_interface_2"); - - - - private Set<Vserver> vserversToAudit = new HashSet<>(); - - LInterface test_port_1 = new LInterface(); - LInterface test_port_2 = new LInterface(); - LInterface ssc_1_int_ha_port_0 = new LInterface(); - LInterface service2_sub_interface_1 = new LInterface(); - LInterface ssc_1_service2_port_0 = new LInterface(); - LInterface ssc_1_mgmt_port_0 = new LInterface(); - LInterface ssc_1_mgmt_port_1 = new LInterface(); - LInterface service1_sub_interface_2 = new LInterface(); - LInterface service1_sub_interface_1 = new LInterface(); - LInterface ssc_1_service1_port_0 = new LInterface(); - LInterface ssc_1_trusted_port_0 = new LInterface(); - - - - @Before - public void setup() { - objectMapper.setSerializationInclusion(Include.NON_NULL); - auditNova.setAaiClient(aaiResourcesMock); - - Vserver vServer1 = new Vserver(); - vServer1.setVserverId("3a4c2ca5-27b3-4ecc-98c5-06804867c4db"); - LInterfaces vServer1Linterfaces = new LInterfaces(); - vServer1.setLInterfaces(vServer1Linterfaces); - - ssc_1_trusted_port_0.setInterfaceId("dec8bdc7-5718-41dc-bfbb-561ff6eeb81c"); - ssc_1_trusted_port_0.setInterfaceName("ssc_1_trusted_port_0"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_trusted_port_0); - - - ssc_1_service1_port_0.setInterfaceId("1c56a24b-5f03-435a-850d-31cd4252de56"); - ssc_1_service1_port_0.setInterfaceName("ssc_1_service1_port_0"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_service1_port_0); - ssc_1_service1_port_0.setLInterfaces(new LInterfaces()); - - - service1_sub_interface_1.setInterfaceId("0d9cd813-2ae1-46c0-9ebb-48081f6cffbb"); - service1_sub_interface_1.setInterfaceName("service1_sub_interface_1"); - ssc_1_service1_port_0.getLInterfaces().getLInterface().add(service1_sub_interface_1); - - - service1_sub_interface_2.setInterfaceId("b7019dd0-2ee9-4447-bdef-ac25676b205a"); - service1_sub_interface_2.setInterfaceName("service1_sub_interface_2"); - ssc_1_service1_port_0.getLInterfaces().getLInterface().add(service1_sub_interface_2); - - - ssc_1_mgmt_port_1.setInterfaceId("12afcd28-929f-4d80-8a5a-0833bfd5e20b"); - ssc_1_mgmt_port_1.setInterfaceName("ssc_1_mgmt_port_1"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_1); - - ssc_1_mgmt_port_0.setInterfaceId("80baec42-ffae-425f-ad8c-3f7b2c24bfff"); - ssc_1_mgmt_port_0.setInterfaceName("ssc_1_mgmt_port_0"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_0); - - - ssc_1_service2_port_0.setLInterfaces(new LInterfaces()); - ssc_1_service2_port_0.setInterfaceId("13eddf95-4cf3-45f2-823a-2d890a6549b4"); - ssc_1_service2_port_0.setInterfaceName("ssc_1_service2_port_0"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_service2_port_0); - - - service2_sub_interface_1.setInterfaceId("f711be16-2654-4a09-b89d-0511fda20e81"); - service2_sub_interface_1.setInterfaceName("service2_sub_interface_1"); - ssc_1_service2_port_0.getLInterfaces().getLInterface().add(service2_sub_interface_1); - - - ssc_1_int_ha_port_0.setInterfaceId("9cab2903-70f7-44fd-b681-491d6ae2adb8"); - ssc_1_int_ha_port_0.setInterfaceName("ssc_1_int_ha_port_0"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_int_ha_port_0); - - Vserver vServer2 = new Vserver(); - vServer2.setVserverId("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz"); - LInterfaces vServer2Linterfaces = new LInterfaces(); - vServer2.setLInterfaces(vServer2Linterfaces); - - test_port_1.setInterfaceId("9cab2903-70f7-44fd-b681-491d6ae2adz1"); - test_port_1.setInterfaceName("test_port_1"); - - - test_port_2.setInterfaceId("9cab2903-70f7-44fd-b681-491d6ae2adz2"); - test_port_2.setInterfaceName("test_port_2"); - - vServer2.getLInterfaces().getLInterface().add(test_port_1); - vServer2.getLInterfaces().getLInterface().add(test_port_2); - - vserversToAudit.add(vServer1); - vserversToAudit.add(vServer2); - } - - @Test - public void audit_Vserver_Empty_HashSet() throws JsonParseException, JsonMappingException, IOException { - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion); - assertEquals(Optional.empty(), actual); - } - - @Test - public void audit_Vserver_Found_Test() throws JsonParseException, JsonMappingException, IOException { - doReturn(true).when(aaiResourcesMock).exists(vserverURI); - doReturn(true).when(aaiResourcesMock).exists(vserverURI2); - doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_trusted_port_0_uri); - doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service1_port_0_uri); - doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri); - doReturn(Optional.of(ssc_1_mgmt_port_0)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri); - doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service2_port_0_uri); - doReturn(Optional.of(service2_sub_interface_1)).when(aaiResourcesMock).get(LInterface.class, - service1_sub_1_uri); - doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_int_ha_port_0_uri); - doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri); - doReturn(Optional.of(test_port_2)).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri); - - doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); - String actualString = objectMapper.writeValueAsString(actual.get()); - String expected = getJson("ExpectedVServerFound.json"); - JSONAssert.assertEquals(expected, actualString, false); - } - - @Test - public void audit_Vserver_Found_Test_Network_Not_Found() - throws JsonParseException, JsonMappingException, IOException { - doReturn(true).when(aaiResourcesMock).exists(vserverURI); - doReturn(true).when(aaiResourcesMock).exists(vserverURI2); - doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_trusted_port_0_uri); - doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service1_port_0_uri); - doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri); - doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri); - doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service2_port_0_uri); - doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_int_ha_port_0_uri); - doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri); - doReturn(Optional.of(test_port_2)).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri); - - doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); - String actualString = objectMapper.writeValueAsString(actual.get()); - String expected = getJson("VServer_Found_network_Not_Found.json"); - JSONAssert.assertEquals(expected, actualString, false); - } - - @Test - public void audit_Vserver_Found_Test_Network_Not_Found_Second_Server() - throws JsonParseException, JsonMappingException, IOException { - doReturn(true).when(aaiResourcesMock).exists(vserverURI); - doReturn(true).when(aaiResourcesMock).exists(vserverURI2); - doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_trusted_port_0_uri); - doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service1_port_0_uri); - doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri); - doReturn(Optional.of(ssc_1_mgmt_port_0)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri); - doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service2_port_0_uri); - doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_int_ha_port_0_uri); - doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri); - doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri); - doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); - String actualString = objectMapper.writeValueAsString(actual.get()); - String expected = getJson("VServer_Found_Network_Sec_Server_Not_Found.json"); - JSONAssert.assertEquals(expected, actualString, false); - } - - @Test - public void audit_Vserver_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { - doReturn(false).when(aaiResourcesMock).exists(vserverURI); - doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); - String actualString = objectMapper.writeValueAsString(actual.get()); - String expected = getJson("Vservers_Not_Found.json"); - JSONAssert.assertEquals(expected, actualString, false); - } - - @Test - public void audit_Vserver_first_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { - doReturn(false).when(aaiResourcesMock).exists(vserverURI); - doReturn(true).when(aaiResourcesMock).exists(vserverURI2); - doReturn(Optional.of(test_port_1)).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri); - doReturn(Optional.of(test_port_2)).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri); - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); - String actualString = objectMapper.writeValueAsString(actual.get()); - String expected = getJson("Vserver2_Found_VServer1_Not_Found.json"); - JSONAssert.assertEquals(expected, actualString, false); - } - - - @Test - public void doesSubInterfaceExistinAAI_Test() { - AAIResourceUri subInterfaceURI = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, - cloudRegion, tenantId, "vserverId", "l-interface", "sub-interface"); - - assertEquals( - "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/cloudRegion/tenants/tenant/tenantId/vservers/vserver/vserverId/l-interfaces/l-interface/l-interface/l-interfaces/l-interface/sub-interface", - subInterfaceURI.build().toString()); - } - - @Test - public void audit_Vserver_Second_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { - doReturn(true).when(aaiResourcesMock).exists(vserverURI); - doReturn(Optional.of(ssc_1_trusted_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_trusted_port_0_uri); - doReturn(Optional.of(ssc_1_service1_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service1_port_0_uri); - doReturn(Optional.of(ssc_1_mgmt_port_1)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_1_uri); - doReturn(Optional.of(ssc_1_mgmt_port_0)).when(aaiResourcesMock).get(LInterface.class, ssc_1_mgmt_port_0_uri); - doReturn(Optional.of(ssc_1_service2_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_service2_port_0_uri); - doReturn(Optional.of(ssc_1_int_ha_port_0)).when(aaiResourcesMock).get(LInterface.class, - ssc_1_int_ha_port_0_uri); - doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, test_port_1_uri); - doReturn(Optional.empty()).when(aaiResourcesMock).get(LInterface.class, test_port_2_uri); - doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); - doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - - doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - Optional<AAIObjectAuditList> actual = - auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); - String actualString = objectMapper.writeValueAsString(actual.get()); - String expected = getJson("VServer_Found_Sec_Server_Not_Found2.json"); - - JSONAssert.assertEquals(expected, actualString, false); - } - - @Test - public void testAuditVserversWithList() { - - AAIObjectAuditList auditList = new AAIObjectAuditList(); - AAIObjectAudit obj1 = new AAIObjectAudit(); - Vserver vserver = new Vserver(); - vserver.setVserverId("testVserverId"); - obj1.setAaiObject(vserver); - obj1.setResourceURI( - AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId")) - .build()); - auditList.getAuditList().add(obj1); - - doReturn(false).when(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder - .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId"))); - - auditNova.auditVservers(auditList); - - Mockito.verify(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder - .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId"))); - - Assert.assertEquals(false, auditList.getAuditList().get(0).isDoesObjectExist()); - } - - @Test - public void testAuditVserversThroughRelationships() { - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("id"); - - AAIResultWrapper wrapper = new AAIResultWrapper(vfModule); - - doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class, - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("genericVnfId").vfModules()) - .queryParam("vf-module-name", "vfModuleName")); - - Optional<AAIObjectAuditList> auditList = - auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName"); - - Assert.assertTrue(auditList.get().getAuditList().isEmpty()); - } - - @Test - public void testAuditVserversThroughRelationships_exists() throws IOException { - - String vfModule = getJson("vfModule.json"); - - AAIResultWrapper wrapper = new AAIResultWrapper(vfModule); - AAIResultWrapper vserverWrapper = new AAIResultWrapper(new Vserver()); - - doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class, - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("genericVnfId").vfModules()) - .queryParam("vf-module-name", "vfModuleName")); - - doReturn(vserverWrapper).when(aaiResourcesMock) - .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .cloudRegion("cloud-owner", "cloud-region-id").tenant("tenant-id").vserver("VUSCHGA1"))); - - Optional<AAIObjectAuditList> auditList = - auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName"); - - Assert.assertFalse(auditList.get().getAuditList().isEmpty()); - } - - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename))); - } - - - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java deleted file mode 100644 index d1d0d96042..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/HeatStackAuditTest.java +++ /dev/null @@ -1,298 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.tasks.audit; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doReturn; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aai.domain.yang.LInterface; -import org.onap.aai.domain.yang.LInterfaces; -import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.tasks.audit.AuditVServer; -import org.onap.so.adapters.tasks.audit.HeatStackAudit; -import org.onap.so.objects.audit.AAIObjectAuditList; -import org.onap.so.openstack.utils.MsoHeatUtils; -import org.onap.so.openstack.utils.MsoNeutronUtils; -import org.skyscreamer.jsonassert.JSONAssert; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.woorea.openstack.heat.model.Resource; -import com.woorea.openstack.heat.model.Resources; -import com.woorea.openstack.heat.model.Stack; -import com.woorea.openstack.quantum.model.Port; - - -@RunWith(MockitoJUnitRunner.Silent.class) -public class HeatStackAuditTest extends HeatStackAudit { - - @InjectMocks - private HeatStackAudit heatStackAudit = new HeatStackAudit(); - - @Mock - private MsoHeatUtils msoHeatUtilsMock; - - @Mock - private MsoNeutronUtils neutronUtilsMock; - - @Mock - private AuditVServer auditVserver; - - private static final String cloudRegion = "cloudRegion"; - private static final String tenantId = "tenantId"; - - private Resources resources = new Resources(); - - private ObjectMapper objectMapper = - new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .setSerializationInclusion(Include.NON_NULL); - - private ObjectMapper stackObjectMapper = new ObjectMapper() - .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true).setSerializationInclusion(Include.NON_NULL); - - private List<Optional<Port>> portList = new ArrayList<>(); - - @Before - public void setup() throws Exception { - resources = objectMapper.readValue(new File("src/test/resources/GetResources.json"), Resources.class); - Port neutronPort1 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort1.json"), Port.class); - doReturn(Optional.of(neutronPort1)).when(neutronUtilsMock) - .getNeutronPort("7ee06d9d-3d18-411c-9d3e-aec930f70413", cloudRegion, tenantId); - Port neutronPort2 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort2.json"), Port.class); - doReturn(Optional.of(neutronPort2)).when(neutronUtilsMock) - .getNeutronPort("27391d94-33af-474a-927d-d409249e8fd3", cloudRegion, tenantId); - Port neutronPort3 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort3.json"), Port.class); - doReturn(Optional.of(neutronPort3)).when(neutronUtilsMock) - .getNeutronPort("fdeedf37-c01e-4ab0-bdd6-8d5fc4913943", cloudRegion, tenantId); - Port neutronPort4 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort4.json"), Port.class); - doReturn(Optional.of(neutronPort4)).when(neutronUtilsMock) - .getNeutronPort("8d93f63e-e972-48c7-ad98-b2122da47315", cloudRegion, tenantId); - Port neutronPort5 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort5.json"), Port.class); - doReturn(Optional.of(neutronPort5)).when(neutronUtilsMock) - .getNeutronPort("0594a2f2-7ea4-42eb-abc2-48ea49677fca", cloudRegion, tenantId); - Port neutronPort6 = stackObjectMapper.readValue(new File("src/test/resources/NeutronPort6.json"), Port.class); - doReturn(Optional.of(neutronPort6)).when(neutronUtilsMock) - .getNeutronPort("00bb8407-650e-48b5-b919-33b88d6f8fe3", cloudRegion, tenantId); - - - portList.add(Optional.empty()); - portList.add(Optional.of(neutronPort1)); - portList.add(Optional.of(neutronPort2)); - portList.add(Optional.of(neutronPort3)); - portList.add(Optional.of(neutronPort4)); - portList.add(Optional.of(neutronPort5)); - portList.add(Optional.of(neutronPort6)); - } - - @Test - public void extract_proper_path_Test() { - Optional<String> actualResult = extractStackPathFromHref( - "https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); - assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81", actualResult.get()); - } - - @Test - public void extract_proper_resources_path_Test() { - Optional<String> actualResult = extractResourcePathFromHref( - "https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); - assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81/resources", actualResult.get()); - } - - @Test - public void extract_invalid_uri_Test() { - Optional<String> actualResult = extractStackPathFromHref( - "orchestrn.com:8004/v18b44d60a6f94bdcb2738f9e//stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); - assertEquals(false, actualResult.isPresent()); - } - - @Test - public void createVserverSet_Test() throws Exception { - List<Resource> novaResources = resources.getList().stream().filter(p -> "OS::Nova::Server".equals(p.getType())) - .collect(Collectors.toList()); - - List<Resource> resourceGroups = resources.getList().stream() - .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType())).collect(Collectors.toList()); - - Resources service1QueryResponse = objectMapper - .readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class); - doReturn(service1QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources", - cloudRegion, tenantId, Resources.class); - - Resources service2QueryResponse = objectMapper - .readValue(new File("src/test/resources/Service2ResourceGroupResponse.json"), Resources.class); - doReturn(service2QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources", - cloudRegion, tenantId, Resources.class); - - - Stack service2StackQuerySubInt = - stackObjectMapper.readValue(new File("src/test/resources/Service2SubInterface0.json"), Stack.class); - doReturn(service2StackQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", - cloudRegion, tenantId, Stack.class); - Resources service2ResourceQuerySubInt = objectMapper - .readValue(new File("src/test/resources/Service2SubInterface1Resources.json"), Resources.class); - doReturn(service2ResourceQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources", - cloudRegion, tenantId, Resources.class); - - Stack service1StackQuerySubInt1 = - stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface0.json"), Stack.class); - doReturn(service1StackQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", - cloudRegion, tenantId, Stack.class); - Resources service1ResourceQuerySubInt1 = objectMapper - .readValue(new File("src/test/resources/Service1SubInterface0Resources.json"), Resources.class); - doReturn(service1ResourceQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb/resources", - cloudRegion, tenantId, Resources.class); - - - Stack service1StackQuerySubInt2 = - stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface1.json"), Stack.class); - doReturn(service1StackQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a", - cloudRegion, tenantId, Stack.class); - Resources service1ResourceQuerySubInt2 = objectMapper - .readValue(new File("src/test/resources/Service1SubInterface1Resources.json"), Resources.class); - doReturn(service1ResourceQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a/resources", - cloudRegion, tenantId, Resources.class); - - Stack service1StackQuerySubInt3 = - stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface2.json"), Stack.class); - doReturn(service1StackQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c", - cloudRegion, tenantId, Stack.class); - Resources service1ResourceQuerySubInt3 = objectMapper - .readValue(new File("src/test/resources/Service1SubInterface2Resources.json"), Resources.class); - doReturn(service1ResourceQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest( - "/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c/resources", - cloudRegion, tenantId, Resources.class); - - Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources, portList); - Set<Vserver> vserversWithSubInterfaces = - heatStackAudit.processSubInterfaces(cloudRegion, tenantId, resourceGroups, vServersToAudit); - - String actualValue = objectMapper.writeValueAsString(vserversWithSubInterfaces); - String expectedValue = getJson("ExpectedVserversToAudit.json"); - JSONAssert.assertEquals(expectedValue, actualValue, false); - } - - @Test - public void auditHeatStackNoServers_Test() throws Exception { - Resources getResource = objectMapper - .readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class); - doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName", 3); - - Optional<AAIObjectAuditList> actual = - heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName"); - assertEquals(true, actual.get().getAuditList().isEmpty()); - } - - @Test - public void auditHeatStackNestedServers_Test() throws Exception { - Resources getResource = - objectMapper.readValue(new File("src/test/resources/GetNestedResources.json"), Resources.class); - List<Resource> novaResources = getResource.getList().stream() - .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); - List<Resource> resourceGroups = getResource.getList().stream() - .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType())).collect(Collectors.toList()); - - doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName", 3); - Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources, portList); - Set<Vserver> vserversWithSubInterfaces = - heatStackAudit.processSubInterfaces(cloudRegion, tenantId, resourceGroups, vServersToAudit); - String actualValue = objectMapper.writeValueAsString(vserversWithSubInterfaces); - String expectedValue = getJson("NestedExpectedValue.json"); - JSONAssert.assertEquals(expectedValue, actualValue, false); - } - - - @Test - public void findInterfaceInformation_Test() { - List<Resource> novaResources = resources.getList().stream().filter(p -> "OS::Nova::Server".equals(p.getType())) - .collect(Collectors.toList()); - Set<Vserver> expectedVservers = new HashSet<>(); - Vserver vServer1 = new Vserver(); - vServer1.setVserverId("92272b67-d23f-42ca-87fa-7b06a9ec81f3"); - LInterfaces vServer1Linterfaces = new LInterfaces(); - vServer1.setLInterfaces(vServer1Linterfaces); - - LInterface ssc_1_trusted_port_0 = new LInterface(); - ssc_1_trusted_port_0.setInterfaceId("7ee06d9d-3d18-411c-9d3e-aec930f70413"); - ssc_1_trusted_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_trusted_port_0); - - LInterface ssc_1_svc2_port_0 = new LInterface(); - ssc_1_svc2_port_0.setInterfaceId("27391d94-33af-474a-927d-d409249e8fd3"); - ssc_1_svc2_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_svc2_port_0); - - LInterface ssc_1_mgmt_port_1 = new LInterface(); - ssc_1_mgmt_port_1.setInterfaceId("fdeedf37-c01e-4ab0-bdd6-8d5fc4913943"); - ssc_1_mgmt_port_1.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_1); - - LInterface ssc_1_mgmt_port_0 = new LInterface(); - ssc_1_mgmt_port_0.setInterfaceId("8d93f63e-e972-48c7-ad98-b2122da47315"); - ssc_1_mgmt_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_0); - - LInterface ssc_1_svc1_port_0 = new LInterface(); - ssc_1_svc1_port_0.setInterfaceId("0594a2f2-7ea4-42eb-abc2-48ea49677fca"); - ssc_1_svc1_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_svc1_port_0); - - LInterface ssc_1_int_ha_port_0 = new LInterface(); - ssc_1_int_ha_port_0.setInterfaceId("00bb8407-650e-48b5-b919-33b88d6f8fe3"); - ssc_1_int_ha_port_0.setInterfaceName("ibcx0026v_ibcx0026vm003_untrusted_port"); - vServer1.getLInterfaces().getLInterface().add(ssc_1_int_ha_port_0); - - expectedVservers.add(vServer1); - - Set<Vserver> actualVservers = heatStackAudit.createVserverSet(resources, novaResources, portList); - - assertThat(actualVservers, sameBeanAs(expectedVservers)); - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename))); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index ebc7c3a81e..7912bceede 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -215,7 +215,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); + verify(transaction, times(2)).create(captor.capture(), any()); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() @@ -259,7 +259,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); + verify(transaction, times(2)).create(captor.capture(), any()); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() @@ -297,15 +297,15 @@ public class HeatBridgeImplTest { org.onap.aai.domain.yang.RelationshipList relList = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, "test-genericVnf-id", "test-vfModule-id", server1); - assertEquals(4, relList.getRelationship().size()); + assertEquals(3, relList.getRelationship().size()); org.onap.aai.domain.yang.RelationshipList relList2 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, "test-genericVnf-id", "test-vfModule-id", server2); - assertEquals(3, relList2.getRelationship().size()); + assertEquals(2, relList2.getRelationship().size()); org.onap.aai.domain.yang.RelationshipList relList3 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, "test-genericVnf-id", "test-vfModule-id", server3); - assertEquals(3, relList3.getRelationship().size()); + assertEquals(2, relList3.getRelationship().size()); } @@ -539,7 +539,7 @@ public class HeatBridgeImplTest { when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); // Act - heatbridge.updateLInterfaceVlan(port, lIf, "hostname"); + heatbridge.createVlanAndSriovVF(port, lIf, "hostname"); // Assert verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); @@ -625,7 +625,7 @@ public class HeatBridgeImplTest { PInterface pIf = mock(PInterface.class); when(pIf.getInterfaceName()).thenReturn("test-port-id"); - doNothing().when(heatbridge).updateSriovPfToPserver(any(), any()); + doNothing().when(heatbridge).updateSriovPfToSriovVF(any(), any()); // Act heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); 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/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java index 62a2e9370e..57b8c1387d 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java @@ -30,6 +30,7 @@ public abstract class Resource extends JsonWrapper implements Serializable { private static final long serialVersionUID = 1L; private String resourceId; // TODO name this field just id instead, should be the id of the object as it is in aai + private String originalResourceId; protected ResourceType resourceType; // Enum of vnf or network or allotted resource protected ModelInfo modelInfo; private long concurrencyCounter = 1L; @@ -52,6 +53,14 @@ public abstract class Resource extends JsonWrapper implements Serializable { this.resourceId = resourceId; } + public String getOriginalResourceId() { + return originalResourceId; + } + + public void setOriginalResourceId(String originalResourceId) { + this.originalResourceId = originalResourceId; + } + public ModelInfo getModelInfo() { return modelInfo; } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn index 01caf38610..383fd27b56 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn @@ -2,14 +2,13 @@ <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0"> <bpmn:process id="ActivateVfModuleBB" name="ActivateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="ActivateVfModuleBB_Start"> - <bpmn:outgoing>SequenceFlow_0ieafii</bpmn:outgoing> + <bpmn:outgoing>Flow_1hz7ga1</bpmn:outgoing> </bpmn:startEvent> - <bpmn:sequenceFlow id="SequenceFlow_0ieafii" sourceRef="ActivateVfModuleBB_Start" targetRef="CheckAuditVariable" /> <bpmn:endEvent id="ActivateVfModuleBB_End"> <bpmn:incoming>SequenceFlow_0xsp0pv</bpmn:incoming> </bpmn:endEvent> <bpmn:serviceTask id="ActivateVfModule" name=" SDNC Activate (vf module) " camunda:expression="${SDNCActivateTasks.activateVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_1b63lv4</bpmn:incoming> + <bpmn:incoming>Flow_1hz7ga1</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1a495wm</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVfModuleActiveStatus" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusActivateVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -29,64 +28,7 @@ </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_1a495wm" sourceRef="ActivateVfModule" targetRef="CallActivity_sdncHandler" /> <bpmn:sequenceFlow id="SequenceFlow_1j4x1ej" sourceRef="CallActivity_sdncHandler" targetRef="UpdateVfModuleActiveStatus" /> - <bpmn:sequenceFlow id="SequenceFlow_0xndboi" sourceRef="Setup_AAI_Inventory_Audit" targetRef="Audit_AAI_Inventory" /> - <bpmn:serviceTask id="Setup_AAI_Inventory_Audit" name="Setup Inventory Audit Variable" camunda:expression="${AuditTasks.setupAuditVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ghzwlo</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0xndboi</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:serviceTask id="Audit_AAI_Inventory" name="Validate A&AI Inventory" camunda:type="external" camunda:topic="InventoryAddAudit"> - <bpmn:incoming>SequenceFlow_0xndboi</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0l8684g</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_07ybdik" name="No" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="ExclusiveGateway_0sqvzll" /> - <bpmn:sequenceFlow id="SequenceFlow_0ghzwlo" name="Yes" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="Setup_AAI_Inventory_Audit"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditInventoryNeeded") == true}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:serviceTask id="CheckAuditVariable" name="Check Audit Variable" camunda:expression="${AuditTasks.isAuditNeeded(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ieafii</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1xqyur9</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_1xqyur9" sourceRef="CheckAuditVariable" targetRef="ExclusiveGateway_1v8bmbu" /> - <bpmn:sequenceFlow id="SequenceFlow_1b63lv4" sourceRef="ExclusiveGateway_0sqvzll" targetRef="ActivateVfModule" /> - <bpmn:subProcess id="SubProcess_0bpsptg" name="Audit Exception Sub Process" triggeredByEvent="true"> - <bpmn:startEvent id="catchInventoryException"> - <bpmn:outgoing>SequenceFlow_19gbhlj</bpmn:outgoing> - <bpmn:errorEventDefinition errorRef="Error_1s3kxze" /> - </bpmn:startEvent> - <bpmn:endEvent id="EndEvent_067jv1n"> - <bpmn:incoming>SequenceFlow_0l4jzc5</bpmn:incoming> - </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_19gbhlj" sourceRef="catchInventoryException" targetRef="processAuditException" /> - <bpmn:sequenceFlow id="SequenceFlow_0l4jzc5" sourceRef="processAuditException" targetRef="EndEvent_067jv1n" /> - <bpmn:serviceTask id="processAuditException" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), false)}"> - <bpmn:incoming>SequenceFlow_19gbhlj</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0l4jzc5</bpmn:outgoing> - </bpmn:serviceTask> - </bpmn:subProcess> - <bpmn:inclusiveGateway id="ExclusiveGateway_1v8bmbu" name="Audit Enabled?" default="SequenceFlow_07ybdik"> - <bpmn:incoming>SequenceFlow_1xqyur9</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_07ybdik</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_0ghzwlo</bpmn:outgoing> - </bpmn:inclusiveGateway> - <bpmn:inclusiveGateway id="ExclusiveGateway_0sqvzll"> - <bpmn:incoming>SequenceFlow_07ybdik</bpmn:incoming> - <bpmn:incoming>Flow_1c5mrjc</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1b63lv4</bpmn:outgoing> - </bpmn:inclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0l8684g" sourceRef="Audit_AAI_Inventory" targetRef="Gateway_1518atw" /> - <bpmn:exclusiveGateway id="Gateway_1518atw" name="Audit Failed?" default="Flow_1c5mrjc"> - <bpmn:incoming>SequenceFlow_0l8684g</bpmn:incoming> - <bpmn:outgoing>Flow_1c5mrjc</bpmn:outgoing> - <bpmn:outgoing>Flow_02xnvmz</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="Flow_1c5mrjc" sourceRef="Gateway_1518atw" targetRef="ExclusiveGateway_0sqvzll" /> - <bpmn:sequenceFlow id="Flow_02xnvmz" sourceRef="Gateway_1518atw" targetRef="Event_1ubxkat"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditIsSuccessful") == false}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:endEvent id="Event_1ubxkat"> - <bpmn:incoming>Flow_02xnvmz</bpmn:incoming> - <bpmn:errorEventDefinition id="ErrorEventDefinition_0qq1s4r" errorRef="Error_1s3kxze" /> - </bpmn:endEvent> + <bpmn:sequenceFlow id="Flow_1hz7ga1" sourceRef="ActivateVfModuleBB_Start" targetRef="ActivateVfModule" /> </bpmn:process> <bpmn:error id="Error_0q258vt" errorCode="7000" /> <bpmn:error id="Error_0zgccif" name="org.onap.so.adapters.inventory.create.InventoryException" errorCode="org.onap.so.adapters.inventory.create.InventoryException" /> @@ -94,167 +36,51 @@ <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateVfModuleBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="ActivateVfModuleBB_Start"> - <dc:Bounds x="156" y="260" width="36" height="36" /> + <dc:Bounds x="156" y="100" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="58" y="270" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ieafii_di" bpmnElement="SequenceFlow_0ieafii"> - <di:waypoint x="192" y="278" /> - <di:waypoint x="272" y="278" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="116" y="231" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1v967li_di" bpmnElement="ActivateVfModuleBB_End"> - <dc:Bounds x="1475" y="261" width="36" height="36" /> + <dc:Bounds x="736" y="101" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="1235" y="275" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0hawa84_di" bpmnElement="ActivateVfModule"> - <dc:Bounds x="1029" y="238" width="100" height="80" /> + <dc:Bounds x="290" y="78" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_175e9ul_di" bpmnElement="UpdateVfModuleActiveStatus"> - <dc:Bounds x="1285" y="238" width="100" height="80" /> + <dc:Bounds x="546" y="78" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0xsp0pv_di" bpmnElement="SequenceFlow_0xsp0pv"> - <di:waypoint x="1385" y="278" /> - <di:waypoint x="1475" y="279" /> + <di:waypoint x="646" y="118" /> + <di:waypoint x="736" y="119" /> <bpmndi:BPMNLabel> <dc:Bounds x="1314" y="231.5" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_03jkesd_di" bpmnElement="CallActivity_sdncHandler"> - <dc:Bounds x="1157" y="238" width="100" height="80" /> + <dc:Bounds x="418" y="78" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1a495wm_di" bpmnElement="SequenceFlow_1a495wm"> - <di:waypoint x="1129" y="278" /> - <di:waypoint x="1157" y="278" /> + <di:waypoint x="390" y="118" /> + <di:waypoint x="418" y="118" /> <bpmndi:BPMNLabel> <dc:Bounds x="1027" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1j4x1ej_di" bpmnElement="SequenceFlow_1j4x1ej"> - <di:waypoint x="1257" y="278" /> - <di:waypoint x="1285" y="278" /> + <di:waypoint x="518" y="118" /> + <di:waypoint x="546" y="118" /> <bpmndi:BPMNLabel> <dc:Bounds x="1155" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0xndboi_di" bpmnElement="SequenceFlow_0xndboi"> - <di:waypoint x="589" y="201" /> - <di:waypoint x="630" y="201" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="457" y="153.5" width="90" height="13" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0krf1ur_di" bpmnElement="Setup_AAI_Inventory_Audit"> - <dc:Bounds x="489" y="161" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_08rxjeb_di" bpmnElement="Audit_AAI_Inventory"> - <dc:Bounds x="630" y="161" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_07ybdik_di" bpmnElement="SequenceFlow_07ybdik"> - <di:waypoint x="426" y="303" /> - <di:waypoint x="426" y="341" /> - <di:waypoint x="952" y="341" /> - <di:waypoint x="952" y="303" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="435" y="320" width="15" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0ghzwlo_di" bpmnElement="SequenceFlow_0ghzwlo"> - <di:waypoint x="426" y="253" /> - <di:waypoint x="426" y="201" /> - <di:waypoint x="489" y="201" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="434" y="211" width="18" height="14" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNEdge id="Flow_1hz7ga1_di" bpmnElement="Flow_1hz7ga1"> + <di:waypoint x="192" y="118" /> + <di:waypoint x="290" y="118" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1eg5ryx_di" bpmnElement="CheckAuditVariable"> - <dc:Bounds x="272" y="238" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1xqyur9_di" bpmnElement="SequenceFlow_1xqyur9"> - <di:waypoint x="372" y="278" /> - <di:waypoint x="401" y="278" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="270.5" y="230.5" width="90" height="13" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1b63lv4_di" bpmnElement="SequenceFlow_1b63lv4"> - <di:waypoint x="977" y="278" /> - <di:waypoint x="1029" y="278" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="887" y="231" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="SubProcess_0mbkb7v_di" bpmnElement="SubProcess_0bpsptg" isExpanded="true"> - <dc:Bounds x="364" y="475" width="350" height="200" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_12r96di_di" bpmnElement="catchInventoryException"> - <dc:Bounds x="395" y="558" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="341.15269461077844" y="571.6127744510978" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_067jv1n_di" bpmnElement="EndEvent_067jv1n"> - <dc:Bounds x="643" y="558" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="590.1526946107784" y="572" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_19gbhlj_di" bpmnElement="SequenceFlow_19gbhlj"> - <di:waypoint x="431" y="576" /> - <di:waypoint x="486" y="576" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="387.5" y="529" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0l4jzc5_di" bpmnElement="SequenceFlow_0l4jzc5"> - <di:waypoint x="586" y="576" /> - <di:waypoint x="643" y="576" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="543.5" y="529" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_08xffml_di" bpmnElement="processAuditException"> - <dc:Bounds x="486" y="536" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="InclusiveGateway_03pi9y4_di" bpmnElement="ExclusiveGateway_1v8bmbu"> - <dc:Bounds x="401" y="253" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="454" y="272" width="74" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="InclusiveGateway_16ap4e3_di" bpmnElement="ExclusiveGateway_0sqvzll"> - <dc:Bounds x="927" y="253" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="836" y="281" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0l8684g_di" bpmnElement="SequenceFlow_0l8684g"> - <di:waypoint x="730" y="201" /> - <di:waypoint x="785" y="201" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="Gateway_1518atw_di" bpmnElement="Gateway_1518atw" isMarkerVisible="true"> - <dc:Bounds x="785" y="176" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="780" y="233" width="64" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="Flow_1c5mrjc_di" bpmnElement="Flow_1c5mrjc"> - <di:waypoint x="835" y="201" /> - <di:waypoint x="952" y="201" /> - <di:waypoint x="952" y="253" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_02xnvmz_di" bpmnElement="Flow_02xnvmz"> - <di:waypoint x="810" y="176" /> - <di:waypoint x="810" y="118" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="Event_133vsyh_di" bpmnElement="Event_1ubxkat"> - <dc:Bounds x="792" y="82" width="36" height="36" /> - </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 87e0b883a9..9a33a3e4bf 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0"> <bpmn:process id="DeleteVfModuleBB" name="DeleteVfModuleBB" isExecutable="true"> <bpmn:startEvent id="DeleteVfModuleBB_Start"> - <bpmn:outgoing>SequenceFlow_1oeootm</bpmn:outgoing> + <bpmn:outgoing>Flow_02lmh6f</bpmn:outgoing> </bpmn:startEvent> <bpmn:serviceTask id="DeleteVfModuleVnfAdapter" name="Prepare Request" camunda:expression="${VnfAdapterDeleteTasks.deleteVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_028rmiu</bpmn:incoming> + <bpmn:incoming>Flow_02lmh6f</bpmn:incoming> <bpmn:outgoing>SequenceFlow_08tvhtf</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVfModuleDeleteStatus" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusDeleteVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -29,9 +29,8 @@ <camunda:out source="contrailServiceInstanceFqdn" target="contrailServiceInstanceFqdn" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> + <bpmn:outgoing>Flow_0hlvlw2</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="ExclusiveGateway_1yvh16a" /> <bpmn:subProcess id="SubProcess_11p7mrh" name="Error Handling " triggeredByEvent="true"> <bpmn:startEvent id="StartEvent_1xp6ewt"> <bpmn:outgoing>SequenceFlow_0h607z0</bpmn:outgoing> @@ -51,7 +50,7 @@ <bpmn:sequenceFlow id="SequenceFlow_09l7pcg" sourceRef="UpdateVfModuleDeleteStatus" targetRef="DeleteVfModuleBB_End" /> <bpmn:sequenceFlow id="SequenceFlow_0xyu3pk" sourceRef="DeleteNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> <bpmn:serviceTask id="DeleteNetworkPolicies" name=" AAI Delete (net policies) " camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0sy2nky</bpmn:incoming> + <bpmn:incoming>Flow_0n2pqrr</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xyu3pk</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVnfManagementV6Address" name=" AAI Update (vnf) " camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -69,496 +68,176 @@ <bpmn:incoming>SequenceFlow_0khqfnc</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0yuz21z</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_032jv5j" name="Yes " sourceRef="auditEnabledCheck" targetRef="Setup_Audit_Variable"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditInventoryNeeded") == true}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_14bu4ys" sourceRef="ExclusiveGateway_1yvh16a" targetRef="ServiceTask_08ulmzc" /> - <bpmn:serviceTask id="Check_Audit" name="Check Audit Variable" camunda:expression="${AuditTasks.isDeleteAuditNeeded(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_1oeootm</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_10af0fk</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:serviceTask id="Audit_Inventory" name=" AAI Audit (vservers) " camunda:type="external" camunda:topic="InventoryDeleteAudit"> - <bpmn:incoming>SequenceFlow_0f5ljoh</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0hpj2mm</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:serviceTask id="Setup_Audit_Variable" name="Setup Audit Variable" camunda:expression="${AuditTasks.setupAuditVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_032jv5j</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1iulltd</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:subProcess id="SubProcess_0grvkj2" name="Audit Exception Sub Process" triggeredByEvent="true"> - <bpmn:endEvent id="EndEvent_1gzq57j"> - <bpmn:incoming>SequenceFlow_1fhst92</bpmn:incoming> - </bpmn:endEvent> - <bpmn:serviceTask id="ServiceTask_1isbxvo" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), true)}"> - <bpmn:incoming>SequenceFlow_0xuodpy</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1fhst92</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_0xuodpy" sourceRef="StartEvent_1euiddy" targetRef="ServiceTask_1isbxvo" /> - <bpmn:sequenceFlow id="SequenceFlow_1fhst92" sourceRef="ServiceTask_1isbxvo" targetRef="EndEvent_1gzq57j" /> - <bpmn:startEvent id="StartEvent_1euiddy" isInterrupting="false"> - <bpmn:outgoing>SequenceFlow_0xuodpy</bpmn:outgoing> - <bpmn:escalationEventDefinition escalationRef="Escalation_130je8j" camunda:escalationCodeVariable="auditCode" /> - </bpmn:startEvent> - </bpmn:subProcess> - <bpmn:sequenceFlow id="SequenceFlow_179btn2" sourceRef="aaiCatch" targetRef="ServiceTask_0itw3by" /> <bpmn:intermediateThrowEvent id="aaiThrow" name="Update AAI"> - <bpmn:incoming>SequenceFlow_1i9ft2r</bpmn:incoming> + <bpmn:incoming>Flow_0plbl7p</bpmn:incoming> <bpmn:linkEventDefinition name="AAI" /> </bpmn:intermediateThrowEvent> <bpmn:intermediateCatchEvent id="aaiCatch" name="Update AAI"> - <bpmn:outgoing>SequenceFlow_179btn2</bpmn:outgoing> + <bpmn:outgoing>Flow_0n2pqrr</bpmn:outgoing> <bpmn:linkEventDefinition name="AAI" /> </bpmn:intermediateCatchEvent> - <bpmn:sequenceFlow id="SequenceFlow_17cd9e2" name="Yes/No" sourceRef="auditSuccessfulCheck" targetRef="ExclusiveGateway_01wvywu"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditIsSuccessful") == false || execution.getVariable("auditIsSuccessful") == true}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_1gdyk9j" name="No" sourceRef="auditSuccessfulCheck" targetRef="EndEvent_0b0ocu0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditIsSuccessful") == false}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:inclusiveGateway id="auditSuccessfulCheck" name="Audit Successful?"> - <bpmn:incoming>SequenceFlow_0hpj2mm</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_17cd9e2</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1gdyk9j</bpmn:outgoing> - </bpmn:inclusiveGateway> - <bpmn:endEvent id="EndEvent_0b0ocu0"> - <bpmn:incoming>SequenceFlow_1gdyk9j</bpmn:incoming> - <bpmn:escalationEventDefinition escalationRef="Escalation_130je8j" /> - </bpmn:endEvent> - <bpmn:exclusiveGateway id="auditEnabledCheck" name="Audit Enabled?" default="SequenceFlow_1bt1p2u"> - <bpmn:incoming>SequenceFlow_10af0fk</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_032jv5j</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1bt1p2u</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:exclusiveGateway id="ExclusiveGateway_1t9q2jl"> - <bpmn:incoming>SequenceFlow_1bt1p2u</bpmn:incoming> - <bpmn:incoming>SequenceFlow_0dzf7hz</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1bq9g02</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_1bt1p2u" name="No" sourceRef="auditEnabledCheck" targetRef="ExclusiveGateway_1t9q2jl" /> - <bpmn:sequenceFlow id="SequenceFlow_1oeootm" sourceRef="DeleteVfModuleBB_Start" targetRef="Check_Audit" /> - <bpmn:sequenceFlow id="SequenceFlow_10af0fk" sourceRef="Check_Audit" targetRef="auditEnabledCheck" /> - <bpmn:serviceTask id="aicQueryStack" name=" AIC Query (stack) " camunda:type="external" camunda:topic="InventoryQueryAudit"> - <bpmn:incoming>SequenceFlow_1iulltd</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0dzf7hz</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_1iulltd" sourceRef="Setup_Audit_Variable" targetRef="aicQueryStack" /> - <bpmn:sequenceFlow id="SequenceFlow_0dzf7hz" sourceRef="aicQueryStack" targetRef="ExclusiveGateway_1t9q2jl" /> - <bpmn:sequenceFlow id="SequenceFlow_1bq9g02" sourceRef="ExclusiveGateway_1t9q2jl" targetRef="ExclusiveGateway_1naduhl" /> - <bpmn:sequenceFlow id="SequenceFlow_0mtzl4z" sourceRef="ExclusiveGateway_1naduhl" targetRef="ExclusiveGateway_13fhmpf" /> - <bpmn:sequenceFlow id="SequenceFlow_028rmiu" sourceRef="ExclusiveGateway_1naduhl" targetRef="DeleteVfModuleVnfAdapter" /> - <bpmn:parallelGateway id="ExclusiveGateway_1naduhl"> - <bpmn:incoming>SequenceFlow_1bq9g02</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0mtzl4z</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_028rmiu</bpmn:outgoing> - </bpmn:parallelGateway> - <bpmn:inclusiveGateway id="ExclusiveGateway_1yvh16a"> - <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> - <bpmn:incoming>SequenceFlow_13mlz57</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_14bu4ys</bpmn:outgoing> - </bpmn:inclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0hpj2mm" sourceRef="Audit_Inventory" targetRef="auditSuccessfulCheck" /> - <bpmn:exclusiveGateway id="ExclusiveGateway_13fhmpf" name="Audit Enabled?" default="SequenceFlow_1gjwivp"> - <bpmn:incoming>SequenceFlow_0mtzl4z</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0f5ljoh</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1gjwivp</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0f5ljoh" name="Yes" sourceRef="ExclusiveGateway_13fhmpf" targetRef="Audit_Inventory"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("auditInventoryNeeded") == true}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:exclusiveGateway id="ExclusiveGateway_01wvywu"> - <bpmn:incoming>SequenceFlow_17cd9e2</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1gjwivp</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_13mlz57</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_1gjwivp" name="No" sourceRef="ExclusiveGateway_13fhmpf" targetRef="ExclusiveGateway_01wvywu" /> - <bpmn:sequenceFlow id="SequenceFlow_13mlz57" sourceRef="ExclusiveGateway_01wvywu" targetRef="ExclusiveGateway_1yvh16a" /> <bpmn:serviceTask id="ServiceTask_0itw3by" name=" AAI Delete (inventory) " camunda:type="external" camunda:topic="InventoryDelete"> - <bpmn:incoming>SequenceFlow_179btn2</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0sy2nky</bpmn:outgoing> + <bpmn:incoming>SequenceFlow_1i9ft2r</bpmn:incoming> + <bpmn:outgoing>Flow_0plbl7p</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_0sy2nky" sourceRef="ServiceTask_0itw3by" targetRef="DeleteNetworkPolicies" /> <bpmn:serviceTask id="ServiceTask_08ulmzc" name=" Create Cloud Variable " camunda:expression="${DeleteVFModule.createInventoryVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_14bu4ys</bpmn:incoming> + <bpmn:incoming>Flow_0hlvlw2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1i9ft2r</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_1i9ft2r" sourceRef="ServiceTask_08ulmzc" targetRef="aaiThrow" /> + <bpmn:sequenceFlow id="SequenceFlow_1i9ft2r" sourceRef="ServiceTask_08ulmzc" targetRef="ServiceTask_0itw3by" /> + <bpmn:sequenceFlow id="Flow_0n2pqrr" sourceRef="aaiCatch" targetRef="DeleteNetworkPolicies" /> + <bpmn:sequenceFlow id="Flow_0plbl7p" sourceRef="ServiceTask_0itw3by" targetRef="aaiThrow" /> + <bpmn:sequenceFlow id="Flow_0hlvlw2" sourceRef="VnfAdapter" targetRef="ServiceTask_08ulmzc" /> + <bpmn:sequenceFlow id="Flow_02lmh6f" sourceRef="DeleteVfModuleBB_Start" targetRef="DeleteVfModuleVnfAdapter" /> </bpmn:process> <bpmn:error id="Error_0jjnve8" name="Error_3k24na6" errorCode="AAIInventoryFailure" /> <bpmn:escalation id="Escalation_130je8j" name="audit" escalationCode="audit1" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="DeleteVfModuleBB_Start"> - <dc:Bounds x="159" y="266" width="36" height="36" /> + <dc:Bounds x="159" y="106" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="132" y="302" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_16798zf_di" bpmnElement="DeleteVfModuleVnfAdapter"> - <dc:Bounds x="888" y="312" width="100" height="80" /> + <dc:Bounds x="290" y="84" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0pbhsub_di" bpmnElement="UpdateVfModuleDeleteStatus"> - <dc:Bounds x="1136" y="468" width="100" height="80" /> + <dc:Bounds x="930" y="308" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_08tvhtf_di" bpmnElement="SequenceFlow_08tvhtf"> - <di:waypoint x="988" y="352" /> - <di:waypoint x="1020" y="352" /> + <di:waypoint x="390" y="124" /> + <di:waypoint x="435" y="124" /> <bpmndi:BPMNLabel> <dc:Bounds x="959" y="331" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1rn6yvh_di" bpmnElement="DeleteVfModuleBB_End"> - <dc:Bounds x="1268" y="490" width="36" height="36" /> + <dc:Bounds x="1142" y="330" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="1241" y="530" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0whogn3_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="1020" y="312" width="100" height="80" /> + <dc:Bounds x="435" y="84" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_02lpx87_di" bpmnElement="SequenceFlow_02lpx87"> - <di:waypoint x="1120" y="352" /> - <di:waypoint x="1203" y="352" /> - <di:waypoint x="1203" y="309" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1116.5" y="337" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_11p7mrh_di" bpmnElement="SubProcess_11p7mrh" isExpanded="true"> - <dc:Bounds x="290" y="878" width="231" height="135" /> + <dc:Bounds x="304" y="500" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1xp6ewt_di" bpmnElement="StartEvent_1xp6ewt"> - <dc:Bounds x="333" y="940" width="36" height="36" /> + <dc:Bounds x="347" y="562" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="261" y="976" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0guhjau_di" bpmnElement="EndEvent_0guhjau"> - <dc:Bounds x="462" y="940" width="36" height="36" /> + <dc:Bounds x="476" y="562" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="390" y="976" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0h607z0_di" bpmnElement="SequenceFlow_0h607z0"> - <di:waypoint x="369" y="958" /> - <di:waypoint x="462" y="958" /> + <di:waypoint x="383" y="580" /> + <di:waypoint x="476" y="580" /> <bpmndi:BPMNLabel> <dc:Bounds x="371" y="937" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0vlgqod_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="969" y="468" width="100" height="80" /> + <dc:Bounds x="800" y="308" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_01vfwtp_di" bpmnElement="SequenceFlow_01vfwtp"> - <di:waypoint x="1069" y="508" /> - <di:waypoint x="1136" y="508" /> + <di:waypoint x="900" y="348" /> + <di:waypoint x="930" y="348" /> <bpmndi:BPMNLabel> <dc:Bounds x="848" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09l7pcg_di" bpmnElement="SequenceFlow_09l7pcg"> - <di:waypoint x="1236" y="508" /> - <di:waypoint x="1268" y="508" /> + <di:waypoint x="1030" y="348" /> + <di:waypoint x="1142" y="348" /> <bpmndi:BPMNLabel> <dc:Bounds x="1092.5" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xyu3pk_di" bpmnElement="SequenceFlow_0xyu3pk"> - <di:waypoint x="420" y="468" /> - <di:waypoint x="420" y="448" /> - <di:waypoint x="443" y="409" /> - <di:waypoint x="497" y="468" /> + <di:waypoint x="370" y="348" /> + <di:waypoint x="400" y="348" /> <bpmndi:BPMNLabel> <dc:Bounds x="345" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0tty0ac_di" bpmnElement="DeleteNetworkPolicies"> - <dc:Bounds x="370" y="468" width="100" height="80" /> + <dc:Bounds x="270" y="308" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0lrrd16_di" bpmnElement="UpdateVnfManagementV6Address"> - <dc:Bounds x="642" y="468" width="100" height="80" /> + <dc:Bounds x="540" y="308" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0jtem3b_di" bpmnElement="SequenceFlow_0jtem3b"> - <di:waypoint x="533" y="468" /> - <di:waypoint x="533" y="448" /> - <di:waypoint x="619" y="387" /> - <di:waypoint x="692" y="448" /> - <di:waypoint x="692" y="468" /> + <di:waypoint x="500" y="348" /> + <di:waypoint x="540" y="348" /> <bpmndi:BPMNLabel> <dc:Bounds x="473" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0w9805b_di" bpmnElement="UpdateVnfIpv4OamAddress"> - <dc:Bounds x="483" y="468" width="100" height="80" /> + <dc:Bounds x="400" y="308" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0khqfnc_di" bpmnElement="SequenceFlow_0khqfnc"> - <di:waypoint x="742" y="493" /> - <di:waypoint x="891" y="448" /> - <di:waypoint x="891" y="468" /> + <di:waypoint x="640" y="348" /> + <di:waypoint x="670" y="348" /> <bpmndi:BPMNLabel> <dc:Bounds x="598" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0yuz21z_di" bpmnElement="SequenceFlow_0yuz21z"> - <di:waypoint x="941" y="508" /> - <di:waypoint x="969" y="508" /> + <di:waypoint x="770" y="348" /> + <di:waypoint x="800" y="348" /> <bpmndi:BPMNLabel> <dc:Bounds x="722" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0v8naz9_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> - <dc:Bounds x="841" y="468" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_032jv5j_di" bpmnElement="SequenceFlow_032jv5j"> - <di:waypoint x="397" y="259" /> - <di:waypoint x="397" y="214" /> - <di:waypoint x="444" y="214" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="405.5348837209302" y="217.95121951219514" width="19" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_14bu4ys_di" bpmnElement="SequenceFlow_14bu4ys"> - <di:waypoint x="1228" y="284" /> - <di:waypoint x="1284" y="284" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1230.5" y="262.5" width="90" height="13" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1vmz3zo_di" bpmnElement="Check_Audit"> - <dc:Bounds x="244" y="244" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1l8r2a6_di" bpmnElement="Audit_Inventory"> - <dc:Bounds x="930" y="117" width="100" height="80" /> + <dc:Bounds x="670" y="308" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1gttdjr_di" bpmnElement="Setup_Audit_Variable"> - <dc:Bounds x="444" y="174" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="SubProcess_0grvkj2_di" bpmnElement="SubProcess_0grvkj2" isExpanded="true"> - <dc:Bounds x="231" y="642" width="350" height="200" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1gzq57j_di" bpmnElement="EndEvent_1gzq57j"> - <dc:Bounds x="510" y="725" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="438" y="765" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1isbxvo_di" bpmnElement="ServiceTask_1isbxvo"> - <dc:Bounds x="353" y="703" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0xuodpy_di" bpmnElement="SequenceFlow_0xuodpy"> - <di:waypoint x="298" y="743" /> - <di:waypoint x="353" y="743" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="280.5" y="722" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1fhst92_di" bpmnElement="SequenceFlow_1fhst92"> - <di:waypoint x="453" y="743" /> - <di:waypoint x="510" y="743" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="393" y="722" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_179btn2_di" bpmnElement="SequenceFlow_179btn2"> - <di:waypoint x="195" y="508" /> - <di:waypoint x="225" y="508" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="191" y="487" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_1sftyjz_di" bpmnElement="aaiThrow"> - <dc:Bounds x="1481" y="266" width="36" height="36" /> + <dc:Bounds x="1062" y="106" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1472" y="305" width="57" height="14" /> + <dc:Bounds x="1053" y="145" width="57" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_13y483m_di" bpmnElement="aaiCatch"> - <dc:Bounds x="159" y="490" width="36" height="36" /> + <dc:Bounds x="159" y="330" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="150" y="530" width="55" height="12" /> + <dc:Bounds x="149" y="370" width="57" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_17cd9e2_di" bpmnElement="SequenceFlow_17cd9e2"> - <di:waypoint x="1108" y="157" /> - <di:waypoint x="1156" y="157" /> - <di:waypoint x="1156" y="189" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1111.0434782608695" y="137" width="36" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1gdyk9j_di" bpmnElement="SequenceFlow_1gdyk9j"> - <di:waypoint x="1083" y="132" /> - <di:waypoint x="1083" y="109" /> - <di:waypoint x="1083" y="109" /> - <di:waypoint x="1083" y="84" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1083" y="110.74468085106383" width="14" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="InclusiveGateway_0i6rdd1_di" bpmnElement="auditSuccessfulCheck"> - <dc:Bounds x="1058" y="132" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1053" y="186" width="60" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_04qhoba_di" bpmnElement="StartEvent_1euiddy"> - <dc:Bounds x="262" y="725" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="189" y="765" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1onxfk1_di" bpmnElement="EndEvent_0b0ocu0"> - <dc:Bounds x="1065" y="48" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1024" y="87" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_05scr6c_di" bpmnElement="auditEnabledCheck" isMarkerVisible="true"> - <dc:Bounds x="371.6051332675222" y="259" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="421" y="272" width="45" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_1t9q2jl_di" bpmnElement="ExclusiveGateway_1t9q2jl" isMarkerVisible="true"> - <dc:Bounds x="697" y="259" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="677" y="313" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1bt1p2u_di" bpmnElement="SequenceFlow_1bt1p2u"> - <di:waypoint x="397" y="309" /> - <di:waypoint x="397" y="352" /> - <di:waypoint x="722" y="352" /> - <di:waypoint x="722" y="309" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="407" y="326" width="14" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1oeootm_di" bpmnElement="SequenceFlow_1oeootm"> - <di:waypoint x="195" y="284" /> - <di:waypoint x="244" y="284" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="219.5" y="263" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_10af0fk_di" bpmnElement="SequenceFlow_10af0fk"> - <di:waypoint x="344" y="284" /> - <di:waypoint x="372" y="284" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="358" y="263" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1l7z1c0_di" bpmnElement="aicQueryStack"> - <dc:Bounds x="571" y="174" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1iulltd_di" bpmnElement="SequenceFlow_1iulltd"> - <di:waypoint x="544" y="214" /> - <di:waypoint x="571" y="214" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="557.5" y="193" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0dzf7hz_di" bpmnElement="SequenceFlow_0dzf7hz"> - <di:waypoint x="671" y="214" /> - <di:waypoint x="722" y="214" /> - <di:waypoint x="722" y="259" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="651.5" y="193" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1bq9g02_di" bpmnElement="SequenceFlow_1bq9g02"> - <di:waypoint x="747" y="284" /> - <di:waypoint x="796" y="284" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="726.5" y="263" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0mtzl4z_di" bpmnElement="SequenceFlow_0mtzl4z"> - <di:waypoint x="821" y="259" /> - <di:waypoint x="821" y="214" /> - <di:waypoint x="846" y="214" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="791" y="231" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_028rmiu_di" bpmnElement="SequenceFlow_028rmiu"> - <di:waypoint x="821" y="309" /> - <di:waypoint x="821" y="352" /> - <di:waypoint x="888" y="352" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="791" y="324.5" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ParallelGateway_1we1ooj_di" bpmnElement="ExclusiveGateway_1naduhl"> - <dc:Bounds x="796" y="259" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="775" y="313" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="InclusiveGateway_07wvmp4_di" bpmnElement="ExclusiveGateway_1yvh16a"> - <dc:Bounds x="1178" y="259" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1067" y="312" width="90" height="12" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNShape id="ServiceTask_0itw3by_di" bpmnElement="ServiceTask_0itw3by"> + <dc:Bounds x="740" y="84" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0hpj2mm_di" bpmnElement="SequenceFlow_0hpj2mm"> - <di:waypoint x="1030" y="157" /> - <di:waypoint x="1058" y="157" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="999" y="136" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ExclusiveGateway_13fhmpf_di" bpmnElement="ExclusiveGateway_13fhmpf" isMarkerVisible="true"> - <dc:Bounds x="846" y="189" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="898" y="202" width="45" height="24" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNShape id="ServiceTask_08ulmzc_di" bpmnElement="ServiceTask_08ulmzc"> + <dc:Bounds x="590" y="84" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0f5ljoh_di" bpmnElement="SequenceFlow_0f5ljoh"> - <di:waypoint x="871" y="189" /> - <di:waypoint x="871" y="157" /> - <di:waypoint x="930" y="157" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="877.601615925754" y="162.89580806038546" width="19" height="12" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNEdge id="SequenceFlow_1i9ft2r_di" bpmnElement="SequenceFlow_1i9ft2r"> + <di:waypoint x="690" y="124" /> + <di:waypoint x="740" y="124" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ExclusiveGateway_01wvywu_di" bpmnElement="ExclusiveGateway_01wvywu" isMarkerVisible="true"> - <dc:Bounds x="1131" y="189" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1111" y="243" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1gjwivp_di" bpmnElement="SequenceFlow_1gjwivp"> - <di:waypoint x="871" y="239" /> - <di:waypoint x="871" y="266" /> - <di:waypoint x="1156" y="266" /> - <di:waypoint x="1156" y="239" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="879" y="244" width="14" height="12" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNEdge id="Flow_0n2pqrr_di" bpmnElement="Flow_0n2pqrr"> + <di:waypoint x="195" y="348" /> + <di:waypoint x="270" y="348" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_13mlz57_di" bpmnElement="SequenceFlow_13mlz57"> - <di:waypoint x="1181" y="214" /> - <di:waypoint x="1203" y="214" /> - <di:waypoint x="1203" y="259" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1147" y="193" width="90" height="12" /> - </bpmndi:BPMNLabel> + <bpmndi:BPMNEdge id="Flow_0plbl7p_di" bpmnElement="Flow_0plbl7p"> + <di:waypoint x="840" y="124" /> + <di:waypoint x="1062" y="124" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0itw3by_di" bpmnElement="ServiceTask_0itw3by"> - <dc:Bounds x="225" y="468" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0sy2nky_di" bpmnElement="SequenceFlow_0sy2nky"> - <di:waypoint x="325" y="508" /> - <di:waypoint x="370" y="508" /> + <bpmndi:BPMNEdge id="Flow_0hlvlw2_di" bpmnElement="Flow_0hlvlw2"> + <di:waypoint x="535" y="124" /> + <di:waypoint x="590" y="124" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_08ulmzc_di" bpmnElement="ServiceTask_08ulmzc"> - <dc:Bounds x="1284" y="244" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1i9ft2r_di" bpmnElement="SequenceFlow_1i9ft2r"> - <di:waypoint x="1384" y="276" /> - <di:waypoint x="1433" y="276" /> - <di:waypoint x="1433" y="284" /> - <di:waypoint x="1481" y="284" /> + <bpmndi:BPMNEdge id="Flow_02lmh6f_di" bpmnElement="Flow_02lmh6f"> + <di:waypoint x="195" y="124" /> + <di:waypoint x="290" y="124" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java index 6f89f3c738..558e785e94 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java @@ -22,12 +22,9 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import java.io.IOException; -import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; -import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; import org.junit.Test; @@ -47,20 +44,10 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest { public void sunnyDay() throws InterruptedException, IOException { mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables); - List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") - .topic("InventoryAddAudit", 60L * 1000L).execute(); - while (!tasks.isEmpty()) { - for (LockedExternalTask task : tasks) { - externalTaskService.complete(task.getId(), "externalWorkerId"); - } - tasks = externalTaskService.fetchAndLock(100, "externalWorkerId").topic("InventoryAddAudit", 60L * 1000L) - .execute(); - } assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("ActivateVfModuleBB_Start", "ExclusiveGateway_1v8bmbu", - "Setup_AAI_Inventory_Audit", "Audit_AAI_Inventory", "ActivateVfModule", "CallActivity_sdncHandler", - "UpdateVfModuleActiveStatus", "ActivateVfModuleBB_End"); + assertThat(pi).isStarted().hasPassedInOrder("ActivateVfModuleBB_Start", "ActivateVfModule", + "CallActivity_sdncHandler", "UpdateVfModuleActiveStatus", "ActivateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -70,19 +57,9 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest { doThrow(BpmnError.class).when(aaiUpdateTasks) .updateOrchestrationStatusActivateVfModule(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables); - List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId") - .topic("InventoryAddAudit", 60L * 1000L).execute(); - while (!tasks.isEmpty()) { - for (LockedExternalTask task : tasks) { - externalTaskService.complete(task.getId(), "externalWorkerId"); - } - tasks = externalTaskService.fetchAndLock(100, "externalWorkerId").topic("InventoryAddAudit", 60L * 1000L) - .execute(); - } assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("ActivateVfModuleBB_Start", "ExclusiveGateway_1v8bmbu", "Setup_AAI_Inventory_Audit", - "Audit_AAI_Inventory", "ActivateVfModule", "UpdateVfModuleActiveStatus") + .hasPassedInOrder("ActivateVfModuleBB_Start", "ActivateVfModule", "UpdateVfModuleActiveStatus") .hasNotPassed("ActivateVfModuleBB_End"); } } 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/vfmodule/CreateVFModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java index f7c42b97e9..b706be92cb 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java @@ -44,7 +44,11 @@ public class CreateVFModule { CloudInformation cloudInformation = new CloudInformation(); cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner()); cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId()); - cloudInformation.setTenantId(gBBInput.getTenant().getTenantId()); + String tenantId = gBBInput.getTenant().getTenantId(); + if (tenantId == null) { + tenantId = gBBInput.getCloudRegion().getTenantId(); + } + cloudInformation.setTenantId(tenantId); cloudInformation.setTenantName(gBBInput.getTenant().getTenantName()); cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext()); cloudInformation.setTemplateInstanceId(execution.getVariable("heatStackId")); 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/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index 614401d32a..9899d89b5e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -52,7 +52,7 @@ import org.springframework.stereotype.Component; @Component public class AAIObjectMapper { - private static final ModelMapper modelMapper = new ModelMapper(); + private final ModelMapper modelMapper = new ModelMapper(); public org.onap.aai.domain.yang.ServiceInstance mapServiceInstance(ServiceInstance serviceInstance) { if (modelMapper.getTypeMap(ServiceInstance.class, org.onap.aai.domain.yang.ServiceInstance.class) == null) { 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/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java index 9552755544..85925e2725 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java @@ -2,13 +2,16 @@ package org.onap.so.logging.jaxrs.filter; import javax.annotation.Priority; import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.PreMatching; +import javax.ws.rs.core.MultivaluedMap; +import org.onap.logging.filter.base.AuditLogContainerFilter; +import org.onap.logging.filter.base.Constants; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.logger.LogConstants; import org.slf4j.MDC; import org.springframework.stereotype.Component; -import org.onap.logging.filter.base.AuditLogContainerFilter; @Priority(1) @PreMatching @@ -27,4 +30,17 @@ public class SOAuditLogContainerFilter extends AuditLogContainerFilter { } MDC.put(LogConstants.URI_BASE, request.getUriInfo().getBaseUri().toString()); } + + @Override + protected void additionalPostHandling(ContainerResponseContext response) { + MultivaluedMap<String, Object> responseHeaders = response.getHeaders(); + String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); + responseHeaders.add(ONAPLogConstants.Headers.REQUEST_ID, requestId); + responseHeaders.add(Constants.HttpHeaders.HEADER_REQUEST_ID, requestId); + responseHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, requestId); + responseHeaders.add(Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId); + responseHeaders.add(ONAPLogConstants.Headers.PARTNER_NAME, getProperty(Constants.Property.PARTNER_NAME)); + responseHeaders.add(ONAPLogConstants.Headers.INVOCATION_ID, + MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java index b921f5beea..64774430cc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java @@ -50,10 +50,6 @@ public class ResponseBuilder { .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion) .header(CommonConstants.X_LATEST_VERSION, latestVersion); - if (StringUtils.isNotBlank(requestId)) { - builder.header(CommonConstants.X_TRANSACTION_ID, requestId); - } - return builder.entity(jsonResponse).build(); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 33d86a2cc6..d43bbb6ea0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -1498,6 +1498,8 @@ public class ServiceInstancesTest extends BaseTest { sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers); // ActualRecord assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", + response.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID).get(0)); } @Test diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java index 1917ee592f..db9f45e3ac 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.http.HttpEntity; @@ -212,6 +213,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest { .withStatus(HttpStatus.SC_OK))); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); + headers.set(ONAPLogConstants.Headers.REQUEST_ID, "e0e0e749-c9e2-48c3-8c4c-d51bf65a86c9"); HttpEntity<String> entity = new HttpEntity<>("", headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1"); @@ -226,7 +228,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest { assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); - assertEquals("90c56827-1c78-4827-bc4d-6afcdb37a51f", response.getHeaders().get("X-TransactionID").get(0)); + assertEquals("e0e0e749-c9e2-48c3-8c4c-d51bf65a86c9", response.getHeaders().get("X-TransactionID").get(0)); } @Test 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/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java index edf212429c..80e50befaa 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java @@ -1,7 +1,11 @@ package org.onap.so.simulator.actions.aai; +import java.util.Optional; import org.onap.aai.domain.yang.Vnfc; +import org.onap.aai.domain.yang.Vserver; +import org.onap.aai.domain.yang.Vservers; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; @@ -29,8 +33,7 @@ public class ProcessVnfc extends AbstractTestAction { AAIResourcesClient aaiResourceClient = new AAIResourcesClient(); if (context.getVariable("requestAction").equals("CreateVfModuleInstance") - && context.getVariable("serviceAction").equals("assign") - && context.getVariable("vfModuleName").equals("nc_dummy_id")) { + && context.getVariable("serviceAction").equals("assign")) { AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc("ssc_server_1")); @@ -47,18 +50,38 @@ public class ProcessVnfc extends AbstractTestAction { vnfc.setModelVersionId("9e314c37-2258-4572-a399-c0dd7d5f1aec"); vnfc.setModelCustomizationId("2bd95cd4-d7ff-4af0-985d-2adea0339921"); - if (!aaiResourceClient.exists(vnfcURI)) { - logger.debug("creating VNFC"); - aaiResourceClient.create(vnfcURI, vnfc); + if (aaiResourceClient.exists(vnfcURI)) { + logger.debug("cleaning up VNFC"); + aaiResourceClient.delete(vnfcURI); + } + logger.debug("creating new VNFC"); + aaiResourceClient.create(vnfcURI, vnfc); - } else { - aaiResourceClient.get(vnfcURI); - } AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network() .genericVnf(context.getVariable("vnfId")).vfModule(context.getVariable("vfModuleId"))); logger.debug("creating VNFC edge to vf module"); aaiResourceClient.connect(vfModuleURI, vnfcURI); + } else if (context.getVariable("requestAction").equals("CreateVfModuleInstance") + && context.getVariable("serviceAction").equals("activate")) { + logger.debug("creating edge between vserver and vnfc"); + AAIResourceUri vnfcURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc("ssc_server_1")); + AAIPluralResourceUri vserverPlural = + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(context.getVariable("cloudOwner"), + context.getVariable("cloudRegion")) + .tenant(context.getVariable("tenant")).vservers()) + .queryParam("vserver-name", "ssc_server_1"); + Optional<Vserver> vserver = aaiResourceClient.getFirst(Vservers.class, Vserver.class, vserverPlural); + if (vserver.isPresent()) { + AAIResourceUri vserverURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(context.getVariable("cloudOwner"), context.getVariable("cloudRegion")) + .tenant(context.getVariable("tenant")).vserver(vserver.get().getVserverId())); + aaiResourceClient.connect(vserverURI, vnfcURI); + } } } catch (Exception e) { diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplace.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplace.java new file mode 100644 index 0000000000..f4ac519f7a --- /dev/null +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplace.java @@ -0,0 +1,25 @@ +package org.onap.so.simulator.scenarios.openstack; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario; +import com.consol.citrus.simulator.scenario.Scenario; +import com.consol.citrus.simulator.scenario.ScenarioDesigner; + +@Scenario("Query-Replace-ID-Name-Resources") +@RequestMapping(value = "/sim/v1/tenantOne/stacks/replace_module/stackId/resources", method = RequestMethod.GET) +public class QueryResourcesByStackNameModuleReplace extends AbstractSimulatorScenario { + + @Override + public void run(ScenarioDesigner scenario) { + scenario.http().receive().get(); + + scenario.variable("stackName", "replace_module"); + + scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json") + .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json")); + + } +} diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplaceVolume.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplaceVolume.java new file mode 100644 index 0000000000..f6eebeb09e --- /dev/null +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplaceVolume.java @@ -0,0 +1,26 @@ +package org.onap.so.simulator.scenarios.openstack; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario; +import com.consol.citrus.simulator.scenario.Scenario; +import com.consol.citrus.simulator.scenario.ScenarioDesigner; + +@Scenario("Query-Replace-Volume-ID-Name-Resources") +@RequestMapping(value = "/sim/v1/tenantOne/stacks/replace_module_volume_id/stackId/resources", + method = RequestMethod.GET) +public class QueryResourcesByStackNameModuleReplaceVolume extends AbstractSimulatorScenario { + + @Override + public void run(ScenarioDesigner scenario) { + scenario.http().receive().get(); + + scenario.variable("stackName", "replace_module_volume_id"); + + scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json") + .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json")); + + } +} diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java index e13a23f397..eb306ccd6f 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java @@ -9,7 +9,7 @@ import com.consol.citrus.simulator.scenario.Scenario; import com.consol.citrus.simulator.scenario.ScenarioDesigner; @Scenario("Openstack-Query-Stack-Resources-Macro1") -@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_1/resources", method = RequestMethod.GET) +@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_1/stackId/resources", method = RequestMethod.GET) public class QueryResourcesByStackNameMacro1 extends AbstractSimulatorScenario { @@ -17,8 +17,8 @@ public class QueryResourcesByStackNameMacro1 extends AbstractSimulatorScenario { public void run(ScenarioDesigner scenario) { scenario.http().receive().get(); - scenario.http().send().response(HttpStatus.OK) - .payload(new ClassPathResource("openstack/gr_api/GetStackResourcesMacro.json")); + scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json") + .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json")); } diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java index 580714ded2..d2551a2fb3 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java @@ -9,7 +9,7 @@ import com.consol.citrus.simulator.scenario.Scenario; import com.consol.citrus.simulator.scenario.ScenarioDesigner; @Scenario("Openstack-Query-Stack-Resources-Macro2") -@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_2/resources", method = RequestMethod.GET) +@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_2/stackId/resources", method = RequestMethod.GET) public class QueryResourcesByStackNameMacro2 extends AbstractSimulatorScenario { @@ -17,8 +17,8 @@ public class QueryResourcesByStackNameMacro2 extends AbstractSimulatorScenario { public void run(ScenarioDesigner scenario) { scenario.http().receive().get(); - scenario.http().send().response(HttpStatus.OK) - .payload(new ClassPathResource("openstack/gr_api/GetStackResourcesMacro.json")); + scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json") + .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json")); } diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java index 096d2aa312..bb33f2c718 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java @@ -9,7 +9,7 @@ import com.consol.citrus.simulator.scenario.Scenario; import com.consol.citrus.simulator.scenario.ScenarioDesigner; @Scenario("Openstack-Query-Stack-Resources-Macro3") -@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_3/resources", method = RequestMethod.GET) +@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_3/stackId/resources", method = RequestMethod.GET) public class QueryResourcesByStackNameMacro3 extends AbstractSimulatorScenario { @@ -17,8 +17,8 @@ public class QueryResourcesByStackNameMacro3 extends AbstractSimulatorScenario { public void run(ScenarioDesigner scenario) { scenario.http().receive().get(); - scenario.http().send().response(HttpStatus.OK) - .payload(new ClassPathResource("openstack/gr_api/GetStackResourcesMacro.json")); + scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json") + .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json")); } diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByBaseStackName.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByBaseStackName.java index b590966e2f..77cc0054cc 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByBaseStackName.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByBaseStackName.java @@ -9,7 +9,7 @@ import com.consol.citrus.simulator.scenario.Scenario; import com.consol.citrus.simulator.scenario.ScenarioDesigner; @Scenario("Openstack-Query-Base-Stack-Resources") -@RequestMapping(value = "/sim/v1/tenantOne/stacks/base_module_id/resources", method = RequestMethod.GET) +@RequestMapping(value = "/sim/v1/tenantOne/stacks/base_module_id/stackId/resources", method = RequestMethod.GET) public class QueryResourcesByBaseStackName extends AbstractSimulatorScenario { @@ -19,8 +19,8 @@ public class QueryResourcesByBaseStackName extends AbstractSimulatorScenario { scenario.variable("stackName", "dummy_id"); - scenario.http().send().response(HttpStatus.OK) - .payload(new ClassPathResource("openstack/gr_api/GetStackResources.json")); + scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json") + .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json")); } diff --git a/so-simulator/src/main/resources/openstack/gr_api/zrdm52emccr01_base_resources.json b/so-simulator/src/main/resources/openstack/gr_api/zrdm52emccr01_base_resources.json new file mode 100644 index 0000000000..0a47889c33 --- /dev/null +++ b/so-simulator/src/main/resources/openstack/gr_api/zrdm52emccr01_base_resources.json @@ -0,0 +1,122 @@ +{ + "resources" : [ { + "resource_name" : "oam_security_group", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/oam_security_group", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "f83b7f23-ce5e-41bf-8dbf-ae53e905db7c", + "logical_resource_id" : "oam_security_group", + "required_by" : [ "cpm_0_oam_protected1_port_0" ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Neutron::SecurityGroup", + "resource_status_reason" : "state changed" + }, { + "resource_name" : "cpm_0_sd_base2_port_0", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/cpm_0_sd_base2_port_0", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "803b18b6-e9ba-4fe8-93eb-4a68832b2869", + "logical_resource_id" : "cpm_0_sd_base2_port_0", + "required_by" : [ "cpm_server_0" ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Neutron::Port", + "resource_status_reason" : "state changed" + }, { + "resource_name" : "cpm_0_sd_base1_port_0", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/cpm_0_sd_base1_port_0", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "56610b2d-6e58-451b-9eb7-5f516f85a458", + "logical_resource_id" : "cpm_0_sd_base1_port_0", + "required_by" : [ "cpm_server_0" ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Neutron::Port", + "resource_status_reason" : "state changed" + }, { + "resource_name" : "cpm_0_sd_eastwest2_port_0", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/cpm_0_sd_eastwest2_port_0", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "67aaf2a1-2ada-4322-8603-dceec9b456a6", + "logical_resource_id" : "cpm_0_sd_eastwest2_port_0", + "required_by" : [ "cpm_server_0" ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Neutron::Port", + "resource_status_reason" : "state changed" + }, { + "resource_name" : "cpm_0_sd_eastwest1_port_0", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/cpm_0_sd_eastwest1_port_0", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "8b5392c9-d3aa-41f4-85ee-a3223182e455", + "logical_resource_id" : "cpm_0_sd_eastwest1_port_0", + "required_by" : [ "cpm_server_0" ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Neutron::Port", + "resource_status_reason" : "state changed" + }, { + "resource_name" : "cpm_0_oam_protected1_port_0", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/cpm_0_oam_protected1_port_0", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "4eec349e-be73-41ae-9457-69d31f3a9305", + "logical_resource_id" : "cpm_0_oam_protected1_port_0", + "required_by" : [ "cpm_server_0" ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Neutron::Port", + "resource_status_reason" : "state changed" + }, { + "resource_name" : "cpm_server_0", + "links" : [ { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e/resources/cpm_server_0", + "rel" : "self" + }, { + "href" : "https://test.onap.org/v1/c162d85d27d54186b699935fd535c57a/stacks/stack_name/cb5e288d-e21f-49ee-87d0-5a2bd6be446e", + "rel" : "stack" + } ], + "resource_status" : "CREATE_COMPLETE", + "physical_resource_id" : "635a609d-bb2b-446c-b955-8fc5a4ba4b8d", + "logical_resource_id" : "cpm_server_0", + "required_by" : [ ], + "updated_time" : "2019-05-28T15:19:10Z", + "creation_time" : "2019-05-28T15:19:10Z", + "resource_type" : "OS::Nova::Server", + "resource_status_reason" : "state changed" + } ] +}
\ 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} |