[yang] Fixing groupings when grouping is in the same module file (#9880)

#### Why I did it
If the grouping is in the same file in the module, fetching the grouping fails

#### How I did it
fixing the `uses_module_name` when the grouping is under the same file

#### How to verify it
Enabled a grouping under the same file which is `lldp`, there is a test in sonic-yang-mgmt that translates `sample-config-db` into yang format. This test passes with grouping in `lldp` used.

#### Which release branch to backport (provide reason below if selected)

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 201811
- [ ] 201911
- [ ] 202006
- [ ] 202012
- [ ] 202106

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->


#### A picture of a cute animal (not mandatory but encouraged)
This commit is contained in:
Mohamed Ghoneim 2022-01-28 10:23:38 -08:00 committed by GitHub
parent 6100a6c8f9
commit f8fd2defb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 38 deletions

View File

@ -330,11 +330,11 @@ class SonicYangExtMixin:
# Assume ':' means reference to another module
if ':' in uses['@name']:
prefix = uses['@name'].split(':')[0].strip()
uses_module = self._findYangModuleFromPrefix(prefix, table_module)
uses_module_name = self._findYangModuleFromPrefix(prefix, table_module)
else:
uses_module = table_module
uses_module_name = table_module['@name']
grouping = uses['@name'].split(':')[-1].strip()
leafs = self.preProcessedYang['grouping'][uses_module][grouping]
leafs = self.preProcessedYang['grouping'][uses_module_name][grouping]
self._fillLeafDict(leafs, leafDict)
except Exception as e:
self.sysLog(msg="_fillLeafDictUses failed:{}".format(str(e)), \

View File

@ -28,6 +28,7 @@ module sonic-lldp {
grouping lldp_mode_config {
leaf enabled {
type boolean;
default true;
description
"Enable/Disable LLDP";
}
@ -99,24 +100,7 @@ module sonic-lldp {
"Suppress sending of System Capabilities TLV in LLDP frames";
}
leaf enabled {
type boolean;
default true;
description
"Enable/Disable LLDP";
}
leaf mode {
type enumeration {
enum RECEIVE;
enum TRANSMIT;
}
description
"RX/TX mode for LLDP frames";
}
//uses lldp_mode_config;
uses lldp_mode_config;
}
}
@ -132,23 +116,7 @@ module sonic-lldp {
"Reference of port on which LLDP to be configured.";
}
leaf enabled {
type boolean;
default true;
description
"Enable/Disable LLDP";
}
leaf mode {
type enumeration {
enum RECEIVE;
enum TRANSMIT;
}
description
"RX/TX mode for LLDP frames";
}
//uses lldp_mode_config;
uses lldp_mode_config;
}
}
}