mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-06 22:32:54 +02:00
fixup osx subnet mask and convert state to an array
This commit is contained in:
35
README.md
35
README.md
@ -493,24 +493,29 @@ $ ifconfig | jc --ifconfig -p
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"state": [
|
||||
"UP",
|
||||
"BROADCAST",
|
||||
"RUNNING",
|
||||
"MULTICAST"
|
||||
],
|
||||
"mtu": 1500,
|
||||
"ipv4_addr": "192.168.71.138",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"ipv4_mask": "255.255.255.0",
|
||||
"ipv4_bcast": "192.168.71.255",
|
||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||
"ipv6_mask": 64,
|
||||
"ipv6_scope": "link",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": 6374,
|
||||
"rx_bytes": 38310,
|
||||
"rx_packets": 8061,
|
||||
"rx_bytes": 1514413,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 3707,
|
||||
"tx_bytes": 13909,
|
||||
"tx_packets": 4502,
|
||||
"tx_bytes": 866622,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@ -521,24 +526,28 @@ $ ifconfig | jc --ifconfig -p
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": 73,
|
||||
"state": "UP,LOOPBACK,RUNNING",
|
||||
"state": [
|
||||
"UP",
|
||||
"LOOPBACK",
|
||||
"RUNNING"
|
||||
],
|
||||
"mtu": 65536,
|
||||
"ipv4_addr": "127.0.0.1",
|
||||
"ipv4_mask": "255.0.0.0",
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": 128,
|
||||
"ipv6_scope": "host",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": 81,
|
||||
"rx_bytes": 310,
|
||||
"rx_packets": 73,
|
||||
"rx_bytes": 6009,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 81,
|
||||
"tx_bytes": 909,
|
||||
"tx_packets": 73,
|
||||
"tx_bytes": 6009,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
|
@ -2,7 +2,7 @@ jc changelog
|
||||
|
||||
2019xxxx v1.6.1
|
||||
- Add OSX support for the ifconfig parser
|
||||
- Updated ifconfig parser to output flags as an array
|
||||
- Updated ifconfig parser to output state as an array
|
||||
|
||||
20191117 v1.5.1
|
||||
- Add ss parser
|
||||
|
@ -12,24 +12,29 @@ Examples:
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"state": [
|
||||
"UP",
|
||||
"BROADCAST",
|
||||
"RUNNING",
|
||||
"MULTICAST"
|
||||
],
|
||||
"mtu": 1500,
|
||||
"ipv4_addr": "192.168.71.138",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"ipv4_mask": "255.255.255.0",
|
||||
"ipv4_bcast": "192.168.71.255",
|
||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||
"ipv6_mask": 64,
|
||||
"ipv6_scope": "link",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": 6374,
|
||||
"rx_bytes": 38310,
|
||||
"rx_packets": 8061,
|
||||
"rx_bytes": 1514413,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 3707,
|
||||
"tx_bytes": 13909,
|
||||
"tx_packets": 4502,
|
||||
"tx_bytes": 866622,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@ -40,24 +45,28 @@ Examples:
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": 73,
|
||||
"state": "UP,LOOPBACK,RUNNING",
|
||||
"state": [
|
||||
"UP",
|
||||
"LOOPBACK",
|
||||
"RUNNING"
|
||||
],
|
||||
"mtu": 65536,
|
||||
"ipv4_addr": "127.0.0.1",
|
||||
"ipv4_mask": "255.0.0.0",
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": 128,
|
||||
"ipv6_scope": "host",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": 81,
|
||||
"rx_bytes": 310,
|
||||
"rx_packets": 73,
|
||||
"rx_bytes": 6009,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 81,
|
||||
"tx_bytes": 909,
|
||||
"tx_packets": 73,
|
||||
"tx_bytes": 6009,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@ -74,22 +83,22 @@ Examples:
|
||||
"flags": "4163",
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"mtu": "1500",
|
||||
"ipv4_addr": "192.168.71.135",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"ipv4_mask": "255.255.255.0",
|
||||
"ipv4_bcast": "192.168.71.255",
|
||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||
"ipv6_mask": "64",
|
||||
"ipv6_scope": "link",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": "26348",
|
||||
"rx_bytes": "38310",
|
||||
"rx_packets": "8061",
|
||||
"rx_bytes": "1514413",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "5308",
|
||||
"tx_bytes": "13909",
|
||||
"tx_packets": "4502",
|
||||
"tx_bytes": "866622",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
@ -107,17 +116,17 @@ Examples:
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": "128",
|
||||
"ipv6_scope": "host",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": "64",
|
||||
"rx_bytes": "310",
|
||||
"rx_packets": "73",
|
||||
"rx_bytes": "6009",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "64",
|
||||
"tx_bytes": "909",
|
||||
"tx_packets": "73",
|
||||
"tx_bytes": "6009",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
@ -147,7 +156,9 @@ def process(proc_data):
|
||||
{
|
||||
"name": string,
|
||||
"flags": integer,
|
||||
"state": string,
|
||||
"state": [
|
||||
string
|
||||
],
|
||||
"mtu": integer,
|
||||
"ipv4_addr": string,
|
||||
"ipv4_mask": string,
|
||||
@ -186,6 +197,25 @@ def process(proc_data):
|
||||
except (ValueError, TypeError):
|
||||
entry[key] = None
|
||||
|
||||
# convert OSX-style subnet mask to decimal
|
||||
if 'ipv4_mask' in entry:
|
||||
try:
|
||||
if entry['ipv4_mask'].find('0x') == 0:
|
||||
new_mask = entry['ipv4_mask']
|
||||
new_mask = new_mask.lstrip('0x')
|
||||
new_mask = '.'.join(str(int(i, 16)) for i in [new_mask[i:i + 2] for i in range(0, len(new_mask), 2)])
|
||||
entry['ipv4_mask'] = new_mask
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
# convert state value to an array
|
||||
if 'state' in entry:
|
||||
try:
|
||||
new_state = entry['state'].split(',')
|
||||
entry['state'] = new_state
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
|
2
tests/fixtures/centos-7.7/ifconfig.json
vendored
2
tests/fixtures/centos-7.7/ifconfig.json
vendored
@ -1 +1 @@
|
||||
[{"name": "docker0", "flags": 4099, "state": "UP,BROADCAST,MULTICAST", "mtu": 1500, "ipv4_addr": "172.17.0.1", "ipv4_mask": "255.255.0.0", "ipv4_bcast": "0.0.0.0", "mac_addr": "02:42:b1:9a:ea:02", "type": "Ethernet", "rx_packets": 0, "rx_bytes": 0, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 0, "tx_bytes": 0, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null}, {"name": "ens33", "flags": 4163, "state": "UP,BROADCAST,RUNNING,MULTICAST", "mtu": 1500, "ipv4_addr": "192.168.71.137", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:3b:58:0e", "type": "Ethernet", "rx_packets": 8061, "rx_bytes": 1514413, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 4502, "tx_bytes": 866622, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}, {"name": "lo", "flags": 73, "state": "UP,LOOPBACK,RUNNING", "mtu": 65536, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "::1", "ipv6_mask": 128, "ipv6_scope": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 73, "rx_bytes": 6009, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 73, "tx_bytes": 6009, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
||||
[{"name": "docker0", "flags": 4099, "state": ["UP", "BROADCAST", "MULTICAST"], "mtu": 1500, "ipv4_addr": "172.17.0.1", "ipv4_mask": "255.255.0.0", "ipv4_bcast": "0.0.0.0", "mac_addr": "02:42:b1:9a:ea:02", "type": "Ethernet", "rx_packets": 0, "rx_bytes": 0, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 0, "tx_bytes": 0, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null}, {"name": "ens33", "flags": 4163, "state": ["UP", "BROADCAST", "RUNNING", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.71.137", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:3b:58:0e", "type": "Ethernet", "rx_packets": 8061, "rx_bytes": 1514413, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 4502, "tx_bytes": 866622, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}, {"name": "lo", "flags": 73, "state": ["UP", "LOOPBACK", "RUNNING"], "mtu": 65536, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "::1", "ipv6_mask": 128, "ipv6_scope": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 73, "rx_bytes": 6009, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 73, "tx_bytes": 6009, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
||||
|
2
tests/fixtures/osx-10.11.6/ifconfig.json
vendored
2
tests/fixtures/osx-10.11.6/ifconfig.json
vendored
@ -1 +1 @@
|
||||
[{"name": "lo0", "flags": 8049, "state": "UP,LOOPBACK,RUNNING,MULTICAST", "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "0xff000000", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": "POINTOPOINT,MULTICAST", "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": "UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST", "mtu": 1500, "ipv4_addr": "192.168.1.81", "ipv4_mask": "0xffffff00", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::6aa8:6dff:fe12:f575", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "68:a8:6d:12:f5:75", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": "UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX", "mtu": 1500, "mac_addr": "b2:00:19:cb:f5:50", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": "UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST", "mtu": 2304, "mac_addr": "0a:a8:6d:12:f5:75", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": "UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST", "mtu": 1500, "mac_addr": "6a:a8:6d:21:38:00", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
||||
[{"name": "lo0", "flags": 8049, "state": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": ["POINTOPOINT", "MULTICAST"], "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.1.81", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::6aa8:6dff:fe12:f575", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "68:a8:6d:12:f5:75", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "PROMISC", "SIMPLEX"], "mtu": 1500, "mac_addr": "b2:00:19:cb:f5:50", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 2304, "mac_addr": "0a:a8:6d:12:f5:75", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "mac_addr": "6a:a8:6d:21:38:00", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
||||
|
2
tests/fixtures/osx-10.11.6/ifconfig2.json
vendored
2
tests/fixtures/osx-10.11.6/ifconfig2.json
vendored
@ -1 +1 @@
|
||||
[{"name": "lo0", "flags": 8049, "state": "UP,LOOPBACK,RUNNING,MULTICAST", "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "0xff000000", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": "POINTOPOINT,MULTICAST", "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": "UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST", "mtu": 1500, "ipv4_addr": "192.168.1.65", "ipv4_mask": "0xffffff00", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::62c5:47ff:fe0a:ce0b", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "60:c5:47:0a:ce:0b", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": "UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX", "mtu": 1500, "mac_addr": "b2:00:14:06:39:21", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": "UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST", "mtu": 2304, "mac_addr": "02:c5:47:0a:ce:0b", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": "UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST", "mtu": 1500, "mac_addr": "62:c5:47:a0:f7:10", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
||||
[{"name": "lo0", "flags": 8049, "state": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": ["POINTOPOINT", "MULTICAST"], "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.1.65", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::62c5:47ff:fe0a:ce0b", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "60:c5:47:0a:ce:0b", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "PROMISC", "SIMPLEX"], "mtu": 1500, "mac_addr": "b2:00:14:06:39:21", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 2304, "mac_addr": "02:c5:47:0a:ce:0b", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "mac_addr": "62:c5:47:a0:f7:10", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
||||
|
2
tests/fixtures/osx-10.14.6/ifconfig.json
vendored
2
tests/fixtures/osx-10.14.6/ifconfig.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/osx-10.14.6/ifconfig2.json
vendored
2
tests/fixtures/osx-10.14.6/ifconfig2.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/ubuntu-18.04/ifconfig.json
vendored
2
tests/fixtures/ubuntu-18.04/ifconfig.json
vendored
@ -1 +1 @@
|
||||
[{"name": "ens33", "flags": 4163, "state": "UP,BROADCAST,RUNNING,MULTICAST", "mtu": 1500, "ipv4_addr": "192.168.71.131", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::20c:29ff:fe99:4517", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:99:45:17", "type": "Ethernet", "rx_packets": 138830, "rx_bytes": 178583682, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 30490, "tx_bytes": 3772041, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}, {"name": "lo", "flags": 73, "state": "UP,LOOPBACK,RUNNING", "mtu": 65536, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "::1", "ipv6_mask": 128, "ipv6_scope": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 825, "rx_bytes": 76797, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 825, "tx_bytes": 76797, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
||||
[{"name": "ens33", "flags": 4163, "state": ["UP", "BROADCAST", "RUNNING", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.71.131", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::20c:29ff:fe99:4517", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:99:45:17", "type": "Ethernet", "rx_packets": 138830, "rx_bytes": 178583682, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 30490, "tx_bytes": 3772041, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}, {"name": "lo", "flags": 73, "state": ["UP", "LOOPBACK", "RUNNING"], "mtu": 65536, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "::1", "ipv6_mask": 128, "ipv6_scope": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 825, "rx_bytes": 76797, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 825, "tx_bytes": 76797, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
||||
|
@ -16,6 +16,18 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ifconfig.out'), 'r') as f:
|
||||
self.ubuntu_18_4_ifconfig = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/ifconfig.out'), 'r') as f:
|
||||
self.osx_10_11_6_ifconfig = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/ifconfig2.out'), 'r') as f:
|
||||
self.osx_10_11_6_ifconfig2 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig.out'), 'r') as f:
|
||||
self.osx_10_14_6_ifconfig = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.out'), 'r') as f:
|
||||
self.osx_10_14_6_ifconfig2 = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ifconfig.json'), 'r') as f:
|
||||
self.centos_7_7_ifconfig_json = json.loads(f.read())
|
||||
@ -23,6 +35,18 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ifconfig.json'), 'r') as f:
|
||||
self.ubuntu_18_4_ifconfig_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/ifconfig.json'), 'r') as f:
|
||||
self.osx_10_11_6_ifconfig_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/ifconfig2.json'), 'r') as f:
|
||||
self.osx_10_11_6_ifconfig2_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig.json'), 'r') as f:
|
||||
self.osx_10_14_6_ifconfig_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.json'), 'r') as f:
|
||||
self.osx_10_14_6_ifconfig2_json = json.loads(f.read())
|
||||
|
||||
def test_ifconfig_centos_7_7(self):
|
||||
"""
|
||||
Test 'ifconfig' on Centos 7.7
|
||||
@ -35,6 +59,30 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ifconfig.parse(self.ubuntu_18_4_ifconfig, quiet=True), self.ubuntu_18_4_ifconfig_json)
|
||||
|
||||
def test_ifconfig_osx_10_11_6(self):
|
||||
"""
|
||||
Test 'ifconfig' on OSX 10.11.6
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_10_11_6_ifconfig, quiet=True), self.osx_10_11_6_ifconfig_json)
|
||||
|
||||
def test_ifconfig_osx_10_11_6_2(self):
|
||||
"""
|
||||
Test 'ifconfig' on OSX 10.11.6
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_10_11_6_ifconfig2, quiet=True), self.osx_10_11_6_ifconfig2_json)
|
||||
|
||||
def test_ifconfig_osx_10_14_6(self):
|
||||
"""
|
||||
Test 'ifconfig' on OSX 10.14.6
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_10_14_6_ifconfig, quiet=True), self.osx_10_14_6_ifconfig_json)
|
||||
|
||||
def test_ifconfig_osx_10_14_6_2(self):
|
||||
"""
|
||||
Test 'ifconfig' on OSX 10.14.6
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_10_14_6_ifconfig2, quiet=True), self.osx_10_14_6_ifconfig2_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user