From d8fea979b57a81c27d88fb8dd24b11cae71c3c6c Mon Sep 17 00:00:00 2001 From: CJ Maxwell Date: Tue, 13 Apr 2021 14:06:27 -0500 Subject: [PATCH 1/2] fix for issue#1103 make cfgtable.get(key=[...]) actually match the passed values against a table's key-fields --- lib/jnpr/junos/factory/cfgtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jnpr/junos/factory/cfgtable.py b/lib/jnpr/junos/factory/cfgtable.py index 49693b975..2257f09cb 100644 --- a/lib/jnpr/junos/factory/cfgtable.py +++ b/lib/jnpr/junos/factory/cfgtable.py @@ -336,7 +336,7 @@ def _encode_namekey(self, get_cmd, dot, namekey_value): encodes the specific namekey_value into the get command so that the returned XML configuration is the complete hierarchy of data. """ - namekey_xpath = self._data_dict.get("key", "name") + namekey_xpath = self._data_dict.get("key-field", "name") keylist_xml = self._grindkey(namekey_xpath, namekey_value) for _add in keylist_xml: dot.append(_add) From 9a3293ac2d9d4a650e63bc5f4720c549892f7dca Mon Sep 17 00:00:00 2001 From: CJ Maxwell Date: Wed, 14 Apr 2021 09:25:55 -0500 Subject: [PATCH 2/2] Tweak fix to fix #1103 namekey_xpath needs to = "name" when "key-field" is not in data_dict and also when data_dict["key-field"] is an empty iterable --- lib/jnpr/junos/factory/cfgtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jnpr/junos/factory/cfgtable.py b/lib/jnpr/junos/factory/cfgtable.py index 2257f09cb..fa931af8f 100644 --- a/lib/jnpr/junos/factory/cfgtable.py +++ b/lib/jnpr/junos/factory/cfgtable.py @@ -336,7 +336,7 @@ def _encode_namekey(self, get_cmd, dot, namekey_value): encodes the specific namekey_value into the get command so that the returned XML configuration is the complete hierarchy of data. """ - namekey_xpath = self._data_dict.get("key-field", "name") + namekey_xpath = self._data_dict.get("key-field") or "name" keylist_xml = self._grindkey(namekey_xpath, namekey_value) for _add in keylist_xml: dot.append(_add)