# 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 #
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
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
sdcUsername=SDC
#The password to access SDC
sdcPassword=SDC
+
###############################################################################
# End of mandatory properties for driver #
###############################################################################
## 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
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
done
echo "Server quit (unexpected)"
done
-
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
+
+
--- /dev/null
+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/
:caption: Contents:
integration.rst
+ fix.rst
samplevnf.rst
vnfintegration.rst
onboarding.rst
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.
- 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.
- 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.
- 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.
- 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>.
.. 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:
- 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
--- /dev/null
+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
--- /dev/null
+{
+ "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
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;
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
@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
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);
return true;
};
executorService.submit(() -> {
- while (!jobManager.isPreparingForShutDown()) {
+ while (!jobManagerForVfc.isPreparingForShutDown() && !jobManagerForSo.isPreparingForShutDown()) {
try {
executorService.submit(singleRegistration).get();
//registration successful
}
});
}
+
}
/**
@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;
* @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);
}
*/
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 {
/**
* @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();
}
*/
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;
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;
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
* @return the description of the VNFM
*/
public abstract VnfmInfo queryVnfmInfoFromSource(String vnfmId);
+
}
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;
/**
* 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}")
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;
}
/**
*/
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;
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);
+ }
}
/**
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());
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);
}
}
+ 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;
}
}
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);
}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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() + '\'' +
+ '}';
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
*/
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;
* 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;
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()));
+ }
}
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;
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 + "/";
}
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;
* 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);
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;
* 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
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();
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.*;
* 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;
}
@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);
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;
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;
}
/**
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;
* 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) {
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();
}
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
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;
* 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
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;
* 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) {
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;
* 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) {
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;
* 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) {
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.*;
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;
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;
}
/**
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;
}
*/
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;
* 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) {
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);
+ }
}
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;
* 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;
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;
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;
* 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()));
} 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);
}
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;
* 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;
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";
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;
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;
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;
private final JobManager jobManager;
@Autowired
- LcmApi(LifecycleManager lifecycleManager, JobManager jobManager) {
+ LcmApi(LifecycleManagerForVfc lifecycleManager, JobManagerForVfc jobManager) {
this.lifecycleManager = lifecycleManager;
this.jobManager = jobManager;
}
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;
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;
@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;
}
/**
@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);
}
}
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.*;
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;
@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;
}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
--- /dev/null
+/*
+ * 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;
+ }
+}
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;
* - 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
private final CbamRestApiProvider cbamRestApiProvider;
private final IPackageProvider packageProvider;
- @Autowired
CatalogManager(CbamRestApiProvider cbamRestApiProvider, IPackageProvider packageProvider) {
this.cbamRestApiProvider = cbamRestApiProvider;
this.packageProvider = packageProvider;
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
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;
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;
}
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;
}
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;
}
}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
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;
/**
* 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")
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;
}
* @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();
} 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));
}
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();
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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";
+}
+++ /dev/null
-/*
- * 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);
- }
-}
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;
* 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>() {
private final SelfRegistrationManager selfRegistrationManager;
private volatile boolean preparingForShutDown = false;
- @Autowired
JobManager(CbamRestApiProvider cbamRestApiProvider, SelfRegistrationManager selfRegistrationManager) {
this.cbamRestApiProvider = cbamRestApiProvider;
this.selfRegistrationManager = selfRegistrationManager;
--- /dev/null
+/*
+ * 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);
+ }
+
+}
--- /dev/null
+/*
+ * 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);
+ }
+
+}
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;
/**
* 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;
*/
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;
--- /dev/null
+/*
+ * 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);
+ }
+
+}
--- /dev/null
+/*
+ * 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);
+ }
+
+}
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;
* 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";
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;
}
/**
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()));
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;
}
} 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();
}
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()));
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
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.*;
TestGrantlessGrantManager.class,
TestSdcPackageProvider.class,
+ TestSoLifecycleManager.class,
+
TestVfcExternalSystemInfoProvider.class,
TestVfcGrantManager.class,
TestVfcPackageProvider.class,
TestSwaggerApi.class,
TestSwaggerDefinitionConsistency.class,
- TestConditions.class,
TestServletInitializer.class,
TestRealConfig.class,
TestCbamRestApiProvider.class,
TestCbamSecurityProvider.class,
TestCbamTokenProvider.class,
- TestDriverProperties.class,
TestJobManager.class,
TestVfcGrantManager.class,
TestLifecycleManager.class,
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.*;
public class TestNokiaSvnfmApplication extends TestBase {
@Mock
- private JobManager jobManager;
+ private JobManagerForVfc jobManagerForVfc;
+ @Mock
+ private JobManagerForSo jobManagerForSo;
private NokiaSvnfmApplication.SelfRegistrationTrigger selfRegistrationTriggerer;
private NokiaSvnfmApplication.SelfDeRegistrationTrigger selfUnregistrationTriggerer;
@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);
}
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;
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
*/
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)
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();
}
/**
@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
}
return null;
}
- }).when(selfRegistrationManager).register();
+ }).when(selfRegistrationManagerForVfc).register();
ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+ useVfc(event);
//when
selfRegistrationTriggerer.onApplicationEvent(event);
//verify
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);
*/
@Test
public void testBasicWorkflow() throws Exception {
+ SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
+
VimInfo nokia_regionOne = externalSystemInfoProvider.getVimInfo("Nokia_RegionOne");
VnfLifecycleChangeNotification recievedNot = new VnfLifecycleChangeNotification();
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) {
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;
public VimInfo getVimInfo(String vimId) {
return null;
}
+
+ @Override
+ public Set<String> getVnfms() {
+ return null;
+ }
}
try {
new TestClass(null).getVnfmInfo(VNFM_ID);
public VimInfo getVimInfo(String vimId) {
return null;
}
+
+ @Override
+ public Set<String> getVnfms() {
+ return null;
+ }
}
}
* 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;
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;
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");
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));
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();
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() {
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);
//given
RuntimeException expectedException = new RuntimeException();
when(lcnApi.subscriptionsPost(any(), any())).thenThrow(expectedException);
+ when(vnfmInfoProvider.getVnfms()).thenReturn(newHashSet(VNFM_ID));
//when
try {
selfRegistrationManager.register();
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());
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
//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();
//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
//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
//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);
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
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;
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);
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());
}
/**
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());
}
/**
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());
}
/**
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;
@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");
//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());
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);
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);
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);
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);
}
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;
@Before
public void init() {
- dummyManager = new DummyManager(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ dummyManager = new DummyManager(aaiRestApiProvider, cbamRestApiProvider);
}
/**
class DummyManager extends AbstractManager {
- DummyManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) {
- super(aaiRestApiProvider, cbamRestApiProvider, driverProperties);
+ DummyManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider) {
+ super(aaiRestApiProvider, cbamRestApiProvider);
}
@Override
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
@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>() {
}
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());
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());
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;
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());
}
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];
});
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());
@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);
}
@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);
}
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;
@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);
}
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;
@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);
}
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.*;
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);
}
/**
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.*;
private GrantVNFResponseVim vim = new GrantVNFResponseVim();
private GrantVNFResponse grantResponse = new GrantVNFResponse();
@Mock
- private CatalogManager cbamCatalogManager;
- @InjectMocks
+ private CatalogManagerForVfc cbamCatalogManager;
private VfcGrantManager vfcGrantManager;
@Before
setField(VfcGrantManager.class, "logger", logger);
when(nsLcmApi.grantvnf(grantRequest.capture())).thenReturn(buildObservable(grantResponse));
grantResponse.setVim(vim);
+ vfcGrantManager = new VfcGrantManager(cbamCatalogManager, cbamRestApiProviderForVfc, vfcRestApiProvider);
}
/**
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;
@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");
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());
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());
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());
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());
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());
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());
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());
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());
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());
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) {
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;
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;
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);
}
/**
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;
@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);
}
/**
//when
lcnApi.handleLcn(lcn);
//verify
- verify(lcnManager).handleLcn(lcn);
+ verify(lifecycleChangeNotificationManagerForVfc).handleLcn(lcn);
verify(logger).info("REST: handle LCN");
}
}
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;
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);
}
/**
@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
+++ /dev/null
-/*
- * 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);
- }
-
-}
--- /dev/null
+/*
+ * 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
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;
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;
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;
@Mock
protected OperationExecutionsApi operationExecutionApi;
@Mock
- protected SelfRegistrationManager selfRegistrationManager;
+ protected SelfRegistrationManagerForVfc selfRegistrationManagerForVfc;
+ @Mock
+ protected SelfRegistrationManagerForSo selfRegistrationManagerForSo;
@Mock
protected Logger logger;
@Mock
@Mock
protected ServiceResourceApi msbClient;
@Mock
- protected DriverProperties driverProperties;
+ protected Constants driverProperties;
@Mock
protected NslcmApi nsLcmApi;
@Mock
@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 {
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
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
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;
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);
}
*/
@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);
//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());
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());
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());
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
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
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
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
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 {
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 {
@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() {
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");
}
+++ /dev/null
-/*
- * 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());
-
- }
-}
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;
@Mock
private HttpServletResponse httpResponse;
- @InjectMocks
private JobManager jobManager;
private List<VnfInfo> vnfs = new ArrayList<>();
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);
}
/**
@Test
public void noJobCanBeStartedIfRegistrationNotFinished() throws Exception {
//given
- when(selfRegistrationManager.isReady()).thenReturn(false);
+ when(selfRegistrationManagerForVfc.isReady()).thenReturn(false);
//when
try {
jobManager.spawnJob(VNF_ID, httpResponse);
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;
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));
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);
//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();
# 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
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
# 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
sdcUsername=SDC
#The password to access SDC
sdcPassword=SDC
+
###############################################################################
# End of mandatory properties for driver #
###############################################################################
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
# 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
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
# 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
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
"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",