Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VerifyPlaybookParams(): parameter validation fixes (#335)
* WIP: VerifyPlaybookParams(): fix eval_string 1. eval_string was using literal strings instead of f-strings. 2. VerifyPlaybookParams().update_decision_set() conditional for playbook_is_valid should compare to False explicitely. * dcnm_fabric: cleanup rule_value and user_value processing Prior to passing eval_string to eval() we need to ensure that rule_value and user_value are not null (None, "", or "null), else, we'll get a syntax error in eval(). Change the handling here such that: if rule_value is in [None, "", "null"], return True (since, in this case, there is no rule for the parameter). if user_value is in [None, "", "null"] set the user_value such that the eval() will pass (given current value of operator). Also, modifications based on pylint recommendations. * Improve KeyError message content. verify_playbook_params.py VerifyPlaybookParams().eval_parameter_rule() - Add class_name and method_name to all raise KeyError() cases. * Raise ValueError if playbook value is None or "" or "null" verify_playbook_params.py - VerifyPlaybookParams().eval_parameter_rule() I can't think of a case where a playbook value should be any of None, "", or "null". These are causing eval() to generate a syntax error, so let's raise a ValueError to avoid this. * dcnm_fabric: update_decision_set() fix, more... 1. verify_playbook_params.py - VerifyPlaybookParams().eval_parameter_rule() - Revert eval_string change from earlier commit. The original eval_string was correct. 2. verify_playbook_params.py - VerifyPlaybookParams().update_decision_set() - Update method docstring - If all called *_is_valid() methods return None, set decision_set to {True}. update_decision_set() calls the following methods: - controller_param_is_valid() - playbook_param_is_valid() - default_param_is_valid() If all of these return None, then decision_set will be empty. If decision_set is empty we now set it to {True}. Below is a summary of when None is returned by these three methods. - controller_param_is_valid() returns None in the following cases: - The fabric does not exist on the controller. - The controller's value for the dependent parameter is None (more accurately, "") - The controller fabric config does not contain the dependent parameter (this is not likely) - default_param_is_valid() returns None in the following cases: - The controller config contains the dependent parameter. - The dependent parameter has no default value. - playbook_param_is_valid() returns None in the following cases: - The dependent parameter is not in the playbook. 3. Add debug statements throughout the above two methods for future troubleshooting. * Update unit tests to work with this PR's fixes. ValueError() is (correctly) not being raised now for the parameter combinations in the following unit tests: - test_verify_playbook_params_00070 - test_verify_playbook_params_00080 Modified the tested parameters and expected regex so that these are now passing. * fix for network_crash * Update unit tests to work with ND 321e ND 321e requires ENABLE_PVLAN and ENABLE_SGT to be false if UNDERLAY_IS_V6 is false. Updating two integration tests to set these correctly. * dcnm_fabric IT: Remove UNDERLAY_IS_V6: false WIth ND 321e, UNDERLAY_IS_V6=false requires ENABLE_PVLAN==false and ENABLE_SGT==false. Since ENABLE_PVLAN is not backwards compatible with earlier versions of NDFC, we're removing UNDERLAY_IS_V6 from integration tests. * Update main.yml * Update main.yml Include matrix name in collection * Add 'skip_validation' knob Add playbook knob to skip parameter validation. * Add documention for skip_validation * Update documentation to include skip_validation. 1. Add an example with skip_validation set to true. 2. Add an example that generates a misleading error message and explain how to interpret the message. * Fix sanity errors Remove markdown backticks from documentation. * Fix sanity errors (continued) Comment out error message since it generates YAML error. * Fix sanity errors (continued) * Run collection_prep to update .rst file. --------- Co-authored-by: prabahal <[email protected]> Co-authored-by: Mike Wiebe <[email protected]>
- Loading branch information