How to ignore warnings

1,395 views
Skip to first unread message

Brian Nelson

unread,
Apr 11, 2016, 4:44:00 PM4/11/16
to Junos Python EZ
I'm trying to homogenize the JunOS configs on a few dozen EX2200 with an ansible-playbook. Using an EX2200.set file, I have "delete [element]" commands to delete configuration statements which may or may not exist. If the configuration statement does not exist, JunOS returns "warning: statement not found"; and the config fails.

ignore_errors and other error handling functions outside the junon_install_config function, and has no effect.

Suggestions on how to approach this problem?

Brian Nelson
Dept of Computer Science
UT Dallas

Nitin Kr (Automation)

unread,
Apr 13, 2016, 4:27:50 AM4/13/16
to Brian Nelson, Junos Python EZ
Hi Brian,

Will try to figure out what option can be provided to handle this scenario. Mean time you can edit our module to get control of the warning. 
Please follow below steps:
  1. You will find our modules as /etc/ansible/roles/Juniper.junos/library
  2. Edit below lines (in the url) to ignore warning with below code
    cu.load(**load_args)
except (ValueError, ConfigLoadError, Exception) as err:
if err.rpc_error['severity'] == 'warning':
logging.info("Ignoring warning: %s"% err.message) #or u can use logging.warning
else:
msg = "Unable to load config: {0}".format(err)
logging.error(msg)
Or replace the attached file (with the modification) with /etc/ansible/roles/Juniper.junos/library/junos_install_config.
Do let me know if you face any problem.

Thanks
Nitin Kr

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/71e10c77-2fdd-4dcc-a8d3-154836681abc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
junos_install_config

Brian Nelson

unread,
Apr 15, 2016, 12:57:16 PM4/15/16
to Junos Python EZ
Thanks for the quick fix; but, the update is still failing.

Brian Nelson

------------------------------------------------------------

/home/brian/ansible>ansible-playbook set-configs/update.yml
Login:
Password:

PLAY [configuration optimization] *********************************************

TASK: [updates] ***************************************************************
failed: [10.176.2.71] => {"failed": true}
msg: Unable to load config: ConfigLoadError(severity: None, bad_element: None, message: warning: statement not found
warning: statement not found
warning: statement not found
warning: statement not found: apply-groups mgmt-networks
warning: statement not found: apply-groups mgmt-networks
warning: statement not found: apply-groups mgmt-networks
warning: statement not found: apply-groups mgmt-networks
warning: statement not found
warning: statement not found
warning: statement not found)

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/home/brian/update.retry

10.176.2.71                : ok=0    changed=0    unreachable=0    failed=1  

Nitin Kr (Automation)

unread,
Apr 15, 2016, 2:57:24 PM4/15/16
to Brian Nelson, Junos Python EZ
Hi Brian,

As you can see incase of multiple warning, exception severity is None 
msg: Unable to load config: ConfigLoadError(severity: None, bad_element: None, message: warning: statement not found warning: statement not found

This looks to be a bug from PyEZ side. Cn you please raise an issue on github. I will try to fix the same and keep you posted.

Thanks
Nitin Kr

From: <junos-p...@googlegroups.com> on behalf of Brian Nelson <brian.ne...@gmail.com>
Date: Friday, April 15, 2016 at 10:27 PM
To: Junos Python EZ <junos-p...@googlegroups.com>
--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.

Nitin Kr (Automation)

unread,
Apr 26, 2016, 2:27:32 AM4/26/16
to Brian Nelson, Junos Python EZ
Hi Brian,

The issue from PyEZ has been fixed. https://github.com/Juniper/py-junos-eznc/pull/501
Now with latest code in github severity will be returned as warning in case of multi warning errors.
To have latest PyEZ, use below command to get it from github master branch
pip install -U junos-eznc

In addition to latest PyEZ used attached ansible module (in 2nd last email) for your purpose.

Thanks
Nitin Kr
Reply all
Reply to author
Forward
0 new messages