diff options
Diffstat (limited to 'vid-app-common/src/main')
11 files changed, 266 insertions, 224 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java index 84e83e8b2..b7f226400 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java @@ -23,6 +23,7 @@ package org.onap.vid.client; import io.joshworks.restclient.http.HttpResponse; import io.joshworks.restclient.http.JsonNode; import io.joshworks.restclient.http.RestClient; +import io.joshworks.restclient.http.exceptions.RestClientException; import io.joshworks.restclient.http.mapper.ObjectMapper; import org.apache.http.impl.client.CloseableHttpClient; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -39,7 +40,7 @@ import java.security.UnrecoverableKeyException; import java.security.NoSuchAlgorithmException; import java.security.KeyManagementException; import java.security.cert.CertificateException; -import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLException; import java.security.KeyStoreException; import java.text.SimpleDateFormat; import javax.net.ssl.SSLContext; @@ -150,13 +151,13 @@ public class SyncRestClient implements SyncRestClientInterface { @SneakyThrows private <T> HttpResponse<T> callWithRetryOverHttp(String url, - CheckedFunction1<String, HttpResponse<T>> httpRequest) { + CheckedFunction1<String, HttpResponse<T>> httpRequest) { try { return httpRequest.apply(url); - } catch (Exception e) { - if (e.getCause() instanceof SSLHandshakeException) { + } catch (RestClientException e) { + if (e.getCause() instanceof SSLException) { logger.warn(EELFLoggerDelegate.debugLogger, - DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e); + DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e); return httpRequest.apply(url.replaceFirst(HTTPS_SCHEMA, HTTP_SCHEMA)); } throw e; diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java index 03dc8083e..12cc68e61 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java @@ -25,6 +25,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.dao.FnAppDoaImpl; import org.onap.vid.model.GitRepositoryState; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -46,7 +47,6 @@ import java.util.Properties; @RequestMapping("/") public class HealthCheckController extends UnRestrictedBaseController { - /** * The logger. */ @@ -58,6 +58,7 @@ public class HealthCheckController extends UnRestrictedBaseController { final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); private static final String HEALTH_CHECK_PATH = "/healthCheck"; + private static final String GIT_PROPERTIES_FILENAME = "git.properties"; /** * Model for JSON response with health-check results. @@ -193,10 +194,10 @@ public class HealthCheckController extends UnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = "/version", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/commitInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public GitRepositoryState getCommitInfo() throws IOException { Properties properties = new Properties(); - properties.load(getClass().getClassLoader().getResourceAsStream("git.properties")); + properties.load(getClass().getClassLoader().getResourceAsStream(GIT_PROPERTIES_FILENAME)); return new GitRepositoryState(properties); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java index 79befe176..0ecb9257e 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java @@ -28,6 +28,8 @@ public interface MsoBusinessLogic { MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId); + MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId); + MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId); MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus); 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 00db464ab..a6226e00e 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); @@ -175,9 +169,24 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } @Override + public MsoResponseWrapper scaleOutVfModuleInstance(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) { + logInvocationInDebug("scaleOutVfModuleInstance"); + + 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); + RequestDetailsWrapper wrapper = new RequestDetailsWrapper(); + requestDetails.setVnfName(null); + requestDetails.setVnfInstanceId(null); + wrapper.requestDetails = requestDetails; + + 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); @@ -187,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); @@ -218,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; @@ -236,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); @@ -251,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; @@ -266,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; @@ -281,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; @@ -289,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; } } @@ -298,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; @@ -306,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; } } @@ -315,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) { @@ -369,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); @@ -383,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 { @@ -406,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"; @@ -420,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; } } @@ -429,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; @@ -443,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; } } @@ -452,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); @@ -464,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); @@ -489,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); @@ -512,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); } } @@ -564,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); @@ -602,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); @@ -616,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; @@ -631,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); @@ -648,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); @@ -663,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); @@ -737,7 +698,6 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic { } - @Override public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) { OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo( @@ -766,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"; @@ -777,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"; @@ -786,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"; - public enum RequestType { + 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"); + } + + 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"), @@ -797,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); @@ -827,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/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java index 3cba12f67..834f80885 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java @@ -74,6 +74,8 @@ public interface MsoInterface { MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint); + MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint); + MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint); MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java index 773b8a83a..1d71e9c75 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java @@ -99,6 +99,8 @@ public class MsoProperties extends SystemProperties { /** The Constant MSO_REST_API_VF_MODULE_INSTANCE. */ public static final String MSO_REST_API_VF_MODULE_INSTANCE = "mso.restapi.vf.module.instance"; + public static final String MSO_REST_API_VF_MODULE_SCALE_OUT = "mso.restapi.vf.module.scaleout"; + /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */ public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance"; //serviceInstances/v2/{serviceInstanceId}/volumeGroups diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java index 9cac3e4e2..59bd66771 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java @@ -124,6 +124,14 @@ public class MsoRestClientNew implements MsoInterface { } @Override + public MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint) { + String methodName = "scaleOutVFModuleInstance"; + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + String path = baseUrl + endpoint; + return createInstance(requestDetailsWrapper, path); + } + + @Override public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint) { String methodName = "createConfigurationInstance"; logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java index df6914843..2b159f812 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java @@ -20,11 +20,20 @@ package org.onap.vid.mso.rest; -import com.fasterxml.jackson.annotation.*; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.onap.vid.domain.mso.*; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.onap.vid.domain.mso.CloudConfiguration; +import org.onap.vid.domain.mso.ModelInfo; +import org.onap.vid.domain.mso.RequestInfo; +import org.onap.vid.domain.mso.RequestParameters; +import org.onap.vid.domain.mso.SubscriberInfo; import java.util.HashMap; import java.util.List; @@ -41,7 +50,8 @@ import java.util.Map; "relatedModelList", "requestInfo", "subscriberInfo", - "requestParameters" + "requestParameters", + "configurationParameters" }) public class RequestDetails{ @@ -71,6 +81,9 @@ public class RequestDetails{ @JsonProperty("requestParameters") private RequestParameters requestParameters; + @JsonProperty("configurationParameters") + protected List<Map<String, String>> configurationParameters; + /** The additional properties. */ @JsonIgnore private Map<String, Object> additionalProperties = new HashMap<String, Object>(); @@ -198,12 +211,31 @@ public class RequestDetails{ this.additionalProperties.put(name, value); } + @JsonProperty("configurationParameters") + public List<Map<String, String>> getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configurationParameters") + public void setConfigurationParameters(List<Map<String, String>> configurationParameters) { + this.configurationParameters = configurationParameters; + } + /* (non-Javadoc) * @see org.onap.vid.domain.mso.RequestDetails#hashCode() */ @Override public int hashCode() { - return new HashCodeBuilder().append(cloudConfiguration).append(modelInfo).append(relatedInstanceList).append(requestInfo).append(getRequestParameters()).append(subscriberInfo).append(additionalProperties).toHashCode(); + return new HashCodeBuilder() + .append(cloudConfiguration) + .append(modelInfo) + .append(relatedInstanceList) + .append(requestInfo) + .append(getRequestParameters()) + .append(subscriberInfo) + .append(additionalProperties) + .append(configurationParameters) + .toHashCode(); } /* (non-Javadoc) @@ -214,11 +246,20 @@ public class RequestDetails{ if (other == this) { return true; } - if ((other instanceof RequestDetails) == false) { + if (!(other instanceof RequestDetails)) { return false; } RequestDetails rhs = ((RequestDetails) other); - return new EqualsBuilder().append(cloudConfiguration, rhs.cloudConfiguration).append(modelInfo, rhs.modelInfo).append(relatedInstanceList, rhs.relatedInstanceList).append(requestInfo, rhs.requestInfo).append(getRequestParameters(), rhs.getRequestParameters()).append(subscriberInfo, rhs.subscriberInfo).append(additionalProperties, rhs.additionalProperties).isEquals(); + return new EqualsBuilder() + .append(cloudConfiguration, rhs.cloudConfiguration) + .append(modelInfo, rhs.modelInfo) + .append(relatedInstanceList, rhs.relatedInstanceList) + .append(requestInfo, rhs.requestInfo) + .append(getRequestParameters(), rhs.getRequestParameters()) + .append(subscriberInfo, rhs.subscriberInfo) + .append(additionalProperties, rhs.additionalProperties) + .append(configurationParameters, rhs.configurationParameters) + .isEquals(); } public RequestParameters getRequestParameters() { diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java index 90d1c33e3..e4a6b3990 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java @@ -102,7 +102,7 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { break; } case ChangeManagementRequest.SCALE_OUT:{ - msoResponseWrapperObject = msoBusinessLogic.createVfModuleInstance(currentRequestDetails, serviceInstanceId, vnfInstanceId); + msoResponseWrapperObject = msoBusinessLogic.scaleOutVfModuleInstance(currentRequestDetails, serviceInstanceId, vnfInstanceId); break; } default: diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index c55092e4c..6029ed2d7 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -10,7 +10,7 @@ vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL; vm.configUpdatePatternError = "Invalid file type. Please select a file with a CSV extension."; vm.configUpdateContentError = "Invalid file structure."; - + vm.wizardStep = 1; vm.nextStep = function(){ vm.wizardStep++; @@ -193,9 +193,10 @@ var result = {}; result.requestType = changeManagement.workflow; var workflowType = changeManagement.workflow; + var configurationParameters = changeManagement.configurationParameters; result.requestDetails = []; _.forEach(changeManagement.vnfNames, function (vnf) { - + try{ var requestInfoData ={}; var requestParametersData ={}; @@ -203,13 +204,13 @@ return !item.scale; }); if (vnf.availableVersions && vnf.availableVersions.length!=0){ - + requestInfoData ={ source: vnf.availableVersions[0].requestInfo.source, suppressRollback: vnf.availableVersions[0].requestInfo.suppressRollback, requestorId: vnf.availableVersions[0].requestInfo.requestorId } - + if(workflowType=='Update'){ requestParametersData = { usePreload: vnf.availableVersions[0].requestParameters.usePreload @@ -268,17 +269,22 @@ var data; if(workflowType=="VNF Scale Out") { data = { + vnfName: vnf.name, + vnfInstanceId: vnf.id, modelInfo: { modelType: 'vfModule', modelInvariantId: moduleToScale.invariantUuid, modelName: moduleToScale.modelCustomizationName, modelVersion: moduleToScale.version, + modelCustomizationName: moduleToScale.modelCustomizationName, + modelCustomizationId: moduleToScale.customizationUuid, modelVersionId: moduleToScale.uuid }, cloudConfiguration: vnf.cloudConfiguration, requestInfo: requestInfoData, relatedInstanceList: [], - requestParameters:requestParametersData + requestParameters:requestParametersData, + configurationParameters: JSON.parse(configurationParameters) }; requestInfoData.instanceName = vnf.name + "_" + (moduleToScale.currentCount + 1); }else{ @@ -333,6 +339,7 @@ var relatedInstance = { instanceId: vnf.id, modelInfo: { + modelCustomizationId: vnf.availableVersions[0].modelInfo.modelCustomizationId, modelCustomizationName: vnf.availableVersions[0].modelInfo.modelCustomizationName, modelInvariantId: vnf.availableVersions[0].modelInfo.modelInvariantId, modelName: vnf.availableVersions[0].modelInfo.modelName, @@ -352,7 +359,6 @@ }); return JSON.stringify(result); } - vm.openModal = function () { if(vm.hasScheduler) { //scheduling supported $scope.widgetParameter = ""; // needed by the scheduler? @@ -370,22 +376,14 @@ widgetData: vm.changeManagement, widgetParameter: $scope.widgetParameter }; - + window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL); } else { //no scheduling support var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement); if(dataToSo) { - - if(vm.changeManagement.workflow==="VNF Scale Out") { - dataToSo = JSON.parse(dataToSo); - dataToSo = {requestDetails: dataToSo.requestDetails[0]}; - changeManagementService.postChangeManagementScaleOutNow(dataToSo, vm.changeManagement.vnfNames[0]["service-instance-node"][0].properties["service-instance-id"], vm.changeManagement.vnfNames[0].id); - }else{ - //TODO: foreach - var vnfName = vm.changeManagement.vnfNames[0].name; - changeManagementService.postChangeManagementNow(dataToSo, vnfName); - } + var vnfName = vm.changeManagement.vnfNames[0].name; + changeManagementService.postChangeManagementNow(dataToSo, vnfName); } } }; @@ -649,7 +647,7 @@ vm.isConfigUpdate = function () { return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfConfigUpdate; } - + vm.isScaleOut = function () { return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfScaleOut; } diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html index ec1d4cde6..21f9c5d3f 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html @@ -58,6 +58,10 @@ <option value="" disabled>Select workflow</option> </select> </div> + <div class="form-group" ng-if="vm.isScaleOut()"> + <label class="control-label">Configuration Parameters</label> + <input type="text" name="configurationParameters" ng-model="vm.changeManagement.configurationParameters" id="configuration-parameters" required> + </div> <div class="form-group" ng-if="vm.isConfigUpdate()"> <label class="control-label">Attach configuration file</label> <div class="file-wrapper"> @@ -143,4 +147,4 @@ <button ng-if="vm.isScaleOut() && vm.wizardStep === 1" ng-click="vm.nextStep();" type="button" id="next" name="next" class="btn btn-primary" data-ng-disabled="newChangeManagement.$invalid">Next</button> </div> </div> -</form> +</form>
\ No newline at end of file |