-
Notifications
You must be signed in to change notification settings - Fork 556
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
EOS syntax change updates #1093
Conversation
Items for discussion:
|
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.
That'd be perfectly fine by me to go as-is, although I fear that catching an exception whenever (even when it might be a genuine error), might mask actual issues. What if have an internal method, say _run_commands
that has a hash with the possible commands to be remapped when the EOS version is >= 4.23? Something like (very rudimentary example):
def _run_commands(self, cmds):
convert = {
# old command : new command
'show user-account': 'show user accounts'
}
commands = []
for cmd in cmds:
if cmd in convert:
commands.append(conver[cmd])
else:
commands.append(cmd)
return self.device.run_commands(commands)
Do you think that'd work?
Yes, I agree with @mirceaulinic here that it would probably be better if we had this centeralized in the code i.e. some sort of dictionary and a version check. |
Based on earlier discussions, I believe we wanted to try to avoid blindly changing user input / what is being sent to switches. Perhaps something like def _run_commands(self, cmds):
convert = {
# old command : new command
'show user-account': 'show user accounts'
}
commands = []
try:
return self.device.run_commands(cmds)
except pyeapi.eapilib.CommandError as e:
# Check e for bad commands and convert individually
...
return self.device.run_commands(cmds) |
Yes, good point. I apologize if I contradicted something I said earlier also... I was assuming we would only be doing this for hard-coded commands that were used in napalm So for So that leaves what do we do for |
The other unfortunate part here is that the new commands don't work in older EOS versions -- so we can't blindly use the new commands unless we put a version gate on the EOS driver, and state that older versions aren't supported. Is that something that we should consider? I don't think so, as the first version that supports the new syntax was released less than a year ago. |
What about adding something to the
Then the new
|
Sorry, I dropped the ball here.
My comment was probably misleading - let me try to clarify a little: I meant Additionally, I think I like @tcaiazza's suggestion. We could even consider an optional argument if we want to provide a little more flexibility to toggle this feature. |
Having just learned about distutils.version.LooseVersion, I would change my suggestion to this
and
|
Hey @bewing - have you had a chance to think about the suggestions above? I think your implementation is probably fine either way, just would like to hear your thoughts on a broader use case. Cheers! |
Sorry for the immense delay on this PR. Based on feedback, and internal work at $DAY_JOB, I've force-pushed a different changeset done by a co-worker of mine that implements a pyeapi.Node() shim to handle command translation -- take a look and provide some feedback. (if we hate it, the old code is still in branch fn-0039_old) |
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.
I think this looks good overall. Just left a first-pass questions and nits. :]
Create a new Node class that checks EOS versions for forward and backward compatible command translation for FN-0039, along with unit tests for version detection and translation
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.
Okay, I guess that looks good to me. Will leave it open till next week in case anyone would like to add or suggest anything, then should get this into 3.0.0.
@mirceaulinic @bewing So since Quick additional edit for clarity... If left in its current state, it will revert a devices config to old CLI commands for anyone that has already made the move to the new commands after v4.21.4F. If you change the behavior to send new commands for anyone using v4.21.4F or higher (instead of the current 4.23 cutoff), then it will convert people to new commands that may not have made the move yet that are still on 4.21.4F-4.22.X. |
Thanks for reporting @rbcollins123.
Wondering if we should revisit this discussion: #1093 (comment) (i.e., whether we should offer the flip side, new -> old)? I'm thinking maybe we'll want to add a new optional argument to toggle if the user wants the conversion in the config or not. Thoughts? |
I haven't crawled the code yet, but my initial knee-jerk thought when I saw this behavior was to only use the conversion wrapper in an internal But an arg to control the behavior would work as well. To avoid changing the upstream API consumers, just default the arg to not auto-convert and then have internal methods use the arg where it makes sense. |
Yep, I understood what you were saying from the first comment @rbcollins123. What I'm suggesting is an optional argument that lets this decision down to the user (i.e., if they want |
Yep, makes sense to me |
@rbcollins123 would you be able to test my #1212 patch and confirm that'd fix this issue? (@yeled you may be interested in this as well). Feedback welcome from anyone else watching this thread. Thanks! |
FYI I tested and verified that the behavior is now same in v2.4.0, 2.5.0 and 3.0.1 when doing a full config-replace via napalm-ansible. |
Arista has released FN 0039 (available to Arista customers with support
contract) detailing changes to command syntax that impacts several show
commands used by NAPALM beginning in EOS Release 4.23.0. NAPALM will
re-try specific show commands if a CommandError is raised with the newer
syntax.