From: ajay_dp001 Date: Thu, 21 Jan 2021 14:41:26 +0000 (+0530) Subject: Fixed Config-Over-Netconf CSIT X-Git-Url: https://gerrit.onap.org/r/gitweb?p=integration%2Fcsit.git;a=commitdiff_plain;h=def30df55e27fd1eccbcda7a19f6d7f1ef9004a8 Fixed Config-Over-Netconf CSIT - Added Netconf-Pnp-Simulator - Fix, updated Config-Over-Netconf csit Issue-ID: INT-1835 Signed-off-by: ajay_dp001 Change-Id: Idb769fc027acfa24f82caaa27209d9f3f4084249 --- diff --git a/plans/usecases-config-over-netconf/config-over-netconf/cds/cds_setup.sh b/plans/usecases-config-over-netconf/config-over-netconf/cds/cds_setup.sh deleted file mode 100755 index b595e6b1..00000000 --- a/plans/usecases-config-over-netconf/config-over-netconf/cds/cds_setup.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# -# ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. -# ================================================================================ -# 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. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -# @author Rahul Tyagi (rahul.tyagi@est.tech) - -CDS_DATA_PATH=$WORKSPACE/plans/$PARENT/$SUB_PARENT/cds - -cd $CDS_DATA_PATH -export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') -unset http_proxy https_proxy - -#cd $WORKSPACE/archives/cds/ms/blueprintsprocessor/distribution/src/main/dc/ - -############# update ip of sdnc in docker-compose########### -SDNC_CONTAINER=$(docker ps -a -q --filter="name=sdnc_controller_container") -SDNC_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER) -echo " " >> docker-compose.yaml -echo " extra_hosts:" >> docker-compose.yaml -echo " - 'sdnc:$LOCAL_IP'" >> docker-compose.yaml -############################################################# - -docker-compose up -d -sleep 10 -################# Check state of BP #################### -BP_CONTAINER=$(docker ps -a -q --filter="name=bp-rest") -CCSDK_MARIADB=$(docker ps -a -q --filter="name=ccsdk-mariadb") -for i in {1..10}; do -if [ $(docker inspect --format='{{ .State.Running }}' $BP_CONTAINER) ] && \ -[ $(docker inspect --format='{{ .State.Running }}' $CCSDK_MARIADB) ] -then - echo "Blueprint proc Service Running" - break -else - echo sleep $i - sleep $i -fi -done - diff --git a/plans/usecases-config-over-netconf/config-over-netconf/cds/docker-compose.yaml b/plans/usecases-config-over-netconf/config-over-netconf/cds/docker-compose.yaml index 4834f912..f914e48c 100755 --- a/plans/usecases-config-over-netconf/config-over-netconf/cds/docker-compose.yaml +++ b/plans/usecases-config-over-netconf/config-over-netconf/cds/docker-compose.yaml @@ -23,9 +23,17 @@ services: - "8000:8080" restart: always environment: - APPLICATIONNAME: BlueprintsProcessor - BUNDLEVERSION: 1.0.0 - APP_CONFIG_HOME: /opt/app/onap/config - STICKYSELECTORKEY: - ENVCONTEXT: dev + - APPLICATIONNAME=BlueprintsProcessor + - BUNDLEVERSION=1.0.0 + - APP_CONFIG_HOME=/opt/app/onap/config + - ENVCONTEXT=dev + volumes: + - /etc/localtime:/etc/localtime:ro + - ${WORKSPACE}/plans/usecases-config-over-netconf/config-over-netconf/cds/resources:/opt/app/onap/res + entrypoint: + - /bin/sh + - -c + - "/opt/app/onap/res/importCerAndStartService.sh" + extra_hosts: + - sdnc:${LOCAL_IP} diff --git a/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/application.properties b/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/application.properties new file mode 100755 index 00000000..34d572e5 --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/application.properties @@ -0,0 +1,97 @@ +# Web Server Configurations +# START -Controller Blueprints Properties & Load Resource Source Mappings +resourceSourceMappings=processor-db=source-db,input=source-input,default=source-default,sdnc=source-rest,aai-data=source-rest,capability=source-capability,rest=source-rest,vault-data=source-rest,script=source-capability + +# Controller Blueprints Core Configuration +blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy +blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive +blueprintsprocessor.blueprintWorkingPath=/opt/app/onap/blueprints/working + +# Controller Blueprint Load Configurations +blueprintsprocessor.loadBluePrintPaths=/opt/app/onap/model-catalog/blueprint-model +blueprintsprocessor.loadModeTypePaths=/opt/app/onap/model-catalog/definition-type +blueprintsprocessor.loadResourceDictionaryPaths=/opt/app/onap/model-catalog/resource-dictionary + +# CBA file extension +controllerblueprints.loadCbaExtension=zip + +### END -Controller Blueprints Properties + +blueprintsprocessor.grpcEnable=true +blueprintsprocessor.httpPort=8080 +blueprintsprocessor.grpcPort=9111 + +# DB +blueprintsprocessor.db.url=jdbc:mysql://db:3306/sdnctl +blueprintsprocessor.db.username=sdnctl +blueprintsprocessor.db.password=sdnctl +blueprintsprocessor.db.driverClassName=org.mariadb.jdbc.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=update +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect + +# Processor-DB Endpoint +blueprintsprocessor.db.processor-db.type=maria-db +blueprintsprocessor.db.processor-db.url=jdbc:mysql://mariadb-galera:3306/sdnctl +blueprintsprocessor.db.processor-db.username=root +blueprintsprocessor.db.processor-db.password=secretpassword + +# Python Executor +blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython/ccsdk_blueprints +blueprints.processor.functions.python.executor.modulePaths=/opt/app/onap/scripts/jython/ccsdk_blueprints,/opt/app/onap/scripts/jython/ccsdk_netconf,/opt/app/onap/scripts/jython/ccsdk_restconf + +security.user.password: {bcrypt}$2a$10$duaUzVUVW0YPQCSIbGEkQOXwafZGwQ/b32/Ys4R1iwSSawFgz7QNu +security.user.name: ccsdkapps + +# Used in Health Check +#endpoints.user.name=ccsdkapps +#endpoints.user.password=ccsdkapps + +# Executor Options +blueprintsprocessor.resourceResolution.enabled=true +blueprintsprocessor.netconfExecutor.enabled=true +blueprintsprocessor.restConfExecutor.enabled=true +blueprintsprocessor.cliExecutor.enabled=true +blueprintsprocessor.remoteScriptCommand.enabled=true + +# Command Executor +blueprintsprocessor.grpcclient.remote-python.type=token-auth +blueprintsprocessor.grpcclient.remote-python.host=localhost +blueprintsprocessor.grpcclient.remote-python.port=50051 +blueprintsprocessor.grpcclient.remote-python.token=Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + +# Python Executor +blueprintsprocessor.grpcclient.py-executor.type=tls-auth +blueprintsprocessor.grpcclient.py-executor.host=py-executor-default:50052 +blueprintsprocessor.grpcclient.py-executor.trustCertCollection=/opt/app/onap/config/certs/py-executor/py-executor-chain.pem + +# Config Data REST client settings +blueprintsprocessor.restconfEnabled=true +blueprintsprocessor.restclient.sdnc.type=basic-auth +blueprintsprocessor.restclient.sdnc.url=http://sdnc:8282 +blueprintsprocessor.restclient.sdnc.username=admin +blueprintsprocessor.restclient.sdnc.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U +blueprintprocessor.remoteScriptCommand.enabled=true + +# Encrypted username and password for health check service +endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ== +endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ== + +# BaseUrls for health check blueprint processor services +blueprintprocessor.healthcheck.baseUrl=http://localhost:8080/ +blueprintprocessor.healthcheck.mapping-service-name-with-service-link=[Execution service,/api/v1/execution-service/health-check],[Resources service,/api/v1/resources/health-check],[Template service,/api/v1/template/health-check] + +# BaseUrls for health check Cds Listener services +cdslistener.healthcheck.baseUrl=http://cds-sdc-listener:8080/ +cdslistener.healthcheck.mapping-service-name-with-service-link=[SDC Listener service,/api/v1/sdclistener/healthcheck] + +# Actuator Properties +management.endpoints.web.exposure.include=* +management.endpoint.health.show-details=always +management.info.git.mode=full + +# Error Managements +error.catalog.applicationId=cds +error.catalog.type=properties +error.catalog.errorDefinitionDir=/opt/app/onap/config/ \ No newline at end of file diff --git a/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/error-messages_en.properties b/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/error-messages_en.properties new file mode 100755 index 00000000..3b731c70 --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/error-messages_en.properties @@ -0,0 +1,77 @@ +# Error Messages Configurations + +org.onap.ccsdk.cds.blueprintsprocessor.generic_failure=cause=Internal error in Blueprint Processor run time.,action=Contact CDS administrator team. +org.onap.ccsdk.cds.blueprintsprocessor.resource_path_missing=cause=Resource path missing or wrong.,action=Please reload your artifact in run time. +org.onap.ccsdk.cds.blueprintsprocessor.resource_writing_fail=cause=Fail to write resources files.,action=Please reload your files and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.io_file_interrupt=cause=IO file system interruption.,action=Please reload your file and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.invalid_request_format=cause=bad request provided.,action=Verify the request payload. +org.onap.ccsdk.cds.blueprintsprocessor.unauthorized_request=cause=The request requires user authentication.,action=Please provide the right credentials. +org.onap.ccsdk.cds.blueprintsprocessor.request_not_found=cause=Request mapping doesn't exist.,action=Please verify your request. +org.onap.ccsdk.cds.blueprintsprocessor.conflict_adding_resource=cause=Duplicated entry while saving resource.,action=Please make the saving model doesn't exist. +org.onap.ccsdk.cds.blueprintsprocessor.duplicate_data=cause=Duplicated data - was expecting one result, got more than one.,action=Please provide single resource at a time. +org.onap.ccsdk.cds.blueprintsprocessor.resource_not_found=cause=No response was found for this request in the server.,action=Provide the ID to find the resource. +org.onap.ccsdk.cds.blueprintsprocessor.unsupported_media_type=cause=An invalid media was provided.,action=Please make sure your media or artifact is in the proper structure or format. + +# Self Service API +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.generic_failure=cause=Internal error in Self Service API.,action=Verify the request and try again. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.generic_process_failure=cause=Internal error while processing REST call to the Self Service API.,action=Verify the request and try again. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.invalid_file_extension=cause=Failed trying to upload a non ZIP file format.,action=Please reload your file and make sure it is in ZIP format. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.resource_path_missing=cause=Resource path missing or wrong.,action=Please reload your artifact in run time. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.resource_writing_fail=cause=Fail to write resources files.,action=Please reload your files and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.io_file_interrupt=cause=IO file system interruption.,action=Please reload your file and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.invalid_request_format=cause=bad request provided.,action=Verify the request payload. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.unauthorized_request=cause=The request requires user authentication.,action=Please provide the right credentials. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.request_not_found=cause=Request mapping doesn't exist.,action=Please verify your request. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.conflict_adding_resource=cause=Duplicated entry while saving resource.,action=Please make the saving model doesn't exist. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.duplicate_data=cause=Duplicated data - was expecting one result, got more than one.,action=Please provide single resource at a time. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.resource_not_found=cause=No response was found for this request in the server.,action=Provide the ID to find the resource. +org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.unsupported_media_type=cause=An invalid media was provided.,action=Please make sure your media or artifact is in the proper structure or format. + +# Designer API +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.generic_failure=cause=Internal error while processing REST call to the Designer API.,action=Verify the request and try again. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.invalid_file_extension=cause=Failed trying to upload a non ZIP file format.,action=Please reload your file and make sure it is in ZIP format. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.resource_path_missing=cause=Resource path missing or wrong.,action=Please reload your artifact in run time. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.resource_writing_fail=cause=Fail to write resources files.,action=Please reload your files and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.io_file_interrupt=cause=IO file system interruption.,action=Please reload your file and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.invalid_request_format=cause=bad request provided.,action=Verify the request payload. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.unauthorized_request=cause=The request requires user authentication.,action=Please provide the right credentials. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.request_not_found=cause=Request mapping doesn't exist.,action=Please verify your request. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.conflict_adding_resource=cause=Duplicated entry while saving resource.,action=Please make the saving model doesn't exist. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.duplicate_data=cause=Duplicated data - was expecting one result, got more than one.,action=Please provide single resource at a time. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.resource_not_found=cause=No response was found for this request in the server.,action=Provide the ID to find the resource. +org.onap.ccsdk.cds.blueprintsprocessor.designer.api.unsupported_media_type=cause=An invalid media was provided.,action=Please make sure your media or artifact is in the proper structure or format. + +# Resource API +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.generic_failure=cause=Internal error while processing REST call to the Resource API.,action=Verify the request and try again. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.invalid_file_extension=cause=Failed trying to upload a non ZIP file format.,action=Please reload your file and make sure it is in ZIP format. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.resource_path_missing=cause=Resource path missing or wrong.,action=Please reload your artifact in run time. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.resource_writing_fail=cause=Fail to write resources files.,action=Please reload your files and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.io_file_interrupt=cause=IO file system interruption.,action=Please reload your file and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.invalid_request_format=cause=bad request provided.,action=Verify the request payload. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.unauthorized_request=cause=The request requires user authentication.,action=Please provide the right credentials. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.request_not_found=cause=Request mapping doesn't exist.,action=Please verify your request. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.conflict_adding_resource=cause=Duplicated entry while saving resource.,action=Please make the saving model doesn't exist. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.duplicate_data=cause=Duplicated data - was expecting one result, got more than one.,action=Please provide single resource at a time. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.resource_not_found=cause=No response was found for this request in the server.,action=Provide the ID to find the resource. +org.onap.ccsdk.cds.blueprintsprocessor.resource.api.unsupported_media_type=cause=An invalid media was provided.,action=Please make sure your media or artifact is in the proper structure or format. + +# Configs API +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.generic_failure=cause=Internal error while processing REST call to the Configs API.,action=Verify the request and try again. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.resource_path_missing=cause=Resource path missing or wrong.,action=Please reload your artifact in run time. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.io_file_interrupt=cause=IO file system interruption.,action=Please reload your file and make sure it is in the right format. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.invalid_request_format=cause=bad request provided.,action=Verify the request payload. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.unauthorized_request=cause=The request requires user authentication.,action=Please provide the right credentials. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.request_not_found=cause=Request mapping doesn't exist.,action=Please verify your request. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.conflict_adding_resource=cause=Duplicated entry while saving resource.,action=Please make the saving model doesn't exist. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.duplicate_data=cause=Duplicated data - was expecting one result, got more than one.,action=Please provide single resource at a time. +org.onap.ccsdk.cds.blueprintsprocessor.configs.api.resource_not_found=cause=No response was found for this request in the server.,action=Provide the ID to find the resource. + +# Python Executor +org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor.generic_failure=cause=Internal error in Blueprint Processor run time.,action=Contact CDS administrator team. + +# Resource resolution +org.onap.ccsdk.cds.blueprintsprocessor.resource.resolution.invalid_request_format=cause=bad request provided.,action=Verify the request payload. +org.onap.ccsdk.cds.blueprintsprocessor.resource.resolution.resource_not_found=cause=No response was found for this resolution in CDS.,action=Verify definition of the resource in CBA. +org.onap.ccsdk.cds.blueprintsprocessor.resource.resolution.internal_error=cause=Internal error while processing Resource Resolution.,action=Verify the payload. + +org.onap.ccsdk.cds.sdclistener.generic_failure=cause=Internal error in SDC Listener.,action=Contact CDS administrator team. \ No newline at end of file diff --git a/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/importCerAndStartService.sh b/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/importCerAndStartService.sh new file mode 100755 index 00000000..b5816068 --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/cds/resources/importCerAndStartService.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +chmod -R 775 /opt/app/onap/res +cp -f /opt/app/onap/res/application.properties /opt/app/onap/config +cp -f /opt/app/onap/res/error-messages_en.properties /opt/app/onap/config + +echo "Starting Service..." +source /startService.sh \ No newline at end of file diff --git a/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/docker-compose.yml b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/docker-compose.yml new file mode 100755 index 00000000..d8e723ba --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' + +services: + netconf-pnp-simulator: + image: nexus3.onap.org:10001/onap/integration/simulators/netconf-pnp-simulator:2.8.6 + container_name: netconf-simulator + restart: always + ports: + - "830:830" + - "6513:6513" + volumes: + - ${NETCONF_CONFIG_PATH}:/config/modules/mynetconf diff --git a/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/data.json b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/data.json new file mode 100644 index 00000000..63872eef --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/data.json @@ -0,0 +1,10 @@ +{ + "mynetconf:netconflist": { + "netconf": [ + { + "netconf-id": 3, + "netconf-param": 3 + } + ] + } +} diff --git a/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/model.yang b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/model.yang new file mode 100644 index 00000000..6c8c36ab --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/model.yang @@ -0,0 +1,29 @@ +module mynetconf { + yang-version 1.1; + namespace "urn:mynetconf:test"; + + prefix nft; + + organization + "mynetconf"; + contact + "my netconf address"; + description + "yang model for mynetconf"; + revision "2019-03-01" { + description + "initial version"; + } + + container netconflist { + list netconf { + key netconf-id; + leaf netconf-id { + type uint16; + } + leaf netconf-param { + type uint32; + } + } + } +} diff --git a/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/subscriber.py b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/subscriber.py new file mode 100755 index 00000000..61272967 --- /dev/null +++ b/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config/subscriber.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 + +__author__ = "Mislav Novakovic " +__copyright__ = "Copyright 2018, Deutsche Telekom AG" +__license__ = "Apache 2.0" + +# 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. + +# This sample application demonstrates use of Python programming language bindings for sysrepo library. +# Original c application was rewritten in Python to show similarities and differences +# between the two. +# +# Most notable difference is in the very different nature of languages, c is weakly statically typed language +# while Python is strongly dynamically typed. Python code is much easier to read and logic easier to comprehend +# for smaller scripts. Memory safety is not an issue but lower performance can be expected. +# +# The original c implementation is also available in the source, so one can refer to it to evaluate trade-offs. + +import sysrepo as sr +import sys + + +# Helper function for printing changes given operation, old and new value. +def print_change(op, old_val, new_val): + if op == sr.SR_OP_CREATED: + print(f"CREATED: {new_val.to_string()}") + elif op == sr.SR_OP_DELETED: + print(f"DELETED: {old_val.to_string()}") + elif op == sr.SR_OP_MODIFIED: + print(f"MODIFIED: {old_val.to_string()} to {new_val.to_string()}") + elif op == sr.SR_OP_MOVED: + print(f"MOVED: {new_val.xpath()} after {old_val.xpath()}") + + +# Helper function for printing events. +def ev_to_str(ev): + if ev == sr.SR_EV_VERIFY: + return "verify" + elif ev == sr.SR_EV_APPLY: + return "apply" + elif ev == sr.SR_EV_ABORT: + return "abort" + else: + return "unknown" + + +# Function to print current configuration state. +# It does so by loading all the items of a session and printing them out. +def print_current_config(session, module_name): + select_xpath = f"/{module_name}:*//*" + + values = session.get_items(select_xpath) + + if values is not None: + print("========== BEGIN CONFIG ==========") + for i in range(values.val_cnt()): + print(values.val(i).to_string(), end='') + print("=========== END CONFIG ===========") + + +# Function to be called for subscribed client of given session whenever configuration changes. +def module_change_cb(sess, module_name, event, private_ctx): + try: + print("========== Notification " + ev_to_str(event) + " =============================================") + if event == sr.SR_EV_APPLY: + print_current_config(sess, module_name) + + print("========== CHANGES: =============================================") + + change_path = f"/{module_name}:*" + + it = sess.get_changes_iter(change_path) + + while True: + change = sess.get_change_next(it) + if change is None: + break + print_change(change.oper(), change.old_val(), change.new_val()) + + print("========== END OF CHANGES =======================================") + except Exception as e: + print(e) + + return sr.SR_ERR_OK + + +def main(): + # Notable difference between c implementation is using exception mechanism for open handling unexpected events. + # Here it is useful because `Connection`, `Session` and `Subscribe` could throw an exception. + try: + module_name = "ietf-interfaces" + if len(sys.argv) > 1: + module_name = sys.argv[1] + else: + print("\nYou can pass the module name to be subscribed as the first argument") + + print(f"Application will watch for changes in {module_name}") + + # connect to sysrepo + conn = sr.Connection(module_name) + + # start session + sess = sr.Session(conn) + + # subscribe for changes in running config */ + subscribe = sr.Subscribe(sess) + + subscribe.module_change_subscribe(module_name, module_change_cb) + + try: + print_current_config(sess, module_name) + except Exception as e: + print(e) + + print("========== STARTUP CONFIG APPLIED AS RUNNING ==========") + + sr.global_loop() + + print("Application exit requested, exiting.") + + except Exception as e: + print(e) + + +if __name__ == '__main__': + main() diff --git a/plans/usecases-config-over-netconf/config-over-netconf/setup.sh b/plans/usecases-config-over-netconf/config-over-netconf/setup.sh index fcedbecf..2e61da0a 100644 --- a/plans/usecases-config-over-netconf/config-over-netconf/setup.sh +++ b/plans/usecases-config-over-netconf/config-over-netconf/setup.sh @@ -20,101 +20,102 @@ # @author Rahul Tyagi (rahul.tyagi@est.tech) - -SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -export PARENT=usecases-config-over-netconf -export SUB_PARENT=config-over-netconf -source ${WORKSPACE}/plans/$PARENT/$SUB_PARENT/test.properties +SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${WORKSPACE}"/plans/usecases-config-over-netconf/config-over-netconf/test.properties export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) if [ "$MTU" == "" ]; then - export MTU="1450" + export MTU="1450" fi -# clone integration branch for pnf-simulator -mkdir -m 755 -p $WORKSPACE/temp/integration -cd $WORKSPACE/temp -git clone -b dublin --single-branch --depth=1 http://gerrit.onap.org/r/integration.git integration - -HOST_IP_ADDR=localhost +export CONFIG_OVER_NETCONF=${CONFIG_OVER_NETCONF} -# setup sdnc +# Prepare enviroment +echo "Uninstall docker-py and reinstall docker." +pip uninstall -y docker-py +pip uninstall -y docker +pip install -U docker==2.7.0 -cd $SDNC_DOCKER_PATH +# Disable Proxy - for local run unset http_proxy https_proxy -docker pull $NETOPEER_DOCKER_REPO:$NETOPEER_IMAGE_TAG -docker tag $NETOPEER_DOCKER_REPO:$NETOPEER_IMAGE_TAG $NETOPEER_DOCKER_REPO:latest -#sed -i "s/DMAAP_TOPIC_ENV=.*/DMAAP_TOPIC_ENV="AUTO"/g" diocker-compose.yml -docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO +# Export default Networking bridge created on the host machine +export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') -docker pull $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG -docker tag $NEXUS_DOCKER_REPO/onap/sdnc-image:$SDNC_IMAGE_TAG onap/sdnc-image:latest +###################### Netconf-PNP-Simulator Setup ###################### -docker pull $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$ANSIBLE_IMAGE_TAG -docker tag $NEXUS_DOCKER_REPO/onap/sdnc-ansible-server-image:$ANSIBLE_IMAGE_TAG onap/sdnc-ansible-server-image:latest +# Export Netconf-Pnp Simulator conf path +export NETCONF_CONFIG_PATH -docker pull $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$BP_IMAGE_TAG -docker tag $NEXUS_DOCKER_REPO/onap/ccsdk-blueprintsprocessor:$BP_IMAGE_TAG onap/ccsdk-blueprintsprocessor:latest +# Start N etconf-Pnp-Simulator Container with docker-compose and configuration from docker-compose.yml +docker-compose -f "${CONFIG_OVER_NETCONF}"/netconf-pnp-simulator/docker-compose.yml up -d -export SDNC_CERT_PATH=${CERT_SUBPATH} -#sed -i 's/sdnc_controller_container/sdnc_controller_container\n volumes: \n - $SDNC_CERT_PATH:\/opt\/opendaylight\/current\/certs/' docker-compose.yaml -# start SDNC containers with docker compose and configuration from docker-compose.yml -docker-compose up -d +# Update default Networking bridge IP in mount.json file +sed -i "s/pnfaddr/${LOCAL_IP}/g" "${REQUEST_DATA_PATH}"/mount.xml -# start pnf simulator +############################## SDNC Setup ############################## -cd $INT_DOCKER_PATH +export SDNC_CERT_PATH="${CERT_SUBPATH}" -./simulator.sh start& +docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}" +docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}" onap/sdnc-image:latest -# WAIT 10 minutes maximum and test every 5 seconds if SDNC is up using HealthCheck API -TIME_OUT=1000 -INTERVAL=30 -TIME=0 -while [ "$TIME" -lt "$TIME_OUT" ]; do - response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck ); - echo $response +docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-ansible-server-image:"${ANSIBLE_IMAGE_TAG}" +docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-ansible-server-image:"${ANSIBLE_IMAGE_TAG}" onap/sdnc-ansible-server-image:latest - if [ "$response" == "200" ]; then - echo SDNC started in $TIME seconds - break; - fi +docker-compose -f "${CONFIG_OVER_NETCONF}"/sdn/docker-compose.yaml up -d - echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds - sleep $INTERVAL - TIME=$(($TIME+$INTERVAL)) +# Check if SDNC Service is healthy and ready +for i in {1..10}; do + SDNC_IP=$(get-instance-ip.sh sdnc_controller_container) + RESP_CODE=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck) + if [[ "${RESP_CODE}" == '200' ]]; then + echo "SDNC Service is Ready." + break + fi + echo "Waiting for SDNC Service to Start Up..." + sleep 2m done -export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') -sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/mount.xml +if [[ "${SDNC_IP}" == 'none' || "${SDNC_IP}" == '' || "${RESP_CODE}" != '200' ]]; then + echo "SDNC Service not started Could cause problems for testing activities...!" +fi +############################## CDS Setup ############################## -if [ "$TIME" -ge "$TIME_OUT" ]; then - echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... -fi +docker pull "${NEXUS_DOCKER_REPO}"/onap/ccsdk-blueprintsprocessor:"${BP_IMAGE_TAG}" +docker tag "${NEXUS_DOCKER_REPO}"/onap/ccsdk-blueprintsprocessor:"${BP_IMAGE_TAG}" onap/ccsdk-blueprintsprocessor:latest -########################################## blueprintsprocessor setup ########################################################## -source $CDS_DOCKER_PATH/cds_setup.sh +docker-compose -f "${CONFIG_OVER_NETCONF}"/cds/docker-compose.yaml up -d -########## update pnf simulator ip in config deploy request ######## +echo "Sleeping 1 minute" +sleep 1m -NETOPEER_CONTAINER=$(docker ps -a -q --filter="name=netopeer") -NETOPEER_CONTAINER_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $SDNC_CONTAINER) -RES_KEY=$(uuidgen -r) -sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-deploy.json -sed -i "s/pnfaddr/$LOCAL_IP/g" $REQUEST_DATA_PATH/config-assign.json +BP_CONTAINER=$(docker ps -a -q --filter="name=bp-rest") +CCSDK_MARIADB=$(docker ps -a -q --filter="name=ccsdk-mariadb") -sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-deploy.json -sed -i "s/reskey/$RES_KEY/g" $REQUEST_DATA_PATH/config-assign.json +for i in {1..10}; do + if [ $(docker inspect --format='{{ .State.Running }}' "${BP_CONTAINER}") ] && + [ $(docker inspect --format='{{ .State.Running }}' "${CCSDK_MARIADB}") ]; then + echo "Blueprint Proc Service Running" + break + else + echo sleep "${i}" + sleep "${i}" + fi +done -#########################check if server is up gracefully ###################################### +############################ Update Setup ############################ -# Sleep additional 3 minutes (180 secs) to give application time to finish +RES_KEY=$(uuidgen -r) +sed -i "s/pnfaddr/$LOCAL_IP/g" "${REQUEST_DATA_PATH}"/config-deploy.json +sed -i "s/pnfaddr/$LOCAL_IP/g" "${REQUEST_DATA_PATH}"/config-assign.json -sleep 150 +sed -i "s/reskey/$RES_KEY/g" "${REQUEST_DATA_PATH}"/config-deploy.json +sed -i "s/reskey/$RES_KEY/g" "${REQUEST_DATA_PATH}"/config-assign.json # Pass any variables required by Robot test suites in ROBOT_VARIABLES - -ROBOT_VARIABLES="-v SCRIPTS:${SCRIPTS}" +REPO_IP='127.0.0.1' +ROBOT_VARIABLES+=" -v REPO_IP:${REPO_IP} " +ROBOT_VARIABLES+=" -v SCRIPTS:${SCRIPTS} " \ No newline at end of file diff --git a/plans/usecases-config-over-netconf/config-over-netconf/teardown.sh b/plans/usecases-config-over-netconf/config-over-netconf/teardown.sh index 9613e3ee..7257b366 100755 --- a/plans/usecases-config-over-netconf/config-over-netconf/teardown.sh +++ b/plans/usecases-config-over-netconf/config-over-netconf/teardown.sh @@ -1,18 +1,10 @@ #!/bin/bash -SDNC_DOCKER_COMPOSE_PATH=$SDNC_DOCKER_PATH/docker-compose.yaml -PNFSIM_DOCKER_COMPOSE_PATH=$INT_DOCKER_PATH/docker-compose.yml -CDS_DOCKER_COMPOSE_PATH=$CDS_DOCKER_PATH/docker-compose.yaml +echo 'Stop, Removing all running containers...' +docker stop $(docker ps -aq) && docker rm $(docker ps -aq) -echo "==========================blueprint-processor logs ==================================" -docker logs bp-rest +echo 'Removing Volumes...' +echo y | docker volume prune -echo "==========================sdnc-controller logs ======================================" -docker logs sdnc_controller_container - - -docker-compose -f $SDNC_DOCKER_COMPOSE_PATH down -docker-compose -f $PNFSIM_DOCKER_COMPOSE_PATH down -docker-compose -f $CDS_DOCKER_COMPOSE_PATH down - -rm -rf $WORKSPACE/temp +echo 'Removing Networks...' +echo y | docker network prune \ No newline at end of file diff --git a/plans/usecases-config-over-netconf/config-over-netconf/test.properties b/plans/usecases-config-over-netconf/config-over-netconf/test.properties index ee002461..4e4c99b4 100644 --- a/plans/usecases-config-over-netconf/config-over-netconf/test.properties +++ b/plans/usecases-config-over-netconf/config-over-netconf/test.properties @@ -1,14 +1,10 @@ NEXUS_DOCKER_REPO=nexus3.onap.org:10001 NEXUS_USERNAME=docker NEXUS_PASSWD=docker +BP_IMAGE_TAG=0.7.1 SDNC_IMAGE_TAG=1.7.6 ANSIBLE_IMAGE_TAG=1.7.6 -BP_IMAGE_TAG=0.6.4 -REQUEST_DATA_PATH=$WORKSPACE/tests/$PARENT/$SUB_PARENT/data -TC_PLANS_PATH=$WORKSPACE/plans/$PARENT/$SUB_PARENT -CDS_DOCKER_PATH=$TC_PLANS_PATH/cds -SDNC_DOCKER_PATH=$TC_PLANS_PATH/sdn -INT_DOCKER_PATH=$WORKSPACE/temp/integration/test/mocks/pnfsimulator -CERT_SUBPATH=$TC_PLANS_PATH/certs -NETOPEER_DOCKER_REPO=sysrepo/sysrepo-netopeer2 -NETOPEER_IMAGE_TAG=v0.7.7 +CERT_SUBPATH=${WORKSPACE}/plans/usecases-config-over-netconf/config-over-netconf/certs +CONFIG_OVER_NETCONF=${WORKSPACE}/plans/usecases-config-over-netconf/config-over-netconf +REQUEST_DATA_PATH=${WORKSPACE}/tests/usecases-config-over-netconf/config-over-netconf/data +NETCONF_CONFIG_PATH=${WORKSPACE}/plans/usecases-config-over-netconf/config-over-netconf/netconf-pnp-simulator/netconf-config \ No newline at end of file diff --git a/tests/usecases-config-over-netconf/config-over-netconf/config_over_netconf.robot b/tests/usecases-config-over-netconf/config-over-netconf/config_over_netconf.robot index 21c03c6f..e7d923f8 100644 --- a/tests/usecases-config-over-netconf/config-over-netconf/config_over_netconf.robot +++ b/tests/usecases-config-over-netconf/config-over-netconf/config_over_netconf.robot @@ -9,7 +9,7 @@ Library String ${SDNC_KEYSTORE_CONFIG_PATH} /config/netconf-keystore:keystore ${SDNC_MOUNT_PATH} /config/network-topology:network-topology/topology/topology-netconf/node/pnf-simulator ${PNFSIM_MOUNT_PATH} /config/network-topology:network-topology/topology/topology-netconf/node/pnf-simulator/yang-ext:mount/mynetconf:netconflist -${BP_UPLOAD_URL} /api/v1/execution-service/upload +${BP_UPLOAD_URL} /api/v1/blueprint-model/publish ${BP_PROCESS_URL} /api/v1/execution-service/process ${BP_ARCHIVE_PATH} ${CURDIR}/data/blueprint_archive.zip diff --git a/tests/usecases-config-over-netconf/config-over-netconf/data/blueprint_archive.zip b/tests/usecases-config-over-netconf/config-over-netconf/data/blueprint_archive.zip index ac346554..642c85f5 100644 Binary files a/tests/usecases-config-over-netconf/config-over-netconf/data/blueprint_archive.zip and b/tests/usecases-config-over-netconf/config-over-netconf/data/blueprint_archive.zip differ