diff --git a/README.md b/README.md index 69a7f61..1343f3a 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ NAPALM integration is validated with a minimum of Nokia Service Router Operating 6) For testing, please refer to [Test Document](https://github.com/napalm-automation-community/napalm-sros/blob/master/README_TEST.md) #### **Components Version** -1) Python - 3.6 +1) Python - 3.8 or higher 2) ncclient >= 0.6.13 3) paramiko >= 2.11.0 -4) NAPALM >= 3.4.1 +4) NAPALM >= 4.0.0 ##### **Note** -This version of the driver leverages Nokia’s defined YANG models for configuration and state trees for the SROS platform. While SROS also support limited configuration and state retrieval using openconfig standard models, the NAPALM driver does not support configuration or state retrieval of openconfig data models. +This version of the driver leverages Nokia’s defined YANG models for configuration and state trees for the SROS platform. While SROS also supports limited configuration and state retrieval using openconfig standard models, the NAPALM driver does not support configuration or state retrieval of openconfig data models. #### License This project is licensed under the Apache-2.0 license - see the [LICENSE](LICENSE) file. diff --git a/napalm_sros/sros.py b/napalm_sros/sros.py index f405725..b8b014c 100644 --- a/napalm_sros/sros.py +++ b/napalm_sros/sros.py @@ -24,7 +24,6 @@ import json import time import re -import logging import datetime import traceback import xmltodict @@ -41,6 +40,8 @@ SessionLockedException, MergeConfigException, ReplaceConfigException, + CommitError, + CommandErrorException, ) from napalm.base.helpers import convert, ip, as_number import napalm.base.constants as C @@ -295,14 +296,14 @@ def _find_txt(self, xml_tree, path, default="", namespaces=None): value = xpath_result else: if xpath_applied == "": - logging.error( + log.error( "Unable to find the specified-text-element/XML path: %s in \ the XML tree provided. Total Items in XML tree: %d " % (path, xpath_length) ) except Exception as e: # in case of any exception, returns default print("Error while finding text in xml: {}".format(e)) - logging.error("Error while finding text in xml: %s" % traceback.format_exc()) + log.error("Error while finding text in xml: %s" % traceback.format_exc()) value = default return str(value) @@ -323,7 +324,7 @@ def is_alive(self): return is_alive_dict except Exception as e: # in case of any exception, returns default print("Error occurred in is_alive method: {}".format(e)) - logging.error("Error occurred in is_alive: %s" % traceback.format_exc()) + log.error("Error occurred in is_alive: %s" % traceback.format_exc()) def discard_config(self): """ @@ -345,14 +346,13 @@ def commit_config(self, message="", revert_in=None): # If error while performing commit, return the error error = "" for item in buff.split("\n"): - if self.cmd_line_pattern_re.search(item): - continue if any(match.search(item) for match in self.terminal_stderr_re): row = item.strip() row_list = row.split(": ") error += row_list[2] if error: - print("Error while commit: ", error) + log.error(f"Error during commit: {error}") + raise CommitError(error) elif self.fmt == "xml": self.conn.commit() if not self.lock_disable and not self.session_config_lock: @@ -375,8 +375,8 @@ def rollback(self): row_list = row.split(": ") error += row_list[2] if error: - print("Error while rollback: ", error) - break + log.error(f"Error during rollback: {error}") + raise CommandErrorException(error) def compare_config(self): """ @@ -551,6 +551,7 @@ def load_replace_candidate(self, filename=None, config=None): if buff is not None: for item in buff.split("\n"): if any(match.search(item) for match in self.terminal_stderr_re): + log.error( f"Replace issue: {item}" ) raise ReplaceConfigException("Replace issue: %s", item) else: raise ReplaceConfigException("Timeout during load_replace_candidate")