summaryrefslogtreecommitdiffstats
path: root/nokiav2
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2')
-rw-r--r--nokiav2/deployment/src/main/resources/application.properties23
-rwxr-xr-xnokiav2/deployment/src/main/resources/docker-entrypoint.sh7
-rw-r--r--nokiav2/docs/development.rst39
-rw-r--r--nokiav2/docs/fix.rst101
-rw-r--r--nokiav2/docs/index.rst1
-rw-r--r--nokiav2/docs/integration.rst75
-rw-r--r--nokiav2/docs/intro.rst45
-rw-r--r--nokiav2/docs/sample/aai.create.cloud.region.request.json12
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java61
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java3
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java7
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java16
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java80
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForSo.java33
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForVfc.java33
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmCredentials.java79
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmUrls.java67
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java15
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java21
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/GrantlessGrantManager.java5
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java9
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java5
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java47
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java14
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java16
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java7
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java16
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java3
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java3
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java6
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcnApi.java17
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SwaggerApi.java6
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/Conditions.java67
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiException.java54
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForSo.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForVfc.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProvider.java23
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForSo.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForVfc.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java36
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForSo.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForVfc.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java28
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java107
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForSo.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForVfc.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForSo.java37
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java37
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java21
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForSo.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForVfc.java31
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java51
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java11
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java (renamed from nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java)66
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmCredentials.java36
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmUrls.java33
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java25
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestSdcPackageProvider.java9
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAAINotificationProcessor.java8
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAbstractManager.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java24
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestL3NetworkManager.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java9
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVserverManager.java9
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java18
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java24
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java11
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcnApi.java13
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerApi.java10
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java75
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiExceptionTest.java50
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java42
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java22
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java19
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java53
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java1
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java4
-rw-r--r--nokiav2/driver/src/test/resources/application-direct.properties22
-rw-r--r--nokiav2/driver/src/test/resources/application.properties17
-rw-r--r--nokiav2/generatedapis/src/main/resources/so.vnfm.json5
96 files changed, 1597 insertions, 770 deletions
diff --git a/nokiav2/deployment/src/main/resources/application.properties b/nokiav2/deployment/src/main/resources/application.properties
index d52ed498..299213d4 100644
--- a/nokiav2/deployment/src/main/resources/application.properties
+++ b/nokiav2/deployment/src/main/resources/application.properties
@@ -13,10 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
+
server.error.whitelabel.enabled=false
+
###############################################################################
-# Begining of mandatory properties #
+# Begin of mandatory properties #
###############################################################################
+
###############################################################################
# The following section contains the variables set during container creation #
# - all values must be replaced with non sample data #
@@ -26,23 +29,11 @@ server.error.whitelabel.enabled=false
driverMsbExternalIp=127.0.0.1
# the IP address of the server reported to the VNFM
driverVnfmExternalIp=127.0.0.1
-# the IP address of the message bus
-messageBusIp=127.0.0.1
-# the URL of the CBAM catalog service
-cbamCatalogUrl=https://127.0.0.1:443/api/catalog/adapter/
-# the URL of the CBAM LCN service
-cbamLcnUrl=https://127.0.0.1:443/vnfm/lcn/v3/
-# the URL of the CBAM authentication service
-cbamKeyCloakBaseUrl=https://127.0.0.1:443/auth/
-# the username to be used for requesing a token on CBAM authorization interface
-cbamUsername=kukuUser
-# the password to be used for requesing a token on CBAM authorization interface
-cbamPassword=kukuPassword
# the identifier of the VNFM in A&AI external system registry
vnfmId=5e65fe25-bdad-46dc-bba8-b7878fcee264
###############################################################################
-# The following section holds the default valued that may be chaged
+# The following section holds the default valued that may be changed
###############################################################################
# The TCP port of the server
server.port=8089
@@ -50,6 +41,8 @@ server.port=8089
server.context-path=
# the IP address to which the erver binds to
server.address=0.0.0.0
+# the IP address of the message bus
+messageBusIp=127.0.0.1
# the TCP port of the message bus
messageBusPort=80
# skip hostname verification during SSL on CBAM LCN, LCM and authorization interface
@@ -78,6 +71,7 @@ aaiPassword=AAI
sdcUsername=SDC
#The password to access SDC
sdcPassword=SDC
+
###############################################################################
# End of mandatory properties for driver #
###############################################################################
@@ -86,7 +80,6 @@ vnfmInfoCacheEvictionInMs=600000
## for logging begin ##
com.fasterxml.jackson.core=jackson-databind
-#logging.file=${catalina.base}/logs/vfcadaptor.log
logging.level.org.springframework=INFO
logging.level.org.hibernate=OFF
logging.level.org.springframework.web=DEBUG
diff --git a/nokiav2/deployment/src/main/resources/docker-entrypoint.sh b/nokiav2/deployment/src/main/resources/docker-entrypoint.sh
index bd36b617..79ccd05b 100755
--- a/nokiav2/deployment/src/main/resources/docker-entrypoint.sh
+++ b/nokiav2/deployment/src/main/resources/docker-entrypoint.sh
@@ -51,12 +51,6 @@ function configure(){
switchLine driverMsbExternalIp $EXTERNAL_IP
switchLine driverVnfmExternalIp $EXTERNAL_IP
switchLine messageBusIp $MSB_IP
- switchLine cbamCatalogUrl $CBAM_CATALOG_URL
- switchLine cbamLcnUrl $CBAM_LCN_URL
- switchLine cbamKeyCloakBaseUrl $CBAM_KEYCLOAK_URL
- switchLine cbamLcnUrl $CBAM_LCN_URL
- switchLine cbamUsername $CBAM_USERNAME
- switchLine cbamPassword $CBAM_PASSWORD
switchLine vnfmId $VNFM_ID
switchLine ipMap $IP_MAP
fi
@@ -82,4 +76,3 @@ while true ; do
done
echo "Server quit (unexpected)"
done
-
diff --git a/nokiav2/docs/development.rst b/nokiav2/docs/development.rst
index f0bcc714..c16ed935 100644
--- a/nokiav2/docs/development.rst
+++ b/nokiav2/docs/development.rst
@@ -5,24 +5,41 @@ Developing the Nokia v2 SVNFM adapter
Quality gate
------------
-99.9 % unit test converage
-near 0 sonar issues (with the exceptions of FIXME issues)
+- 99.9 % unit test coverage
-Usfull links
+- near 0 sonar issues (with the exceptions of FIXME issues)
+
+Useful links
------------
-Jenkins build bot: https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-svnfm-nokiav2-master-drv-vnfm-nokiav2-verify-java/
-Jenkins sonar analyitcs: https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-vnfm-svnfm-nokiav2-sonar/
-Jenkins CLM: https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-svnfm-nokiav2-maven-clm-master/
-Jenkins daily release https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-svnfm-nokiav2-master-drv-vnfm-nokiav2-release-version-java-daily/
-Sonar: https://sonar.onap.org/dashboard?id=org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2%3Avfc-nfvo-driver-vnfm-svnfm-nokiav2
-Nexus IQ reports: https://nexus-iq.wl.linuxfoundation.org/assets/index.html#/management/view/application/vfc-nfvo-driver-svnfm-nokiav2
+- Jenkins build bot: https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-svnfm-nokiav2-master-drv-vnfm-nokiav2-verify-java/
+
+- Jenkins sonar analyitcs: https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-vnfm-svnfm-nokiav2-sonar/
+
+- Jenkins CLM: https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-svnfm-nokiav2-maven-clm-master/
+
+- Jenkins daily release https://jenkins.onap.org/view/vfc/job/vfc-nfvo-driver-svnfm-nokiav2-master-drv-vnfm-nokiav2-release-version-java-daily/
+
+- Sonar: https://sonar.onap.org/dashboard?id=org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2%3Avfc-nfvo-driver-vnfm-svnfm-nokiav2
+
+- Nexus IQ reports: https://nexus-iq.wl.linuxfoundation.org/assets/index.html#/management/view/application/vfc-nfvo-driver-svnfm-nokiav2
Backlog
-------
-- add driver to OOM based deployments
-- Solve remaining severe & moderate license issues
+- Support micro service auto configuration
+
+- Support logging configuration
+
- Support for operation traces in logging https://wiki.onap.org/pages/viewpage.action?pageId=20087036
+
- Add CSIT using SVNFM simulator
+Recently solved issues
+----------------------
+
+- add driver to OOM based deployments
+
+- Solve remaining severe & moderate license issues
+
+
diff --git a/nokiav2/docs/fix.rst b/nokiav2/docs/fix.rst
new file mode 100644
index 00000000..68f82534
--- /dev/null
+++ b/nokiav2/docs/fix.rst
@@ -0,0 +1,101 @@
+Fix ONAP installation
+=====================
+
+This document is intended to help to fix common problems in the ONAP released software. Since the ONAP software in some
+cases uses "snapshots" or "master" these steps may not be 100 percent accurate.
+
+Amsterdam release
+-----------------
+
+- Create SDC consumer in SDC (username = SDC password=SDC )
+
+ - curl -X POST -i -H "Accept: application/json; charset=UTF-8" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://sdc.api.simpledemo.onap.org:8080/sdc2/rest/v1/consumers/ -d '{"consumerName": "SDC", "consumerSalt": "00ae7619efccee9bf5b53d7f72c3cdf7","consumerPassword": "516e53e4b822601ef58d96abcc054709d15cb42179aa3b6302f48c6c7cf575a6"}'
+
+- Log into the multi-service node via SSH
+
+ - Fix VF-C
+
+ - docker exec -it `docker ps | grep nslcm | awk '{print $1}'` /bin/bash
+
+ - vim.tiny /service/vfc/nfvo/lcm/lcm/pub/config/config.py
+
+ - AAI_BASE_URL = "https://10.0.1.1:8443/aai/v11"
+
+ - SDC_BASE_URL = "https://10.0.3.1:8443/sdc/v1"
+
+ - vim.tiny /service/vfc/nfvo/lcm/lcm/ns/vnfs/grant_vnfs.py
+
+ - Fix according to: https://gerrit.onap.org/r/#/c/27941/3/lcm/ns/vnfs/grant_vnfs.py
+
+ - vim.tiny /service/vfc/nfvo/lcm/lcm/ns/vnfs/notify_lcm.py
+
+ - Fix according to: https://gerrit.onap.org/r/#/c/25447/1/lcm/ns/vnfs/notify_lcm.py
+
+ - vim.tiny /service/vfc/nfvo/lcm/lcm/ns/ns_delete.py
+
+ - Fix according to: https://gerrit.onap.org/r/#/c/25373/
+
+ - exit
+
+ - Fix catalog
+
+ - docker exec -it `docker ps | grep catalog | awk '{print $1}'` /bin/bash
+
+ - vim.tiny /service/vfc/nfvo/catalog/catalog/pub/config/config.py
+
+ - SDC_BASE_URL = "https://10.0.3.1:8443"
+
+ - vim.tiny /service/vfc/nfvo/catalog/catalog/pub/utils/toscaparser/vnfdmodel.py
+
+ - Fix according to: https://gerrit.onap.org/r/#/c/27937/1/catalog/pub/utils/toscaparser/vnfdmodel.py
+
+ - vim.tiny /service/vfc/nfvo/catalog/catalog/pub/utils/toscaparser/basemodel.py
+
+ - Fix according to: https://gerrit.onap.org/r/#/c/25157/1/catalog/pub/utils/toscaparser/basemodel.py
+
+ - exit
+
+ - Fix multi cloud (required if cloud endpoint is over HTTPS)
+
+ - docker exec -it `docker ps | grep ocata | awk '{print $1}'` /bin/bash
+
+ - apt-get install vim
+
+ - vim /opt/ocata/lib/newton/newton/requests/views/util.py
+
+ - Change from return session.Session(auth=auth) to: session.Session(auth=auth, verify=False)
+
+ - exit
+
+- Specify quotas for the tenant (VF-C resource managed does not handle unlimited quotas)
+
+Beijing release
+---------------
+
+- create SDC user (SDC:SDC)
+
+ - curl -X POST -i -H "Accept: application/json; charset=UTF-8" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://sdc.api.simpledemo.onap.org:8080/sdc2/rest/v1/consumers/ -d '{"consumerName": "SDC", "consumerSalt": "00ae7619efccee9bf5b53d7f72c3cdf7","consumerPassword": "516e53e4b822601ef58d96abcc054709d15cb42179aa3b6302f48c6c7cf575a6"}'
+
+- Log into the multi-service node via SSH
+
+ - Fix catalog
+
+ - docker exec -it `docker ps | grep catalog | awk '{print $1}'` /bin/bash
+
+ - vim.tiny /service/vfc/nfvo/catalog/catalog/pub/config/config.py
+
+ - SDC_BASE_URL = "https://10.0.3.1:8443"
+
+ - Fix VF-C
+
+ - docker exec -it `docker ps | grep nslcm | awk '{print $1}'` /bin/bash
+
+ - vim.tiny /service/vfc/nfvo/lcm/lcm/pub/config/config.py
+
+ - AAI_BASE_URL = "https://10.0.1.1:8443/aai/v11"
+
+ - SDC_BASE_URL = "https://10.0.3.1:8443/sdc/v1"
+
+
+
+https://gerrit.onap.org/r/#/c/44203/
diff --git a/nokiav2/docs/index.rst b/nokiav2/docs/index.rst
index b9a98466..fabd0d6a 100644
--- a/nokiav2/docs/index.rst
+++ b/nokiav2/docs/index.rst
@@ -10,6 +10,7 @@ Welcome to Nokia SVNFM documentation!
:caption: Contents:
integration.rst
+ fix.rst
samplevnf.rst
vnfintegration.rst
onboarding.rst
diff --git a/nokiav2/docs/integration.rst b/nokiav2/docs/integration.rst
index 4a0fb36f..2ce93e80 100644
--- a/nokiav2/docs/integration.rst
+++ b/nokiav2/docs/integration.rst
@@ -1,14 +1,14 @@
Integrate ONAP with Nokia VNFM
==============================
-The following section describes how to integrate the Nokia Virtualized Network Function Manager (VNFM) into ONAP. The integration is easier if the
-VNFM is installed before ONAP.
+The following section describes how to integrate the Nokia Virtualized Network Function Manager (VNFM) into ONAP.
Prepare the VNFM
----------------
* Start the VNFM.
- The VNFM must be able to communicate with the ONAP VF-C interface, the virtualized infrastructure manager (VIM) and the virtualized network function (VNF), so the VNFM must
+
+ - The VNFM must be able to communicate with the ONAP VF-C interface, the virtualized infrastructure manager (VIM) and the virtualized network function (VNF), so the VNFM must
have the correct network setup. The VNFM uses lifecycle notifications (LCNs) to notify the VF-C about the executed changes, therefore, the LCN zone of the
VNFM must be configured so that the VNFM is able to reach the VF-C LCN interface.
@@ -17,7 +17,7 @@ Prepare the VNFM
- Using SSH, log in to the CloudBand Application Manager (CBAM) virtual machine as cbam user and determine the Keycloak
auto-generated admin password with the following command: ectl get /cbam/cluster/components/keycloak/admin_credentials/password
- - Copy the printout of the command.
+ - Copy the printout of the command.
- Access the Keycloak login page with the following URL: https://<cbamIp>/auth/admin where <cbamIp> is the FQDN or IP
address assigned to CBAM node during instantiation. Optionally, it may contain a port, for example, cbam.mycompany.com:port or 1.2.3.4:port.
@@ -196,12 +196,20 @@ Add the VNFM driver to ONAP
- Register the VNFM as an external system:
- - Note: - Repeat this step for all VIMs planned to be used.
-
- Access the following URL: http://msb.api.simpledemo.onap.org/iui/aai-esr-gui/extsys/vnfm/vnfmView.html
- Result: The ONAP platform opens
+ - The VNFM has four end points. These end points must be configured in the external system configuration of the VNFM.
+
+ - Authentication endpoint: https://$CBAM_IP:443/auth/
+
+ - Life-cycle management endpoint: https://<cbamIp>:443/vnfm/lcm/v3/
+
+ - Life-cycle change notification endpoint: https://<cbamIp>:443/vnfm/lcn/v3/
+
+ - Catalog endpoint: https://<cbamIp>:443/api/catalog/adapter/
+
- On the platform, click Register.
- Result: The registration form opens.
@@ -210,27 +218,27 @@ Add the VNFM driver to ONAP
- Note: Cloud credentials are supplied by the VNF integrator.
-+-----------------+-----------------------------------+
-| key | Value |
-+-----------------+-----------------------------------+
-| Name | CbamVnfm |
-+-----------------+-----------------------------------+
-| type | NokiaSVNFM |
-+-----------------+-----------------------------------+
-| Vendor | Nokia |
-+-----------------+-----------------------------------+
-| version | v1 |
-+-----------------+-----------------------------------+
-| URL | https://<cbamIp>:443/vnfm/lcm/v3/ |
-+-----------------+-----------------------------------+
-| VIM | <cloudOwner>_<cloudRegionId> |
-+-----------------+-----------------------------------+
-| certificate URL | |
-+-----------------+-----------------------------------+
-| Username | <clientId> |
-+-----------------+-----------------------------------+
-| Password | <clientSecret> |
-+-----------------+-----------------------------------+
++-----------------+------------------------------------------+
+| key | Value |
++-----------------+------------------------------------------+
+| Name | CbamVnfm |
++-----------------+------------------------------------------+
+| type | NokiaSVNFM |
++-----------------+------------------------------------------+
+| Vendor | Nokia |
++-----------------+------------------------------------------+
+| version | v1 |
++-----------------+------------------------------------------+
+| URL | <authUrl>_<lcmUrl>_<lcnUrl>_<catalogUrl> |
++-----------------+------------------------------------------+
+| VIM | any |
++-----------------+------------------------------------------+
+| certificate URL | |
++-----------------+------------------------------------------+
+| Username | <onapUsername>_<clientId> |
++-----------------+------------------------------------------+
+| Password | <onapPassword>_<clientSecret> |
++-----------------+------------------------------------------+
- Click Save.
@@ -238,7 +246,6 @@ Add the VNFM driver to ONAP
- Determine the UUID of the VNFM:
- - Note: If the VNFM was registered multiple times, select one of them at random
- Access the following URL: http://msb.api.simpledemo.onap.org:9518/api/aai-esr-server/v1/vnfms
- Look for the previously registered VNFM and note the value of <vnfmId>.
@@ -260,13 +267,10 @@ Configure the SVNFM driver (generic)
.. code-block:: console
- export CBAM_IP=<cbamIp>
export MULTI_NODE_IP=<multiNodeIp>
export VNFM_ID=<vnfmId>
export IMAGE_ID=<imageId>
- export CBAM_PASSWORD=<onapPassword>
- export CBAM_USERNAME=<onapUsername>
- docker run --name vfc_nokia -p 8089:8089 -e "MSB_IP=$MULTI_NODE_IP" -e "CONFIGURE=kuku" -e "EXTERNAL_IP=$MULTI_NODE_IP" -e "CBAM_CATALOG_URL=https://$CBAM_IP:443/api/catalog/adapter/" -e "CBAM_LCN_URL=https://$CBAM_IP:443/vnfm/lcn/v3/" -e "CBAM_KEYCLOAK_URL=https://$CBAM_IP:443/auth/" -e "CBAM_USERNAME=$CBAM_USERNAME" -e "CBAM_PASSWORD=$CBAM_PASSWORD" -e "VNFM_ID=$VNFM_ID" -d --stop-timeout 300 $IMAGE_ID
+ docker run --name vfc_nokia -p 8089:8089 -e "MSB_IP=$MULTI_NODE_IP" -e "CONFIGURE=kuku" -e "EXTERNAL_IP=$MULTI_NODE_IP" -e "VNFM_ID=$VNFM_ID" -d --stop-timeout 300 $IMAGE_ID
- Determine the identifier of the container:
@@ -295,6 +299,11 @@ This step is executed instead of the "Configure the SVNFM driver (generic)" in c
- Configure the already running instance:
- Execute the following command: docker exec -it `docker ps | grep nokiav2 | awk '{print $1}'` /bin/bash
+
- Edit /service/application.properties:
- - In this file, change the default values of the following keys to the correct values: cbamCatalogUrl, cbamLcnUrl, cbamKeyCloakBaseUrl, cbamUsername, cbamPassword, vnfmId
+ - In this file, change the default values of the following keys to the correct values: vnfmId
+
+ - Restart the VNFM service
+
+ - Execute the following command: ps -ef | grep java | \ No newline at end of file
diff --git a/nokiav2/docs/intro.rst b/nokiav2/docs/intro.rst
new file mode 100644
index 00000000..fb7678f9
--- /dev/null
+++ b/nokiav2/docs/intro.rst
@@ -0,0 +1,45 @@
+Introduction to ONAP with Nokia VNFM
+====================================
+
+Supported features
+------------------
+
+ - Use VF-C LCM as data source for VIM & VNFM information
+
+ - Use VF-C catalog as data source for VNF template artifacts
+
+ - Integrate with multiple VNFM instances
+
+ - VNF instantiation with VF-C API
+
+ - VNF termination with VF-C API
+
+ - VNF scaling with VF-C API
+
+ - VNF healing with VF-C API
+
+ - VNF on-boarding to VNFM (part of instantiation)
+
+ - Send LCN to VF-C of the following elements:
+
+ - VNFC
+
+ - virtual link (internal)
+
+ - connection point (internal & external)
+
+ - Use SDC as data source for VNF template artifacts
+
+ - Use AAI as data source for VIM & VNFM information
+
+ - Directly manipulate the following resource in A&AI
+
+ - generic VNF (may also be created previously)
+
+ - VNFC
+
+ - virtual server
+
+ - L3 networks
+
+ - logical interfaces \ No newline at end of file
diff --git a/nokiav2/docs/sample/aai.create.cloud.region.request.json b/nokiav2/docs/sample/aai.create.cloud.region.request.json
new file mode 100644
index 00000000..9aa5a06c
--- /dev/null
+++ b/nokiav2/docs/sample/aai.create.cloud.region.request.json
@@ -0,0 +1,12 @@
+{
+ "cloud-owner": "Nokia",
+ "cloud-region-id": "RegionOne",
+ "cloud-type": "openstack",
+ "owner-defined-type": "Nokia",
+ "cloud-region-version": "ocata",
+ "identity-url": "https://10.41.49.22:5000/v3",
+ "cloud-zone": "any",
+ "complex-name": "any",
+ "sriov-automation": false,
+ "cloud-extra-info": ""
+} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
index 23c2e4bf..40abab1a 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
@@ -16,21 +16,26 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia;
+import com.google.common.collect.Sets;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForVfc;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManagerForVfc;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Profile;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;
import static java.util.concurrent.Executors.newCachedThreadPool;
+import static com.google.common.collect.Sets.newHashSet;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
import static org.slf4j.LoggerFactory.getLogger;
@@ -50,6 +55,10 @@ public class NokiaSvnfmApplication {
systemFunctions().newSpringApplication(NokiaSvnfmApplication.class).run(args);
}
+ private static boolean isDirect(ConfigurableApplicationContext applicationContext) {
+ return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct");
+ }
+
/**
* Responsible for starting the self registration process after the servlet has been started
* and is ready to answer REST request
@@ -59,17 +68,22 @@ public class NokiaSvnfmApplication {
@Component
@Profile("!test")
public static class SelfRegistrationTrigger implements ApplicationListener<ApplicationReadyEvent> {
- private final SelfRegistrationManager selfRegistrationManager;
- private final JobManager jobManager;
+ private final SelfRegistrationManagerForSo selfRegistrationManagerForSo;
+ private final SelfRegistrationManagerForVfc selfRegistrationManagerForVfc;
+ private final JobManagerForSo jobManagerForSo;
+ private final JobManagerForVfc jobManagerForVfc;
+
/**
* Runs the registration process
*/
private ExecutorService executorService = newCachedThreadPool();
@Autowired
- SelfRegistrationTrigger(SelfRegistrationManager selfRegistrationManager, JobManager jobManager) {
- this.jobManager = jobManager;
- this.selfRegistrationManager = selfRegistrationManager;
+ SelfRegistrationTrigger(SelfRegistrationManagerForVfc selfRegistrationManagerForVfc, SelfRegistrationManagerForSo selfRegistrationManagerForSo, JobManagerForSo jobManagerForSo, JobManagerForVfc jobManagerForVfc) {
+ this.jobManagerForSo = jobManagerForSo;
+ this.jobManagerForVfc = jobManagerForVfc;
+ this.selfRegistrationManagerForVfc = selfRegistrationManagerForVfc;
+ this.selfRegistrationManagerForSo = selfRegistrationManagerForSo;
}
@Override
@@ -77,7 +91,11 @@ public class NokiaSvnfmApplication {
Callable<Boolean> singleRegistration = () -> {
logger.info("Self registration started");
try {
- selfRegistrationManager.register();
+ if (isDirect(contextRefreshedEvent.getApplicationContext())) {
+ selfRegistrationManagerForSo.register();
+ } else {
+ selfRegistrationManagerForVfc.register();
+ }
logger.info("Self registration finished");
} catch (RuntimeException e) {
logger.error("Self registration failed", e);
@@ -86,7 +104,7 @@ public class NokiaSvnfmApplication {
return true;
};
executorService.submit(() -> {
- while (!jobManager.isPreparingForShutDown()) {
+ while (!jobManagerForVfc.isPreparingForShutDown() && !jobManagerForSo.isPreparingForShutDown()) {
try {
executorService.submit(singleRegistration).get();
//registration successful
@@ -98,6 +116,7 @@ public class NokiaSvnfmApplication {
}
});
}
+
}
/**
@@ -108,21 +127,31 @@ public class NokiaSvnfmApplication {
@Component
@Profile("!test")
public static class SelfDeRegistrationTrigger implements ApplicationListener<ContextClosedEvent> {
- private final SelfRegistrationManager selfRegistrationManager;
- private final JobManager jobManager;
+ private final JobManagerForSo jobManagerForSo;
+ private final JobManagerForVfc jobManagerForVfc;
+ private final SelfRegistrationManagerForVfc selfRegistrationManagerForVfc;
+ private final SelfRegistrationManagerForSo selfRegistrationManagerForSo;
+
@Autowired
- SelfDeRegistrationTrigger(SelfRegistrationManager selfRegistrationManager, JobManager jobManager) {
- this.jobManager = jobManager;
- this.selfRegistrationManager = selfRegistrationManager;
+ SelfDeRegistrationTrigger(SelfRegistrationManagerForVfc selfRegistrationManager, SelfRegistrationManagerForSo selfRegistrationManagerForSo, JobManagerForSo jobManager, JobManagerForVfc jobManagerForVfc) {
+ this.jobManagerForSo = jobManager;
+ this.jobManagerForVfc = jobManagerForVfc;
+ this.selfRegistrationManagerForVfc = selfRegistrationManager;
+ this.selfRegistrationManagerForSo = selfRegistrationManagerForSo;
}
@Override
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
logger.info("Self de-registration started");
try {
- jobManager.prepareForShutdown();
- selfRegistrationManager.deRegister();
+ jobManagerForVfc.prepareForShutdown();
+ jobManagerForSo.prepareForShutdown();
+ if (Sets.newHashSet(contextClosedEvent.getApplicationContext().getEnvironment().getActiveProfiles()).contains("direct")) {
+ selfRegistrationManagerForSo.deRegister();
+ } else {
+ selfRegistrationManagerForVfc.deRegister();
+ }
} catch (RuntimeException e) {
logger.error("Self de-registration failed", e);
throw e;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java
index 87f56db2..0f908767 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java
@@ -33,6 +33,7 @@ public interface INotificationSender {
* @param operationExecution the executed operation that triggered the LCN
* @param affectedConnectionPoints the affected connection points during the operation
* @param vimId the identifier of the VIM in ONAP
+ * @param vnfmId the identifier of the VNFM
*/
- void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedConnectionPoints, String vimId);
+ void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedConnectionPoints, String vimId, String vnfmId);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java
index c659b91d..a32f59c4 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java
@@ -15,12 +15,12 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api;
+import java.util.Set;
import org.onap.vnfmdriver.model.VnfmInfo;
/**
* Responsible for providing information from the VNFM itself
*/
-@FunctionalInterface
public interface VnfmInfoProvider {
/**
@@ -28,4 +28,9 @@ public interface VnfmInfoProvider {
* @return the description of the VNFM
*/
VnfmInfo getVnfmInfo(String vnfmId);
+
+ /**
+ * @return the identifiers of the VNFMs that are managed by this driver
+ */
+ Set<String> getVnfms();
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java
index 38665877..4ec6717a 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java
@@ -15,8 +15,11 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+import com.google.common.base.Splitter;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
@@ -28,6 +31,7 @@ import org.springframework.core.env.Environment;
import static java.lang.Long.valueOf;
import static com.google.common.cache.CacheBuilder.newBuilder;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
@@ -52,6 +56,17 @@ public abstract class GenericExternalSystemInfoProvider extends IpMappingProvide
this.environment = environment;
}
+ public static VnfmUrls convert(VnfmInfo vnfmInfo) {
+ ArrayList<String> urls = Lists.newArrayList(Splitter.on(SEPARATOR).split(vnfmInfo.getUrl()));
+ return new VnfmUrls(urls.get(0), urls.get(1), urls.get(2), urls.get(3));
+ }
+
+ public static VnfmCredentials convertToCredentials(VnfmInfo vnfmInfo) {
+ ArrayList<String> userNames = Lists.newArrayList(Splitter.on(SEPARATOR).split(vnfmInfo.getUserName()));
+ ArrayList<String> passwords = Lists.newArrayList(Splitter.on(SEPARATOR).split(vnfmInfo.getPassword()));
+ return new VnfmCredentials(userNames.get(0), passwords.get(0), userNames.get(1), passwords.get(1));
+ }
+
/**
* After the Bean has been initialized the IP mapping and the VMFM cache is initialized
* It is done in this phase because the logic requires the the @Value anoted fields to
@@ -88,4 +103,5 @@ public abstract class GenericExternalSystemInfoProvider extends IpMappingProvide
* @return the description of the VNFM
*/
public abstract VnfmInfo queryVnfmInfoFromSource(String vnfmId);
+
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
index 1dc32209..17060d67 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
@@ -16,18 +16,23 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
import com.nokia.cbam.lcn.v32.api.SubscriptionsApi;
import com.nokia.cbam.lcn.v32.model.*;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
import org.onap.msb.model.MicroServiceFullInfo;
import org.onap.msb.model.MicroServiceInfo;
import org.onap.msb.model.Node;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.MultiException;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants;
+import org.onap.vnfmdriver.model.VnfmInfo;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
import static com.nokia.cbam.lcn.v32.model.SubscriptionAuthentication.TypeEnum.NONE;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
@@ -38,15 +43,15 @@ import static org.slf4j.LoggerFactory.getLogger;
/**
* Responsible for registering the driver in the core systems.
*/
-@Component
public class SelfRegistrationManager {
public static final String DRIVER_VERSION = "v1";
public static final String SERVICE_NAME = "NokiaSVNFM";
public static final String SWAGGER_API_DEFINITION = "self.swagger.json";
private static Logger logger = getLogger(SelfRegistrationManager.class);
- private final DriverProperties driverProperties;
private final MsbApiProvider msbApiProvider;
private final CbamRestApiProvider cbamRestApiProvider;
+ private final VnfmInfoProvider vnfmInfoProvider;
+ private final BiMap<String, String> vnfmIdToSubscriptionId = HashBiMap.create();
@Value("${driverMsbExternalIp}")
private String driverMsbExternalIp;
@Value("${driverVnfmExternalIp}")
@@ -55,11 +60,10 @@ public class SelfRegistrationManager {
private String driverPort;
private volatile boolean ready = false;
- @Autowired
- SelfRegistrationManager(DriverProperties driverProperties, MsbApiProvider msbApiProvider, CbamRestApiProvider cbamRestApiProvider) {
+ SelfRegistrationManager(VnfmInfoProvider vnfmInfoProvider, MsbApiProvider msbApiProvider, CbamRestApiProvider cbamRestApiProvider) {
this.cbamRestApiProvider = cbamRestApiProvider;
this.msbApiProvider = msbApiProvider;
- this.driverProperties = driverProperties;
+ this.vnfmInfoProvider = vnfmInfoProvider;
}
/**
@@ -67,11 +71,11 @@ public class SelfRegistrationManager {
*/
public void register() {
//the order is important (only publish it's existence after the subscription has been created)
- subscribeToLcn(driverProperties.getVnfmId());
+ subscribeToLcns();
try {
registerMicroService();
} catch (RuntimeException e) {
- deleteSubscription(driverProperties.getVnfmId());
+ deleteSubscriptions();
throw e;
}
ready = true;
@@ -98,7 +102,18 @@ public class SelfRegistrationManager {
throw buildFatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e);
}
}
- deleteSubscription(driverProperties.getVnfmId());
+ deleteSubscriptions();
+ }
+
+ /**
+ * Subscribes to LCN if not yet subscribed
+ *
+ * @param vnfmId the identifier of the VNFM
+ */
+ public void assureSubscription(String vnfmId) {
+ if (!vnfmIdToSubscriptionId.containsKey(vnfmId)) {
+ subscribeToLcn(vnfmId);
+ }
}
/**
@@ -108,15 +123,38 @@ public class SelfRegistrationManager {
return systemFunctions().loadFile(SWAGGER_API_DEFINITION);
}
+ /**
+ * @param subscriptionId the identifier of the subscription
+ * @return the identifier of the VNFM for the subscription
+ */
+ public String getVnfmId(String subscriptionId) {
+ return vnfmIdToSubscriptionId.inverse().get(subscriptionId);
+ }
+
private String getDriverVnfmUrl() {
- return "http://" + driverVnfmExternalIp + ":" + driverPort + DriverProperties.BASE_URL;
+ return "http://" + driverVnfmExternalIp + ":" + driverPort + Constants.BASE_URL;
+ }
+
+ private void deleteSubscriptions() {
+ Set<Exception> exceptions = new HashSet<>();
+ for (String vnfmId : vnfmIdToSubscriptionId.keySet()) {
+ try {
+ deleteSubscription(vnfmId);
+ } catch (Exception e) {
+ exceptions.add(e);
+ logger.warn("Unable to delete subscription for the " + vnfmId);
+ }
+ }
+ if (!exceptions.isEmpty()) {
+ throw new MultiException("Unable to delete some of the subscriptions", exceptions);
+ }
}
private void deleteSubscription(String vnfmId) {
logger.info("Deleting CBAM LCN subscription");
SubscriptionsApi lcnApi = cbamRestApiProvider.getCbamLcnApi(vnfmId);
try {
- String callbackUrl = getDriverVnfmUrl() + DriverProperties.LCN_URL;
+ String callbackUrl = getDriverVnfmUrl() + Constants.LCN_URL;
for (Subscription subscription : lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION).blockingFirst()) {
if (subscription.getCallbackUrl().equals(callbackUrl)) {
logger.info("Deleting subscription with {} identifier", subscription.getId());
@@ -131,7 +169,7 @@ public class SelfRegistrationManager {
private MicroServiceFullInfo registerMicroService() {
logger.info("Registering micro service");
MicroServiceInfo microServiceInfo = new MicroServiceInfo();
- microServiceInfo.setUrl(DriverProperties.BASE_URL);
+ microServiceInfo.setUrl(Constants.BASE_URL);
//the PATH should not be set
microServiceInfo.setProtocol(MicroServiceInfo.ProtocolEnum.REST);
microServiceInfo.setVisualRange(MicroServiceInfo.VisualRangeEnum._1);
@@ -151,14 +189,23 @@ public class SelfRegistrationManager {
}
}
+ private void subscribeToLcns() {
+ for (String vnfmId : vnfmInfoProvider.getVnfms()) {
+ subscribeToLcn(vnfmId);
+ }
+ }
+
private void subscribeToLcn(String vnfmId) {
- String callbackUrl = getDriverVnfmUrl() + DriverProperties.LCN_URL;
- logger.info("Subscribing to CBAM LCN {} with callback to {}", driverProperties.getCbamLcnUrl(), callbackUrl);
+ String callbackUrl = getDriverVnfmUrl() + Constants.LCN_URL;
+ VnfmInfo vnfmInfo = vnfmInfoProvider.getVnfmInfo(vnfmId);
+ VnfmUrls vnfmUrls = GenericExternalSystemInfoProvider.convert(vnfmInfo);
+ logger.info("Subscribing to CBAM LCN {} with callback to {}", vnfmUrls.getLcnUrl(), callbackUrl);
SubscriptionsApi lcnApi = cbamRestApiProvider.getCbamLcnApi(vnfmId);
try {
for (Subscription subscription : lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION).blockingFirst()) {
if (subscription.getCallbackUrl().equals(callbackUrl)) {
logger.warn("The subscription with {} identifier has the same callback URL", subscription.getId());
+ vnfmIdToSubscriptionId.put(vnfmId, subscription.getId());
return;
}
}
@@ -176,6 +223,7 @@ public class SelfRegistrationManager {
request.setAuthentication(subscriptionAuthentication);
Subscription createdSubscription = lcnApi.subscriptionsPost(request, NOKIA_LCN_API_VERSION).blockingFirst();
logger.info("Subscribed to LCN with {} identifier", createdSubscription.getId());
+ vnfmIdToSubscriptionId.put(vnfmId, createdSubscription.getId());
} catch (Exception e) {
throw buildFatalFailure(logger, "Unable to subscribe to CBAM LCN", e);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForSo.java
new file mode 100644
index 00000000..bffd444d
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForSo.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Responsible for registering the driver in the core systems.
+ */
+@Component
+public class SelfRegistrationManagerForSo extends SelfRegistrationManager {
+ @Autowired
+ SelfRegistrationManagerForSo(AAIExternalSystemInfoProvider vnfmInfoProvider, MsbApiProvider msbApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) {
+ super(vnfmInfoProvider, msbApiProvider, cbamRestApiProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForVfc.java
new file mode 100644
index 00000000..c550e887
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManagerForVfc.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForVfc;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Responsible for registering the driver in the core systems.
+ */
+@Component
+public class SelfRegistrationManagerForVfc extends SelfRegistrationManager {
+ @Autowired
+ SelfRegistrationManagerForVfc(VfcExternalSystemInfoProvider vnfmInfoProvider, MsbApiProvider msbApiProvider, CbamRestApiProviderForVfc cbamRestApiProvider) {
+ super(vnfmInfoProvider, msbApiProvider, cbamRestApiProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmCredentials.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmCredentials.java
new file mode 100644
index 00000000..270d004c
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmCredentials.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import static com.google.common.hash.Hashing.sha512;
+
+/**
+ * Describes the VNFM credentials
+ */
+public class VnfmCredentials {
+ private final String username;
+ private final String password;
+ private final String clientId;
+ private final String clientSecret;
+
+ /**
+ * @param username the username for the VNFM
+ * @param password the password for the VNFM
+ * @param clientId the client identifier
+ * @param clientSecret the client secret
+ */
+ VnfmCredentials(String username, String password, String clientId, String clientSecret) {
+ this.username = username;
+ this.password = password;
+ this.clientId = clientId;
+ this.clientSecret = clientSecret;
+ }
+
+ /**
+ * @return the username for the VNFM
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @return the password for the VNFM
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @return the client identifier
+ */
+ public String getClientId() {
+ return clientId;
+ }
+
+ /**
+ * @return the client secret
+ */
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ @Override
+ public String toString() {
+ return "VnfmCredentials{" +
+ "username='" + username + '\'' +
+ ", password='" + sha512().hashBytes(password.getBytes()).toString() + '\'' +
+ ", clientId='" + clientId + '\'' +
+ ", clientSecret='" + sha512().hashBytes(clientSecret.getBytes()).toString() + '\'' +
+ '}';
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmUrls.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmUrls.java
new file mode 100644
index 00000000..04088459
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmUrls.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+/**
+ * Describes the VNFM URLs
+ */
+public class VnfmUrls {
+ private final String lcmUrl;
+ private final String lcnUrl;
+ private final String authUrl;
+ private final String catalogUrl;
+
+ /**
+ * @param authUrl the authentication server URL of the VNFM
+ * @param lcmUrl the LCM URL of the VNFM
+ * @param lcnUrl the LCN URL of the VNFM
+ * @param catalogUrl the catalog URL of the VNFM
+ */
+ VnfmUrls(String authUrl, String lcmUrl, String lcnUrl, String catalogUrl) {
+ this.lcmUrl = lcmUrl;
+ this.lcnUrl = lcnUrl;
+ this.authUrl = authUrl;
+ this.catalogUrl = catalogUrl;
+ }
+
+ /**
+ * @return the LCM URL of the VNFM
+ */
+ public String getLcmUrl() {
+ return lcmUrl;
+ }
+
+ /**
+ * @return the LCN URL of the VNFM
+ */
+ public String getLcnUrl() {
+ return lcnUrl;
+ }
+
+ /**
+ * @return the authentication server URL of the VNFM
+ */
+ public String getAuthUrl() {
+ return authUrl;
+ }
+
+ /**
+ * @return the catalog URL of the VNFM
+ */
+ public String getCatalogUrl() {
+ return catalogUrl;
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java
index 81834bcb..fb4de3f2 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java
@@ -15,18 +15,21 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct;
+import java.util.Set;
import org.onap.aai.model.EsrSystemInfo;
import org.onap.aai.model.EsrVnfm;
+import org.onap.aai.model.EsrVnfmList;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vnfmdriver.model.VimInfo;
import org.onap.vnfmdriver.model.VnfmInfo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Sets.newHashSet;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getRegionName;
@@ -36,7 +39,7 @@ import static org.slf4j.LoggerFactory.getLogger;
* Responsible for providing information related to the VNFM from VF-C source
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
+@Qualifier("so")
public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProvider {
private static Logger logger = getLogger(AAIExternalSystemInfoProvider.class);
private final AAIRestApiProvider aaiRestApiProvider;
@@ -114,4 +117,10 @@ public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProv
vnfmInfo.setVnfmId(vnfmInAai.getVnfmId());
return vnfmInfo;
}
+
+ @Override
+ public Set<String> getVnfms() {
+ EsrVnfmList esrVnfmList = aaiRestApiProvider.getExternalSystemApi().getExternalSystemEsrVnfmList().blockingFirst();
+ return newHashSet(transform(esrVnfmList.getEsrVnfm(), esr -> esr.getVnfmId()));
+ }
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java
index 08bf2c41..ed437841 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java
@@ -16,12 +16,13 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct;
import com.google.common.annotations.VisibleForTesting;
-import okhttp3.Credentials;
+import java.util.UUID;
import okhttp3.Request;
import org.onap.aai.ApiClient;
import org.onap.aai.api.CloudInfrastructureApi;
import org.onap.aai.api.ExternalSystemApi;
import org.onap.aai.api.NetworkApi;
+import org.onap.aai.auth.HttpBasicAuth;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.MsbApiProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -76,14 +77,22 @@ public class AAIRestApiProvider {
apiClient.getOkBuilder().sslSocketFactory(aaiSecurityProvider.buildSSLSocketFactory(), aaiSecurityProvider.buildTrustManager());
apiClient.getOkBuilder().hostnameVerifier(aaiSecurityProvider.buildHostnameVerifier());
apiClient.getOkBuilder().addInterceptor(chain -> {
- Request request = chain.request().newBuilder().addHeader("X-FromAppId", SERVICE_NAME).build();
+ Request request = chain.request().newBuilder()
+ .addHeader("X-FromAppId", SERVICE_NAME)
+ //backward incompatibe API change in Beijing release
+ .addHeader("X-TransactionId", UUID.randomUUID().toString())
+ .addHeader("Accept", "application/json").
+ build();
return chain.proceed(request);
});
- apiClient.getOkBuilder().authenticator((route, response) -> {
- String credential = Credentials.basic(aaiUsername, aaiPassword);
- return response.request().newBuilder().header("Authorization", credential).build();
- });
+ HttpBasicAuth httpBasicAuth = new HttpBasicAuth();
+ httpBasicAuth.setCredentials(aaiUsername, aaiPassword);
+ apiClient.addAuthorization("basic", httpBasicAuth);
String url = msbApiProvider.getMicroServiceUrl(service.getServiceName(), "v11");
+ //the returned swagger schema is inconsistent with base URL
+ url = url.replaceAll("/external-system$", "");
+ url = url.replaceAll("/cloud-infrastructure$", "");
+ url = url.replaceAll("/network$", "");
if (!url.endsWith("/")) {
url = url + "/";
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/GrantlessGrantManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/GrantlessGrantManager.java
index a113405a..9dd35687 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/GrantlessGrantManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/GrantlessGrantManager.java
@@ -18,12 +18,11 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct;
import com.nokia.cbam.lcm.v32.model.VnfInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IGrantManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vnfmdriver.model.GrantVNFResponseVim;
import org.onap.vnfmdriver.model.VnfHealRequest;
import org.onap.vnfmdriver.model.VnfScaleRequest;
import org.slf4j.Logger;
-import org.springframework.context.annotation.Conditional;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import static org.slf4j.LoggerFactory.getLogger;
@@ -32,7 +31,7 @@ import static org.slf4j.LoggerFactory.getLogger;
* Responsible for handling granting before the execution of a VNF operation in case of direct integration
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
+@Qualifier("so")
public class GrantlessGrantManager implements IGrantManager {
private static Logger logger = getLogger(GrantlessGrantManager.class);
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java
index a7e6e404..b2a82fa6 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java
@@ -25,12 +25,9 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IPackageProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.MsbApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;
@@ -51,23 +48,20 @@ import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
* Handles authentication and mandatory parameters.
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
public class SdcPackageProvider implements IPackageProvider {
private static final String SDC_MSB_NAME = "sdc";
private static final String SDC_MSB_VERSION = "v1";
private static final String GET_PACKAGE_URL = "%s/sdc/v1/catalog/resources/%s/toscaModel";
private static Logger logger = getLogger(SdcPackageProvider.class);
private final MsbApiProvider msbApiProvider;
- private final DriverProperties driverProperties;
@Value("${sdcUsername}")
private String sdcUsername;
@Value("${sdcPassword}")
private String sdcPassword;
@Autowired
- SdcPackageProvider(MsbApiProvider msbApiProvider, DriverProperties driverProperties) {
+ SdcPackageProvider(MsbApiProvider msbApiProvider) {
this.msbApiProvider = msbApiProvider;
- this.driverProperties = driverProperties;
}
@Override
@@ -77,7 +71,7 @@ public class SdcPackageProvider implements IPackageProvider {
CloseableHttpClient client = systemFunctions().getHttpClient();
HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE);
- httpget.setHeader("X-ECOMP-InstanceID", driverProperties.getVnfmId());
+ httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME);
httpget.setHeader("X-FromAppId", SERVICE_NAME);
CloseableHttpResponse response = client.execute(httpget);
HttpEntity entity = response.getEntity();
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java
index 86517435..e419407d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java
@@ -23,14 +23,14 @@ import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
+import static java.util.Optional.empty;
+
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.tryFind;
import static com.nokia.cbam.lcm.v32.model.ChangeType.*;
@@ -43,7 +43,6 @@ import static org.springframework.util.StringUtils.isEmpty;
* Responsible for providing information related to the VNFM from VF-C source
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
public class AAINotificationProcessor implements INotificationSender {
private static Logger logger = getLogger(AAINotificationProcessor.class);
private final GenericVnfManager genericVnfManager;
@@ -62,9 +61,9 @@ public class AAINotificationProcessor implements INotificationSender {
}
@Override
- public void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedConnectionPoints, String vimId) {
+ public void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedConnectionPoints, String vimId, String vnfmId) {
boolean inMaintenance = STARTED.equals(receivedNotification.getStatus());
- genericVnfManager.createOrUpdate(receivedNotification.getVnfInstanceId(), inMaintenance);
+ genericVnfManager.createOrUpdate(receivedNotification.getVnfInstanceId(), inMaintenance, vnfmId, empty());
addOrUpdateVls(receivedNotification, vimId);
addOrUpdateVnfcs(receivedNotification, vimId, inMaintenance);
processCps(receivedNotification, affectedConnectionPoints, vimId, inMaintenance);
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java
index ee7a3feb..16800fbd 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java
@@ -24,7 +24,6 @@ import org.onap.aai.model.Relationship;
import org.onap.aai.model.RelationshipData;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
import org.slf4j.Logger;
import static com.google.common.collect.Iterables.find;
@@ -36,12 +35,10 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR
abstract class AbstractManager {
protected final AAIRestApiProvider aaiRestApiProvider;
protected final CbamRestApiProvider cbamRestApiProvider;
- protected final DriverProperties driverProperties;
- AbstractManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
+ AbstractManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider) {
this.aaiRestApiProvider = aaiRestApiProvider;
this.cbamRestApiProvider = cbamRestApiProvider;
- this.driverProperties = driverProperties;
}
/**
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
index 52e9151d..953eda95 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
@@ -18,17 +18,17 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification;
import com.nokia.cbam.lcm.v32.model.VnfInfo;
import java.util.ArrayList;
import java.util.NoSuchElementException;
+import java.util.Optional;
import org.onap.aai.model.GenericVnf;
import org.onap.aai.model.Relationship;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager.SERVICE_NAME;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
@@ -36,14 +36,13 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.sys
* Responsible for managing the {@link GenericVnf} in AAI
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
-class GenericVnfManager extends AbstractManager {
+public class GenericVnfManager extends AbstractManager {
private static final long MAX_MS_TO_WAIT_FOR_VNF_TO_APPEAR = 30 * 1000L;
private static Logger logger = org.slf4j.LoggerFactory.getLogger(GenericVnfManager.class);
@Autowired
- GenericVnfManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ GenericVnfManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
static Relationship linkTo(String vnfId) {
@@ -54,43 +53,54 @@ class GenericVnfManager extends AbstractManager {
return relationship;
}
+ private static Relationship linkToNs(String nsId) {
+ Relationship relationship = new Relationship();
+ relationship.setRelatedTo("service-instance");
+ relationship.setRelationshipData(new ArrayList<>());
+ relationship.getRelationshipData().add(buildRelationshipData("service-instance.service-instance-id", nsId));
+ return relationship;
+ }
+
@Override
protected Logger getLogger() {
return logger;
}
- void createOrUpdate(String vnfId, boolean inMaintenance) {
+ public void createOrUpdate(String vnfId, boolean inMaintenance, String vnfmId, Optional<String> nsId) {
try {
GenericVnf vnf = waitForVnfToAppearInAai(vnfId);
- updateFields(vnf, vnfId, inMaintenance);
+ updateFields(vnf, vnfId, inMaintenance, vnfmId, nsId);
} catch (NoSuchElementException e) {
try {
logger.warn("The VNF with " + vnfId + " identifier did not appear in time", e);
- updateFields(new GenericVnf(), vnfId, inMaintenance);
+ updateFields(new GenericVnf(), vnfId, inMaintenance, vnfmId, nsId);
} catch (Exception e2) {
logger.warn("The VNF with " + vnfId + " identifier has been created since after the maximal wait for VNF to appear timeout", e2);
//the VNF might have been created since the last poll
- updateFields(getExistingVnf(vnfId), vnfId, inMaintenance);
+ updateFields(getExistingVnf(vnfId), vnfId, inMaintenance, vnfmId, nsId);
}
}
}
- private GenericVnf getExistingVnf(String vnfId) {
- return aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfId, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
- }
-
- private void updateFields(GenericVnf vnf, String vnfId, boolean inMaintenance) {
+ private void updateFields(GenericVnf vnf, String vnfId, boolean inMaintenance, String vnfmId, Optional<String> nsId) {
try {
- VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(driverProperties.getVnfmId()).vnfsVnfInstanceIdGet(vnfId, CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst();
+ VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst();
vnf.setVnfName(vnfInfo.getName());
} catch (RuntimeException e) {
throw buildFatalFailure(logger, "Unable to query VNF with " + vnfId + " identifier from CBAM", e);
}
vnf.setVnfId(vnfId);
vnf.setInMaint(inMaintenance);
+ vnf.setNfType(SERVICE_NAME);
//FIXME whould be good to know if this parameter is relevant or not? (mandatory)
vnf.setVnfType("NokiaVNF");
vnf.setIsClosedLoopDisabled(inMaintenance);
+ if (vnf.getRelationshipList() == null) {
+ vnf.setRelationshipList(new ArrayList<>());
+ }
+ if (nsId.isPresent()) {
+ addSingletonRelation(vnf.getRelationshipList(), linkTo(nsId.get()));
+ }
aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst();
}
@@ -107,4 +117,7 @@ class GenericVnfManager extends AbstractManager {
throw new NoSuchElementException();
}
+ private GenericVnf getExistingVnf(String vnfId) {
+ return aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfId, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ }
} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java
index f1c47d5b..04f601d5 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java
@@ -21,12 +21,9 @@ import java.util.ArrayList;
import org.onap.aai.model.L3Network;
import org.onap.aai.model.Relationship;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
@@ -37,13 +34,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge
* Responsible for managing the {@link L3Network} in AAI
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
class L3NetworkManager extends AbstractManager {
private static Logger logger = org.slf4j.LoggerFactory.getLogger(L3NetworkManager.class);
@Autowired
- L3NetworkManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ L3NetworkManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
@Override
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java
index 37a6993a..6e37cd1e 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java
@@ -21,13 +21,10 @@ import org.onap.aai.model.L3InterfaceIpv4AddressList;
import org.onap.aai.model.L3InterfaceIpv6AddressList;
import org.onap.aai.model.LInterface;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import static java.lang.String.format;
@@ -39,13 +36,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge
* Responsible for managing the {@link LInterface} in AAI
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
class LInterfaceManager extends AbstractManager {
private static Logger logger = org.slf4j.LoggerFactory.getLogger(LInterfaceManager.class);
@Autowired
- LInterfaceManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ LInterfaceManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
static String buildUrl(String vimId, ReportedAffectedCp affectedCp) {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java
index db65d2f1..80d7eb7d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java
@@ -19,12 +19,9 @@ import io.reactivex.Observable;
import java.util.ArrayList;
import org.onap.aai.model.Vnfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import static com.google.common.base.Splitter.on;
@@ -35,13 +32,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR
* Responsible for managing {@link Vnfc} in AAI
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
public class VnfcManager extends AbstractManager {
private static Logger logger = org.slf4j.LoggerFactory.getLogger(VnfcManager.class);
@Autowired
- VnfcManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ VnfcManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
private static String buildId(String vnfId, String cbamVnfcId) {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java
index 6aeefd77..05f5f6f5 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java
@@ -27,13 +27,10 @@ import org.onap.aai.model.Relationship;
import org.onap.aai.model.Volume;
import org.onap.aai.model.Vserver;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import static com.google.common.collect.Iterables.find;
@@ -45,13 +42,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge
* Responsible for managing {@link Vserver} in AAI
*/
@Component
-@Conditional(value = Conditions.UseForDirect.class)
class VserverManager extends AbstractManager {
private static Logger logger = LoggerFactory.getLogger(AbstractManager.class);
@Autowired
- VserverManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ VserverManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
static Relationship linkTo(String vimId, String tenantId, String serverProviderId) {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
index 2d2f0159..b368fa1f 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
@@ -22,11 +22,10 @@ import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.GenericVnfManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.AdditionalParameters;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.*;
import org.onap.vnfmadapter.so.model.*;
import org.onap.vnfmdriver.model.ExtVirtualLinkInfo;
import org.onap.vnfmdriver.model.*;
@@ -35,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import static java.util.Optional.of;
+import static java.util.Optional.ofNullable;
import static com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.VnfcManager.buildCbamId;
@@ -53,13 +53,16 @@ public class SoLifecycleManager {
private final VimInfoProvider vimInfoProvider;
private final CbamRestApiProvider cbamRestApiProvider;
private final JobManager jobManager;
+ private final GenericVnfManager genericVnfManager;
+
@Autowired
- SoLifecycleManager(LifecycleManager lifecycleManager, VimInfoProvider vimInfoProvider, CbamRestApiProvider cbamRestApiProvider, JobManager jobManager) {
+ SoLifecycleManager(LifecycleManagerForSo lifecycleManager, AAIExternalSystemInfoProvider vimInfoProvider, CbamRestApiProviderForSo cbamRestApiProvider, JobManagerForSo jobManager, GenericVnfManager genericVnfManager) {
this.lifecycleManager = lifecycleManager;
this.vimInfoProvider = vimInfoProvider;
this.cbamRestApiProvider = cbamRestApiProvider;
this.jobManager = jobManager;
+ this.genericVnfManager = genericVnfManager;
}
/**
@@ -73,6 +76,7 @@ public class SoLifecycleManager {
SoVnfCreationResponse response = new SoVnfCreationResponse();
LifecycleManager.VnfCreationResult result = lifecycleManager.create(vnfmId, request.getCsarId(), request.getName(), request.getDescription());
response.setVnfId(result.getVnfInfo().getId());
+ genericVnfManager.createOrUpdate(response.getVnfId(), false, vnfmId, ofNullable(request.getNsId()));
return response;
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java
index eb8e1f65..a93b97a0 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java
@@ -15,16 +15,18 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc;
+import java.util.Set;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vnfmdriver.model.VimInfo;
import org.onap.vnfmdriver.model.VnfmInfo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import static com.google.common.collect.Sets.newHashSet;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
@@ -32,10 +34,12 @@ import static org.slf4j.LoggerFactory.getLogger;
* Responsible for providing information related to the VNFM from VF-C source
*/
@Component
-@Conditional(value = Conditions.UseForVfc.class)
+@Qualifier("vfc")
public class VfcExternalSystemInfoProvider extends GenericExternalSystemInfoProvider {
private static Logger logger = getLogger(VfcExternalSystemInfoProvider.class);
private final VfcRestApiProvider vfcRestApiProvider;
+ @Value("${vnfmId}")
+ private String vnfmId;
@Autowired
VfcExternalSystemInfoProvider(Environment environment, VfcRestApiProvider vfcRestApiProvider) {
@@ -60,4 +64,10 @@ public class VfcExternalSystemInfoProvider extends GenericExternalSystemInfoProv
throw buildFatalFailure(logger, "Unable to query VIM from VF-C with " + vimId + " identifier", e);
}
}
+
+ @Override
+ public Set<String> getVnfms() {
+ //FIXME in the Casablanca release add API to VF-C to be able to list VNFMs VFC-886 task
+ return newHashSet(vnfmId);
+ }
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java
index 7b985c84..c2ba4642 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java
@@ -25,13 +25,13 @@ import com.nokia.cbam.lcm.v32.model.VnfInfo;
import com.nokia.cbam.lcm.v32.model.VnfcResourceInfo;
import java.util.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IGrantManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForVfc;
import org.onap.vnfmdriver.model.*;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;
@@ -46,7 +46,6 @@ import static org.slf4j.LoggerFactory.getLogger;
* Responsible for handling granting before the execution of a VNF operation
*/
@Component
-@Conditional(value = Conditions.UseForVfc.class)
public class VfcGrantManager implements IGrantManager {
private static Logger logger = getLogger(VfcGrantManager.class);
private final CatalogManager catalogManager;
@@ -54,7 +53,7 @@ public class VfcGrantManager implements IGrantManager {
private final VfcRestApiProvider vfcRestApiProvider;
@Autowired
- VfcGrantManager(CatalogManager catalogManager, CbamRestApiProvider cbamRestApiProvider, VfcRestApiProvider vfcRestApiProvider) {
+ VfcGrantManager(CatalogManagerForVfc catalogManager, CbamRestApiProviderForVfc cbamRestApiProvider, VfcRestApiProvider vfcRestApiProvider) {
this.catalogManager = catalogManager;
this.cbamRestApiProvider = cbamRestApiProvider;
this.vfcRestApiProvider = vfcRestApiProvider;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java
index 65cef408..b44c1531 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java
@@ -22,15 +22,12 @@ import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
import java.util.ArrayList;
import java.util.Optional;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp;
import org.onap.vnfmdriver.model.*;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import static java.util.Optional.of;
@@ -46,20 +43,17 @@ import static org.slf4j.LoggerFactory.getLogger;
* Responsible for sending notifications to VF-C
*/
@Component
-@Conditional(value = Conditions.UseForVfc.class)
public class VfcNotificationSender implements INotificationSender {
private static Logger logger = getLogger(VfcNotificationSender.class);
- private final DriverProperties driverProperties;
private final VfcRestApiProvider vfcRestApiProvider;
@Autowired
- VfcNotificationSender(DriverProperties driverProperties, VfcRestApiProvider vfcRestApiProvider) {
- this.driverProperties = driverProperties;
+ VfcNotificationSender(VfcRestApiProvider vfcRestApiProvider) {
this.vfcRestApiProvider = vfcRestApiProvider;
}
@Override
- public void processNotification(VnfLifecycleChangeNotification recievedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedCps, String vimId) {
+ public void processNotification(VnfLifecycleChangeNotification recievedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedCps, String vimId, String vnfmId) {
VNFLCMNotification notificationToSend = new VNFLCMNotification();
notificationToSend.setJobId(extractOnapJobId(operationExecution.getOperationParams()));
notificationToSend.setOperation(getOperation(operationExecution, recievedNotification.getOperation()));
@@ -72,15 +66,15 @@ public class VfcNotificationSender implements INotificationSender {
} else {
notificationToSend.setStatus(VnfLcmNotificationStatus.START);
}
- sendNotification(notificationToSend);
+ sendNotification(vnfmId, notificationToSend);
}
- private void sendNotification(VNFLCMNotification notification) {
+ private void sendNotification(String vnfmId, VNFLCMNotification notification) {
try {
if (logger.isInfoEnabled()) {
logger.info("Sending LCN: {}", new Gson().toJson(notification));
}
- vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(driverProperties.getVnfmId(), notification.getVnfInstanceId(), notification);
+ vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(vnfmId, notification.getVnfInstanceId(), notification);
} catch (Exception e) {
throw buildFatalFailure(logger, "Unable to send LCN to VF-C", e);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java
index 5831d9b5..03fa3f18 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java
@@ -28,12 +28,10 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IPackageProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.IpMappingProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vfccatalog.api.VnfpackageApi;
import org.onap.vfccatalog.model.VnfPkgDetailInfo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
@@ -45,7 +43,6 @@ import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
* Retrieves a package from VF-C
*/
@Component
-@Conditional(value = Conditions.UseForVfc.class)
public class VfcPackageProvider implements IPackageProvider {
private static Logger logger = getLogger(VfcPackageProvider.class);
private final VfcRestApiProvider restApiProvider;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java
index c2473aae..5c9dc543 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java
@@ -17,19 +17,16 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc;
import com.google.common.annotations.VisibleForTesting;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.MsbApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions;
import org.onap.vfccatalog.api.VnfpackageApi;
import org.onap.vnfmdriver.ApiClient;
import org.onap.vnfmdriver.api.NslcmApi;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
/**
* Responsible for providing access to VF-C REST APIs
*/
@Component
-@Conditional(value = Conditions.UseForVfc.class)
public class VfcRestApiProvider {
static final String NSLCM_API_SERVICE_NAME = "nslcm";
static final String NSLCM_API_VERION = "v1";
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
index da07ef25..5ecd884c 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpHeaders.*;
import static org.springframework.http.HttpStatus.OK;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
index a3be0636..736735e1 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
@@ -17,7 +17,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManagerForVfc;
import org.onap.vnfmdriver.model.*;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,7 +32,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import static javax.servlet.http.HttpServletResponse.SC_CREATED;
import static java.util.Optional.empty;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@@ -48,7 +50,7 @@ public class LcmApi {
private final JobManager jobManager;
@Autowired
- LcmApi(LifecycleManager lifecycleManager, JobManager jobManager) {
+ LcmApi(LifecycleManagerForVfc lifecycleManager, JobManagerForVfc jobManager) {
this.lifecycleManager = lifecycleManager;
this.jobManager = jobManager;
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcnApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcnApi.java
index d11226b0..d9034ce3 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcnApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcnApi.java
@@ -18,6 +18,8 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -25,8 +27,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.LCN_URL;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.LCN_URL;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@@ -40,11 +42,13 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RequestMapping(value = BASE_URL)
public class LcnApi {
private static Logger logger = getLogger(LcnApi.class);
- private final LifecycleChangeNotificationManager lcnManager;
+ private final LifecycleChangeNotificationManager lifecycleChangeNotificationManagerForSo;
+ private final LifecycleChangeNotificationManager lifecycleChangeNotificationManagerForVfc;
@Autowired
- LcnApi(LifecycleChangeNotificationManager lcnManager) {
- this.lcnManager = lcnManager;
+ LcnApi(LifecycleChangeNotificationManagerForSo lifecycleManagerForSo, LifecycleChangeNotificationManagerForVfc lifecycleManagerForVfc) {
+ this.lifecycleChangeNotificationManagerForSo = lifecycleManagerForSo;
+ this.lifecycleChangeNotificationManagerForVfc = lifecycleManagerForVfc;
}
/**
@@ -66,6 +70,7 @@ public class LcnApi {
@ResponseStatus(code = NO_CONTENT)
public void handleLcn(@RequestBody VnfLifecycleChangeNotification lcn) {
logger.info("REST: handle LCN");
- lcnManager.handleLcn(lcn);
+ //FIXME fork between where the VNF is managed
+ lifecycleChangeNotificationManagerForVfc.handleLcn(lcn);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
index f3b4a1e6..eb6c289f 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
@@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import static javax.servlet.http.HttpServletResponse.SC_CREATED;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.*;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SwaggerApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SwaggerApi.java
index 51423ae8..969467dd 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SwaggerApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SwaggerApi.java
@@ -18,13 +18,14 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForVfc;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpHeaders.CONTENT_LENGTH;
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
@@ -38,10 +39,11 @@ import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RequestMapping(value = BASE_URL)
public class SwaggerApi {
private static Logger logger = getLogger(SwaggerApi.class);
+ //FIXME this should not depened on self registration manager
private final SelfRegistrationManager selfRegistrationManager;
@Autowired
- SwaggerApi(SelfRegistrationManager selfRegistrationManager) {
+ SwaggerApi(SelfRegistrationManagerForVfc selfRegistrationManager) {
this.selfRegistrationManager = selfRegistrationManager;
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/Conditions.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/Conditions.java
deleted file mode 100644
index d27f4be1..00000000
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/Conditions.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring;
-
-import com.google.common.collect.Sets;
-import java.util.HashSet;
-import java.util.Set;
-import org.springframework.context.annotation.Condition;
-import org.springframework.context.annotation.ConditionContext;
-import org.springframework.core.type.AnnotatedTypeMetadata;
-
-import static com.google.common.collect.Sets.newHashSet;
-
-/**
- * Collects the possibilities of sources
- */
-public class Conditions {
- private static final String USE_DIRECT_INTEGRATION = "direct";
-
- private Conditions() {
- //use static way
- }
-
- /**
- * Represents the condition for using VF-C
- */
- public static class UseForVfc implements Condition {
- private static Set<Condition> getAllSources() {
- return newHashSet(new UseForVfc(), new UseForDirect());
- }
-
- @Override
- public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean anyOtherSourceAvailable = false;
- for (Condition condition : UseForVfc.getAllSources()) {
- if (!(condition instanceof UseForVfc) && condition.matches(conditionContext, annotatedTypeMetadata)) {
- anyOtherSourceAvailable = true;
- }
- }
- return !anyOtherSourceAvailable;
- }
- }
-
- /**
- * Represents the condition for using ONAP components directly
- */
- public static class UseForDirect implements Condition {
- @Override
- public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
- HashSet<String> activeProfiles = Sets.newHashSet(conditionContext.getEnvironment().getActiveProfiles());
- return activeProfiles.contains(USE_DIRECT_INTEGRATION);
- }
- }
-}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiException.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiException.java
new file mode 100644
index 00000000..ab7f909a
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiException.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util;
+
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+/**
+ * The collects multiple exceptions into a single exception
+ */
+public class MultiException extends RuntimeException {
+
+ private final List<Exception> causes;
+
+ /**
+ * @param msg the message of the collection of exceptions
+ * @param causes the causes of the exception
+ */
+ public MultiException(String msg, Exception... causes) {
+ super(msg);
+ this.causes = newArrayList(causes);
+ }
+
+ /**
+ * @param msg the message of the collection of exceptions
+ * @param causes the causes of the exception
+ */
+ public MultiException(String msg, Iterable<Exception> causes) {
+ super(msg);
+ this.causes = newArrayList(causes);
+ }
+
+ /**
+ * @return the causes of the exception
+ */
+ public List<Exception> getCauses() {
+ return causes;
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
index 6283cfbc..7908d2e4 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
@@ -30,8 +30,6 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IPackageProvider;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import static com.google.common.base.Splitter.on;
import static com.google.common.collect.Iterables.filter;
@@ -47,7 +45,6 @@ import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
* - the VNF package is uploaded as part of the instantiation
* - the VNF package is not deleted after VNF deletion
*/
-@Component
public class CatalogManager {
/**
* The location of the CBAM package within the ONAP package
@@ -59,7 +56,6 @@ public class CatalogManager {
private final CbamRestApiProvider cbamRestApiProvider;
private final IPackageProvider packageProvider;
- @Autowired
CatalogManager(CbamRestApiProvider cbamRestApiProvider, IPackageProvider packageProvider) {
this.cbamRestApiProvider = cbamRestApiProvider;
this.packageProvider = packageProvider;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForSo.java
new file mode 100644
index 00000000..93d6d03a
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForSo.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CatalogManagerForSo extends CatalogManager {
+
+ @Autowired
+ CatalogManagerForSo(CbamRestApiProviderForSo cbamRestApiProvider, SdcPackageProvider packageProvider) {
+ super(cbamRestApiProvider, packageProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForVfc.java
new file mode 100644
index 00000000..e28dfb4f
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManagerForVfc.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcPackageProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CatalogManagerForVfc extends CatalogManager {
+
+ @Autowired
+ CatalogManagerForVfc(CbamRestApiProviderForVfc cbamRestApiProvider, VfcPackageProvider packageProvider) {
+ super(cbamRestApiProvider, packageProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProvider.java
index de850da6..cda091c0 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProvider.java
@@ -23,32 +23,21 @@ import com.nokia.cbam.lcm.v32.api.VnfsApi;
import com.nokia.cbam.lcn.v32.api.SubscriptionsApi;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
import org.onap.vnfmdriver.model.VnfmInfo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
+
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider.convert;
/**
* Responsible for providing client to access CBAM REST API
*/
-@Component
public class CbamRestApiProvider {
public static final String NOKIA_LCN_API_VERSION = "3.2";
public static final String NOKIA_LCM_API_VERSION = "3.2";
public static final String AUTH_NAME = "test";
- private final DriverProperties driverProperties;
private final CbamTokenProvider tokenProvider;
private final VnfmInfoProvider vnfmInfoProvider;
private final CbamSecurityProvider cbamSecurityProvider;
- @Value("${cbamKeyCloakBaseUrl}")
- private String cbamKeyCloakBaseUrl;
- @Value("${cbamUsername}")
- private String username;
- @Value("${cbamPassword}")
- private String password;
- @Autowired
- public CbamRestApiProvider(DriverProperties driverProperties, CbamTokenProvider cbamTokenProvider, VnfmInfoProvider vnfmInfoProvider, CbamSecurityProvider cbamSecurityProvider) {
- this.driverProperties = driverProperties;
+ CbamRestApiProvider(CbamTokenProvider cbamTokenProvider, VnfmInfoProvider vnfmInfoProvider, CbamSecurityProvider cbamSecurityProvider) {
this.tokenProvider = cbamTokenProvider;
this.vnfmInfoProvider = vnfmInfoProvider;
this.cbamSecurityProvider = cbamSecurityProvider;
@@ -92,7 +81,7 @@ public class CbamRestApiProvider {
apiClient.getOkBuilder().sslSocketFactory(cbamSecurityProvider.buildSSLSocketFactory(), cbamSecurityProvider.buildTrustManager());
apiClient.getOkBuilder().hostnameVerifier(cbamSecurityProvider.buildHostnameVerifier());
apiClient.addAuthorization(AUTH_NAME, tokenProvider.getToken(vnfmId));
- apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl(driverProperties.getCbamLcnUrl()));
+ apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl(convert(vnfmInfoProvider.getVnfmInfo(vnfmId)).getLcnUrl()));
return apiClient;
}
@@ -102,7 +91,7 @@ public class CbamRestApiProvider {
apiClient.getOkBuilder().sslSocketFactory(cbamSecurityProvider.buildSSLSocketFactory(), cbamSecurityProvider.buildTrustManager());
apiClient.getOkBuilder().hostnameVerifier(cbamSecurityProvider.buildHostnameVerifier());
apiClient.addAuthorization(AUTH_NAME, tokenProvider.getToken(vnfmId));
- apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl(driverProperties.getCbamCatalogUrl()));
+ apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl(convert(vnfmInfoProvider.getVnfmInfo(vnfmId)).getCatalogUrl()));
return apiClient;
}
@@ -113,7 +102,7 @@ public class CbamRestApiProvider {
apiClient.getOkBuilder().sslSocketFactory(cbamSecurityProvider.buildSSLSocketFactory(), cbamSecurityProvider.buildTrustManager());
apiClient.getOkBuilder().hostnameVerifier(cbamSecurityProvider.buildHostnameVerifier());
apiClient.addAuthorization(AUTH_NAME, tokenProvider.getToken(vnfmId));
- apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl(vnfmInfo.getUrl()));
+ apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl(convert(vnfmInfoProvider.getVnfmInfo(vnfmId)).getLcmUrl()));
return apiClient;
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForSo.java
new file mode 100644
index 00000000..5d5b1907
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForSo.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Responsible for providing client to access CBAM REST API
+ */
+@Component
+public class CbamRestApiProviderForSo extends CbamRestApiProvider {
+ @Autowired
+ public CbamRestApiProviderForSo(CbamTokenProviderForSo cbamTokenProvider, AAIExternalSystemInfoProvider vnfmInfoProvider, CbamSecurityProvider cbamSecurityProvider) {
+ super(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForVfc.java
new file mode 100644
index 00000000..f283d098
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProviderForVfc.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Responsible for providing client to access CBAM REST API
+ */
+@Component
+public class CbamRestApiProviderForVfc extends CbamRestApiProvider {
+ @Autowired
+ public CbamRestApiProviderForVfc(CbamTokenProviderForVfc cbamTokenProvider, VfcExternalSystemInfoProvider vnfmInfoProvider, CbamSecurityProvider cbamSecurityProvider) {
+ super(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java
index df21e52d..c4a6645a 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java
@@ -23,12 +23,11 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.VnfmCredentials;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.VnfmUrls;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
-import org.onap.vnfmdriver.model.VnfmInfo;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
@@ -38,7 +37,6 @@ import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VAL
/**
* Responsible for providing a token to access CBAM APIs
*/
-@Component
//even if the value for grant type an user password is the same they do not mean the same thing
//the duplication of this is intentional
@SuppressWarnings("squid:S1192")
@@ -49,15 +47,8 @@ public class CbamTokenProvider extends CbamSecurityProvider {
private static final String CBAM_TOKEN_URL = "realms/cbam/protocol/openid-connect/token";
private static Logger logger = getLogger(CbamTokenProvider.class);
private final VnfmInfoProvider vnfmInfoProvider;
- @Value("${cbamKeyCloakBaseUrl}")
- private String cbamKeyCloakBaseUrl;
- @Value("${cbamUsername}")
- private String username;
- @Value("${cbamPassword}")
- private String password;
private volatile CurrentToken token;
- @Autowired
CbamTokenProvider(VnfmInfoProvider vnfmInfoProvider) {
this.vnfmInfoProvider = vnfmInfoProvider;
}
@@ -66,11 +57,10 @@ public class CbamTokenProvider extends CbamSecurityProvider {
* @return the token to access CBAM APIs (ex. 123456)
*/
public Interceptor getToken(String vnfmId) {
- VnfmInfo vnfmInfo = vnfmInfoProvider.getVnfmInfo(vnfmId);
- return new OauthInterceptor(getToken(vnfmInfo.getUserName(), vnfmInfo.getPassword()));
+ return new OauthInterceptor(getTokenInternal(vnfmId));
}
- private String getToken(String clientId, String clientSecret) {
+ private String getTokenInternal(String vnfmId) {
logger.trace("Requesting token for accessing CBAM API");
synchronized (this) {
long now = SystemFunctions.systemFunctions().currentTimeMillis();
@@ -80,7 +70,7 @@ public class CbamTokenProvider extends CbamSecurityProvider {
} else {
logger.debug("Token expired {} ms ago", (now - token.refreshAfter));
}
- refresh(clientId, clientSecret);
+ refresh(vnfmId);
} else {
logger.debug("Token will expire in {} ms", (now - token.refreshAfter));
}
@@ -88,13 +78,17 @@ public class CbamTokenProvider extends CbamSecurityProvider {
return token.token.accessToken;
}
- private void refresh(String clientId, String clientSecret) {
+ private void refresh(String vnfmId) {
+ VnfmUrls vnfmUrls = GenericExternalSystemInfoProvider.convert(vnfmInfoProvider.getVnfmInfo(vnfmId));
+ VnfmCredentials vnfmCredentials = GenericExternalSystemInfoProvider.convertToCredentials(vnfmInfoProvider.getVnfmInfo(vnfmId));
+
FormBody body = new FormBody.Builder()
.add("grant_type", GRANT_TYPE)
- .add("client_id", clientId)
- .add("client_secret", clientSecret)
- .add("username", username)
- .add(CLIENT_SECRET, password).build();
+ .add("client_id", vnfmCredentials.getClientId())
+ .add("client_secret", vnfmCredentials.getClientSecret())
+ .add("username", vnfmCredentials.getUsername())
+ .add(CLIENT_SECRET, vnfmCredentials.getPassword()).build();
+ String cbamKeyCloakBaseUrl = vnfmUrls.getAuthUrl();
Request request = new Request.Builder().url(cbamKeyCloakBaseUrl + CBAM_TOKEN_URL).addHeader(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE).post(body).build();
OkHttpClient.Builder builder = new OkHttpClient.Builder();
SSLSocketFactory sslSocketFac = buildSSLSocketFactory();
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForSo.java
new file mode 100644
index 00000000..30eae6ba
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForSo.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+@Component
+@Qualifier("so")
+public class CbamTokenProviderForSo extends CbamTokenProvider {
+
+ @Autowired
+ CbamTokenProviderForSo(AAIExternalSystemInfoProvider vnfmInfoProvider) {
+ super(vnfmInfoProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForVfc.java
new file mode 100644
index 00000000..3e442dcd
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProviderForVfc.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+@Component
+@Qualifier("vfc")
+public class CbamTokenProviderForVfc extends CbamTokenProvider {
+
+ @Autowired
+ CbamTokenProviderForVfc(VfcExternalSystemInfoProvider vnfmInfoProvider) {
+ super(vnfmInfoProvider);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java
new file mode 100644
index 00000000..3d4ec93a
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+
+/**
+ * Common constants
+ */
+public class Constants {
+ public static final String BASE_SUFFIX = "/" + SelfRegistrationManager.SERVICE_NAME + "/v1";
+ public static final String BASE_URL = "/api" + BASE_SUFFIX;
+ public static final String LCN_URL = "/lcn";
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java
deleted file mode 100644
index b15d2850..00000000
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-
-import java.util.Objects;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-/**
- * Wraps the properties supplied to the servlet
- */
-@Component
-public class DriverProperties {
- public static final String BASE_SUFFIX = "/" + SelfRegistrationManager.SERVICE_NAME + "/v1";
- public static final String BASE_URL = "/api" + BASE_SUFFIX;
- public static final String LCN_URL = "/lcn";
-
- @Value("${cbamCatalogUrl}")
- private String cbamCatalogUrl;
- @Value("${cbamLcnUrl}")
- private String cbamLcnUrl;
- @Value("${vnfmId}")
- private String vnfmId;
-
- /**
- * @return the URL on which the CBAM catalog API can be accessed (ex. https://1.2.3.4:443/api/catalog/adapter )
- */
- public String getCbamCatalogUrl() {
- return cbamCatalogUrl;
- }
-
- /**
- * @param cbamCatalogUrl the URL on which the CBAM catalog API can be accessed (ex. https://1.2.3.4:443/api/catalog/adapter )
- */
- public void setCbamCatalogUrl(String cbamCatalogUrl) {
- this.cbamCatalogUrl = cbamCatalogUrl;
- }
-
- /**
- * @return the URL on which the CBAM LCN subscription API can be accessed (ex. https://1.2.3.4:443/vnfm/lcn/v3 )
- */
- public String getCbamLcnUrl() {
- return cbamLcnUrl;
- }
-
- /**
- * @param cbamLcnUrl the URL on which the CBAM LCN subscription API can be accessed (ex. https://1.2.3.4:443/vnfm/lcn/v3 )
- */
- public void setCbamLcnUrl(String cbamLcnUrl) {
- this.cbamLcnUrl = cbamLcnUrl;
- }
-
- /**
- * @return the identifier of the VNFM
- */
- public String getVnfmId() {
- return vnfmId;
- }
-
- /**
- * @param vnfmId the identifier of the VNFM
- */
- public void setVnfmId(String vnfmId) {
- this.vnfmId = vnfmId;
- }
-
- @Override
- public String toString() {
- return "DriverProperties{" +
- ", cbamCatalogUrl='" + cbamCatalogUrl + '\'' +
- ", cbamLcnUrl='" + cbamLcnUrl + '\'' +
- ", vnfmId='" + vnfmId + '\'' +
- '}';
- }
-
- @Override
- //generated code. This is the recommended way to formulate equals
- @SuppressWarnings({"squid:S00122", "squid:S1067"})
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- DriverProperties that = (DriverProperties) o;
- return Objects.equals(cbamCatalogUrl, that.cbamCatalogUrl) &&
- Objects.equals(cbamLcnUrl, that.cbamLcnUrl) &&
- Objects.equals(vnfmId, that.vnfmId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(cbamCatalogUrl, cbamLcnUrl, vnfmId);
- }
-}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
index 5624327b..34dce147 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
@@ -32,8 +32,6 @@ import org.onap.vnfmdriver.model.JobDetailInfoResponseDescriptor;
import org.onap.vnfmdriver.model.JobResponseInfo;
import org.onap.vnfmdriver.model.JobStatus;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import static javax.servlet.http.HttpServletResponse.SC_SERVICE_UNAVAILABLE;
import static java.util.Optional.empty;
@@ -59,7 +57,6 @@ import static org.springframework.util.StringUtils.isEmpty;
* The second UUID is passed as mandatory parameter to each executed operation.
* This UUID is used to locate the operation execution from the ONAP job identifier
*/
-@Component
public class JobManager {
public static final String OPERATION_STARTED_DESCRIPTION = "Operation started";
private static final Ordering<JobResponseInfo> OLDEST_FIRST = new Ordering<JobResponseInfo>() {
@@ -74,7 +71,6 @@ public class JobManager {
private final SelfRegistrationManager selfRegistrationManager;
private volatile boolean preparingForShutDown = false;
- @Autowired
JobManager(CbamRestApiProvider cbamRestApiProvider, SelfRegistrationManager selfRegistrationManager) {
this.cbamRestApiProvider = cbamRestApiProvider;
this.selfRegistrationManager = selfRegistrationManager;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForSo.java
new file mode 100644
index 00000000..0fca4309
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForSo.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForSo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class JobManagerForSo extends JobManager {
+
+ @Autowired
+ JobManagerForSo(CbamRestApiProviderForSo cbamRestApiProvider, SelfRegistrationManagerForSo selfRegistrationManager) {
+ super(cbamRestApiProvider, selfRegistrationManager);
+ }
+
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForVfc.java
new file mode 100644
index 00000000..66e8a904
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForVfc.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForVfc;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class JobManagerForVfc extends JobManager {
+
+ @Autowired
+ JobManagerForVfc(CbamRestApiProviderForVfc cbamRestApiProvider, SelfRegistrationManagerForVfc selfRegistrationManager) {
+ super(cbamRestApiProvider, selfRegistrationManager);
+ }
+
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index ce9da78c..5115aefd 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -35,8 +35,6 @@ import org.onap.vnfmdriver.model.*;
import org.onap.vnfmdriver.model.VimInfo;
import org.onap.vnfmdriver.model.VnfInfo;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;
import static java.lang.Integer.parseInt;
@@ -60,7 +58,6 @@ import static org.springframework.util.StringUtils.isEmpty;
/**
* Responsible for executing lifecycle operation on the VNF
*/
-@Component
public class LifecycleManager {
public static final String ONAP_CSAR_ID = "onapCsarId";
public static final long OPERATION_STATUS_POLLING_INTERVAL_IN_MS = 5000L;
@@ -82,7 +79,6 @@ public class LifecycleManager {
*/
private ExecutorService executorService = Executors.newCachedThreadPool();
- @Autowired
LifecycleManager(CatalogManager catalogManager, IGrantManager grantManager, CbamRestApiProvider restApiProvider, VimInfoProvider vimInfoProvider, JobManager jobManager, ILifecycleChangeNotificationManager notificationManager) {
this.vimInfoProvider = vimInfoProvider;
this.grantManager = grantManager;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForSo.java
new file mode 100644
index 00000000..b2f2bba2
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForSo.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Responsible for executing lifecycle operation on the VNF
+ */
+@Component
+public class LifecycleManagerForSo extends LifecycleManager {
+
+ @Autowired
+ LifecycleManagerForSo(CatalogManagerForSo catalogManager, GrantlessGrantManager grantManager, CbamRestApiProviderForSo restApiProvider, AAIExternalSystemInfoProvider vimInfoProvider, JobManagerForSo jobManager, LifecycleChangeNotificationManagerForSo notificationManager) {
+ super(catalogManager, grantManager, restApiProvider, vimInfoProvider, jobManager, notificationManager);
+ }
+
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java
new file mode 100644
index 00000000..014b7145
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Responsible for executing lifecycle operation on the VNF
+ */
+@Component
+public class LifecycleManagerForVfc extends LifecycleManager {
+
+ @Autowired
+ LifecycleManagerForVfc(CatalogManagerForVfc catalogManager, GrantlessGrantManager grantManager, CbamRestApiProviderForVfc restApiProvider, VfcExternalSystemInfoProvider vimInfoProvider, JobManagerForVfc jobManager, LifecycleChangeNotificationManagerForVfc notificationManager) {
+ super(catalogManager, grantManager, restApiProvider, vimInfoProvider, jobManager, notificationManager);
+ }
+
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
index 3ff04990..9b497343 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
@@ -27,14 +27,12 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import static java.util.Optional.empty;
import static java.util.Optional.of;
@@ -64,7 +62,6 @@ import static org.slf4j.LoggerFactory.getLogger;
* on all LCN deliveries. The consequence of this is that the information known by VF-C / A&AI may be inconsistent with
* reality (VNF having been deleted)
*/
-@Component
public class LifecycleChangeNotificationManager implements ILifecycleChangeNotificationManager {
public static final String PROBLEM = "All operations must return the { \"operationResult\" : { \"cbam_pre\" : [<fillMeOut>], \"cbam_post\" : [<fillMeOut>] } } structure";
@@ -84,15 +81,14 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
private static Logger logger = getLogger(LifecycleChangeNotificationManager.class);
private final CbamRestApiProvider restApiProvider;
- private final DriverProperties driverProperties;
private final INotificationSender notificationSender;
+ private final SelfRegistrationManager selfRegistrationManager;
private Set<ProcessedNotification> processedNotifications = newConcurrentHashSet();
- @Autowired
- LifecycleChangeNotificationManager(CbamRestApiProvider restApiProvider, DriverProperties driverProperties, INotificationSender notificationSender) {
+ LifecycleChangeNotificationManager(CbamRestApiProvider restApiProvider, SelfRegistrationManager selfRegistrationManager, INotificationSender notificationSender) {
this.notificationSender = notificationSender;
- this.driverProperties = driverProperties;
this.restApiProvider = restApiProvider;
+ this.selfRegistrationManager = selfRegistrationManager;
}
/**
@@ -115,7 +111,8 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
if (logger.isInfoEnabled()) {
logger.info("Received LCN: {}", new Gson().toJson(receivedNotification));
}
- VnfsApi cbamLcmApi = restApiProvider.getCbamLcmApi(driverProperties.getVnfmId());
+ String vnfmId = selfRegistrationManager.getVnfmId(receivedNotification.getSubscriptionId());
+ VnfsApi cbamLcmApi = restApiProvider.getCbamLcmApi(vnfmId);
try {
List<VnfInfo> vnfs = cbamLcmApi.vnfsGet(NOKIA_LCM_API_VERSION).blockingFirst();
com.google.common.base.Optional<VnfInfo> currentVnf = tryFind(vnfs, vnf -> vnf.getId().equals(receivedNotification.getVnfInstanceId()));
@@ -131,7 +128,7 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
logger.warn(vnfHeader + " is not a managed VNF");
return;
}
- if (!externalVnfmId.get().getValue().equals(driverProperties.getVnfmId())) {
+ if (!externalVnfmId.get().getValue().equals(vnfmId)) {
logger.warn(vnfHeader + " is not a managed by the VNFM with id " + externalVnfmId.get().getValue());
return;
}
@@ -139,7 +136,7 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
} catch (Exception e) {
throw buildFatalFailure(logger, "Unable to list VNFs / query VNF", e);
}
- OperationExecutionsApi cbamOperationExecutionApi = restApiProvider.getCbamOperationExecutionApi(driverProperties.getVnfmId());
+ OperationExecutionsApi cbamOperationExecutionApi = restApiProvider.getCbamOperationExecutionApi(vnfmId);
List<OperationExecution> operationExecutions;
try {
operationExecutions = cbamLcmApi.vnfsVnfInstanceIdOperationExecutionsGet(receivedNotification.getVnfInstanceId(), NOKIA_LCM_API_VERSION).blockingFirst();
@@ -154,7 +151,7 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
}
OperationExecution closestInstantiationToOperation = findLastInstantiationBefore(operationExecutions, operationExecution);
String vimId = getVimId(cbamOperationExecutionApi, closestInstantiationToOperation);
- notificationSender.processNotification(receivedNotification, operationExecution, buildAffectedCps(operationExecution), vimId);
+ notificationSender.processNotification(receivedNotification, operationExecution, buildAffectedCps(operationExecution), vimId, vnfmId);
if (isTerminationFinished(receivedNotification)) {
//signal LifecycleManager to continue the deletion of the VNF
processedNotifications.add(new ProcessedNotification(receivedNotification.getLifecycleOperationOccurrenceId(), receivedNotification.getStatus()));
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForSo.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForSo.java
new file mode 100644
index 00000000..c354f3f9
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForSo.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LifecycleChangeNotificationManagerForSo extends LifecycleChangeNotificationManager {
+
+ @Autowired
+ LifecycleChangeNotificationManagerForSo(CbamRestApiProviderForSo restApiProvider, SelfRegistrationManagerForSo selfRegistrationManager, AAINotificationProcessor notificationSender) {
+ super(restApiProvider, selfRegistrationManager, notificationSender);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForVfc.java
new file mode 100644
index 00000000..8b843629
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManagerForVfc.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
+
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForVfc;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForVfc;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LifecycleChangeNotificationManagerForVfc extends LifecycleChangeNotificationManager {
+
+ @Autowired
+ LifecycleChangeNotificationManagerForVfc(CbamRestApiProviderForVfc restApiProvider, SelfRegistrationManagerForVfc selfRegistrationManager, VfcNotificationSender notificationSender) {
+ super(restApiProvider, selfRegistrationManager, notificationSender);
+ }
+}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java
index 640097f3..69e3482c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java
@@ -20,18 +20,19 @@ import org.junit.runners.Suite;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.TestGenericExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.TestIpMappingProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.TestMsbApiProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.TestSelfRegistrationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestAAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestAAIRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestGrantlessGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestSdcPackageProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.*;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so.TestSoLifecycleManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.TestCbamVnfPackageBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.TestCbamVnfdBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.TestOnapVnfPackageBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.TestOnapVnfdBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi.*;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.TestConditions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.TestRealConfig;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.TestServletInitializer;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.*;
@@ -60,6 +61,8 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestReportedA
TestGrantlessGrantManager.class,
TestSdcPackageProvider.class,
+ TestSoLifecycleManager.class,
+
TestVfcExternalSystemInfoProvider.class,
TestVfcGrantManager.class,
TestVfcPackageProvider.class,
@@ -77,7 +80,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestReportedA
TestSwaggerApi.class,
TestSwaggerDefinitionConsistency.class,
- TestConditions.class,
TestServletInitializer.class,
TestRealConfig.class,
@@ -97,7 +99,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestReportedA
TestCbamRestApiProvider.class,
TestCbamSecurityProvider.class,
TestCbamTokenProvider.class,
- TestDriverProperties.class,
TestJobManager.class,
TestVfcGrantManager.class,
TestLifecycleManager.class,
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
index b4eed27c..69a74bc3 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
@@ -25,11 +25,15 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.core.env.ConfigurableEnvironment;
import static junit.framework.TestCase.*;
import static org.mockito.Mockito.*;
@@ -38,7 +42,9 @@ import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestNokiaSvnfmApplication extends TestBase {
@Mock
- private JobManager jobManager;
+ private JobManagerForVfc jobManagerForVfc;
+ @Mock
+ private JobManagerForSo jobManagerForSo;
private NokiaSvnfmApplication.SelfRegistrationTrigger selfRegistrationTriggerer;
private NokiaSvnfmApplication.SelfDeRegistrationTrigger selfUnregistrationTriggerer;
@@ -46,8 +52,8 @@ public class TestNokiaSvnfmApplication extends TestBase {
@Before
public void initMocks() throws Exception {
- selfRegistrationTriggerer = new NokiaSvnfmApplication.SelfRegistrationTrigger(selfRegistrationManager, jobManager);
- selfUnregistrationTriggerer = new NokiaSvnfmApplication.SelfDeRegistrationTrigger(selfRegistrationManager, jobManager);
+ selfRegistrationTriggerer = new NokiaSvnfmApplication.SelfRegistrationTrigger(selfRegistrationManagerForVfc, selfRegistrationManagerForSo, jobManagerForSo, jobManagerForVfc);
+ selfUnregistrationTriggerer = new NokiaSvnfmApplication.SelfDeRegistrationTrigger(selfRegistrationManagerForVfc, selfRegistrationManagerForSo, jobManagerForSo, jobManagerForVfc);
setField(NokiaSvnfmApplication.class, "logger", logger);
}
@@ -70,13 +76,14 @@ public class TestNokiaSvnfmApplication extends TestBase {
public void testRegistrationIsCalledAfterComponentIsUp() throws Exception {
//given
ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+ useVfc(event);
//when
selfRegistrationTriggerer.onApplicationEvent(event);
//verify
boolean success = false;
while (!success) {
try {
- verify(selfRegistrationManager).register();
+ verify(selfRegistrationManagerForVfc).register();
verify(logger).info("Self registration started");
verify(logger).info("Self registration finished");
success = true;
@@ -89,6 +96,21 @@ public class TestNokiaSvnfmApplication extends TestBase {
assertTrue(ApplicationReadyEvent.class.isAssignableFrom(event.getClass()));
}
+ private void useVfc(ApplicationReadyEvent event) {
+ ConfigurableApplicationContext context = Mockito.mock(ConfigurableApplicationContext.class);
+ ConfigurableEnvironment environment = Mockito.mock(ConfigurableEnvironment.class);
+ when(context.getEnvironment()).thenReturn(environment);
+ when(event.getApplicationContext()).thenReturn(context);
+ when(environment.getActiveProfiles()).thenReturn(new String[]{});
+ }
+
+ private void useVfc(ContextClosedEvent event) {
+ ApplicationContext context = Mockito.mock(ApplicationContext.class);
+ when(context.getEnvironment()).thenReturn(environment);
+ when(event.getApplicationContext()).thenReturn(context);
+ when(environment.getActiveProfiles()).thenReturn(new String[]{});
+ }
+
/**
* Assert that the self de-registration process is started after the servlet has been ramped down
*/
@@ -96,12 +118,14 @@ public class TestNokiaSvnfmApplication extends TestBase {
public void testUnRegistrationIsCalledAfterComponentIsUp() throws Exception {
//given
ContextClosedEvent event = Mockito.mock(ContextClosedEvent.class);
+ useVfc(event);
//when
selfUnregistrationTriggerer.onApplicationEvent(event);
//verify
- InOrder inOrder = Mockito.inOrder(jobManager, selfRegistrationManager);
- inOrder.verify(jobManager).prepareForShutdown();
- inOrder.verify(selfRegistrationManager).deRegister();
+ InOrder inOrder = Mockito.inOrder(jobManagerForVfc, jobManagerForSo, selfRegistrationManagerForVfc);
+ inOrder.verify(jobManagerForVfc).prepareForShutdown();
+ inOrder.verify(jobManagerForSo).prepareForShutdown();
+ inOrder.verify(selfRegistrationManagerForVfc).deRegister();
verify(logger).info("Self de-registration started");
verify(logger).info("Self de-registration finished");
// this forces the event to be fired after the servlet is down (prevents refactor)
@@ -115,11 +139,11 @@ public class TestNokiaSvnfmApplication extends TestBase {
public void testPreparingForShutdownDoesNotStartRegistration() throws Exception {
//given
ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
- when(jobManager.isPreparingForShutDown()).thenReturn(true);
+ when(jobManagerForVfc.isPreparingForShutDown()).thenReturn(true);
//when
selfRegistrationTriggerer.onApplicationEvent(event);
//verify
- verify(selfRegistrationManager, never()).register();
+ verify(selfRegistrationManagerForVfc, never()).register();
}
/**
@@ -129,6 +153,7 @@ public class TestNokiaSvnfmApplication extends TestBase {
@SuppressWarnings("squid:S2925") //the execution is asynchronous no other way to wait
public void failedFirstRegistration() {
//given
+
Set<RuntimeException> expectedException = new HashSet<>();
doAnswer(new Answer() {
@Override
@@ -140,8 +165,9 @@ public class TestNokiaSvnfmApplication extends TestBase {
}
return null;
}
- }).when(selfRegistrationManager).register();
+ }).when(selfRegistrationManagerForVfc).register();
ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+ useVfc(event);
//when
selfRegistrationTriggerer.onApplicationEvent(event);
//verify
@@ -167,8 +193,9 @@ public class TestNokiaSvnfmApplication extends TestBase {
public void failedDeRegistration() {
//given
RuntimeException expectedException = new RuntimeException();
- Mockito.doThrow(expectedException).when(selfRegistrationManager).deRegister();
+ Mockito.doThrow(expectedException).when(selfRegistrationManagerForVfc).deRegister();
ContextClosedEvent event = Mockito.mock(ContextClosedEvent.class);
+ useVfc(event);
//when
try {
selfUnregistrationTriggerer.onApplicationEvent(event);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java
index 2bd0820c..a284f28f 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java
@@ -50,6 +50,8 @@ public class CTDirectReal {
*/
@Test
public void testBasicWorkflow() throws Exception {
+ SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
+
VimInfo nokia_regionOne = externalSystemInfoProvider.getVimInfo("Nokia_RegionOne");
VnfLifecycleChangeNotification recievedNot = new VnfLifecycleChangeNotification();
@@ -86,8 +88,7 @@ public class CTDirectReal {
addedCp.setTenantId("de8fd0d1d5874503a47b920c10f4322a");
addedCp.setCpdId("cpdId");
affectedConnectionPoints.getPost().add(addedCp);
- notificationProcessor.processNotification(recievedNot, null, of(affectedConnectionPoints), "Nokia_RegionOne");
- SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
+ notificationProcessor.processNotification(recievedNot, null, of(affectedConnectionPoints), "Nokia_RegionOne", "vnfmId");
}
JsonObject additionalData(String key, String value) {
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
index efa45234..850579f0 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
@@ -16,6 +16,7 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -108,6 +109,11 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
public VimInfo getVimInfo(String vimId) {
return null;
}
+
+ @Override
+ public Set<String> getVnfms() {
+ return null;
+ }
}
try {
new TestClass(null).getVnfmInfo(VNFM_ID);
@@ -133,5 +139,10 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
public VimInfo getVimInfo(String vimId) {
return null;
}
+
+ @Override
+ public Set<String> getVnfms() {
+ return null;
+ }
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java
index 671b4b50..d1e2dea1 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
import com.google.common.collect.Lists;
import com.nokia.cbam.lcn.v32.model.CreateSubscriptionRequest;
@@ -26,18 +26,22 @@ import java.util.Arrays;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.*;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.msb.model.MicroServiceFullInfo;
import org.onap.msb.model.MicroServiceInfo;
import org.onap.msb.model.Node;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+import static com.google.common.collect.Sets.newHashSet;
import static com.nokia.cbam.lcn.v32.model.OperationType.*;
import static junit.framework.TestCase.*;
-import static org.mockito.Mockito.any;
import static org.mockito.Mockito.*;
import static org.onap.msb.model.MicroServiceInfo.ProtocolEnum.REST;
import static org.onap.msb.model.MicroServiceInfo.VisualRangeEnum._1;
@@ -52,14 +56,14 @@ public class TestSelfRegistrationManager extends TestBase {
private java.util.List<Subscription> subscriptions = new ArrayList<>();
private ArgumentCaptor<MicroServiceInfo> registeredMicroservice = ArgumentCaptor.forClass(MicroServiceInfo.class);
private ArgumentCaptor<CreateSubscriptionRequest> subscriptionToCreate = ArgumentCaptor.forClass(CreateSubscriptionRequest.class);
- @InjectMocks
private SelfRegistrationManager selfRegistrationManager;
@Before
public void initMocks() throws Exception {
+ selfRegistrationManager = new SelfRegistrationManager(vnfmInfoProvider, msbApiProvider, cbamRestApiProvider);
+
setField(SelfRegistrationManager.class, "logger", logger);
when(lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION)).thenReturn(buildObservable(subscriptions));
- when(driverProperties.getVnfmId()).thenReturn(VNFM_ID);
setField(selfRegistrationManager, "driverMsbExternalIp", "1.2.3.4");
setField(selfRegistrationManager, "driverVnfmExternalIp", "5.6.7.8");
setField(selfRegistrationManager, "driverPort", "12345");
@@ -78,6 +82,8 @@ public class TestSelfRegistrationManager extends TestBase {
public void testRegistration() throws Exception {
//given
Subscription subscription = new Subscription();
+ subscription.setId(SUBCRIPTION_ID);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenReturn(buildObservable(subscription));
MicroServiceFullInfo returnedMicroService = new MicroServiceFullInfo();
when(msbClient.addMicroService(registeredMicroservice.capture(), eq(true), eq(false))).thenReturn(buildObservable(returnedMicroService));
@@ -87,7 +93,7 @@ public class TestSelfRegistrationManager extends TestBase {
InOrder registrationOrder = Mockito.inOrder(lcnApi, msbClient);
registrationOrder.verify(lcnApi).subscriptionsPost(any(), any());
registrationOrder.verify(msbClient).addMicroService(any(), any(), any());
-
+ assertEquals(VNFM_ID, selfRegistrationManager.getVnfmId(SUBCRIPTION_ID));
assertMicroserviceRegistered();
assertNewLcnSubscription();
assertServiceUp();
@@ -112,7 +118,7 @@ public class TestSelfRegistrationManager extends TestBase {
assertTrue(subscriptionCreation.getFilter().getOperationTypes().contains(TERMINATE));
assertTrue(subscriptionCreation.getFilter().getOperationTypes().contains(INSTANTIATE));
assertEquals(4, subscriptionCreation.getFilter().getOperationTypes().size());
- verify(logger).info("Subscribing to CBAM LCN {} with callback to {}", driverProperties.getCbamLcnUrl(), "http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
+ verify(logger).info("Subscribing to CBAM LCN {} with callback to {}", HTTP_LCN_URL, "http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
}
private void assertMicroserviceRegistered() {
@@ -142,6 +148,7 @@ public class TestSelfRegistrationManager extends TestBase {
MicroServiceFullInfo returnedMicroService = new MicroServiceFullInfo();
when(msbClient.addMicroService(registeredMicroservice.capture(), eq(true), eq(false))).thenReturn(buildObservable(returnedMicroService));
Subscription existingSubscription = new Subscription();
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
existingSubscription.setId(UUID.randomUUID().toString());
existingSubscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
subscriptions.add(existingSubscription);
@@ -161,6 +168,7 @@ public class TestSelfRegistrationManager extends TestBase {
//given
RuntimeException expectedException = new RuntimeException();
when(lcnApi.subscriptionsPost(any(), any())).thenThrow(expectedException);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
//when
try {
selfRegistrationManager.register();
@@ -181,6 +189,8 @@ public class TestSelfRegistrationManager extends TestBase {
public void testFailedMsbPublish() throws Exception {
//given
Subscription subscription = new Subscription();
+ subscription.setId(SUBCRIPTION_ID);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenAnswer(invocationOnMock -> {
subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
subscription.setId(UUID.randomUUID().toString());
@@ -188,7 +198,6 @@ public class TestSelfRegistrationManager extends TestBase {
when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
return buildObservable(subscription);
});
- MicroServiceFullInfo returnedMicroService = new MicroServiceFullInfo();
RuntimeException expectedException = new RuntimeException();
when(msbClient.addMicroService(registeredMicroservice.capture(), eq(true), eq(false))).thenThrow(expectedException);
//when
@@ -215,8 +224,16 @@ public class TestSelfRegistrationManager extends TestBase {
//given
Subscription subscription = new Subscription();
subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
- subscription.setId(UUID.randomUUID().toString());
- subscriptions.add(subscription);
+ subscription.setId(SUBCRIPTION_ID);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
+ when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenAnswer(invocationOnMock -> {
+ subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
+ subscription.setId(UUID.randomUUID().toString());
+ subscriptions.add(subscription);
+ when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
+ return buildObservable(subscription);
+ });
+ selfRegistrationManager.assureSubscription(VNFM_ID);
when(jobManager.hasOngoingJobs()).thenReturn(false);
when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
VoidObservable MSB_DELETE = new VoidObservable();
@@ -242,8 +259,16 @@ public class TestSelfRegistrationManager extends TestBase {
//given
Subscription subscription = new Subscription();
subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
- subscription.setId(UUID.randomUUID().toString());
- subscriptions.add(subscription);
+ subscription.setId(SUBCRIPTION_ID);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
+ when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenAnswer(invocationOnMock -> {
+ subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
+ subscription.setId(UUID.randomUUID().toString());
+ subscriptions.add(subscription);
+ when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
+ return buildObservable(subscription);
+ });
+ selfRegistrationManager.assureSubscription(VNFM_ID);
when(jobManager.hasOngoingJobs()).thenReturn(false);
when(msbClient.deleteMicroService(SERVICE_NAME, DRIVER_VERSION, null, null)).then(new Answer<Observable<Void>>() {
@Override
@@ -272,7 +297,8 @@ public class TestSelfRegistrationManager extends TestBase {
//given
Subscription subscription = new Subscription();
subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
- subscription.setId(UUID.randomUUID().toString());
+ subscription.setId(SUBCRIPTION_ID);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
subscriptions.add(subscription);
when(msbClient.deleteMicroService(SERVICE_NAME, DRIVER_VERSION, null, null)).then(new Answer<Observable<Void>>() {
@Override
@@ -303,8 +329,16 @@ public class TestSelfRegistrationManager extends TestBase {
//given
Subscription subscription = new Subscription();
subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
- subscription.setId(UUID.randomUUID().toString());
- subscriptions.add(subscription);
+ subscription.setId(SUBCRIPTION_ID);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
+ when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenAnswer(invocationOnMock -> {
+ subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
+ subscription.setId(UUID.randomUUID().toString());
+ subscriptions.add(subscription);
+ when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
+ return buildObservable(subscription);
+ });
+ selfRegistrationManager.assureSubscription(VNFM_ID);
when(jobManager.hasOngoingJobs()).thenReturn(false);
RuntimeException expectedException = new RuntimeException();
doThrow(expectedException).when(lcnApi).subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmCredentials.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmCredentials.java
new file mode 100644
index 00000000..5043efc7
--- /dev/null
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmCredentials.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestVnfmCredentials {
+
+ @Test
+ public void testPojo() {
+ VnfmCredentials vnfmCredentials = new VnfmCredentials("myUsername", "myPassword", "myClientId", "myClientSecret");
+ assertEquals("myUsername", vnfmCredentials.getUsername());
+ assertEquals("myClientId", vnfmCredentials.getClientId());
+ assertEquals("myPassword", vnfmCredentials.getPassword());
+ assertEquals("myClientSecret", vnfmCredentials.getClientSecret());
+ assertEquals("VnfmCredentials{username='myUsername', password='450ad03db9395dfccb5e03066fd7f16cfba2b61e23d516373714471459052ec90a9a4bf3a151e600ea8aaed36e3b8c21a3d38ab1705839749d130da4380f1448', clientId='myClientId', clientSecret='ce1b1f932289546075ea7f98928cf9948181c1b72e12f61a244e1a49d85f52afa74dcb3b290b8eae2b7e26c3bebcd798a641e43533144e9624be741f8827065c'}", vnfmCredentials.toString());
+ assertTrue(!vnfmCredentials.toString().contains("myPassword"));
+ assertTrue(!vnfmCredentials.toString().contains("myClientSecret"));
+ }
+} \ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmUrls.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmUrls.java
new file mode 100644
index 00000000..f4f2f330
--- /dev/null
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestVnfmUrls.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestVnfmUrls extends TestBase {
+
+ @Test
+ public void testPojo() {
+ VnfmUrls vnfmUrls = new VnfmUrls(HTTP_AUTH_URL, HTTP_LCM_URL, HTTP_LCN_URL, HTTP_CATLOG_URL);
+ assertEquals(HTTP_AUTH_URL, vnfmUrls.getAuthUrl());
+ assertEquals(HTTP_LCN_URL, vnfmUrls.getLcnUrl());
+ assertEquals(HTTP_LCM_URL, vnfmUrls.getLcmUrl());
+ assertEquals(HTTP_CATLOG_URL, vnfmUrls.getCatalogUrl());
+ }
+} \ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java
index bd5e42f1..efbe1f8f 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java
@@ -31,6 +31,7 @@ import org.mockito.stubbing.Answer;
import org.onap.aai.api.CloudInfrastructureApi;
import org.onap.aai.api.ExternalSystemApi;
import org.onap.aai.api.NetworkApi;
+import org.onap.aai.auth.HttpBasicAuth;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
@@ -82,15 +83,12 @@ public class TestAAIRestApiProvider extends TestBase {
assertEquals("http://1.2.3.4/a/", apiClient.getAdapterBuilder().build().baseUrl().toString());
assertEquals(sslSocketFactoryResultCaptor.getResult(), apiClient.getOkBuilder().build().sslSocketFactory());
assertEquals(hostnameVerifier, apiClient.getOkBuilder().build().hostnameVerifier());
+ HttpBasicAuth basic = (HttpBasicAuth) apiClient.getApiAuthorizations().get("basic");
+ assertEquals("username", basic.getUsername());
+ assertEquals("aaiPassword", basic.getPassword());
//given
Response resp = new Response.Builder().message("a").code(200).protocol(Protocol.HTTP_1_0).request(new Request.Builder().url("http://1.2.3.4/d").build()).build();
- //when
- Request authenticate = apiClient.getOkBuilder().build().authenticator().authenticate(null, resp);
- //verify
- assertEquals("Basic dXNlcm5hbWU6YWFpUGFzc3dvcmQ=", authenticate.headers().get("Authorization"));
-
- //given
Interceptor.Chain chain = Mockito.mock(Interceptor.Chain.class);
when(chain.request()).thenReturn(new Request.Builder().url("http://1.2.3.4/d").build());
ArgumentCaptor<Request> modifedRequest = ArgumentCaptor.forClass(Request.class);
@@ -122,8 +120,9 @@ public class TestAAIRestApiProvider extends TestBase {
assertEquals(sslSocketFactoryResultCaptor.getResult(), apiClient.getOkBuilder().build().sslSocketFactory());
assertEquals(hostnameVerifier, apiClient.getOkBuilder().build().hostnameVerifier());
Response resp = new Response.Builder().message("a").code(200).protocol(Protocol.HTTP_1_0).request(new Request.Builder().url("http://1.2.3.4/d").build()).build();
- Request authenticate = apiClient.getOkBuilder().build().authenticator().authenticate(null, resp);
- assertEquals("Basic dXNlcm5hbWU6YWFpUGFzc3dvcmQ=", authenticate.headers().get("Authorization"));
+ HttpBasicAuth basic = (HttpBasicAuth) apiClient.getApiAuthorizations().get("basic");
+ assertEquals("username", basic.getUsername());
+ assertEquals("aaiPassword", basic.getPassword());
}
/**
@@ -146,8 +145,9 @@ public class TestAAIRestApiProvider extends TestBase {
assertEquals(sslSocketFactoryResultCaptor.getResult(), apiClient.getOkBuilder().build().sslSocketFactory());
assertEquals(hostnameVerifier, apiClient.getOkBuilder().build().hostnameVerifier());
Response resp = new Response.Builder().message("a").code(200).protocol(Protocol.HTTP_1_0).request(new Request.Builder().url("http://1.2.3.4/d").build()).build();
- Request authenticate = apiClient.getOkBuilder().build().authenticator().authenticate(null, resp);
- assertEquals("Basic dXNlcm5hbWU6YWFpUGFzc3dvcmQ=", authenticate.headers().get("Authorization"));
+ HttpBasicAuth basic = (HttpBasicAuth) apiClient.getApiAuthorizations().get("basic");
+ assertEquals("username", basic.getUsername());
+ assertEquals("aaiPassword", basic.getPassword());
}
/**
@@ -170,8 +170,9 @@ public class TestAAIRestApiProvider extends TestBase {
assertEquals(sslSocketFactoryResultCaptor.getResult(), apiClient.getOkBuilder().build().sslSocketFactory());
assertEquals(hostnameVerifier, apiClient.getOkBuilder().build().hostnameVerifier());
Response resp = new Response.Builder().message("a").code(200).protocol(Protocol.HTTP_1_0).request(new Request.Builder().url("http://1.2.3.4/d").build()).build();
- Request authenticate = apiClient.getOkBuilder().build().authenticator().authenticate(null, resp);
- assertEquals("Basic dXNlcm5hbWU6YWFpUGFzc3dvcmQ=", authenticate.headers().get("Authorization"));
+ HttpBasicAuth basic = (HttpBasicAuth) apiClient.getApiAuthorizations().get("basic");
+ assertEquals("username", basic.getUsername());
+ assertEquals("aaiPassword", basic.getPassword());
}
/**
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestSdcPackageProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestSdcPackageProvider.java
index 1af96992..3c8333e4 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestSdcPackageProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestSdcPackageProvider.java
@@ -27,10 +27,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.fail;
import static org.apache.http.HttpHeaders.ACCEPT;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager.SERVICE_NAME;
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
import static org.springframework.test.util.ReflectionTestUtils.setField;
@@ -40,7 +37,7 @@ public class TestSdcPackageProvider extends TestBase {
@Before
public void init() {
- sdcPackageProvider = new SdcPackageProvider(msbApiProvider, driverProperties);
+ sdcPackageProvider = new SdcPackageProvider(msbApiProvider);
setField(SdcPackageProvider.class, "logger", logger);
setFieldWithPropertyAnnotation(sdcPackageProvider, "${sdcUsername}", "sdcUsername");
setFieldWithPropertyAnnotation(sdcPackageProvider, "${sdcPassword}", "sdcPassword");
@@ -58,7 +55,7 @@ public class TestSdcPackageProvider extends TestBase {
//verify
assertEquals("test", new String("test"));
HttpGet httpGet = (HttpGet) request.getValue();
- assertEquals(VNFM_ID, httpGet.getFirstHeader("X-ECOMP-InstanceID").getValue());
+ assertEquals(SERVICE_NAME, httpGet.getFirstHeader("X-ECOMP-InstanceID").getValue());
assertEquals(SERVICE_NAME, httpGet.getFirstHeader("X-FromAppId").getValue());
assertEquals(APPLICATION_OCTET_STREAM_VALUE, httpGet.getFirstHeader(ACCEPT).getValue());
assertEquals("https://1.2.3.4:456/g/sdc/v1/catalog/resources/csarId/toscaModel", httpGet.getURI().toASCIIString());
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAAINotificationProcessor.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAAINotificationProcessor.java
index d183e38e..8b95f00d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAAINotificationProcessor.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAAINotificationProcessor.java
@@ -89,7 +89,7 @@ public class TestAAINotificationProcessor extends TestBase {
addedCp.setServerProviderId("serverId");
affectedConnectionPoints.getPost().add(addedCp);
//when
- aaiNotificationProcessor.processNotification(recievenNotification, null, of(affectedConnectionPoints), VIM_ID);
+ aaiNotificationProcessor.processNotification(recievenNotification, null, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
InOrder inOrder = Mockito.inOrder(genericVnfManager, l3NetworkManager, lInterfaceManager, vnfcManager, vserverManager);
inOrder.verify(l3NetworkManager).update(VIM_ID, VNF_ID, addedLink);
@@ -137,7 +137,7 @@ public class TestAAINotificationProcessor extends TestBase {
affectedConnectionPoints.getPost().add(changedCpAfter);
//when
- aaiNotificationProcessor.processNotification(recievenNotification, null, of(affectedConnectionPoints), VIM_ID);
+ aaiNotificationProcessor.processNotification(recievenNotification, null, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
verify(lInterfaceManager).update(VNF_ID, VIM_ID, unchangedCp, inMaintenance);
verify(lInterfaceManager, never()).update(VNF_ID, VIM_ID, changedCpBefore, inMaintenance);
@@ -182,7 +182,7 @@ public class TestAAINotificationProcessor extends TestBase {
affectedConnectionPoints.getPost().add(cpWithoutServer);
//when
- aaiNotificationProcessor.processNotification(recievenNotification, null, of(affectedConnectionPoints), VIM_ID);
+ aaiNotificationProcessor.processNotification(recievenNotification, null, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
InOrder inOrder = Mockito.inOrder(genericVnfManager, l3NetworkManager, lInterfaceManager, vnfcManager, vserverManager);
inOrder.verify(l3NetworkManager).update(VIM_ID, VNF_ID, addedLink);
@@ -212,7 +212,7 @@ public class TestAAINotificationProcessor extends TestBase {
recievenNotification.setAffectedVirtualLinks(new ArrayList<>());
recievenNotification.setVnfInstanceId(VNF_ID);
//when
- aaiNotificationProcessor.processNotification(recievenNotification, null, empty(), VIM_ID);
+ aaiNotificationProcessor.processNotification(recievenNotification, null, empty(), VIM_ID, VNFM_ID);
//verify
verify(logger).warn("The changed connection points are not present in VNF with {} identifier", VNF_ID);
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAbstractManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAbstractManager.java
index 8991b819..04513d39 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAbstractManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestAbstractManager.java
@@ -26,7 +26,6 @@ import org.onap.aai.model.Relationship;
import org.onap.aai.model.RelationshipData;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.slf4j.Logger;
@@ -40,7 +39,7 @@ public class TestAbstractManager extends TestBase {
@Before
public void init() {
- dummyManager = new DummyManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ dummyManager = new DummyManager(aaiRestApiProvider, cbamRestApiProvider);
}
/**
@@ -234,8 +233,8 @@ public class TestAbstractManager extends TestBase {
class DummyManager extends AbstractManager {
- DummyManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ DummyManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
@Override
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java
index 9feaf74c..5ade389d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java
@@ -33,22 +33,23 @@ import org.onap.aai.api.NetworkApi;
import org.onap.aai.model.GenericVnf;
import org.onap.aai.model.Relationship;
import org.onap.aai.model.RelationshipData;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import static java.lang.Boolean.TRUE;
+import static java.util.Optional.of;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.fail;
-import static org.mockito.Mockito.anyLong;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.*;
import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestGenericVnfManager extends TestBase {
private ArgumentCaptor<GenericVnf> payload = ArgumentCaptor.forClass(GenericVnf.class);
+
@Mock
private AAIRestApiProvider aaiRestApiProvider;
@Mock
@@ -75,7 +76,7 @@ public class TestGenericVnfManager extends TestBase {
@Before
public void init() {
when(aaiRestApiProvider.getNetworkApi()).thenReturn(networkApi);
- genericVnfManager = new GenericVnfManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ genericVnfManager = new GenericVnfManager(aaiRestApiProvider, cbamRestApiProviderForSo);
setField(GenericVnfManager.class, "logger", logger);
AtomicLong currentTime = new AtomicLong(0L);
when(systemFunctions.currentTimeMillis()).thenAnswer(new Answer<Long>() {
@@ -106,19 +107,20 @@ public class TestGenericVnfManager extends TestBase {
}
return buildObservable(vnfs.iterator().next());
});
- when(cbamRestApiProvider.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
+ when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
when(networkApi.createOrUpdateNetworkGenericVnfsGenericVnf(eq(VNF_ID), payload.capture())).thenAnswer(invocation -> {
vnfs.add(vnfInAaai);
return VOID_OBSERVABLE.value();
});
vnfInfo.setName("vnfName");
//when
- genericVnfManager.createOrUpdate(VNF_ID, true);
+ genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, of("nsId"));
//verify
GenericVnf vnfSentToAai = payload.getValue();
assertEquals(VNF_ID, vnfSentToAai.getVnfId());
assertEquals(VNF_ID, vnfSentToAai.getVnfId());
assertEquals("NokiaVNF", vnfSentToAai.getVnfType());
+ assertEquals(SelfRegistrationManager.SERVICE_NAME, vnfSentToAai.getNfType());
assertEquals(TRUE, vnfSentToAai.isInMaint());
assertEquals(TRUE, vnfSentToAai.isIsClosedLoopDisabled());
assertEquals("vnfName", vnfSentToAai.getVnfName());
@@ -135,11 +137,11 @@ public class TestGenericVnfManager extends TestBase {
GenericVnf vnfInAaai = new GenericVnf();
vnfInAaai.setResourceVersion("v1");
when(networkApi.getNetworkGenericVnfsGenericVnf(VNF_ID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)).thenReturn(buildObservable(vnfInAaai));
- when(cbamRestApiProvider.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
+ when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
when(networkApi.createOrUpdateNetworkGenericVnfsGenericVnf(eq(VNF_ID), payload.capture())).thenReturn(VOID_OBSERVABLE.value());
vnfInfo.setName("vnfName");
//when
- genericVnfManager.createOrUpdate(VNF_ID, true);
+ genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, of("nsId"));
//verify
GenericVnf vnfSentToAai = payload.getValue();
assertEquals(VNF_ID, vnfSentToAai.getVnfId());
@@ -162,7 +164,7 @@ public class TestGenericVnfManager extends TestBase {
vnfInAaai.setResourceVersion("v1");
when(networkApi.getNetworkGenericVnfsGenericVnf(VNF_ID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)).thenReturn(buildObservable(vnfInAaai));
RuntimeException expectedException = new RuntimeException();
- when(cbamRestApiProvider.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenThrow(expectedException);
+ when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenThrow(expectedException);
when(networkApi.createOrUpdateNetworkGenericVnfsGenericVnf(eq(VNF_ID), payload.capture())).thenAnswer(invocation -> {
vnfInAaai.setResourceVersion("v2");
return null;
@@ -170,7 +172,7 @@ public class TestGenericVnfManager extends TestBase {
vnfInfo.setName("vnfName");
//when
try {
- genericVnfManager.createOrUpdate(VNF_ID, true);
+ genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, of("nsId"));
} catch (Exception e) {
verify(logger).error("Unable to query VNF with myVnfId identifier from CBAM", expectedException);
assertEquals("Unable to query VNF with myVnfId identifier from CBAM", e.getMessage());
@@ -193,7 +195,7 @@ public class TestGenericVnfManager extends TestBase {
}
throw new NoSuchElementException();
});
- when(cbamRestApiProvider.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
+ when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
RuntimeException runtimeException = new RuntimeException();
when(networkApi.createOrUpdateNetworkGenericVnfsGenericVnf(eq(VNF_ID), payload.capture())).thenAnswer(invocation -> {
GenericVnf vnfSentToAAi = (GenericVnf) invocation.getArguments()[1];
@@ -204,7 +206,7 @@ public class TestGenericVnfManager extends TestBase {
});
vnfInfo.setName("vnfName");
//when
- genericVnfManager.createOrUpdate(VNF_ID, true);
+ genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, of("nsId"));
//verify
GenericVnf vnfSentToAai = payload.getValue();
assertEquals(VNF_ID, vnfSentToAai.getVnfId());
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestL3NetworkManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestL3NetworkManager.java
index 30141638..f160447b 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestL3NetworkManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestL3NetworkManager.java
@@ -49,7 +49,7 @@ public class TestL3NetworkManager extends TestBase {
@Before
public void init() {
- l3NetworkManager = new L3NetworkManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ l3NetworkManager = new L3NetworkManager(aaiRestApiProvider, cbamRestApiProviderForSo);
setField(L3NetworkManager.class, "logger", logger);
when(aaiRestApiProvider.getNetworkApi()).thenReturn(networkApi);
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java
index 6d03eb55..e22491f2 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java
@@ -47,7 +47,7 @@ public class TestLInterfaceManager extends TestBase {
@Before
public void init() {
- lInterfaceManager = new LInterfaceManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ lInterfaceManager = new LInterfaceManager(aaiRestApiProvider, cbamRestApiProviderForSo);
setField(LInterfaceManager.class, "logger", logger);
when(aaiRestApiProvider.getCloudInfrastructureApi()).thenReturn(cloudInfrastructureApi);
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java
index b2dc063a..43a47d24 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java
@@ -27,12 +27,11 @@ import org.mockito.Mock;
import org.onap.aai.api.NetworkApi;
import org.onap.aai.model.Vnfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import static junit.framework.TestCase.assertEquals;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AbstractManager.buildRelationshipData;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.TestGenericVnfManager.assertRelation;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner;
@@ -44,13 +43,15 @@ public class TestVnfcManager extends TestBase {
@Mock
private AAIRestApiProvider aaiRestApiProvider;
+ @Mock
+ private CbamRestApiProviderForSo cbamRestApiProviderForSo;
private VnfcManager vnfcManager;
@Mock
private NetworkApi networkApi;
@Before
public void init() {
- vnfcManager = new VnfcManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ vnfcManager = new VnfcManager(aaiRestApiProvider, cbamRestApiProviderForSo);
setField(VnfcManager.class, "logger", logger);
when(aaiRestApiProvider.getNetworkApi()).thenReturn(networkApi);
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVserverManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVserverManager.java
index 080615a1..892b4e8e 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVserverManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVserverManager.java
@@ -30,12 +30,11 @@ import org.onap.aai.api.CloudInfrastructureApi;
import org.onap.aai.model.Relationship;
import org.onap.aai.model.Vserver;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import static junit.framework.TestCase.assertEquals;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AbstractManager.buildRelationshipData;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.TestGenericVnfManager.assertRelation;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner;
@@ -47,13 +46,15 @@ public class TestVserverManager extends TestBase {
@Mock
private AAIRestApiProvider aaiRestApiProvider;
+ @Mock
+ private CbamRestApiProviderForSo cbamRestApiProviderForSo;
private VserverManager vserverManager;
@Mock
private CloudInfrastructureApi cloudInfrastructureApi;
@Before
public void init() {
- vserverManager = new VserverManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ vserverManager = new VserverManager(aaiRestApiProvider, cbamRestApiProviderForSo);
setField(VserverManager.class, "logger", logger);
when(aaiRestApiProvider.getCloudInfrastructureApi()).thenReturn(cloudInfrastructureApi);
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
index 77005f41..582b41df 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
@@ -27,11 +27,9 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.AdditionalParameters;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.GenericVnfManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.*;
import org.onap.vnfmadapter.so.model.*;
import org.onap.vnfmdriver.model.*;
@@ -46,16 +44,18 @@ public class TestSoLifecycleManager extends TestBase {
private static final String VNFD_ID = "cbamVnfdId";
@Mock
- private LifecycleManager lifecycleManager;
+ private LifecycleManagerForSo lifecycleManager;
@Mock
- private VimInfoProvider vimInfoProvider;
+ private AAIExternalSystemInfoProvider vimInfoProvider;
@Mock
- private JobManager jobManager;
+ private JobManagerForSo jobManager;
+ @Mock
+ private GenericVnfManager genericVnfManager;
private SoLifecycleManager soLifecycleManager;
@Before
public void init() {
- soLifecycleManager = new SoLifecycleManager(lifecycleManager, vimInfoProvider, cbamRestApiProvider, jobManager);
+ soLifecycleManager = new SoLifecycleManager(lifecycleManager, vimInfoProvider, cbamRestApiProviderForSo, jobManager, genericVnfManager);
}
/**
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java
index b9d44603..f1ed1e16 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java
@@ -28,10 +28,9 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.onap.vnfmdriver.model.*;
@@ -50,8 +49,7 @@ public class TestVfcGrantManager extends TestBase {
private GrantVNFResponseVim vim = new GrantVNFResponseVim();
private GrantVNFResponse grantResponse = new GrantVNFResponse();
@Mock
- private CatalogManager cbamCatalogManager;
- @InjectMocks
+ private CatalogManagerForVfc cbamCatalogManager;
private VfcGrantManager vfcGrantManager;
@Before
@@ -59,6 +57,7 @@ public class TestVfcGrantManager extends TestBase {
setField(VfcGrantManager.class, "logger", logger);
when(nsLcmApi.grantvnf(grantRequest.capture())).thenReturn(buildObservable(grantResponse));
grantResponse.setVim(vim);
+ vfcGrantManager = new VfcGrantManager(cbamCatalogManager, cbamRestApiProviderForVfc, vfcRestApiProvider);
}
/**
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
index ded1bcd9..06cb6434 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
@@ -42,8 +42,6 @@ import static java.util.Optional.empty;
import static java.util.Optional.of;
import static junit.framework.TestCase.*;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
import static org.springframework.test.util.ReflectionTestUtils.setField;
@@ -62,7 +60,7 @@ public class TestVfcNotificationSender extends TestBase {
@Before
public void init() throws Exception {
- vfcNotificationSender = new VfcNotificationSender(driverProperties, vfcRestApiProvider);
+ vfcNotificationSender = new VfcNotificationSender(vfcRestApiProvider);
setField(VfcNotificationSender.class, "logger", logger);
when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(null);
instantiationOperation.setId("instantiationOperationExecutionId");
@@ -114,7 +112,7 @@ public class TestVfcNotificationSender extends TestBase {
recievedLcn.setStatus(OperationStatus.STARTED);
recievedLcn.setOperation(OperationType.INSTANTIATE);
//when
- vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, empty(), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, empty(), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
assertNull(sentLcnToVfc.getValue().getAffectedVl());
@@ -188,7 +186,7 @@ public class TestVfcNotificationSender extends TestBase {
JsonElement additionalData = new Gson().toJsonTree(operationResult);
instantiationOperation.setAdditionalData(additionalData);
//when
- vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -271,7 +269,7 @@ public class TestVfcNotificationSender extends TestBase {
JsonElement additionalData = new Gson().toJsonTree(operationResult);
instantiationOperation.setAdditionalData(additionalData);
//when
- vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -352,7 +350,7 @@ public class TestVfcNotificationSender extends TestBase {
JsonElement additionalData = new Gson().toJsonTree(operationResult);
instantiationOperation.setAdditionalData(additionalData);
//when
- vfcNotificationSender.processNotification(recievedLcn, terminationOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, terminationOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -473,7 +471,7 @@ public class TestVfcNotificationSender extends TestBase {
JsonElement additionalData = new Gson().toJsonTree(operationResult);
instantiationOperation.setAdditionalData(additionalData);
//when
- vfcNotificationSender.processNotification(recievedLcn, healOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, healOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -585,7 +583,7 @@ public class TestVfcNotificationSender extends TestBase {
JsonElement additionalData = new Gson().toJsonTree(operationResult);
scaleOperation.setAdditionalData(additionalData);
//when
- vfcNotificationSender.processNotification(recievedLcn, scaleOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, scaleOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -698,7 +696,7 @@ public class TestVfcNotificationSender extends TestBase {
scaleOperation.setAdditionalData(additionalData);
scaleOperation.setOperationType(OperationType.SCALE);
//when
- vfcNotificationSender.processNotification(recievedLcn, scaleOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, scaleOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -762,7 +760,7 @@ public class TestVfcNotificationSender extends TestBase {
scaleOperation.setOperationType(OperationType.SCALE);
when(logger.isInfoEnabled()).thenReturn(false);
//when
- vfcNotificationSender.processNotification(recievedLcn, scaleOperation, empty(), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, scaleOperation, empty(), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -821,7 +819,7 @@ public class TestVfcNotificationSender extends TestBase {
JsonElement additionalData = new Gson().toJsonTree(operationResult);
instantiationOperation.setAdditionalData(additionalData);
//when
- vfcNotificationSender.processNotification(recievedLcn, healOperation, of(affectedConnectionPoints), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, healOperation, of(affectedConnectionPoints), VIM_ID, VNFM_ID);
//verify
assertEquals(1, sentLcnToVfc.getAllValues().size());
@@ -846,7 +844,7 @@ public class TestVfcNotificationSender extends TestBase {
recievedLcn.setOperation(OperationType.INSTANTIATE);
//when
try {
- vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, empty(), VIM_ID);
+ vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, empty(), VIM_ID, VNFM_ID);
//verify
fail();
} catch (Exception e) {
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
index 9f3c00ec..8a79a33a 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
@@ -39,10 +39,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.mock.web.DelegatingServletOutputStream;
import static junit.framework.TestCase.*;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getFileInZip;
import static org.springframework.test.util.ReflectionTestUtils.setField;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
index 15505ba7..55252c2b 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
@@ -18,10 +18,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManagerForVfc;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.onap.vnfmdriver.model.VnfHealRequest;
import org.onap.vnfmdriver.model.VnfInstantiateRequest;
@@ -38,15 +37,15 @@ import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestLcmApi extends TestBase {
@Mock
- private LifecycleManager lifecycleManager;
+ private LifecycleManagerForVfc lifecycleManager;
@Mock
- private JobManager jobManager;
- @InjectMocks
+ private JobManagerForVfc jobManager;
private LcmApi lcmApi;
@Before
public void initMocks() throws Exception {
setField(LcmApi.class, "logger", logger);
+ lcmApi = new LcmApi(lifecycleManager, jobManager);
}
/**
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcnApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcnApi.java
index 67842f61..d600f18b 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcnApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcnApi.java
@@ -19,10 +19,10 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
import static org.mockito.Mockito.verify;
import static org.springframework.test.util.ReflectionTestUtils.setField;
@@ -33,13 +33,16 @@ public class TestLcnApi extends TestBase {
@Mock
private VnfLifecycleChangeNotification lcn;
@Mock
- private LifecycleChangeNotificationManager lcnManager;
- @InjectMocks
+ private LifecycleChangeNotificationManagerForVfc lifecycleChangeNotificationManagerForVfc;
+ @Mock
+ private LifecycleChangeNotificationManagerForSo lifecycleChangeNotificationManagerForSo;
+
private LcnApi lcnApi;
@Before
public void initMocks() throws Exception {
setField(LcnApi.class, "logger", logger);
+ lcnApi = new LcnApi(lifecycleChangeNotificationManagerForSo, lifecycleChangeNotificationManagerForVfc);
}
/**
@@ -59,7 +62,7 @@ public class TestLcnApi extends TestBase {
//when
lcnApi.handleLcn(lcn);
//verify
- verify(lcnManager).handleLcn(lcn);
+ verify(lifecycleChangeNotificationManagerForVfc).handleLcn(lcn);
verify(logger).info("REST: handle LCN");
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerApi.java
index f9b6f3ce..bbe78793 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerApi.java
@@ -19,8 +19,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
import javax.servlet.ServletOutputStream;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@@ -32,13 +33,14 @@ import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestSwaggerApi extends TestBase {
- @InjectMocks
private SwaggerApi swaggerApi;
-
+ @Mock
+ private SelfRegistrationManagerForVfc selfRegistrationManagerForVfc;
@Before
public void initMocks() throws Exception {
setField(SwaggerApi.class, "logger", logger);
+ swaggerApi = new SwaggerApi(selfRegistrationManagerForVfc);
}
/**
@@ -47,7 +49,7 @@ public class TestSwaggerApi extends TestBase {
@Test
public void testSwaggerRetrieval() throws Exception {
byte[] bytes = new byte[]{1, 2};
- when(selfRegistrationManager.getSwaggerApiDefinition()).thenReturn(bytes);
+ when(selfRegistrationManagerForVfc.getSwaggerApiDefinition()).thenReturn(bytes);
ServletOutputStream os = Mockito.mock(ServletOutputStream.class);
when(httpResponse.getOutputStream()).thenReturn(os);
//when
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java
deleted file mode 100644
index 671764ae..00000000
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring;
-
-import junit.framework.TestCase;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
-import org.springframework.context.annotation.ConditionContext;
-import org.springframework.core.env.Environment;
-
-import static org.mockito.Mockito.when;
-
-public class TestConditions {
-
- @Mock
- private ConditionContext conditionContext;
- @Mock
- private Environment environment;
-
- private String[] activeProfiles = new String[]{"a", "b"};
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
- when(conditionContext.getEnvironment()).thenReturn(environment);
- when(environment.getActiveProfiles()).thenReturn(activeProfiles);
- }
-
- /**
- * if direct integration is not specified VF-C based integration is used
- */
- @Test
- public void testVfcBased() throws Exception {
- //verify
- TestCase.assertTrue(new Conditions.UseForVfc().matches(conditionContext, null));
- TestCase.assertFalse(new Conditions.UseForDirect().matches(conditionContext, null));
- }
-
- /**
- * if direct integration is not specified VF-C based integration is used
- */
- @Test
- public void testDirectBased() throws Exception {
- activeProfiles[1] = "direct";
- //verify
- TestCase.assertFalse(new Conditions.UseForVfc().matches(conditionContext, null));
- TestCase.assertTrue(new Conditions.UseForDirect().matches(conditionContext, null));
- }
-
- /**
- * use class in a static way
- */
- @Test
- public void useStaticway() {
- TestUtil.coveragePrivateConstructorForClassesWithStaticMethodsOnly(Conditions.class);
- }
-
-}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiExceptionTest.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiExceptionTest.java
new file mode 100644
index 00000000..549aa759
--- /dev/null
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/MultiExceptionTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util;
+
+
+import com.google.common.collect.Lists;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class MultiExceptionTest {
+ @Test
+ public void testConstruction() {
+ Exception c1 = new Exception();
+ Exception c2 = new Exception();
+ //when
+ MultiException e = new MultiException("msg", c1, c2);
+ //verify
+ assertEquals("msg", e.getMessage());
+ assertEquals(c1, e.getCauses().get(0));
+ assertEquals(c2, e.getCauses().get(1));
+ assertEquals(2, e.getCauses().size());
+ }
+
+ @Test
+ public void testConstruction2() {
+ Exception c1 = new Exception();
+ Exception c2 = new Exception();
+ //when
+ MultiException e = new MultiException("msg", Lists.newArrayList(c1, c2));
+ //verify
+ assertEquals("msg", e.getMessage());
+ assertEquals(c1, e.getCauses().get(0));
+ assertEquals(c2, e.getCauses().get(1));
+ assertEquals(2, e.getCauses().size());
+ }
+} \ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
index 804f395d..347d6d2b 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
@@ -50,12 +50,14 @@ import org.onap.msb.api.ServiceResourceApi;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.MsbApiProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManagerForVfc;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AaiSecurityProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
import org.onap.vfccatalog.api.VnfpackageApi;
import org.onap.vnfmdriver.api.NslcmApi;
+import org.onap.vnfmdriver.model.VnfmInfo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
@@ -66,6 +68,7 @@ import retrofit2.Response;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.mockito.Mockito.when;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getFileInZip;
@@ -77,10 +80,19 @@ public class TestBase {
public static final String VIM_ID = "myCloudOwnerId_myRegionName";
public static final String JOB_ID = "myJobId";
public static final String CBAM_VNFD_ID = "cbamVnfdId";
+ public static final String HTTP_AUTH_URL = "http://authurl/";
+ public static final String HTTP_LCM_URL = "http://lcmurl/";
+ public static final String HTTP_LCN_URL = "http://lcnurl/";
+ public static final String HTTP_CATLOG_URL = "http://catlogurl/";
+ public static final String SUBCRIPTION_ID = "subcriptionId";
protected static VoidObservable VOID_OBSERVABLE = new VoidObservable();
@Mock
protected CbamRestApiProvider cbamRestApiProvider;
@Mock
+ protected CbamRestApiProviderForSo cbamRestApiProviderForSo;
+ @Mock
+ protected CbamRestApiProviderForVfc cbamRestApiProviderForVfc;
+ @Mock
protected VfcRestApiProvider vfcRestApiProvider;
@Mock
protected MsbApiProvider msbApiProvider;
@@ -93,7 +105,9 @@ public class TestBase {
@Mock
protected OperationExecutionsApi operationExecutionApi;
@Mock
- protected SelfRegistrationManager selfRegistrationManager;
+ protected SelfRegistrationManagerForVfc selfRegistrationManagerForVfc;
+ @Mock
+ protected SelfRegistrationManagerForSo selfRegistrationManagerForSo;
@Mock
protected Logger logger;
@Mock
@@ -101,7 +115,7 @@ public class TestBase {
@Mock
protected ServiceResourceApi msbClient;
@Mock
- protected DriverProperties driverProperties;
+ protected Constants driverProperties;
@Mock
protected NslcmApi nsLcmApi;
@Mock
@@ -124,6 +138,8 @@ public class TestBase {
@Mock
protected Environment environment;
+ protected VnfmInfo vnfmInfo = new VnfmInfo();
+
protected static <T> Call<T> buildCall(T response) {
Call<T> call = Mockito.mock(Call.class);
try {
@@ -146,18 +162,34 @@ public class TestBase {
when(cbamRestApiProvider.getCbamOperationExecutionApi(VNFM_ID)).thenReturn(operationExecutionApi);
when(cbamRestApiProvider.getCbamLcnApi(VNFM_ID)).thenReturn(lcnApi);
when(cbamRestApiProvider.getCbamCatalogApi(VNFM_ID)).thenReturn(cbamCatalogApi);
+ when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID)).thenReturn(vnfApi);
+ when(cbamRestApiProviderForSo.getCbamOperationExecutionApi(VNFM_ID)).thenReturn(operationExecutionApi);
+ when(cbamRestApiProviderForSo.getCbamLcnApi(VNFM_ID)).thenReturn(lcnApi);
+ when(cbamRestApiProviderForSo.getCbamCatalogApi(VNFM_ID)).thenReturn(cbamCatalogApi);
+
+ when(cbamRestApiProviderForVfc.getCbamLcmApi(VNFM_ID)).thenReturn(vnfApi);
+ when(cbamRestApiProviderForVfc.getCbamOperationExecutionApi(VNFM_ID)).thenReturn(operationExecutionApi);
+ when(cbamRestApiProviderForVfc.getCbamLcnApi(VNFM_ID)).thenReturn(lcnApi);
+ when(cbamRestApiProviderForVfc.getCbamCatalogApi(VNFM_ID)).thenReturn(cbamCatalogApi);
+
when(msbApiProvider.getMsbApi()).thenReturn(msbClient);
when(vfcRestApiProvider.getNsLcmApi()).thenReturn(nsLcmApi);
when(vfcRestApiProvider.getVfcCatalogApi()).thenReturn(vfcCatalogApi);
when(systemFunctions.getHttpClient()).thenReturn(httpClient);
when(httpClient.execute(request.capture())).thenReturn(response);
when(response.getEntity()).thenReturn(entity);
- when(driverProperties.getVnfmId()).thenReturn(VNFM_ID);
when(systemFunctions.getHttpClient()).thenReturn(httpClient);
when(logger.isInfoEnabled()).thenReturn(true);
when(logger.isDebugEnabled()).thenReturn(true);
when(logger.isWarnEnabled()).thenReturn(true);
when(logger.isErrorEnabled()).thenReturn(true);
+ when(vnfmInfoProvider.getVnfmInfo(VNFM_ID)).thenReturn(vnfmInfo);
+ vnfmInfo.setUrl(HTTP_AUTH_URL + SEPARATOR + HTTP_LCM_URL + SEPARATOR + HTTP_LCN_URL + SEPARATOR + HTTP_CATLOG_URL);
+ vnfmInfo.setUserName("myUsername" + SEPARATOR + "myClientId");
+ vnfmInfo.setPassword("myPassword" + SEPARATOR + "myClientSecret");
+ when(selfRegistrationManagerForSo.getVnfmId(SUBCRIPTION_ID)).thenReturn(VNFM_ID);
+ when(selfRegistrationManagerForVfc.getVnfmId(SUBCRIPTION_ID)).thenReturn(VNFM_ID);
+
}
@After
@@ -215,7 +247,7 @@ public class TestBase {
throw new NoSuchElementException("The " + obj.getClass() + " does not have a filed with " + key + " annotation");
}
- protected static class VoidObservable {
+ public static class VoidObservable {
boolean called = false;
ObservableFromCallable<Void> s = new ObservableFromCallable(new Callable() {
@Override
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java
index 74c40a2a..e9170e4c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java
@@ -36,7 +36,6 @@ import org.onap.msb.model.MicroServiceFullInfo;
import org.onap.msb.model.NodeInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.IpMappingProvider;
-import org.onap.vnfmdriver.model.VnfmInfo;
import org.springframework.core.env.Environment;
import static junit.framework.TestCase.assertEquals;
@@ -80,7 +79,7 @@ public class TestCbamRestApiProvider extends TestBase {
setFieldWithPropertyAnnotation(real, "${skipHostnameVerification}", true);
cbamSecurityProvider = spy(real);
microServiceInfo.setNodes(nodes);
- cbamRestApiProvider = new CbamRestApiProvider(driverProperties, cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ cbamRestApiProvider = new CbamRestApiProvider(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("");
when(environment.getProperty(GenericExternalSystemInfoProvider.VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, Long.valueOf(10 * 60 * 1000))).thenReturn(10 * 60 * 1000L);
}
@@ -90,9 +89,6 @@ public class TestCbamRestApiProvider extends TestBase {
*/
@Test
public void testCbamLcmApi() throws Exception {
- VnfmInfo expectedVnfmInfo = new VnfmInfo();
- when(vnfmInfoProvider.getVnfmInfo(VNFM_ID)).thenReturn(expectedVnfmInfo);
- expectedVnfmInfo.setUrl("https://cbamurl:123/d/");
ResultCaptor<SSLSocketFactory> sslSocketFactoryResultCaptor = new ResultCaptor<>();
doAnswer(sslSocketFactoryResultCaptor).when(cbamSecurityProvider).buildSSLSocketFactory();
when(cbamSecurityProvider.buildHostnameVerifier()).thenReturn(hostnameVerifier);
@@ -100,7 +96,7 @@ public class TestCbamRestApiProvider extends TestBase {
//when
ApiClient cbamLcmApi = cbamRestApiProvider.buildLcmApiClient(VNFM_ID);
//verify
- assertEquals("https://cbamurl:123/d/", cbamLcmApi.getAdapterBuilder().build().baseUrl().toString());
+ assertEquals(HTTP_LCM_URL, cbamLcmApi.getAdapterBuilder().build().baseUrl().toString());
assertEquals(sslSocketFactoryResultCaptor.getResult(), cbamLcmApi.getOkBuilder().build().sslSocketFactory());
Map<String, Interceptor> apiAuthorizations = cbamLcmApi.getApiAuthorizations();
assertEquals(1, apiAuthorizations.size());
@@ -117,12 +113,11 @@ public class TestCbamRestApiProvider extends TestBase {
doAnswer(sslSocketFactoryResultCaptor).when(cbamSecurityProvider).buildSSLSocketFactory();
when(cbamSecurityProvider.buildHostnameVerifier()).thenReturn(hostnameVerifier);
when(cbamTokenProvider.getToken(VNFM_ID)).thenReturn(interceptor);
- when(driverProperties.getCbamCatalogUrl()).thenReturn("https://cbamurl:123/d/");
//when
com.nokia.cbam.catalog.v1.ApiClient cbamLcmApi = cbamRestApiProvider.buildCatalogApiClient(VNFM_ID);
//verify
String actual = cbamLcmApi.getAdapterBuilder().build().baseUrl().toString();
- assertEquals("https://cbamurl:123/d/", actual);
+ assertEquals(HTTP_CATLOG_URL, actual);
assertEquals(sslSocketFactoryResultCaptor.getResult(), cbamLcmApi.getOkBuilder().build().sslSocketFactory());
Map<String, Interceptor> apiAuthorizations = cbamLcmApi.getApiAuthorizations();
assertEquals(1, apiAuthorizations.size());
@@ -139,12 +134,11 @@ public class TestCbamRestApiProvider extends TestBase {
doAnswer(sslSocketFactoryResultCaptor).when(cbamSecurityProvider).buildSSLSocketFactory();
when(cbamSecurityProvider.buildHostnameVerifier()).thenReturn(hostnameVerifier);
when(cbamTokenProvider.getToken(VNFM_ID)).thenReturn(interceptor);
- when(driverProperties.getCbamLcnUrl()).thenReturn("https://cbamurl:123/d/");
//when
com.nokia.cbam.lcn.v32.ApiClient cbamLcmApi = cbamRestApiProvider.buildLcnApiClient(VNFM_ID);
//verify
String actual = cbamLcmApi.getAdapterBuilder().build().baseUrl().toString();
- assertEquals("https://cbamurl:123/d/", actual);
+ assertEquals(HTTP_LCN_URL, actual);
assertEquals(sslSocketFactoryResultCaptor.getResult(), cbamLcmApi.getOkBuilder().build().sslSocketFactory());
Map<String, Interceptor> apiAuthorizations = cbamLcmApi.getApiAuthorizations();
assertEquals(1, apiAuthorizations.size());
@@ -162,7 +156,7 @@ public class TestCbamRestApiProvider extends TestBase {
com.nokia.cbam.catalog.v1.ApiClient c = Mockito.mock(com.nokia.cbam.catalog.v1.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
public TestClasss() {
- super(driverProperties, cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ super(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
}
@Override
@@ -189,7 +183,7 @@ public class TestCbamRestApiProvider extends TestBase {
com.nokia.cbam.lcn.v32.ApiClient c = Mockito.mock(com.nokia.cbam.lcn.v32.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
public TestClasss() {
- super(driverProperties, cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ super(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
}
@Override
@@ -216,7 +210,7 @@ public class TestCbamRestApiProvider extends TestBase {
com.nokia.cbam.lcm.v32.ApiClient c = Mockito.mock(com.nokia.cbam.lcm.v32.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
public TestClasss() {
- super(driverProperties, cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ super(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
}
@Override
@@ -243,7 +237,7 @@ public class TestCbamRestApiProvider extends TestBase {
com.nokia.cbam.lcm.v32.ApiClient c = Mockito.mock(com.nokia.cbam.lcm.v32.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
public TestClasss() {
- super(driverProperties, cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
+ super(cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
}
@Override
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java
index 26816a13..6c6a6aeb 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java
@@ -26,13 +26,10 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
-import org.onap.vnfmdriver.model.VnfmInfo;
import org.springframework.http.HttpStatus;
import static junit.framework.TestCase.*;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestCbamTokenProvider extends TestBase {
@@ -40,7 +37,6 @@ public class TestCbamTokenProvider extends TestBase {
private static String GOOD_RESPONSE = "{ \"access_token\" : \"myToken\", \"expires_in\" : 1000 }";
@InjectMocks
private CbamTokenProvider cbamTokenProvider;
- private VnfmInfo vnfmInfo = new VnfmInfo();
private HttpTestServer testServer;
public static String extractToken(Interceptor token) throws IOException {
@@ -56,18 +52,13 @@ public class TestCbamTokenProvider extends TestBase {
@Before
public void initMocks() throws Exception {
setField(CbamTokenProvider.class, "logger", logger);
- setField(cbamTokenProvider, "username", "myUserName");
- setField(cbamTokenProvider, "password", "myPassword");
setField(cbamTokenProvider, "skipCertificateVerification", true);
setField(cbamTokenProvider, "skipHostnameVerification", true);
when(vnfmInfoProvider.getVnfmInfo(VNFM_ID)).thenReturn(vnfmInfo);
- vnfmInfo.setPassword("vnfmPassword");
- vnfmInfo.setUserName("vnfmUserName");
- vnfmInfo.setUrl("http://127.0.0.3:12345");
testServer = new HttpTestServer();
testServer.start();
URI uri = testServer._server.getURI();
- setField(cbamTokenProvider, "cbamKeyCloakBaseUrl", uri.toString());
+ vnfmInfo.setUrl(vnfmInfo.getUrl().replace(HTTP_AUTH_URL, uri.toString()));
}
private void addGoodTokenResponse() {
@@ -203,9 +194,9 @@ public class TestCbamTokenProvider extends TestBase {
private void assertTokenRequest(String body) {
assertContains(body, "grant_type", "password");
- assertContains(body, "client_id", "vnfmUserName");
- assertContains(body, "client_secret", "vnfmPassword");
- assertContains(body, "username", "myUserName");
+ assertContains(body, "client_id", "myClientId");
+ assertContains(body, "client_secret", "myClientSecret");
+ assertContains(body, "username", "myUsername");
assertContains(body, "password", "myPassword");
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java
deleted file mode 100644
index 1db7d975..00000000
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertEquals;
-import static pl.pojo.tester.api.assertion.Assertions.assertPojoMethodsFor;
-
-
-public class TestDriverProperties extends TestBase {
-
- /**
- * Test basic POJO behaviour
- */
- @Test
- public void test() {
- assertPojoMethodsFor(DriverProperties.class).areWellImplemented();
- }
-
- /**
- * Test parameter initialization by Spring
- * - changes in this constants should be also altered in
- * - application*.properties
- * - in deployment configuration file
- * - documentation
- */
- @Test
- public void testSpringParameterLoading() {
- DriverProperties driverProperties = new DriverProperties();
- setFieldWithPropertyAnnotation(driverProperties, "${cbamCatalogUrl}", "cbamCatalogUrl");
- setFieldWithPropertyAnnotation(driverProperties, "${cbamLcnUrl}", "cbamLcnUrl");
- setFieldWithPropertyAnnotation(driverProperties, "${vnfmId}", "vnfmId");
- assertEquals("cbamCatalogUrl", driverProperties.getCbamCatalogUrl());
- assertEquals("cbamLcnUrl", driverProperties.getCbamLcnUrl());
- assertEquals("vnfmId", driverProperties.getVnfmId());
-
- }
-}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
index 432fff6d..79dcac31 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
@@ -31,7 +31,6 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -54,7 +53,6 @@ public class TestJobManager extends TestBase {
@Mock
private HttpServletResponse httpResponse;
- @InjectMocks
private JobManager jobManager;
private List<VnfInfo> vnfs = new ArrayList<>();
@@ -62,7 +60,8 @@ public class TestJobManager extends TestBase {
public void initMocks() throws Exception {
ReflectionTestUtils.setField(JobManager.class, "logger", logger);
when(vnfApi.vnfsGet(NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfs));
- when(selfRegistrationManager.isReady()).thenReturn(true);
+ when(selfRegistrationManagerForVfc.isReady()).thenReturn(true);
+ jobManager = new JobManager(cbamRestApiProviderForVfc, selfRegistrationManagerForVfc);
}
/**
@@ -550,7 +549,7 @@ public class TestJobManager extends TestBase {
@Test
public void noJobCanBeStartedIfRegistrationNotFinished() throws Exception {
//given
- when(selfRegistrationManager.isReady()).thenReturn(false);
+ when(selfRegistrationManagerForVfc.isReady()).thenReturn(false);
//when
try {
jobManager.spawnJob(VNF_ID, httpResponse);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
index fba5e0d5..14e764c9 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
@@ -51,7 +51,6 @@ import static java.nio.file.Files.readAllBytes;
import static java.util.Optional.empty;
import static junit.framework.TestCase.*;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
index 449217f9..bfb30abd 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
@@ -71,6 +71,7 @@ public class TestLifecycleChangeNotificationManager extends TestBase {
healOperation.setId("healOperaitonExecutionId");
healOperation.setOperationType(OperationType.HEAL);
recievedLcn.setLifecycleOperationOccurrenceId("instantiationOperationExecutionId");
+ recievedLcn.setSubscriptionId(SUBCRIPTION_ID);
healOperation.setStartTime(OffsetDateTime.now().plusDays(1));
recievedLcn.setVnfInstanceId(VNF_ID);
when(vnfApi.vnfsVnfInstanceIdOperationExecutionsGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(operationExecutions));
@@ -78,7 +79,7 @@ public class TestLifecycleChangeNotificationManager extends TestBase {
prepOperation(scaleOperation);
prepOperation(healOperation);
prepOperation(terminationOperation);
- doNothing().when(notificationSender).processNotification(eq(recievedLcn), currentOperationExecution.capture(), affectedConnectionPoints.capture(), eq(VIM_ID));
+ doNothing().when(notificationSender).processNotification(eq(recievedLcn), currentOperationExecution.capture(), affectedConnectionPoints.capture(), eq(VIM_ID), eq(VNFM_ID));
InstantiateVnfRequest instantiateVnfRequest = new InstantiateVnfRequest();
VimInfo vimInfo = new VimInfo();
vimInfo.setId(VIM_ID);
@@ -341,6 +342,7 @@ public class TestLifecycleChangeNotificationManager extends TestBase {
//given
//add an non processed notification
VnfLifecycleChangeNotification nonProcessedEvent = new VnfLifecycleChangeNotification();
+ nonProcessedEvent.setSubscriptionId(SUBCRIPTION_ID);
nonProcessedEvent.setStatus(OperationStatus.FINISHED);
nonProcessedEvent.setOperation(OperationType.TERMINATE);
OperationExecution secondTerminationOperationExecution = new OperationExecution();
diff --git a/nokiav2/driver/src/test/resources/application-direct.properties b/nokiav2/driver/src/test/resources/application-direct.properties
index 27ce13e0..5702c913 100644
--- a/nokiav2/driver/src/test/resources/application-direct.properties
+++ b/nokiav2/driver/src/test/resources/application-direct.properties
@@ -13,14 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
+
server.error.whitelabel.enabled=false
+
###############################################################################
-# Beginning of mandatory properties #
+# Beginning of mandatory properties #
###############################################################################
# The TCP port of the server
server.port=8089
# the base path of the server
-server.context-path=
+server.servlet.context-path=
# the IP address to which the server binds to
server.address=127.0.0.1
# the IP address of the server reported to the micro service bus
@@ -31,12 +33,6 @@ driverVnfmExternalIp=10.41.63.151
messageBusIp=msb.api.simpledemo.onap.org
# the TCP port of the message bus
messageBusPort=80
-# the URL of the CBAM catalog service
-cbamCatalogUrl=https://10.41.63.149:443/api/catalog/adapter
-# the URL of the CBAM LCN service
-cbamLcnUrl=https://10.41.63.149:443/vnfm/lcn/v3
-# the URL of the CBAM authentication service
-cbamKeyCloakBaseUrl=https://10.41.63.149:443/auth
# skip hostname verification during SSL on CBAM LCN, LCM and authorization interface
skipHostnameVerification=true
# skip certificate verification during SSL on CBAM LCN, LCM and authorization interface
@@ -44,10 +40,6 @@ skipCertificateVerification=true
# the collection of trusted certificates for SSL on CBAM LCN, LCM and authorization interface
# in PEM format encoded in BASE64 to a single line
trustedCertificates=
-# the username to be used for requesting a token on CBAM authorization interface
-cbamUsername=onap
-# the password to be used for requesting a token on CBAM authorization interface
-cbamPassword=Admin@123
# the identifier of the VNFM in A&AI core system registry
vnfmId=7c267318-2a6a-4d47-b039-a7cce5fea38b
@@ -69,6 +61,7 @@ aaiPassword=AAI
sdcUsername=SDC
#The password to access SDC
sdcPassword=SDC
+
###############################################################################
# End of mandatory properties for driver #
###############################################################################
@@ -76,10 +69,9 @@ ipMap=10.0.14.1->msb.api.simpledemo.onap.org,172.17.0.15->msb.api.simpledemo.ona
vnfmInfoCacheEvictionInMs=600000
## for logging begin ##
com.fasterxml.jackson.core=jackson-databind
-#logging.file=${catalina.base}/logs/vfcadaptor.log
logging.level.org.springframework=INFO
logging.level.org.hibernate=OFF
logging.level.org.springframework.web=DEBUG
## for logging end ##
-spring.http.multipart.max-file-size=50000KB
-spring.http.multipart.max-request-size=50000KB
+spring.servlet.multipart.max-file-size=50000KB
+spring.servlet.multipart.max-request-size=50000KB \ No newline at end of file
diff --git a/nokiav2/driver/src/test/resources/application.properties b/nokiav2/driver/src/test/resources/application.properties
index 8446b483..af64fd95 100644
--- a/nokiav2/driver/src/test/resources/application.properties
+++ b/nokiav2/driver/src/test/resources/application.properties
@@ -13,14 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
+
server.error.whitelabel.enabled=false
+
###############################################################################
# Beginning of mandatory properties #
###############################################################################
# The TCP port of the server
server.port=8089
# the base path of the server
-server.context-path=
+server.servlet.context-path=
# the IP address to which the server binds to
server.address=127.0.0.1
# the IP address of the server reported to the micro service bus
@@ -31,12 +33,6 @@ driverVnfmExternalIp=127.0.0.1
messageBusIp=127.0.0.1
# the TCP port of the message bus
messageBusPort=8089
-# the URL of the CBAM catalog service
-cbamCatalogUrl=https://127.0.0.1:443/api/catalog/adapter
-# the URL of the CBAM LCN service
-cbamLcnUrl=https://127.0.0.0.1:443/vnfm/lcn/v3
-# the URL of the CBAM authentication service
-cbamKeyCloakBaseUrl=https://127.0.0.0.1:443/auth
# skip hostname verification during SSL on CBAM LCN, LCM and authorization interface
skipHostnameVerification=true
# skip certificate verification during SSL on CBAM LCN, LCM and authorization interface
@@ -44,10 +40,6 @@ skipCertificateVerification=true
# the collection of trusted certificates for SSL on CBAM LCN, LCM and authorization interface
# in PEM format encoded in BASE64 to a single line
trustedCertificates=
-# the username to be used for requesting a token on CBAM authorization interface
-cbamUsername=onap
-# the password to be used for requesting a token on CBAM authorization interface
-cbamPassword=myPassword
# the identifier of the VNFM in A&AI core system registry
vnfmId=53fbba58-464e-4cc4-8d33-aaaf072f0a27
@@ -77,7 +69,8 @@ spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.oau
vnfmInfoCacheEvictionInMs=600000
## for logging begin ##
com.fasterxml.jackson.core=jackson-databind
-#logging.file=${catalina.base}/logs/vfcadaptor.log
logging.level.org.springframework.web=TRACE
logging.level.org.hibernate=OFF
## for logging end ##
+spring.servlet.multipart.max-file-size=50000KB
+spring.servlet.multipart.max-request-size=50000KB \ No newline at end of file
diff --git a/nokiav2/generatedapis/src/main/resources/so.vnfm.json b/nokiav2/generatedapis/src/main/resources/so.vnfm.json
index 75b76a3c..c70a83bf 100644
--- a/nokiav2/generatedapis/src/main/resources/so.vnfm.json
+++ b/nokiav2/generatedapis/src/main/resources/so.vnfm.json
@@ -440,6 +440,11 @@
"description": "The identifier of the VNF package in SDC",
"type": "string"
},
+ "nsId": {
+ "required": false,
+ "description": "The identifier of the NS in AAI",
+ "type": "string"
+ },
"description": {
"required": false,
"description": "The description of the VNF",