-
Notifications
You must be signed in to change notification settings - Fork 46
Add prefix and negate_prefix to container #67
Add prefix and negate_prefix to container #67
Conversation
napalm_yang/translators/text.py
Outdated
@@ -76,7 +82,7 @@ def _default_element_container(self, mapping, translation, replacing): | |||
|
|||
def _xml_to_text(self, xml, text=""): | |||
for element in xml: | |||
if element.tag == "command": | |||
if element.tag == "command" and element.text is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a container without key_value
you'll get an empty <command/>
element in the XML document. In that case element.text
is None and the next line crashes.
I'll see if I can avoid creating the element in such cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably cleaner to do:
if element.tag == "command":
text += element.text or ""
But it doesn't matter, both do the same.
Overall it looks great :) I see CI is broken but it might be because you actually fixed it so feel free to update the test cases if needed. |
Yeah, no. Some test cases will indeed need to be updated. But there's still a bunch of things broken ATM, namely XMLTranslator and interaction of Trying to fix it now. |
so they are available in subtree when continue_negating: True
I'm a bit stumped. I have the changes behave the way I wanted - mostly. The only thing not working is It will keep negating route - first by So if you have a minimal openconfig structure with a single static route and use it for candidate and running config: d = {'network_instances': {'network_instance': {u'global': {'config': {'enabled': True,
'type': u'DEFAULT_INSTANCE'},
'name': u'global',
'protocols': {'protocol': {u'static static': {'identifier': u'static',
'name': u'static',
'static_routes': {'static': {u'2.2.2.2/32': {'config': {'prefix': u'2.2.2.2/32'},
'next_hops': {'next_hop': {u'10.1.1.9': {'config': {'next_hop': u'10.1.1.9'},
'index': u'10.1.1.9'}}},
'prefix': u'2.2.2.2/32'}}}}}}}}}}
running.load_dict(d)
candidate.load_dict(d) So I'd expect it to do this:
But it does this:
And on the second
Which is not ideal if you want to deploy this config. I'll try to take |
Ok, if you don't manage to get it fixed don't worry. Push everything you have into a branch, build a test case that fails so I have the same scenario as you and I can try to help you looking into it. Maybe we could expose via some variables if we are "replacing", "merging" or even "negating". For example, we could stop the execution of the tree after the |
Sorry for a late reply, other things got in the way. Just pushed an updated test case that fails. This is what we'd have to fix. |
OK, I've followed you suggestion and passed additional variables to But I'm afraid, I am making a right mess of the code :) |
Great job! I will try to test and provide feedback later this week :) |
Ok, this is great. Code wise is a bit of a mess but I don't think there is much we can do right now. At some point when the framework is more feature complete we might want to revisit/refactor and improve some bits but right now I mostly care about the Awesome job! Will be rebasing and doing tiny changes to your code before merging. Will link the commit here for reference when done.. |
Implementation of discussion in #66 Just a POC for now, more changes to be done.