summaryrefslogtreecommitdiff
path: root/ncserver/base/modman.py
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-12-07 19:20:52 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-12-07 19:20:52 -0600
commitec8637540f403a607a18f3f77ee6c10c141e4291 (patch)
tree7c2a436cd972085f2eb1c0234a9464b6f7dc05c6 /ncserver/base/modman.py
parent8dc6ad089193ad285812579d324fdb20f3d67493 (diff)
downloadnetconfapk-ec8637540f403a607a18f3f77ee6c10c141e4291.tar.gz
netconfapk-ec8637540f403a607a18f3f77ee6c10c141e4291.tar.bz2
netconfapk-ec8637540f403a607a18f3f77ee6c10c141e4291.tar.xz
netconfapk-ec8637540f403a607a18f3f77ee6c10c141e4291.zip
Module Manager: Support augmenting models
This is very early code, but seems to work.
Diffstat (limited to 'ncserver/base/modman.py')
-rw-r--r--ncserver/base/modman.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/ncserver/base/modman.py b/ncserver/base/modman.py
index d8659a2..5033afa 100644
--- a/ncserver/base/modman.py
+++ b/ncserver/base/modman.py
@@ -146,6 +146,25 @@ class ModuleManager:
return None
+ def _augments_for_ns(self, namespace):
+ """Find modules that augment the specified namespace.
+
+ :param str namespace:
+ The namespace of the model whose augments are desired.
+
+ :returns:
+ An Iterable of modules that augment the namespace.
+ The Iterable may be empty.
+ """
+ augments = list()
+
+ for mod in self.modules.values():
+ if getattr(mod, 'M_AUGMENTS', None) is not None and \
+ namespace in mod.M_AUGMENTS:
+ augments.append(mod)
+
+ return augments
+
def load_module(self, name):
"""Load a module.
@@ -325,6 +344,15 @@ class ModuleManager:
raise error.OperationNotSupportedAppError(rpc)
self.logger.debug('Dispatching edit-config to %s', module.M_NAME)
module.edit(session, rpc, child, def_op)
+ for augment in self._augments_for_ns(namespace):
+ try:
+ self.logger.debug(
+ 'Augment: Dispatching edit-config for %s to %s',
+ namespace, augment.M_NAME
+ )
+ augment.edit(session, rpc, child, def_op)
+ except error.OperationNotSupportedAppError:
+ continue
MODMAN = ModuleManager()