Add utilities to get ansible variables by hostname or group name#2687
Merged
wangxin merged 1 commit intosonic-net:masterfrom Dec 21, 2020
wangxin:get_vars
Merged
Add utilities to get ansible variables by hostname or group name#2687wangxin merged 1 commit intosonic-net:masterfrom wangxin:get_vars
wangxin merged 1 commit intosonic-net:masterfrom
wangxin:get_vars
Conversation
Signed-off-by: Xin Wang <xiwang5@microsoft.com>
lolyu
approved these changes
Dec 20, 2020
kazinator-arista
pushed a commit
to kazinator-arista/sonic-mgmt
that referenced
this pull request
Mar 4, 2026
swss: * 143cd44 2023-03-04 | Revert "[aclorch] Fixed issue sonic-net#2204.Support IN_PORTS qualifer in MIRRORV6 table. (sonic-net#2668)" (sonic-net#2687) (HEAD -> 202205, github/202205) [StormLiangMS] * 25812f8 2023-02-06 | [test_mux] add sleep in test_NH (sonic-net#2648) [Nikola Dancejic] Signed-off-by: Ying Xie <ying.xie@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes # (issue)
This change added utilities to get ansible variables by hostname or group name.
Type of change
Approach
What is the motivation for this PR?
In test code and library code, there is a frequent need of getting value of specific ansible variables belong to or is visible to specific ansible host or ansible group. This changed added utility functions to simplify this effort. By using these functions, we just need to supply the list of inventory files, server or group name, variable name.
How did you do it?
The functions will take advantage of the ansible's InventoryManager and VariableManager to get value of variables. Added functions:
The
inv_filesargument can be a string or list. It's value should be inventory file path or list of inventory file paths. In tests, it can be retrieved from the pytest builtin fixturerequest, for example:request.config.getoption("ansible_inventory")How did you verify/test it?
Import the utility file and test run the functions.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation