From d570f9d051b8445be5fc764d827de1cab424a5b8 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Tue, 8 Dec 2020 19:17:56 -0600 Subject: Factor get_nmsa into a util module for DRY --- ncserver/module/ip.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'ncserver/module/ip.py') diff --git a/ncserver/module/ip.py b/ncserver/module/ip.py index e6a2de1..cd4cde0 100644 --- a/ncserver/module/ip.py +++ b/ncserver/module/ip.py @@ -15,8 +15,8 @@ import logging from lxml.etree import QName # pylint: disable=E0611 from netconf import util -from ncserver.base.modman import MODMAN from ncserver.base.util import _ +from ncserver.util import get_nmsa LOGGER = logging.getLogger(__name__) @@ -76,14 +76,6 @@ def _get_ifaces(node): return ifaces -def _get_nmsa(): - """Retrieve our NMSA module handle.""" - nmsa_ns = "http://netconf.adelielinux.org/ns/netmgmt" - nmsa = MODMAN._module_for_ns(nmsa_ns) # pylint: disable=W0212 - - return nmsa - - def from_bool(value: bool) -> str: """Turn a Python bool into an XML bool.""" return str(value).lower() @@ -141,7 +133,7 @@ def _add_ipv6(iface, getter): def running(node): """Retrieve the IP configuration for this device.""" ifaces = _get_ifaces(node) - nmsa = _get_nmsa() + nmsa = get_nmsa() if None in (ifaces, nmsa): # We can't retrieve configuration unless both the ietf-interfaces and @@ -183,7 +175,7 @@ def running(node): def operational(node): """Retrieve the IP state for this device.""" ifaces = _get_ifaces(node) - nmsa = _get_nmsa() + nmsa = get_nmsa() if None in (ifaces, nmsa): # We can't retrieve configuration unless both the ietf-interfaces and -- cgit v1.2.3-60-g2f50