diff options
27 files changed, 681 insertions, 57 deletions
diff --git a/docs/humaninterfaces.rst b/docs/humaninterfaces.rst index 25c7b5d7e..97ae05d25 100644 --- a/docs/humaninterfaces.rst +++ b/docs/humaninterfaces.rst @@ -13,3 +13,8 @@ The following VID user guides are available on the ONAP Wiki: - `VID Application Overview <https://wiki.onap.org/display/DW/VID>`_ - `Gather and validate data for an infrastructure service/network <https://wiki.onap.org/pages/viewpage.action?pageId=1019313>`_ - `Instantiate an infrastructure service <https://wiki.onap.org/display/DW/Instantiate+an+infrastructure+service>`_ + +.. toctree:: + :maxdepth: 1 + + instantiate.rst diff --git a/docs/images/API_selection.png b/docs/images/API_selection.png Binary files differnew file mode 100755 index 000000000..46b125a7b --- /dev/null +++ b/docs/images/API_selection.png diff --git a/docs/images/browse-service-models.png b/docs/images/browse-service-models.png Binary files differnew file mode 100755 index 000000000..d582d6935 --- /dev/null +++ b/docs/images/browse-service-models.png diff --git a/docs/images/create-network-instance-alacarte-after-instantiated.png b/docs/images/create-network-instance-alacarte-after-instantiated.png Binary files differnew file mode 100755 index 000000000..cf1b99566 --- /dev/null +++ b/docs/images/create-network-instance-alacarte-after-instantiated.png diff --git a/docs/images/create-network-instance-alacarte.png b/docs/images/create-network-instance-alacarte.png Binary files differnew file mode 100755 index 000000000..cadcdc0f5 --- /dev/null +++ b/docs/images/create-network-instance-alacarte.png diff --git a/docs/images/create-service-instance-alacarte-VNF-network.png b/docs/images/create-service-instance-alacarte-VNF-network.png Binary files differnew file mode 100755 index 000000000..73b77eea0 --- /dev/null +++ b/docs/images/create-service-instance-alacarte-VNF-network.png diff --git a/docs/images/create-service-instance-alacarte-after-vfmodule-instantiated.png b/docs/images/create-service-instance-alacarte-after-vfmodule-instantiated.png Binary files differnew file mode 100755 index 000000000..17a74f77c --- /dev/null +++ b/docs/images/create-service-instance-alacarte-after-vfmodule-instantiated.png diff --git a/docs/images/create-service-instance-alacarte-after-vnf-instantiated.png b/docs/images/create-service-instance-alacarte-after-vnf-instantiated.png Binary files differnew file mode 100755 index 000000000..97a363ef6 --- /dev/null +++ b/docs/images/create-service-instance-alacarte-after-vnf-instantiated.png diff --git a/docs/images/create-service-instance-alacarte-success.png b/docs/images/create-service-instance-alacarte-success.png Binary files differnew file mode 100755 index 000000000..e5dcd9768 --- /dev/null +++ b/docs/images/create-service-instance-alacarte-success.png diff --git a/docs/images/create-service-instance-alacarte.png b/docs/images/create-service-instance-alacarte.png Binary files differnew file mode 100755 index 000000000..e96c3adfd --- /dev/null +++ b/docs/images/create-service-instance-alacarte.png diff --git a/docs/images/create-vfmodule-instance-alacarte.png b/docs/images/create-vfmodule-instance-alacarte.png Binary files differnew file mode 100755 index 000000000..278fc5083 --- /dev/null +++ b/docs/images/create-vfmodule-instance-alacarte.png diff --git a/docs/images/create-vnf-instance-alacarte-success.png b/docs/images/create-vnf-instance-alacarte-success.png Binary files differnew file mode 100755 index 000000000..d0a7895a0 --- /dev/null +++ b/docs/images/create-vnf-instance-alacarte-success.png diff --git a/docs/images/create-vnf-instance-alacarte.png b/docs/images/create-vnf-instance-alacarte.png Binary files differnew file mode 100755 index 000000000..d4a9b216a --- /dev/null +++ b/docs/images/create-vnf-instance-alacarte.png diff --git a/docs/images/delete-service-instance.png b/docs/images/delete-service-instance.png Binary files differnew file mode 100755 index 000000000..aeda9bdd6 --- /dev/null +++ b/docs/images/delete-service-instance.png diff --git a/docs/images/home.png b/docs/images/home.png Binary files differnew file mode 100755 index 000000000..97f8b769d --- /dev/null +++ b/docs/images/home.png diff --git a/docs/images/onap-portal.png b/docs/images/onap-portal.png Binary files differnew file mode 100755 index 000000000..a58b44736 --- /dev/null +++ b/docs/images/onap-portal.png diff --git a/docs/images/service-instance-details.png b/docs/images/service-instance-details.png Binary files differnew file mode 100755 index 000000000..6d12aa682 --- /dev/null +++ b/docs/images/service-instance-details.png diff --git a/docs/images/vid-icon-on-portal.png b/docs/images/vid-icon-on-portal.png Binary files differnew file mode 100755 index 000000000..50ea1179e --- /dev/null +++ b/docs/images/vid-icon-on-portal.png diff --git a/docs/images/vnf-instance-detail.png b/docs/images/vnf-instance-detail.png Binary files differnew file mode 100755 index 000000000..bdff1fd15 --- /dev/null +++ b/docs/images/vnf-instance-detail.png diff --git a/docs/instantiate.rst b/docs/instantiate.rst new file mode 100644 index 000000000..66276def3 --- /dev/null +++ b/docs/instantiate.rst @@ -0,0 +1,418 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 + International License. +.. http://creativecommons.org/licenses/by/4.0 + +Instantiate Service, VNF, VF modules and Network +================================================ + + +Overview +-------- + +Using VID with A-La-Carte method means that the user needs to performed +by himself the instantiation of each object : service, VNF(s), VF module(s), +network(s). + +ONAP to VIM interactions will occurs when instantiating/deleting VF module(s) +or Network(s). In case of an Openstack VIM, Heat Stack(s) will +be created/deleted. + +In the following description, the service model in SDC was composed of 1 VF +and 1 Virtual Link (Generic Neutron Network) + +To be able to instantiate VF-module or Network object, some data need to be +declared in ONAP SDNC using SDNC Rest API. It is the place where to put +the instance specific values such as an IP address value specific +to the VNF instance for example. + +In VID, terminologies are sometimes different than in other components: + +VNF in VID = VF in SDC + +Node instance = VF in SDC + +Network = Virtual Link in SDC + + +Pre-requisites +-------------- + +pre-instantiation operations must have been performed in AAI and VID, +via Rest API, to declare some values for: + +- Subscriber Name (= customer in AAI) +- Service Type or product family (= service subscription in AAI) +- Project +- Owning Entity +- Line Of Business +- Platform +- LCP Region (= CloudOwner/RegionId in AAI) +- Tenant + +see, in the ONAP User Guides, section about adding a CloudSite +and section about pre-instantiation Operations + + +Access to VID portal +-------------------- + +.. figure:: images/onap-portal.png + :align: center + +Select the VID icon + +.. figure:: images/vid-icon-on-portal.png + :align: center + + +Here after, the VID Home page starts + +.. figure:: images/home.png + :align: center + + +SDNC API selection +------------------ + +Select the API for "A-la-carte" + +There are two choices: + +- VNF_API (old) : VID will use the (old) "VNF" SDNC API + to get/check some parameters +- GR_API (new) : VID will use the "Generic Resource" + SDNC API to get/check some parameters + +.. figure:: images/API_selection.png + :align: center + + + +Instantiate Service +------------------- + +Click Browse SDC Service Models and search for the service to instantiate. + +The view show only service models in the DISTRIBUTED state. + +.. figure:: images/browse-service-models.png + :align: center + + +Select a service and click Deploy. + +A dialog box displays. + +Complete the fields indicated by the red star and click Confirm. + +.. figure:: images/create-service-instance-alacarte.png + :align: center + +A status ox appears that shows the ONAP SO instantiation progress +as well as any messages associated with the process. + +.. figure:: images/create-service-instance-alacarte-success.png + :align: center + +A Service object is created in ONAP. + +Click Close and next screen should appear. +It will allow to declare VNF(s) and Network(s) +that are part of the service model composition. + +.. figure:: images/create-service-instance-alacarte-VNF-network.png + :align: center + + +Instantiate a VNF +----------------- + +From previous screen, it is possible to declare a VNF: click on +"Add node instance" and select the VNF you want to instantiate in the list + +The following screen should appear: + +.. figure:: images/create-vnf-instance-alacarte.png + :align: center + +Complete the fields indicated by the red star and click Confirm. + +A VNF object will be declared in ONAP. + +Once, ONAP SO process is finished, click on close button. + +The following screen then should appear: + + +.. figure:: images/create-service-instance-alacarte-after-vnf-instantiated.png + :align: center + + +Warning: a this step, no VNF instance (e.g. VM) is created on the Cloud Platform. + +Click on "i" blue button to obtain VNF instance display information. + +From this screen, it will be possible to get: + +- the service instance id value +- the VNF Type value + +Those information will be necessary for the "SDNC preload" step +to instantiate the VF module + +Close that screen + + +Instantiate VF Module +--------------------- + +It is now possible to declare a VF Module: click on +"Add VF-Module" and select the VF-module you want to instantiate in the list + +The following screen should appear: + +.. figure:: images/create-vfmodule-instance-alacarte.png + :align: center + +From this screen, it will be possible to get: + +- "Model Name" value + +At this step, with this "A-La-Carte" method, it is necessary to declare +some information in ONAP SDNC. + +SDNC needs to be aware about the VNF before trying to use ONAP SO +to instantiate the VF-module. + +This group of data is usually called "SDNC preload" and will contain: + +- vf-module instance Name +- vnf instance Name +- service instance id +- the list of vnf parameters with values, when not using the default values + +Here is an example of SDNC preload for VNF, using "curl" tool +to push those data using SDNC Rest API: + +:: + + curl -X POST \ + http://sdnc.api.simpledemo.onap.org:30202/restconf/operations/VNF-API:preload-vnf-topology-operation \ + -H 'Accept: application/json' \ + -H 'Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==' \ + -H 'Content-Type: application/json' \ + -H 'X-FromAppId: API client' \ + -H 'X-TransactionId: 0a3f6713-ba96-4971-a6f8-c2da85a3176e' \ + -H 'cache-control: no-cache' \ + -d '{ + "input": { + "request-information": { + "notification-url": "onap.org", + "order-number": "1", + "order-version": "1", + "request-action": "PreloadVNFRequest", + "request-id": "test" + }, + "sdnc-request-header": { + "svc-action": "reserve", + "svc-notification-url": "http:\/\/onap.org:8080\/adapters\/rest\/SDNCNotify", + "svc-request-id": "test" + }, + "vnf-topology-information": { + "vnf-assignments": { + "availability-zones": [], + "vnf-networks": [], + "vnf-vms": [] + }, + "vnf-parameters": [ + { + "name": "oam_net_id", + "value": "oam_network_tXWW" + } + ], + "vnf-topology-identifier": { + "generic-vnf-name": "my-vnf-instance-01", + "generic-vnf-type": "Service-model-with-VNF-and-Virtual-Link/FreeRadius_VF 0", + "service-type": "09f9ffad-1069-43fa-97e8-da7b9a439601", + "vnf-name": "my_vf_module-instance-01", + "vnf-type": "FreeradiusVf..base_freeRadius..module-0" + } + } + } + } + ' + + +Data mapping between ONAP SDNC terminology and ONAP SO + +- "generic-vnf-name" value must be equal to the VNF instance name value + (see VNF instance detail screen) +- "generic-vnf-type" value must be equal to VNF Type value + (see VNF instance detail screen) +- "service-type" value must be equal to the service instance id value + (see VNF instance detail screen) +- "vnf-name" value must be equal to the VF module instance name value +- "vnf-type" value must be equal to the "Model Name" value + (see create VF module screen) + + +If there is a need for an instance specific value +of a VNF parameter (for example : an OAM network id value, +specific to this VNF instance), +the "vnf-parameters" must be completed with a list of name/value. + +Once the "SDNC preload" is completed, send it to SDNC using any Rest API Tool. + +Then, continue on VID and complete the fields indicated by the red star +and click "Confirm". + +Warning : be very careful to use exactly the same VF module instance name +on this screen and in the "SDNC preload" + +Wait for success and close the popup screen. + +The following screen should appear: + +.. figure:: images/create-service-instance-alacarte-after-vfmodule-instantiated.png + :align: center + +At that point, the VNF is now instantiated in the cloud platform. + + +Instantiate Network +------------------- + +Instantiating a network is quite similar to vf-module instantiation +(there is also the need for a "SDNC preload") + +Click on "Add Network" and select the Network you want +to instantiate in the list + +The following screen should appear: + +.. figure:: images/create-network-instance-alacarte.png + :align: center + + +Prepare the "SDNC preload" with: + +- "network-role": provide any value, +- "network-technology": use "neutron" as this example will instantiate + a network using openstack neutron application +- "service-type": value must be equal to "Service Name" + (=service model name) displayed on VID screen +- "network-name": value must be equal to the desired network instance name, +- "network-type": value must be equal to "Model Name""Generic NeutronNet" + displayed on VID screen + +In addition: + +- in "provider-network-information" section, it is possible to indicate + some network characteristics +- it is possible to add a section about "subnets" + +Here after, an "SDNC preload" example that can be use for Network +instantiation. + +:: + + curl -X POST \ + http://sdnc.api.simpledemo.onap.org:30202/restconf/operations/VNF-API:preload-network-topology-operation \ + -H 'Accept: application/json' \ + -H 'Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==' \ + -H 'Content-Type: application/json' \ + -H 'X-FromAppId: API client' \ + -H 'X-TransactionId: 0a3f6713-ba96-4971-a6f8-c2da85a3176e' \ + -H 'cache-control: no-cache' \ + -d '{ + "input": { + "request-information": { + "request-id": "postman001", + "notification-url": "http://so.onap.org", + "order-number": "postman001", + "request-sub-action": "SUPP", + "request-action": "PreloadNetworkRequest", + "source": "postman", + "order-version": "1.0" + }, + "network-topology-information": { + "network-policy": [], + "route-table-reference": [], + "vpn-bindings": [], + "network-topology-identifier": { + "network-role": "integration_test_net", + "network-technology": "neutron", + "service-type": "Service-model-with-VNF-and-Virtual-Link", + "network-name": "my-network-instance-001", + "network-type": "Generic NeutronNet" + }, + "provider-network-information": { + "is-external-network": "false", + "is-provider-network": "false", + "is-shared-network": "false" + }, + "subnets": [ + { + "subnet-name": "my-sub_network-instance-001", + "subnet-role": "OAM", + "start-address": "192.168.90.0", + "cidr-mask": "24", + "ip-version": "4", + "dhcp-enabled": "Y", + "dhcp-start-address": "", + "dhcp-end-address": "", + "gateway-address": "192.168.90.1", + "host-routes":[] + } + ] + }, + "sdnc-request-header": { + "svc-action": "reserve", + "svc-notification-url": "http://so.onap.org", + "svc-request-id": "postman001" + } + } + } + ' + +Once the "SDNC preload" is completed, send it to SDNC using any Rest API Tool. + +Then, continue on VID and complete the fields indicated by the red star +and click "Confirm". + +Warning : be very careful to use exactly the same network instance name +on this screen and in the "SDNC preload" + +Wait for success and close the popup screen. + +The following screen should appear: + +.. figure:: images/create-network-instance-alacarte-after-instantiated.png + :align: center + +At that point, the Network and subnets are now instantiated +in the cloud platform. + +Also, all those network information are available in ONAP AAI, +under the terminology +"l3-network", with the "neutron-network-id" and the "neutron-subnet-id" +provided by +the openstack platform. + + +Deleting Network, VF module, VNF, Service +----------------------------------------- + +To delete a service instance using VID, it is necessary to delete objects +in the following sequence: + +- delete VF module(s) +- delete VNF instance(s) +- delete Network(s) +- delete service instance + +To proceed those deletion, from VID Home screen + +- search for existing service instance +- edit/view the service instance you want to delete +- click on red button with white cross and confirm for each object diff --git a/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties b/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties index 4d54d8eb5..a11007f4b 100755 --- a/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties +++ b/epsdk-app-onap/src/main/webapp/WEB-INF/conf/system.properties @@ -147,6 +147,9 @@ vid.truststore.passwd.x=OBF:1dx01j0e1hs01t981mis1dws156s1ojc1qjc1zsx1pw31qob1qr7 mso.dme2.client.timeout=30000 mso.dme2.client.read.timeout=120000 +scheduler.user.name=test1 +scheduler.password=test2 + scheduler.create.new.vnf.change.instance=/v1/ChangeManagement/schedules/ scheduler.get.time.slots=/v1/ChangeManagement/schedules/ scheduler.server.url=http://localhost:1080/scheduler diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java index f511a4746..6fe295c15 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java @@ -3,6 +3,7 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +28,8 @@ import java.util.List; @JsonIgnoreProperties(ignoreUnknown = true) public class RelationshipList { + public List<Relationship> relationship; + @JsonProperty("relationship") public List<Relationship> getRelationship() { return relationship; @@ -37,7 +40,6 @@ public class RelationshipList { this.relationship = relationship; } - public List<Relationship> relationship; diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java index eee2acc51..2b3ad60ea 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java @@ -77,6 +77,7 @@ public class AaiController extends RestrictedBaseController { private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class); private static final String FROM_APP_ID = "VidAaiController"; + private final ObjectMapper objectMapper = new ObjectMapper(); private AaiService aaiService; private AAIRestInterface aaiRestInterface; @@ -157,7 +158,7 @@ public class AaiController extends RestrictedBaseController { throws IOException { ResponseEntity<String> responseEntity; if (aaiResponseData.getHttpCode() == 200) { - responseEntity = new ResponseEntity<>(new ObjectMapper().writeValueAsString(aaiResponseData.getT()), + responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK); } else { responseEntity = new ResponseEntity<>(aaiResponseData.getErrorMessage(), @@ -225,7 +226,6 @@ public class AaiController extends RestrictedBaseController { @RequestMapping(value = "/aai_get_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); ResponseEntity<String> responseEntity; RoleValidator roleValidator = RoleValidator.by(roleProvider.getUserRoles(request)); SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator); @@ -270,17 +270,14 @@ public class AaiController extends RestrictedBaseController { @RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET) public ResponseEntity<String> getSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId, @RequestParam(value="omitServiceInstances", required = false, defaultValue = "false") boolean omitServiceInstances) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - ResponseEntity responseEntity; List<Role> roles = roleProvider.getUserRoles(request); RoleValidator roleValidator = RoleValidator.by(roles); - AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator, featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH) && omitServiceInstances); - String httpMessage = subscriberData.getT() != null ? - objectMapper.writeValueAsString(subscriberData.getT()) : - subscriberData.getErrorMessage(); + AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator, + featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH) && omitServiceInstances); + String httpMessage = subscriberData.getT() != null ? objectMapper.writeValueAsString(subscriberData.getT()) : subscriberData.getErrorMessage(); - responseEntity = new ResponseEntity<>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode())); - return responseEntity; + return new ResponseEntity<>(httpMessage, + HttpStatus.valueOf(subscriberData.getHttpCode())); } @RequestMapping(value = "/search_service_instances", method = RequestMethod.GET) @@ -289,7 +286,6 @@ public class AaiController extends RestrictedBaseController { @RequestParam(value = "serviceInstanceIdentifier", required = false) String instanceIdentifier, @RequestParam(value = "project", required = false) List<String> projects, @RequestParam(value = "owningEntity", required = false) List<String> owningEntities) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); ResponseEntity responseEntity; List<Role> roles = roleProvider.getUserRoles(request); @@ -354,7 +350,6 @@ public class AaiController extends RestrictedBaseController { @RequestMapping(value = "/aai_get_network_collection_details/{serviceInstanceId}", method = RequestMethod.GET) public ResponseEntity<String> getNetworkCollectionDetails( @PathVariable("serviceInstanceId") String serviceInstanceId) throws IOException { - com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper(); AaiResponse<String> resp = aaiService.getNetworkCollectionDetails(serviceInstanceId); String httpMessage = resp.getT() != null ? @@ -367,7 +362,6 @@ public class AaiController extends RestrictedBaseController { public ResponseEntity<String> getInstanceGroupsByCloudRegion(@PathVariable("cloudOwner") String cloudOwner, @PathVariable("cloudRegionId") String cloudRegionId, @PathVariable("networkFunction") String networkFunction) throws IOException { - com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper(); AaiResponse<AaiGetInstanceGroupsByCloudRegion> resp = aaiService .getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction); @@ -424,7 +418,6 @@ public class AaiController extends RestrictedBaseController { ResponseEntity responseEntity; try { - ObjectMapper objectMapper = new ObjectMapper(); List<Role> roles = roleProvider.getUserRoles(request); RoleValidator roleValidator = RoleValidator.by(roles); AaiResponse<GetTenantsResponse[]> response = aaiService diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java index befbe0320..693c84bff 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nokia. All rights reserved. + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,9 +46,7 @@ public final class ControllersUtils { public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) { logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodCallerName(), ExceptionUtils.getMessage(e), e); - - ExceptionResponse exceptionResponse = new ExceptionResponse(e); - return exceptionResponse; + return new ExceptionResponse(e); } public static ResponseEntity handleWebApplicationException(WebApplicationException e, EELFLoggerDelegate logger) { diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java index 7878c2fb8..001a8ae6d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java @@ -98,12 +98,13 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc { status = response.getStatus(); restObject.setStatusCode(status); rawData = response.getBody(); + restObject.setRaw(rawData); if (status == 200) { if (t instanceof String) { restObject.set((T)rawData); } else { - restObject.set(JACKSON_OBJECT_MAPPER.readValue(rawData, new TypeReference<T>() {})); + restObject.set(JACKSON_OBJECT_MAPPER.readValue(rawData, (Class<T>)t.getClass())); } logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE); logger.info(EELFLoggerDelegate.errorLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java index 2377c8055..b51bbdc31 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java @@ -21,14 +21,11 @@ package org.onap.vid.controller; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.booleanThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -40,16 +37,14 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; -import java.io.IOException; import java.util.Map; import java.util.UUID; -import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Answers; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData; @@ -62,13 +57,13 @@ import org.onap.vid.aai.model.PortDetailsTranslator.PortDetails; import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsError; import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsOk; import org.onap.vid.aai.util.AAIRestInterface; -import org.onap.vid.properties.Features; -import org.onap.vid.roles.Role; import org.onap.vid.model.VersionByInvariantIdsRequest; +import org.onap.vid.properties.Features; import org.onap.vid.roles.RoleProvider; -import org.onap.vid.roles.RoleValidator; +import org.onap.vid.roles.RoleValidatorByRoles; import org.onap.vid.services.AaiService; import org.onap.vid.utils.SystemPropertiesWrapper; +import org.onap.vid.utils.Unchecked; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; @@ -83,7 +78,7 @@ public class AaiControllerTest { private final ObjectMapper objectMapper = new ObjectMapper(); @Mock private AaiService aaiService; - @Mock + @Mock(answer = Answers.RETURNS_DEEP_STUBS) private AAIRestInterface aaiRestInterface; @Mock private RoleProvider roleProvider; @@ -98,11 +93,140 @@ public class AaiControllerTest { @Before public void setUp() { - aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper, featureManager); + aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper, + featureManager); mockMvc = MockMvcBuilders.standaloneSetup(aaiController).build(); } @Test + public void getAicZoneForPnf_shouldReturnOKResponse() throws Exception { + String globalCustomerId = "testCustomerId"; + String serviceType = "testServiceType"; + String serviceId = "testServiceId"; + String expectedResponseBody = "OK_RESPONSE"; + AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, null, HttpStatus.OK.value()); + given(aaiService.getAicZoneForPnf(globalCustomerId, serviceType, serviceId)).willReturn(aaiResponse); + + mockMvc.perform( + get("/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}", globalCustomerId, serviceType, + serviceId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody))); + } + + @Test + public void getInstanceGroupsByVnfInstanceId_shouldReturnOKResponse() throws Exception { + String vnfInstanceId = "testVndInstanceId"; + String expectedResponseBody = "OK_RESPONSE"; + AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, null, HttpStatus.OK.value()); + given(aaiService.getInstanceGroupsByVnfInstanceId(vnfInstanceId)).willReturn(aaiResponse); + + mockMvc.perform(get("/aai_get_instance_groups_by_vnf_instance_id/{vnfInstanceId}", vnfInstanceId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody))); + } + + @Test + public void doGetServiceInstance_shouldFetchServiceInstance_byServiceInstanceId() throws Exception { + String serviceInstanceId = "testServiceInstanceId"; + String serviceInstanceType = "Service Instance Id"; + String expectedResponseBody = "OK_RESPONSE"; + Response response = mock(Response.class); + given(response.readEntity(String.class)).willReturn(expectedResponseBody); + given(response.getStatus()).willReturn(HttpStatus.OK.value()); + + given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI( + "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:" + + serviceInstanceId)), + eq(false)).getResponse()).willReturn(response); + + mockMvc + .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId, + serviceInstanceType) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); + } + + @Test + public void doGetServiceInstance_shouldFetchServiceInstance_byServiceInstanceName() throws Exception { + String serviceInstanceId = "testServiceInstanceId"; + String serviceInstanceType = "testServiceInstanceType"; + String expectedResponseBody = "OK_RESPONSE"; + Response response = mock(Response.class); + given(response.readEntity(String.class)).willReturn(expectedResponseBody); + given(response.getStatus()).willReturn(HttpStatus.OK.value()); + + given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI( + "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:" + + serviceInstanceId)), + eq(false)).getResponse()).willReturn(response); + + mockMvc + .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId, + serviceInstanceType) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); + } + + @Test + public void doGetServices_shouldReturnOkResponse() throws Exception { + String globalCustomerId = "testGlobalCustomerId"; + String serviceSubscriptionId = "testServiceSubscriptionId"; + String expectedResponseBody = "OK_RESPONSE"; + Response response = mock(Response.class); + given(response.readEntity(String.class)).willReturn(expectedResponseBody); + given(response.getStatus()).willReturn(HttpStatus.OK.value()); + + given(aaiRestInterface.RestGet( + eq("VidAaiController"), + anyString(), + eq(Unchecked.toURI( + "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceSubscriptionId + "?depth=0")), + eq(false)).getResponse()).willReturn(response); + + mockMvc + .perform( + get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId, + serviceSubscriptionId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); + } + + @Test + public void doGetServices_shouldReturnInternalServerError_forEmptyResponse() throws Exception { + String globalCustomerId = "testGlobalCustomerId"; + String serviceSubscriptionId = "testServiceSubscriptionId"; + String expectedResponseBody = "Failed to fetch data from A&AI, check server logs for details."; + given(aaiRestInterface.RestGet( + eq("VidAaiController"), + anyString(), + eq(Unchecked.toURI( + "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceSubscriptionId + "?depth=0")), + eq(false)).getResponse()).willReturn(null); + + mockMvc + .perform( + get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId, + serviceSubscriptionId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isInternalServerError()) + .andExpect(content().string(expectedResponseBody)); + } + + @Test public void getPortMirroringConfigData_givenIds_shouldReturnConfigDataMappedById() throws Exception { PortMirroringConfigDataOk okConfigData = new PortMirroringConfigDataOk("foo"); PortMirroringConfigDataError errorConfigData = new PortMirroringConfigDataError("bar", "{ baz: qux }"); @@ -259,7 +383,7 @@ public class AaiControllerTest { mockMvc.perform( post("/aai_get_version_by_invariant_id") - .content(new ObjectMapper().writeValueAsString(request)) + .content(objectMapper.writeValueAsString(request)) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) @@ -267,40 +391,71 @@ public class AaiControllerTest { } @Test - public void getSubscriberDetailsOmitServiceInstances_reduceDepthEnabledAndOmitQueryParam() throws IOException { - getSubscriberDetailsOmitServiceInstances("some subscriber id", - true, true, true); + public void getSubscriberDetails_shouldOmitServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsTrue() + throws Exception { + boolean isFeatureActive = true; + boolean omitServiceInstances = true; + + String subscriberId = "subscriberId"; + String okResponseBody = "OK_RESPONSE"; + AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value()); + given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive); + given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class), + eq(isFeatureActive && omitServiceInstances))) + .willReturn(aaiResponse); + + mockMvc.perform( + get("/aai_sub_details/{subscriberId}", subscriberId) + .param("omitServiceInstances", Boolean.toString(omitServiceInstances)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody))); } @Test - public void getSubscriberDetailsOmitServiceInstances_reduceDepthDisabledAndOmitQueryParam() throws IOException { - getSubscriberDetailsOmitServiceInstances("another-subscriber-id-123", - false, true, false); + public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsFalse() + throws Exception { + boolean isFeatureActive = true; + boolean omitServiceInstances = false; + + getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances); } @Test - public void getSubscriberDetailsOmitServiceInstances_reduceDepthDisabled() throws IOException { - getSubscriberDetailsOmitServiceInstances("123-456-789-123-345-567-6", - false, false, false); + public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsTrue() + throws Exception { + boolean isFeatureActive = false; + boolean omitServiceInstances = true; + + getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances); } @Test - public void getSubscriberDetailsOmitServiceInstances_reduceDepthEnabled() throws IOException { - getSubscriberDetailsOmitServiceInstances("0000000000000000000000000", - true, false, false); + public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsFalse() + throws Exception { + boolean isFeatureActive = false; + boolean omitServiceInstances = false; + getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances); } - private void getSubscriberDetailsOmitServiceInstances(String subscriberId, boolean isFlag1906AaiSubDetailsReduceDepthEnabled, - boolean omitServiceInstancesQueryParam, boolean omitServiceInstancesExpectedGetSubscriberDataParam) throws IOException { - when(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).thenReturn(isFlag1906AaiSubDetailsReduceDepthEnabled); - HttpServletRequest request = mock(HttpServletRequest.class); - when(roleProvider.getUserRoles(request)).thenReturn(ImmutableList.of(mock(Role.class), mock(Role.class))); - AaiResponse subscriberData = mock(AaiResponse.class); - when(subscriberData.getT()).thenReturn(null); - when(subscriberData.getHttpCode()).thenReturn(200); - when(aaiService.getSubscriberData(any(), any(), anyBoolean())).thenReturn(subscriberData); - aaiController.getSubscriberDetails(request, subscriberId, omitServiceInstancesQueryParam); - verify(aaiService).getSubscriberData(argThat(subscriberId::equals), any(RoleValidator.class), booleanThat(b -> omitServiceInstancesExpectedGetSubscriberDataParam == b)); + private void getSubscriberDetails_assertServiceInstancesInclusion(boolean isFeatureActive, + boolean omitServiceInstances) throws Exception { + String subscriberId = "subscriberId"; + String okResponseBody = "OK_RESPONSE"; + AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value()); + given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive); + given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class), + eq(isFeatureActive && omitServiceInstances))) + .willReturn(aaiResponse); + + mockMvc.perform( + get("/aai_sub_details/{subscriberId}", subscriberId) + .param("omitServiceInstances", Boolean.toString(omitServiceInstances)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody))); } } diff --git a/vid-automation/src/test/resources/sdcApiTest/minMaxInitialExpectedResponse.json b/vid-automation/src/test/resources/sdcApiTest/minMaxInitialExpectedResponse.json index 2b648c1ed..e10872b00 100644 --- a/vid-automation/src/test/resources/sdcApiTest/minMaxInitialExpectedResponse.json +++ b/vid-automation/src/test/resources/sdcApiTest/minMaxInitialExpectedResponse.json @@ -25,6 +25,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "AV_vPE" }, "2017488pasqualevpe20_bandwidth": { @@ -34,6 +38,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "10" }, "2017488pasqualevpe20_bandwidth_units": { @@ -43,6 +51,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "Gbps" }, "2017488pasqualevpe20_AIC_CLLI": { @@ -52,6 +64,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "ATLMY8GA" }, "2017488pasqualevpe20_vnf_config_template_version": { @@ -61,6 +77,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "17.2" }, "2017488pasqualevpe20_vnf_instance_name": { @@ -70,6 +90,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "mtnj309me6" } } @@ -90,6 +114,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "17.2" }, "bandwidth_units": { @@ -99,6 +127,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "Gbps" }, "bandwidth": { @@ -108,6 +140,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "10" }, "AIC_CLLI": { @@ -117,6 +153,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "ATLMY8GA" }, "ASN": { @@ -126,6 +166,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "AV_vPE" }, "vnf_instance_name": { @@ -135,6 +179,10 @@ "inputProperties": null, "constraints": [], "required": true, + "templateName": null, + "templateUUID": null, + "templateInvariantUUID": null, + "templateCustomizationUUID": null, "default": "mtnj309me6" } }, |