mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Adding ethtool info to Ansible interface facts (#16513)
This will give the user details on how the interfaces are configured. They user could query to see if TSO, GSO, etc are enbaled on an interface.
This commit is contained in:
parent
7fdbfd490e
commit
2219339dd5
1 changed files with 21 additions and 2 deletions
|
@ -2277,6 +2277,25 @@ class LinuxNetwork(Network):
|
|||
parse_ip_output(primary_data)
|
||||
parse_ip_output(secondary_data, secondary=True)
|
||||
|
||||
def parse_ethtool_output(device,output):
|
||||
interfaces[device]['features'] = {}
|
||||
for line in output.strip().split('\n'):
|
||||
if not line:
|
||||
continue
|
||||
if line.endswith(":") :
|
||||
continue
|
||||
key,value = line.split(": ")
|
||||
if not value :
|
||||
continue
|
||||
interfaces[device]['features'][key.strip().replace('-','_')] = value.strip()
|
||||
|
||||
ethtool_path = self.module.get_bin_path("ethtool")
|
||||
if ethtool_path:
|
||||
args = [ethtool_path, '-k', device]
|
||||
rc, stdout, stderr = self.module.run_command(args)
|
||||
ethtool_data = stdout
|
||||
parse_ethtool_output(device,ethtool_data)
|
||||
|
||||
# replace : by _ in interface name since they are hard to use in template
|
||||
new_interfaces = {}
|
||||
for i in interfaces:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue