summaryrefslogtreecommitdiff
path: root/ncserver/module/nms_ifupdownng.py
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-11-18 14:28:32 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-11-18 14:28:32 -0600
commitd1ef363d806a2d67ab0ed0c99ee20e8028c11f75 (patch)
tree7f7ba0560e75e7b1103cea38c5b053bb468997d6 /ncserver/module/nms_ifupdownng.py
parent557adae9056c81247e713ad4fb133c24db6e8b7f (diff)
downloadnetconfapk-d1ef363d806a2d67ab0ed0c99ee20e8028c11f75.tar.gz
netconfapk-d1ef363d806a2d67ab0ed0c99ee20e8028c11f75.tar.bz2
netconfapk-d1ef363d806a2d67ab0ed0c99ee20e8028c11f75.tar.xz
netconfapk-d1ef363d806a2d67ab0ed0c99ee20e8028c11f75.zip
ncserver: Style improvements
Diffstat (limited to 'ncserver/module/nms_ifupdownng.py')
-rw-r--r--ncserver/module/nms_ifupdownng.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ncserver/module/nms_ifupdownng.py b/ncserver/module/nms_ifupdownng.py
index d5d5da8..a05d7cc 100644
--- a/ncserver/module/nms_ifupdownng.py
+++ b/ncserver/module/nms_ifupdownng.py
@@ -12,6 +12,7 @@ SPDX-License-Identifier: NCSA
import ipaddress
import logging
+import socket
import subprocess
import yaml
@@ -83,7 +84,7 @@ def _save():
for item in _CONFIG[iface]:
for key, val in item.items():
if key == 'auto' and \
- val == True or val.lower()[0] == 't':
+ (val is True or val.lower()[0] == 't'):
buf = "auto " + iface + "\n" + buf
continue
if isinstance(val, bool):
@@ -215,10 +216,12 @@ def list_addresses(iface: str) -> list:
fallback_prefix = str(net.prefixlen)
addrs = _find_many(iface, 'address')
+
def fixup(addr):
if '/' not in addr:
addr = addr + "/" + fallback_prefix
return addr
+
return list(map(fixup, addrs))
@@ -232,6 +235,10 @@ def add_address(iface: str, _type, addr: str, prefix):
)
return
+ if _type not in (socket.AF_INET, socket.AF_INET6):
+ LOGGER.error(_("unknown address type %r"), _type)
+ return
+
# implement this.
raise NotImplementedError