From 65de8bc8d0d949f0ea12a84dba9b7963ac1a74f6 Mon Sep 17 00:00:00 2001 From: vdhingra Date: Fri, 5 Jun 2020 00:10:41 -0700 Subject: lib: Add support to load submodules in embedded modules framework BGP Yang is using sub modules and at present FRR is not processing submodules in embedded framework yang Signed-off-by: VishalDhingra --- yang/embedmodel.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'yang/embedmodel.py') diff --git a/yang/embedmodel.py b/yang/embedmodel.py index 624a11da9d..0a25c93da7 100644 --- a/yang/embedmodel.py +++ b/yang/embedmodel.py @@ -20,6 +20,8 @@ if not os.path.isdir(outdir): # to make it even harder. re_name = re.compile(r'\bmodule\s+([^\s]+)\s+\{') +re_subname = re.compile(r'\bsubmodule\s+([^\s]+)\s+\{') +re_mainname = re.compile(r'\bbelongs-to\s+([^\s]+)\s+\{') re_rev = re.compile(r'\brevision\s+([\d-]+)\s+\{') @@ -34,6 +36,8 @@ static const char model[] = static struct yang_module_embed embed = { \t.mod_name = "%s", \t.mod_rev = "%s", +\t.sub_mod_name = "%s", +\t.sub_mod_rev = "%s", \t.data = model, \t.format = %s, }; @@ -62,6 +66,10 @@ def escape(line): with open(inname, 'r') as fd: data = fd.read() +sub_name = "" +rev = "" +sub_rev = "" + # XML support isn't actively used currently, but it's here in case the need # arises. It does avoid the regex'ing. if '