Update pnf-sw-upgrade module to latest engine v2.8.1 55/105555/3
authorebo <eliezio.oliveira@est.tech>
Wed, 8 Apr 2020 11:32:14 +0000 (12:32 +0100)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Fri, 10 Apr 2020 09:19:27 +0000 (09:19 +0000)
- Using loguru to follow new recommend standard

- Renamed Yang model filename to comply with
  https://tools.ietf.org/html/rfc6020#section-5.2

- Renamed initialization data to reflect the target datastore

Issue-ID: INT-1516
Signed-off-by: ebo <eliezio.oliveira@est.tech>
Change-Id: Ifde9e832b6a308dc918e3a84e03bfd43ad0f9b63

test/mocks/netconf-pnp-simulator/modules/docker-compose.yml
test/mocks/netconf-pnp-simulator/modules/pnf-sw-upgrade/pnf-sw-upgrade.yang [moved from test/mocks/netconf-pnp-simulator/modules/pnf-sw-upgrade/model.yang with 100% similarity]
test/mocks/netconf-pnp-simulator/modules/pnf-sw-upgrade/startup.xml [moved from test/mocks/netconf-pnp-simulator/modules/pnf-sw-upgrade/data.xml with 100% similarity]
test/mocks/netconf-pnp-simulator/modules/pnf-sw-upgrade/subscriber.py

index e8f2f9a..fcfcec4 100644 (file)
@@ -2,7 +2,7 @@ version: '3'
 
 services:
   netconf-pnp-simulator:
-    image: nexus3.onap.org:10001/onap/integration/simulators/netconf-pnp-simulator:2.6.2
+    image: nexus3.onap.org:10001/onap/integration/simulators/netconf-pnp-simulator:2.8.1
     container_name: netconf-pnp-simulator
     restart: always
     ports:
index 810fe45..0786637 100755 (executable)
@@ -27,6 +27,7 @@ from concurrent.futures import ThreadPoolExecutor
 from threading import Timer
 
 import sysrepo as sr
+from loguru import logger
 
 YANG_MODULE_NAME = 'pnf-sw-upgrade'
 
@@ -117,13 +118,13 @@ def main():
         try:
             print_current_config(sess, YANG_MODULE_NAME)
         except Exception as e:
-            print(e)
+            logger.error(e)
 
         sr.global_loop()
 
-        print("Application exit requested, exiting.")
+        logger.info("Application exit requested, exiting.")
     except Exception as e:
-        print(e)
+        logger.error(e)
 
 
 # Function to be called for subscribed client of given session whenever configuration changes.
@@ -138,7 +139,7 @@ def module_change_cb(sess, module_name, event, private_ctx):
                 break
             handle_change(conn, change.oper(), change.old_val(), change.new_val())
     except Exception as e:
-        print(e)
+        logger.error(e)
     return sr.SR_ERR_OK
 
 
@@ -150,10 +151,10 @@ def print_current_config(session, module_name):
     values = session.get_items(select_xpath)
 
     if values is not None:
-        print("========== BEGIN CONFIG ==========")
+        logger.info("========== BEGIN CONFIG ==========")
         for i in range(values.val_cnt()):
-            print(values.val(i).to_string(), end='')
-        print("=========== END CONFIG ===========")
+            logger.info(values.val(i).to_string().strip())
+        logger.info("=========== END CONFIG ===========")
 
 
 def handle_change(conn, op, old_val, new_val):
@@ -161,7 +162,7 @@ def handle_change(conn, op, old_val, new_val):
     Handle individual changes on the model.
     """
     if op == sr.SR_OP_CREATED:
-        print("CREATED: %s" % new_val.to_string())
+        logger.info("CREATED: %s" % new_val.to_string())
         xpath = new_val.xpath()
         last_node = xpath_ctx.last_node(xpath)
         # Warning: 'key_value' modifies 'xpath'!
@@ -169,11 +170,11 @@ def handle_change(conn, op, old_val, new_val):
         if key_id and last_node == 'action':
             executor.submit(execute_action, conn, key_id, new_val.data().get_enum())
     elif op == sr.SR_OP_DELETED:
-        print("DELETED: %s" % old_val.to_string())
+        logger.info("DELETED: %s" % old_val.to_string())
     elif op == sr.SR_OP_MODIFIED:
-        print("MODIFIED: %s to %s" % (old_val.to_string(), new_val.to_string()))
+        logger.info("MODIFIED: %s to %s" % (old_val.to_string(), new_val.to_string()))
     elif op == sr.SR_OP_MOVED:
-        print("MOVED: %s after %s" % (new_val.xpath(), old_val.xpath()))
+        logger.info("MOVED: %s after %s" % (new_val.xpath(), old_val.xpath()))
 
 
 def execute_action(conn, key_id, action):