Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins(feature): Add Optional Warning or Error to Defined test #951

Conversation

ClausHolbechArista
Copy link
Contributor

Change Summary

Add Optional Warning or Error to Defined test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Documentation content changes
  • Other (please describe):

Related Issue(s)

Fixes #943 since that was caused by running the playbook for only a subset of devices.

Component(s) name

arista.avd.eos_designs
arista.avd.defined

Proposed changes

defined test

Optionally the test can emit warnings or errors if the test fails.

Syntax:

{% <value> is arista.avd.defined(test_value=<test_value>,fail_action=['warning','error'],var_name=<string representing name of value>) %}

Warnings or Errors can be emitted with the optional arguments fail_action and var_name:

{% if my_dict.my_list[12].my_var is arista.avd.defined(fail_action='warning', var_name='my_dict.my_list[12].my_var' %}
>>> [WARNING]: my_dict.my_list[12].my_var was expected but not set. Output may be incorrect or incomplete!

{% if my_dict.my_list[12].my_var is arista.avd.defined(fail_action='error', var_name='my_dict.my_list[12].my_var' %}
>>> fatal: [DC2-RS1]: FAILED! => {"msg": "my_dict.my_list[12].my_var was expected but not set!"}

{% set my_dict.my_list[12].my_var = 'not_my_value' %}

{% if my_dict.my_list[12].my_var is arista.avd.defined('my_value', fail_action='warning', var_name='my_dict.my_list[12].my_var' %}
>>> [WARNING]: my_dict.my_list[12].my_var was set to not_my_value but we expected my_value. Output may be incorrect or incomplete!

{% if my_dict.my_list[12].my_var is arista.avd.defined('my_value', fail_action='error', var_name='my_dict.my_list[12].my_var' %}
>>> fatal: [DC2-RS1]: FAILED! => {"msg": "my_dict.my_list[12].my_var was set to not_my_value but we expected my_value!"}

Added warnings to EVPN EBGP overlay.

Warn if switch facts are not set for a fabric device, since this can potentially result in incomplete or incorrect config.

How to test

By running a playbook with --limit for a device with overlay config will produce warnings.
Ex. for a two-dc scenario run the playbook for only one of the DCs.

Checklist:

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated molecule CI testing accordingly
  • All new and existing tests passed (pre-commit, make linting and make sanity-lint).

@ClausHolbechArista ClausHolbechArista force-pushed the add_optional_warnings_or_errors_to_defined_test branch from e551553 to ed5aeff Compare May 31, 2021 09:46
@ClausHolbechArista
Copy link
Contributor Author

@carlbuchmann CI passes now. Please review.

Copy link
Member

@carlbuchmann carlbuchmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@carlbuchmann carlbuchmann changed the title Add Optional Warning or Error to Defined test Plugins(feature): Add Optional Warning or Error to Defined test May 31, 2021
@carlbuchmann carlbuchmann merged commit 27a8f30 into aristanetworks:devel May 31, 2021
@carlbuchmann carlbuchmann added this to the v2.2.0 milestone Jun 1, 2021
@titom73 titom73 mentioned this pull request Jun 11, 2021
@ClausHolbechArista ClausHolbechArista deleted the add_optional_warnings_or_errors_to_defined_test branch July 9, 2021 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
role: eos_designs issue related to eos_designs role type: Python filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evpn-overlay peering spine-spine dci no more rendered with commit #932
3 participants