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

Add napalm commit confirmed features #48909

merged 8 commits into from Aug 3, 2018


Copy link

@mirceaulinic mirceaulinic commented Aug 3, 2018

What does this PR do?

In line with my previous PR #48779, adding now two new features revert_in and revert_at that would schedule a configuration revert, similar to what we have on Junos (where is called "commit confirmed"). I opted to use these names as I find it makes it more obvious that the configuration will be reverted unless instructed otherwise.

The main problem is not the naming nevertheless, but the fact that not all the platforms support this natively (only Junos AFAIK). However, via Salt this would be available on any platform, but with some caveats and the user must be very cautious when using this (not that the feature itself can cause issues, but to have the right expectations when using this).

Usage example:

$ sudo salt veos-lab net.load_config text='ntp server' revert_in=2m
        The commit ID is: 20180802145541882500.
        This commit will be reverted at: 2018-08-02T14:57:49, unless confirmed.
        To confirm the commit and avoid reverting, you can execute:

        salt veos-lab net.confirm_commit 20180802145541882500
        @@ -5,6 +5,7 @@
         transceiver qsfp default-mode 4x10G
         ntp server
        +ntp server
         snmp-server location Tampa, FL
$ sudo salt veos-lab net.confirm_commit 20180802145541882500
        Commit #20180802145541882500 confirmed.

With this PR, I am also:

  • Cleaning up the schedule after the job is executed (so we don't endup with tens of scheduled jobs)
  • Store the config schedule to be loaded into a temporary file from where the Minion will read it, as in opposite to storing this in the schedule directly - inefficient especially as the config can be huge.
  • Remove the temporary files after using them.
  • Add the commit_confirmed and commit_cancelled State functions to the netconfig State.
  • The functions would return a commit_id key which can be used using the __slots__ feature to be sent to the state functions mentioned above.

Copy link

@cachedout cachedout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeClimate has a few ideas about some possible refactoring for DRY and breaking up some of the nested logic but otherwise this looks good!

Copy link
Contributor Author

Hi @cachedout - I looked through the warnings from codeclimate, but I couldn't identify which one I could fix (some are not relevant to these changes though)...

@rallytime rallytime merged commit 64fa32a into saltstack:develop Aug 3, 2018
@mirceaulinic mirceaulinic deleted the napalm-commit-confirmed branch August 3, 2018 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants