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

Implement chatops-enabled configuration consistency checks #10

Merged
merged 11 commits into from Apr 10, 2017

Conversation

Mierdin
Copy link
Contributor

@Mierdin Mierdin commented Mar 18, 2017

This PR provides an action, and accompanying action-aliase for performing automated WIRI (what it really is) vs WISB (what it should be) comparisons.

Here's an example:

vagrant@st2vagrant:~$ st2 run napalm.check_consistency hostname=vsrx01
..
id: 58ebd2b6c4da5f05575d9b8d
status: succeeded
parameters:
  hostname: vsrx01
result:
  exit_code: 0
  result:
    deviation: true
    diff_contents: "---
+++
@@ -72,6 +72,7 @@
         unit 0 {
             family inet {
                 address 192.168.50.51/24;
+                address 192.168.50.50/24;
             }
         }
     }
"
  stderr: ''
  stdout: ''

Also some misc corrections/cleanups.

Matt Oswalt added 5 commits March 18, 2017 16:32
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
action_ref: "napalm.check_consistency"
description: "Check consistency of the device's configuration"
formats:
- "check consistency on {{hostname}}"

Choose a reason for hiding this comment

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

@Mierdin Since there would be other packs as well on the ST2 installation, does it make sense to give the alias a keyword at the beginning so that chatops commands for this pack are easily identifiable? Some like napalm check consistency on {{hostname}}. I normally do this for integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right, will do

@sidkrishna
Copy link

Otherwise, changes LGTM...

Matt Oswalt added 4 commits April 7, 2017 13:16
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
@Mierdin Mierdin changed the title [WIP] Implementing consistency checks Implement chatops-enabled configuration consistency checks Apr 7, 2017
@Mierdin Mierdin added the RFR label Apr 7, 2017
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Copy link

@lakshmi-kannan lakshmi-kannan left a comment

Choose a reason for hiding this comment

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

Minor comments to be addressed.

type: "string"
description: "The hostname of the device to connect to. Driver must be specified if hostname is not in configuration. Hostname without FQDN can be given if device is in configuration."
required: true
position: 0

Choose a reason for hiding this comment

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

Python actions don't need positions. If it's a python script then, yes. The runner type being python-script can be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack that. Unfortunately all the actions in the pack are like this. So I'll address this in a follow-up PR that tackles all of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#11

htmlout:
type: "boolean"
description: "In addition to the normal output also includes html output."
required: false

Choose a reason for hiding this comment

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

You can probably supply default: false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as last comment - this needs to get fixed on all actions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#12

return "".join(config_file.readlines())

except IOError:
self.logger.error("Golden config not present in repo")

Choose a reason for hiding this comment

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

Provide the repo name for easy debugging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack that, done in 651bcc2

self.logger.error(str(e))
return (False, str(e))

return (True, result)

Choose a reason for hiding this comment

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

Can you paste an example of the diff in description please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just realized you meant the PR description. Duh. Posted

Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
@Mierdin Mierdin merged commit 1593ea5 into master Apr 10, 2017
@Mierdin Mierdin deleted the consistency-check branch April 10, 2017 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants