Add support of running general Ansible modules on EosHost#1721
Add support of running general Ansible modules on EosHost#1721yxieca merged 2 commits intosonic-net:masterfrom wangxin:improve-eoshost-pr
Conversation
tests/common/devices.py
Outdated
There was a problem hiding this comment.
Should this be getattribute? I think you want to setup credential for all methods, right?
Did you try to call both EOS and Linux method from a same instance?
There was a problem hiding this comment.
I think the idea here is create NetworkCli based host if user call eos module and create LinuxShell based host if user call other module.
The judgement happens when invoking a module because we couldn't keep two types hosts in a single instance and that's why Xin use getattr.
The only overhead is we need to override extra-var and create a host every time when calling a module.
There was a problem hiding this comment.
Thanks @Blueve for the explanation.
@yxieca According to https://stackoverflow.com/questions/3278077/difference-between-getattr-vs-getattribute:
A key difference between getattr and getattribute is that getattr is only invoked if the attribute wasn't found the usual ways.
When an attribute is not found on the EosHost or FanoutHost instance, the getattr will try to get a function for running the ansible module. This is the key technique for us to invoke ansible module using format like fanouthost.<ansible_module_name>(*args, **kwargs) or eoshost.<ansible_module_name>(*args, **kwargs)
Here the ansible module can a EOS module like eos_command, eos_config, or a regular module like command, shell, etc.
Yes, I have tested that both EOS and Linux method can be called from a same instance.
To support this, the EosHost need two sets of credential. But the credential for running Linux methods is optional.
The EOS hosts support two types of command line interface: 1. Linux shell 2. EOS shell This change is to add the support of running general Ansible modules that can only be executed under Linux shell. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
* If not able to get the explicitly defined username and password, fallback to use the value of "fanout_admin_user" and "fanout_admin_password". It is unlikely to break the existing code. * Resolve merge conflicts
)" This reverts commit 64ab433.
…et#7487) * [202012][swss/swss-common/utilities/kernel] Update submodule sonic-swss: - [Monitor Vlan] Fix a typo in hostif (sonic-net#1722) - Update pool sizes during initialization from timer only (sonic-net#1708) - [SflowMgr] SamplingRate Update by Speed Change Added (sonic-net#1721) sonic-swss-common: - [swss-common] Add MUX Metrics Table (sonic-net#482) - [azp] Purge swss before installing the newly built deb package (sonic-net#472) sonic-utilities: - disk_check: Check & mount RO as RW using tmpfs (sonic-net#1569) - No more IP validation as it is more likely a URL (sonic-net#1555) - Stop PMON docker before cold and soft reboots (sonic-net#1514) - Add soft-reboot reboot type (sonic-net#1453) - [acl] Use a list instead of a comma-separated string for ACL port list (sonic-net#1519) - sonic-installer: fix py3 issues in bootloader.aboot (sonic-net#1553) - Fix unsupported fs.squashfs extraction in sonic-installer (sonic-net#1366) - [show][config] cli support for firmware upgrade on Y-Cable (sonic-net#1528) (sonic-net#1558) sonic-linux-kernel: - [Mellanox] backport kernel patches for hw-management 7.0100.2303 (sonic-net#211) Signed-off-by: Danny Allen <daall@microsoft.com> * Update utilities w/ build fix
This PR updates the following commits a9606fb [show] fix show muxcable metrics <port> for sorted output (sonic-net#1731) 7355016 [minigraph][port_config] Use imported config.main and add conditional patch (sonic-net#1728) cc1d6e4 [configlet] Python3 compatible syntax for extracting a key from the dict (sonic-net#1721) Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
8b149a3 Load the database global_db only once for show cli (sonic-net#1712) cd0e560 [config][interface][speed] Fixed the config interface speed in multiasic issue (sonic-net#1739) b595ba6 [fast-reboot] revert the change of disabling counter polling before fast-reboot (sonic-net#1744) 8518820 [minigraph] Donot enable PFC watchdog for MgmtTsToR (sonic-net#1734) 2213774 [CLI][show][bgp] Fix the show ip bgp network command (sonic-net#1733) 3526507 [configlet] Python3 compatible syntax for extracting a key from the dict (sonic-net#1721) 5b56b97 [sonic_installer] don't print errors when installing an image not supporting app ext (sonic-net#1719) a581955 [LLDP] Fix lldpshow script to enable display multiple MAC addresses on the same remote physical interface (sonic-net#1657)
Description of PR
Summary:
Fixes # (issue)
The EOS hosts support two types of command line interface:
Currently the EosHost class can only support running eos_* ansible modules. This change is to add the support of running general Ansible modules that can only be executed under Linux shell.
Type of change
Approach
How did you do it?
Improved the EosHost class defined in tests/common/devices.py to make it accepts two sets of credential:
network_cli.ssh.If name of the ansible module to be executed on EOS hosts starts with "eos_", then use ansible_connection
network_clito run the module. Otherwise, use ansible_connectionsshto run the module.How did you verify/test it?
Use a simple script to run both eos_* ansible module and general ansible modules on the EOS hosts and fanout hosts.
For this PR to work, please add your own fanout credentials in the ansible variable files. For example, you can add a secrets.yml file under ansible/group_vars/all or ansible/group_vars/sonic. The fanout credentials can be defined in it, for example:
Credential set fanout_admin_user/fanout_admin_password should expose the EOS CLI interface. Credential set fanout_root_user/fanout_root_password should expose the Linux CLI shell.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation