diff options
author | koblosz <sandra.koblosz@nokia.com> | 2018-10-12 14:41:18 +0200 |
---|---|---|
committer | koblosz <sandra.koblosz@nokia.com> | 2018-10-12 14:51:47 +0200 |
commit | 281ed983c5deb49d085ad1417fa417aed0fe42fa (patch) | |
tree | 46f0cf31b76d8b0ef532ffd5b5939582e2e20a5d /vid-app-common | |
parent | 14c0e1ba34802d3baa76eb360964bd8a11030cc0 (diff) |
Added scaleOut to dashboard orchestrationRequests
Change-Id: Ib4862e5f151f8f231022109ee65997e83bdcff7b
Issue-ID: VID-326
Signed-off-by: Sandra Koblosz <sandra.koblosz@nokia.com>
Diffstat (limited to 'vid-app-common')
4 files changed, 478 insertions, 199 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java index 0b4ca122..a6226e00 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java @@ -46,7 +46,11 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; import static org.apache.commons.lang.StringUtils.upperCase; import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest; import static org.onap.vid.controllers.MsoController.*; @@ -56,10 +60,14 @@ import static org.onap.vid.utils.Logging.debugRequestDetails; public class MsoBusinessLogicImpl implements MsoBusinessLogic { - public static final String START = " start"; - public static final String RESOURCE_TYPE = "resourceType"; - FeatureManager featureManager; - + static final List<String> DASHBOARD_ALLOWED_TYPES = Stream.of(RequestType.REPLACE_INSTANCE, + RequestType.UPDATE_INSTANCE, + RequestType.APPLY_UPDATED_CONFIG, + RequestType.IN_PLACE_SOFTWARE_UPDATE, + RequestType.SCALE_OUT) + .map(requestType -> requestType.toString().toUpperCase()) + .collect(collectingAndThen(toList(), Collections::unmodifiableList)); + private static final String RESOURCE_TYPE = "resourceType"; /** * The Constant dateFormat. */ @@ -74,16 +82,16 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { private static final String SOURCE_OPERATIONAL_ENVIRONMENT = "VID"; private static final ObjectMapper objectMapper = new ObjectMapper(); /** + * The logger. + */ + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class); + /** * The Mso REST client * This should be replaced with mso client factory. */ private final MsoInterface msoClientInterface; + FeatureManager featureManager; - /** - * The logger. - */ - private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class); - @Autowired public MsoBusinessLogicImpl(MsoInterface msoClientInterface, FeatureManager featureManager) { this.msoClientInterface = msoClientInterface; @@ -101,34 +109,26 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { // this function should get params from tosca and send them to instance at mso, then return success response. @Override public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) { - String methodName = "createSvcInstance "; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createSvcInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); return msoClientInterface.createSvcInstance(msoRequest, endpoint); } @Override - public MsoResponseWrapper createE2eSvcInstance(Object msoRequest){ - String methodName = "createE2eSvcInstance "; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE); - + public MsoResponseWrapper createE2eSvcInstance(Object msoRequest) { + logInvocationInDebug("createE2eSvcInstance"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE); return msoClientInterface.createE2eSvcInstance(msoRequest, endpoint); - } + } @Override public MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "createVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createVnf"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); return msoClientInterface.createVnf(requestDetails, vnf_endpoint); @@ -136,11 +136,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "createNwInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createNwInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); return msoClientInterface.createNwInstance(requestDetails, nw_endpoint); @@ -148,11 +146,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "createVolumeGroupInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createVolumeGroupInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); @@ -162,11 +158,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "createVfModuleInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createVfModuleInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); @@ -176,11 +170,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "scaleOutVfModuleInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("scaleOutVfModuleInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT); String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); @@ -191,10 +183,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.scaleOutVFModuleInstance(wrapper, vf_module_endpoint); } + @Override public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId) { - String methodName = "createConfigurationInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("createConfigurationInstance"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATIONS); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); @@ -204,24 +196,21 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String serviceInstanceId) { - String methodName = "deleteE2eSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deleteE2eSvcInstance"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId; + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId; return msoClientInterface.deleteE2eSvcInstance(requestDetails, endpoint); } @Override public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus) { - String methodName = "deleteSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deleteSvcInstance"); String endpoint; - if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)){ + if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)) { endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE); - if (shouldUnassignService(serviceStatus)){ + if (shouldUnassignService(serviceStatus)) { logger.debug(EELFLoggerDelegate.debugLogger, "unassign service"); String svc_endpoint = endpoint + "/" + serviceInstanceId + "/unassign"; return msoClientInterface.unassignSvcInstance(requestDetails, svc_endpoint); @@ -235,16 +224,14 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } private boolean shouldUnassignService(String serviceStatus) { - return ImmutableList.of("created","pendingdelete","pending-delete", "assigned").contains(serviceStatus.toLowerCase()); + return ImmutableList.of("created", "pendingdelete", "pending-delete", "assigned").contains(serviceStatus.toLowerCase()); } @Override public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "deleteVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deleteVnf"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId; @@ -253,14 +240,10 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) { - String methodName = "deleteVfModule"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); + logInvocationInDebug("deleteVfModule"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE); String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); - String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId; return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint); @@ -268,12 +251,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId) { - String methodName = "deleteVolumeGroupInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); + logInvocationInDebug("deleteVolumeGroupInstance"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE); String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String vnf_endpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId); String delete_volume_group_endpoint = vnf_endpoint + "/" + volumeGroupId; @@ -283,12 +263,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) { - String methodName = "deleteNwInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); + logInvocationInDebug("deleteNwInstance"); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE); String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId; @@ -298,7 +275,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper getOrchestrationRequest(String requestId) { String methodName = "getOrchestrationRequest"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ); String path = p + "/" + requestId; @@ -306,8 +283,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.getOrchestrationRequest(path); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -315,7 +291,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper getOrchestrationRequests(String filterString) { String methodName = "getOrchestrationRequest"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); String path = p + filterString; @@ -323,8 +299,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.getOrchestrationRequest(path); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -332,48 +307,51 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public List<Request> getOrchestrationRequestsForDashboard() { String methodName = "getOrchestrationRequestsForDashboard"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - List<Request> filteredOrchestrationRequests = new ArrayList<>(); - try { - String path = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS); - path += "filter=modelType:EQUALS:vnf"; - RestObject<String> restObjStr = new RestObject<>(); - String str = new String(); - restObjStr.set(str); + logInvocationInDebug(methodName); - MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", path, restObjStr); - List<RequestWrapper> allOrchestrationRequests = deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity()); - - final ImmutableList<String> suppoertedRequestTypes = ImmutableList.of( - RequestType.REPLACE_INSTANCE.toString().toUpperCase(), - RequestType.UPDATE_INSTANCE.toString().toUpperCase(), - RequestType.APPLY_UPDATED_CONFIG.toString().toUpperCase(), - RequestType.IN_PLACE_SOFTWARE_UPDATE.toString().toUpperCase() - ); - - for (RequestWrapper currentRequest : allOrchestrationRequests) { - if (currentRequest.getRequest() != null - && "vnf".equalsIgnoreCase(currentRequest.getRequest().getRequestScope()) - && suppoertedRequestTypes.contains(upperCase(currentRequest.getRequest().getRequestType())) - ) { - filteredOrchestrationRequests.add(currentRequest.getRequest()); - } - } + List<Request> dashboardOrchestrationReqs = new ArrayList<>(); + try { + List<RequestWrapper> vnfOrchestrationReqsWrappers = getOrchestrationRequestsByFilter("modelType", "vnf"); + dashboardOrchestrationReqs = vnfOrchestrationReqsWrappers.stream() + .filter(reqWrapper -> Objects.nonNull(reqWrapper.getRequest()) + && DASHBOARD_ALLOWED_TYPES.contains(upperCase(reqWrapper.getRequest().getRequestType()))) + .map(RequestWrapper::getRequest) + .collect(Collectors.toList()); + + List<RequestWrapper> scaleOutOrchestrationReqWrappers = getOrchestrationRequestsByFilter("action", "scaleOut"); + List<Request> scaleoutRequests = scaleOutOrchestrationReqWrappers.stream() + .filter(reqWrapper -> Objects.nonNull(reqWrapper.getRequest())) + .map(RequestWrapper::getRequest) + .collect(Collectors.toList()); + + dashboardOrchestrationReqs.addAll(scaleoutRequests); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); } - return filteredOrchestrationRequests; + return dashboardOrchestrationReqs; + } + + private String constructOrchestrationRequestFilter(String filterName, String filterValue) { + return String.format("%sfilter=%s:EQUALS:%s", + SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS), filterName, filterValue); + } + + private List<RequestWrapper> getOrchestrationRequestsByFilter(String filterName, String filterValue) { + String orchestrationReqPath = constructOrchestrationRequestFilter(filterName, filterValue); + RestObject<String> restObjStr = new RestObject<>(); + String str = new String(); + restObjStr.set(str); + MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", orchestrationReqPath, restObjStr); + return deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity()); } private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) { - String methodName = "deserializeOrchestrationRequestsJson"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deserializeOrchestrationRequestsJson"); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true); - RequestList requestList = null; + RequestList requestList; try { requestList = mapper.readValue(orchestrationRequestsJson, RequestList.class); } catch (IOException e) { @@ -386,7 +364,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public List<Task> getManualTasksByRequestId(String originalRequestId) { String methodName = "getManualTasksByRequestId"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS); @@ -400,15 +378,13 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return deserializeManualTasksJson(msoResponseWrapper.getEntity()); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } private List<Task> deserializeManualTasksJson(String manualTasksJson) { - String methodName = "deserializeManualTasksJson"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("deserializeManualTasksJson"); ObjectMapper mapper = new ObjectMapper(); try { @@ -423,7 +399,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId) { String methodName = "completeManualTask"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS); String path = p + "/" + taskId + "/complete"; @@ -437,8 +413,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return MsoUtil.wrapResponse(restObjStr); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -446,7 +421,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId) { String methodName = "activateServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug(methodName); try { String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + ACTIVATE; @@ -460,8 +435,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return MsoUtil.wrapResponse(restObjStr); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logException(methodName, e); throw e; } } @@ -469,8 +443,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "updateVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("updateVnf"); String endpoint; endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE); @@ -481,11 +454,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "replaceVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("replaceVnf"); - String endpoint; - endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId); vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, MsoChangeManagementRequest.REPLACE); @@ -506,22 +477,17 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) { validateUpdateVnfConfig(requestDetails); - RequestDetails ConfigUpdateRequest = new RequestDetails(); - ConfigUpdateRequest.setRequestParameters(requestDetails.getRequestParameters()); - ConfigUpdateRequest.setRequestInfo(requestDetails.getRequestInfo()); + RequestDetails configUpdateRequest = new RequestDetails(); + configUpdateRequest.setRequestParameters(requestDetails.getRequestParameters()); + configUpdateRequest.setRequestInfo(requestDetails.getRequestInfo()); RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); - requestDetailsWrapper.requestDetails = ConfigUpdateRequest; + requestDetailsWrapper.requestDetails = configUpdateRequest; return requestDetailsWrapper; } - - - - @Override public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "updateVnfSoftware"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("updateVnfSoftware"); String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.SOFTWARE_UPDATE); //workflow name in mso is different than workflow name in vid UI RequestDetailsWrapper finalRequestDetails = generateInPlaceMsoRequest(requestDetails); return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint); @@ -529,30 +495,28 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { - String methodName = "updateVnfConfig"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("updateVnfConfig"); RequestDetailsWrapper finalRequestDetails = generateConfigMsoRequest(requestDetails); String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.CONFIG_UPDATE); return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint); } private String getChangeManagementEndpoint(String serviceInstanceId, String vnfInstanceId, String vnfRequestType) { - String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); + String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE); String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId); vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId); vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, vnfRequestType); return vnf_endpoint; } - private Map getChangeManagementPayload(RequestDetails requestDetails, String message){ - if(requestDetails.getRequestParameters()==null||requestDetails.getRequestParameters().getAdditionalProperties()==null){ + private Map getChangeManagementPayload(RequestDetails requestDetails, String message) { + if (requestDetails.getRequestParameters() == null || requestDetails.getRequestParameters().getAdditionalProperties() == null) { throw new BadRequestException(message); } - Object payloadRaw=requestDetails.getRequestParameters().getAdditionalProperties().get("payload"); - try{ - return objectMapper.readValue((String)payloadRaw,Map.class); - } - catch(Exception exception){ + Object payloadRaw = requestDetails.getRequestParameters().getAdditionalProperties().get("payload"); + try { + return objectMapper.readValue((String) payloadRaw, Map.class); + } catch (Exception exception) { throw new BadRequestException(message); } } @@ -581,30 +545,12 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } } - private void validateUpdateVnfConfig(RequestDetails requestDetails) { - final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request"; - - Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg); - validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters"); - validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters"); - } - - private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) { - final String noValidPayloadPropertyMsg = noValidPayloadMsg+ ", "+ propertyName + " property is not valid"; - if(!payload.containsKey(propertyName)) { - throw new BadRequestException( noValidPayloadPropertyMsg); - } - } - @Override - public MsoResponseWrapper deleteConfiguration( - org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, - String serviceInstanceId, - String configurationId) { - - String methodName = "deleteConfiguration"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + public MsoResponseWrapper deleteConfiguration(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, + String serviceInstanceId, + String configurationId) { + logInvocationInDebug("deleteConfiguration"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); endpoint = endpoint.replace(CONFIGURATION_ID, configurationId); @@ -619,8 +565,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String configurationId, boolean isActivate) { - String methodName = "setConfigurationActiveStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("setConfigurationActiveStatus"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); @@ -633,9 +578,9 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } @Override - public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate) { + public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails, String serviceInstanceId, boolean isActivate) { + logInvocationInDebug("setServiceInstanceStatus"); String methodName = "setServiceInstanceStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); try { String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE); String endpoint = serviceEndpoint + "/" + serviceInstanceId; @@ -648,7 +593,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String str = ""; restObjStr.set(str); - msoClientInterface.setServiceInstanceStatus(requestDetails , str, "", endpoint, restObjStr); + msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", endpoint, restObjStr); return MsoUtil.wrapResponse(restObjStr); @@ -665,8 +610,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { String serviceInstanceId, String configurationId, boolean isEnable) { - String methodName = "setPortOnConfigurationStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("setPortOnConfigurationStatus"); String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE); endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId); @@ -680,7 +624,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override - public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) { + public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) { RequestDetails requestDetails = new RequestDetails(); RequestInfo requestInfo = new RequestInfo(); requestInfo.setAdditionalProperty(RESOURCE_TYPE, RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT); @@ -754,7 +698,6 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } - @Override public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) { OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo( @@ -783,8 +726,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "removeRelationshipFromServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("removeRelationshipFromServiceInstance"); String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships"; @@ -794,8 +736,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { @Override public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) { - String methodName = "addRelationshipToServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logInvocationInDebug("addRelationshipToServiceInstance"); String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE); String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships"; @@ -803,8 +744,31 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath); } + private void validateUpdateVnfConfig(RequestDetails requestDetails) { + final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request"; + + Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg); + validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters"); + validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters"); + } + + private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) { + final String noValidPayloadPropertyMsg = noValidPayloadMsg + ", " + propertyName + " property is not valid"; + if (!payload.containsKey(propertyName)) { + throw new BadRequestException(noValidPayloadPropertyMsg); + } + } + + private void logInvocationInDebug(String methodName) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start"); + } - public enum RequestType { + private void logException(String methodName, Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + } + + enum RequestType { CREATE_INSTANCE("createInstance"), DELETE_INSTANCE("deleteInstance"), @@ -814,27 +778,23 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { DEACTIVATE_INSTANCE("deactivateInstance"), APPLY_UPDATED_CONFIG("applyUpdatedConfig"), IN_PLACE_SOFTWARE_UPDATE("inPlaceSoftwareUpdate"), + SCALE_OUT("scaleOut"), UNKNOWN("unknown"), NOT_PROVIDED("not provided"); - private final String value; private static final Map<String, RequestType> CONSTANTS = new HashMap<>(); static { - for (RequestType c: values()) { + for (RequestType c : values()) { CONSTANTS.put(c.value, c); } } + private final String value; + RequestType(String value) { this.value = value; } - @JsonValue - @Override - public String toString() { - return this.value; - } - @JsonCreator public static RequestType fromValue(String value) { RequestType constant = CONSTANTS.get(value); @@ -844,5 +804,11 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { return constant; } } + + @JsonValue + @Override + public String toString() { + return this.value; + } } }
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java index e0e3c363..54e924d9 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java @@ -2,14 +2,11 @@ package org.onap.vid.mso; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.*; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.controllers.MsoController; +import org.onap.vid.mso.rest.Request; import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.properties.Features; import org.springframework.test.context.ContextConfiguration; @@ -22,13 +19,15 @@ import org.testng.annotations.Test; import org.togglz.core.manager.FeatureManager; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import static org.onap.vid.controllers.MsoController.SVC_INSTANCE_ID; import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath; @@ -41,7 +40,9 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests { private static final String EXPECTED_SCALE_OUT_PATH = "/serviceInstantiation/v7/serviceInstances/1/vnfs/1/vfModules/scaleOut"; private static final Path PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayload.json"); private static final Path PATH_TO_FINAL_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayloadToMso.json"); - private static final ObjectMapper OBJECT_MAPPER=new ObjectMapper(); + private static final Path PATH_TO_EXPECTED_MSO_MODEL_TYPE_REQ = Paths.get("src", "test", "resources", "payload_jsons", "mso_model_info_sample_response.json"); + private static final Path PATH_TO_EXPECTED_MSO_SCALEOUT_REQ = Paths.get("src", "test", "resources", "payload_jsons", "mso_action_scaleout_sample_response.json"); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @InjectMocks private MsoBusinessLogicImpl msoBusinessLogic; @@ -161,6 +162,36 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests { assertThat(expectedRequestWrapper.requestDetails).isEqualTo(actual.requestDetails); } + @Test + public void shouldFilterOutOrchestrationRequestsNotAllowedInDashboard() throws IOException { + String vnfModelTypeOrchestrationRequests = getFileContentAsString(PATH_TO_EXPECTED_MSO_MODEL_TYPE_REQ); + String scaleOutActionOrchestrationRequests = getFileContentAsString(PATH_TO_EXPECTED_MSO_SCALEOUT_REQ); + + MsoResponseWrapper msoResponseWrapperMock = mock(MsoResponseWrapper.class); + when(msoInterfaceMock.getOrchestrationRequestsForDashboard(any(String.class), any(String.class), any(String.class), any(RestObject.class))) + .thenReturn(msoResponseWrapperMock); + when(msoResponseWrapperMock.getEntity()).thenReturn(vnfModelTypeOrchestrationRequests, scaleOutActionOrchestrationRequests); + + List<Request> filteredOrchestrationReqs = msoBusinessLogic.getOrchestrationRequestsForDashboard(); + + assertThat(filteredOrchestrationReqs).hasSize(3); + assertThat(MsoBusinessLogicImpl.DASHBOARD_ALLOWED_TYPES) + .containsAll(filteredOrchestrationReqs + .stream() + .map(el -> el.getRequestType().toUpperCase()) + .collect(Collectors.toList())); + assertThat(filteredOrchestrationReqs + .stream() + .map(org.onap.vid.domain.mso.Request::getRequestScope) + .collect(Collectors.toList())) + .containsOnly("vnf", "vfModule"); + } + + + private String getFileContentAsString(Path pathToFile) throws IOException { + return new String(Files.readAllBytes(pathToFile)); + } + private org.onap.vid.changeManagement.RequestDetails getScaleOutRequest() throws IOException { return OBJECT_MAPPER.readValue(PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST.toFile(), org.onap.vid.changeManagement.RequestDetails.class); } diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json b/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json new file mode 100644 index 00000000..d37f6af1 --- /dev/null +++ b/vid-app-common/src/test/resources/payload_jsons/mso_action_scaleout_sample_response.json @@ -0,0 +1,174 @@ +{ + "requestList": [ + { + "request": { + "requestId": "799d7380-60fe-4b64-9d99-82f6ab09163b", + "startTime": "Fri, 12 Oct 2018 08:53:07 GMT", + "requestScope": "vfModule", + "requestType": "scaleOut", + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "WsSp..base_ws..module-0", + "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc", + "modelType": "vfModule", + "modelName": "WsSp..base_ws..module-0", + "modelVersion": "1", + "modelCustomizationUuid": "bfcc8f57-7b56-4be8-a8f1-e44262c83318", + "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0", + "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318", + "modelUuid": "53f52586-236b-4d52-a94c-990883e054f0", + "modelInvariantUuid": "763b1172-b5f5-4062-9d79-2459710fa0bc", + "modelInstanceName": "WsSp..base_ws..module-0" + }, + "requestInfo": { + "source": "VID", + "instanceName": "ws-test-0310-8_NaN", + "suppressRollback": false, + "requestorId": "demo" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "modelInfo": { + "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b", + "modelType": "service", + "modelName": "ws-service", + "modelVersion": "1.0", + "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b" + } + } + }, + { + "relatedInstance": { + "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75", + "modelInfo": { + "modelCustomizationName": "ws-sp 0", + "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687", + "modelType": "vnf", + "modelName": "ws-sp", + "modelVersion": "1.0", + "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986", + "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986", + "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687", + "modelInstanceName": "ws-sp 0" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e", + "lcpCloudRegionId": "RegionOne" + }, + "requestParameters": {}, + "configurationParameters": [ + { + "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] + }, + "instanceReferences": { + "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75", + "vfModuleInstanceName": "ws-test-0310-8_NaN", + "requestorId": "demo" + }, + "requestStatus": { + "requestState": "FAILED", + "statusMessage": "No valid vfModuleCustomization is specified", + "percentProgress": 100, + "finishTime": "Fri, 12 Oct 2018 08:53:07 GMT" + } + } + }, + { + "request": { + "requestId": "44b534c7-57b5-42ec-85bb-219167021b34", + "startTime": "Fri, 12 Oct 2018 09:08:01 GMT", + "requestScope": "vfModule", + "requestType": "scaleOut", + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "WsSp..base_ws..module-0", + "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc", + "modelType": "vfModule", + "modelName": "WsSp..base_ws..module-0", + "modelVersion": "1", + "modelCustomizationUuid": "bfcc8f57-7b56-4be8-a8f1-e44262c83318", + "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0", + "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318", + "modelUuid": "53f52586-236b-4d52-a94c-990883e054f0", + "modelInvariantUuid": "763b1172-b5f5-4062-9d79-2459710fa0bc", + "modelInstanceName": "WsSp..base_ws..module-0" + }, + "requestInfo": { + "source": "VID", + "instanceName": "ws-test-0310-8_NaN", + "suppressRollback": false, + "requestorId": "demo" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "modelInfo": { + "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b", + "modelType": "service", + "modelName": "ws-service", + "modelVersion": "1.0", + "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b" + } + } + }, + { + "relatedInstance": { + "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75", + "modelInfo": { + "modelCustomizationName": "ws-sp 0", + "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687", + "modelType": "vnf", + "modelName": "ws-sp", + "modelVersion": "1.0", + "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986", + "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986", + "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687", + "modelInstanceName": "ws-sp 0" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e", + "lcpCloudRegionId": "RegionOne" + }, + "requestParameters": {}, + "configurationParameters": [ + { + "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] + }, + "instanceReferences": { + "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75", + "vfModuleInstanceId": "scaleOut", + "vfModuleInstanceName": "ws-test-0310-8_NaN", + "requestorId": "demo" + }, + "requestStatus": { + "requestState": "FAILED" + } + } + } + ] +}
\ No newline at end of file diff --git a/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json b/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json new file mode 100644 index 00000000..9dbdfb04 --- /dev/null +++ b/vid-app-common/src/test/resources/payload_jsons/mso_model_info_sample_response.json @@ -0,0 +1,108 @@ +{ + "requestList": [ + { + "request": { + "requestId": "f8c813a2-b22b-4e3d-9be0-8e2d16b1add3", + "startTime": "Wed, 03 Oct 2018 13:13:04 GMT", + "requestScope": "vnf", + "requestType": "createInstance", + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "ws-sp 0", + "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687", + "modelType": "vnf", + "modelName": "ws-sp", + "modelVersion": "1.0", + "modelCustomizationUuid": "5815868c-35f8-4c5a-b899-e6eb49f52986", + "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986", + "modelUuid": "0e0bb964-e687-4439-9a9e-de9cd1ff5367", + "modelInvariantUuid": "734f0952-6678-44e7-8918-f9aa4694b687", + "modelInstanceName": "ws-sp 0" + }, + "requestInfo": { + "productFamilyId": "61cc3239-5c2e-4762-a281-7422a2e54d5a", + "source": "VID", + "instanceName": "ws-test-0310-8", + "suppressRollback": false, + "requestorId": "demo" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "modelInfo": { + "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b", + "modelType": "service", + "modelName": "ws-service", + "modelVersion": "1.0", + "modelVersionId": "cd3fbd06-6bc8-43a4-b803-933fc2e3cdf7", + "modelUuid": "cd3fbd06-6bc8-43a4-b803-933fc2e3cdf7", + "modelInvariantUuid": "c9817f08-07b2-458b-a02f-cd5407ee7a7b" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e", + "lcpCloudRegionId": "RegionOne" + }, + "requestParameters": { + "testApi": "VNF_API" + }, + "platform": { + "platformName": "Demo" + }, + "lineOfBusiness": { + "lineOfBusinessName": "Demo" + } + }, + "instanceReferences": { + "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75", + "vnfInstanceName": "ws-test-0310-8", + "requestorId": "demo" + }, + "requestStatus": { + "requestState": "COMPLETE", + "statusMessage": "Vnf has been created successfully.", + "percentProgress": 100, + "finishTime": "Wed, 03 Oct 2018 13:13:09 GMT" + } + } + }, + { + "request": { + "requestId": "3447ba35-015d-4d72-9345-d89b1e35b2d6", + "startTime": "Thu, 04 Oct 2018 10:35:17 GMT", + "requestScope": "vnf", + "requestType": "inPlaceSoftwareUpdate", + "requestDetails": { + "requestInfo": { + "source": "VID", + "suppressRollback": false, + "requestorId": "demo" + }, + "cloudConfiguration": { + "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e", + "lcpCloudRegionId": "RegionOne" + }, + "requestParameters": { + "payload": "{\"existing_software_version\":\"0.7\",\"new_software_version\":\"1.0\",\"operations_timeout\":\"10\"}" + } + }, + "instanceReferences": { + "serviceInstanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b", + "vnfInstanceId": "980fe98e-47f8-4164-862d-4ebb026cec75", + "requestorId": "demo" + }, + "requestStatus": { + "requestState": "FAILED", + "statusMessage": "Cloud Region with cloudRegionId RegionOne does not exist in A&AI", + "percentProgress": 100, + "finishTime": "Thu, 04 Oct 2018 10:35:21 GMT" + } + } + } + ] +}
\ No newline at end of file |