summaryrefslogtreecommitdiff
path: root/ncserver/module
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-10-29 19:41:04 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-10-29 19:41:04 -0500
commit02493e74f7d9499dd090f63ca1ccfe397b23758a (patch)
tree6f9c8ba20475015cdd0f6ef8a398162313b132b7 /ncserver/module
parent4bf16df586bb7ee18b6e09616cbd8e7a66cc28f5 (diff)
downloadnetconfapk-02493e74f7d9499dd090f63ca1ccfe397b23758a.tar.gz
netconfapk-02493e74f7d9499dd090f63ca1ccfe397b23758a.tar.bz2
netconfapk-02493e74f7d9499dd090f63ca1ccfe397b23758a.tar.xz
netconfapk-02493e74f7d9499dd090f63ca1ccfe397b23758a.zip
ietf-interfaces: Add type field
Diffstat (limited to 'ncserver/module')
-rw-r--r--ncserver/module/interfaces.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/ncserver/module/interfaces.py b/ncserver/module/interfaces.py
index 497c63a..7e48b2e 100644
--- a/ncserver/module/interfaces.py
+++ b/ncserver/module/interfaces.py
@@ -51,6 +51,9 @@ M_REVISION = "2018-02-20"
M_IMPORTS = {
'ietf-yang-types@2013-07-15': {
'ns': "urn:ietf:params:xml:ns:yang:ietf-yang-types", 'prefix': "yang"
+ },
+ 'iana-if-type@2017-01-19': {
+ 'ns': "urn:ietf:params:xml:ns:yang:iana-if-type", 'prefix': "ianaift"
}
}
"""The imported YANG modules for this module."""
@@ -64,9 +67,38 @@ def _add_running_contents(ifaces):
"""Retrieve the interface configuration for this device.
Allows returning the 'config true' data for both datastores."""
+ types = {
+ '1': 'ethernetCsmacd',
+ '3': 'rfc877x25',
+ '7': 'arcnet',
+ '8': 'arap',
+ '19': 'atm',
+ '24': 'ieee1394',
+ '32': 'infiniband',
+ '256': 'slip',
+ '512': 'ppp',
+ '513': 'hdlc',
+ '516': 'lapb',
+ '768': 'tunnel',
+ '770': 'frameRelay',
+ '772': 'softwareLoopback',
+ '774': 'fddi',
+ '804': 'ieee802154'
+ }
+
for ifname in pathlib.Path('/sys/class/net').iterdir():
iface = util.subelm(ifaces, 'if:interface')
iface.append(util.leaf_elm('if:name', ifname.name))
+ type_file = open(ifname / "type", 'r')
+ type_num = type_file.read()
+ type_file.close()
+ type_num = type_num.strip()
+ if type_num in types.keys():
+ iface.append(util.leaf_elm('if:type', 'ianaift:'+types[type_num],
+ nsmap={'ianaift': "urn:ietf:params:xml:ns:yang:iana-if-type"}))
+ else:
+ LOGGER.warning(_('unknown Linux hwtype for %s: %s'),
+ ifname.name, type_num)
def running(node):