Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfgtable.get(key=...) Ignoring multiple key-fields. (semantics error in factory.cfgtable_encode_namekey) #1103

Open
xerotolerance opened this issue Apr 13, 2021 · 2 comments

Comments

@xerotolerance
Copy link

Walkthrough

  1. Table objects are created by FactoryCfgTable(table_name, data_dict), w/ data_dict containing the sections of the YAML spec. Ex (note the dict key 'key-field'):
{'set': 'routing-options/static/route', 'key-field': ['dest', 'next_hop'], 'view': <class '...StaticRouteView'>}
  1. FactoryCfgTable sets
new_cls.DEFINE = deepcopy(data_dict)  #(line 23)
  1. CfgTable's constructor sets
self._data_dict = self.DEFINE #(line 22)
  1. Eventually, cfgtable.get() calls
self._encode_namekey(get_cmd, dot, named_item) #line 504
  1. PROBLEM: _encode_namekey(...) calls self._data_dict.get("key","name") instead of "key-field" causing the default field, name, to be checked every time regardless of whether the YAML definition specifies multiple key-fields.
    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")    # line 339 is the problem: "key" should be "key-field"
        keylist_xml = self._grindkey(namekey_xpath, namekey_value)
        for _add in keylist_xml:
            dot.append(_add)
xerotolerance added a commit to xerotolerance/py-junos-eznc that referenced this issue Apr 14, 2021
namekey_xpath needs to = "name" when "key-field" is not in data_dict and also when data_dict["key-field"] is an empty iterable
@rahkumar651991 rahkumar651991 self-assigned this Jun 1, 2021
@rahkumar651991 rahkumar651991 removed their assignment Oct 12, 2021
@rahkumar651991
Copy link
Contributor

Can you share the netconf logs for this example. Need full configuration to replicate the scenario and verify it.

Refer here -https://www.juniper.net/documentation/us/en/software/junos/junos-xml-protocol/topics/example/netconf-traceoptions-configuring.html

@dineshbaburam91
Copy link
Collaborator

@xerotolerance Kindly share the table/view YAML data to replicate the scenario and verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants