blob: 4811b3b1d2f4a8d3c309279fdef0fd55ddcd190a [file] [log] [blame]
David K. Bainbridgea677d4e2016-09-11 20:01:32 -07001#!/usr/bin/env python
2
3import sys
4import json
5import ethtool
6import shlex
7
8# read the argument string from the arguments file
9args_file = sys.argv[1]
10args_data = file(args_file).read()
11
12ignore=["tun", "bridge", "bonding", "veth"]
13bus_ignore=["", "N/A", "tap"]
14
15# parse the task options
16arguments = shlex.split(args_data)
17for arg in arguments:
18 # ignore any arguments without an equals in it
19 if "=" in arg:
20 (key, value) = arg.split("=")
21 # if setting the time, the key 'time'
22 # will contain the value we want to set the time to
23
24all = {}
25for i in ethtool.get_devices():
26 o = { "name": i }
27 try:
28 module = ethtool.get_module(i)
29 businfo = ethtool.get_businfo(i)
30 if module in ignore or businfo in bus_ignore:
31 continue
32 all[i] = {
33 "name": i,
34 "module" : module,
35 }
36 except:
37 pass
38
39print json.dumps({
40 "changed" : False,
41 "ansible_facts" : {
42 "netinfo" : all,
43 },
44})