-
Notifications
You must be signed in to change notification settings - Fork 20
Healthbot REST calls with Python
We will use the python module requests
to make REST calls to healthbot to:
- configure healthbot with an end to end configuration
- collect and print the healthbot configuration
- delete healthbot configuration
run this command on ubuntu to install these python libraries
$ pip install requests
$ pip install pyyaml
$ pip install jinja2
edit the file python_input.yml to indicate healthbot ip address and credentials, and the healthbot desired configuration (devices ip address ...)
$ vi python_input.yml
The python script configure_healthbot.py configures healthbot with the details described in the file python_input.yml
It adds an end to end configuration:
- devices (
vMX1
tovMX7
) - A topic (
bgp
) and rules to monitor BGP using- snmp (rule
check-bgp-state-using-snmp
) - netconf (rule
check-bgp-state-using-netconf
)
- snmp (rule
- tables and views for BGP (
bgp_sessions_state.yml
for the rulecheck-bgp-state-using-netconf
) - playbooks
-
bgp-using-netconf
uses the rulecheck-bgp-state-using-netconf
-
bgp-using-snmp
uses the rulecheck-bgp-state-using-snmp
-
- webhook notifications
- device-groups
-
Group1
with devicesvMX1
tovMX7
and an instance of playbookbgp-using-netconf
-
Group2
with devicesvMX3
andvMX4
and an instance of playbookbgp-using-snmp
-
Run this command to execute the The python script configure_healthbot.py
$ python ./configure_healthbot.py
****************** Adding devices to healthbot ******************
loaded healthbot configuration for the device: vMX1
loaded healthbot configuration for the device: vMX2
loaded healthbot configuration for the device: vMX3
loaded healthbot configuration for the device: vMX4
loaded healthbot configuration for the device: vMX5
loaded healthbot configuration for the device: vMX6
loaded healthbot configuration for the device: vMX7
****************** Adding tables to healthbot ******************
added table: bgp_sessions_state.yml
****************** Adding notifications to healthbot ******************
loaded healthbot configuration for the notification: healthbot_to_saltstack
****************** Adding topics and rules to healthbot ******************
loaded healthbot configuration for the topic: bgp
****************** Adding playbooks to healthbot ******************
loaded healthbot configuration for the playbook: bgp-using-netconf
loaded healthbot configuration for the playbook: bgp-using-snmp
****************** Adding device groups to healthbot ******************
loaded healthbot configuration for the device group: Group1
loaded healthbot configuration for the device group: Group2
****************** commiting healthbot configuration ******************
healthbot configuration commited!
Healthbot dashboard:
Run this command to verify you were able to configure Healthbot properly with the details described in the file python_input.yml.
This will collect configuration from Healthbot and print it.
$ python ./audit_healthbot_configuration.py
Run this command to delete the healthtbot configuration described in the file python_input.yml
This will delete:
- device-groups (including playbook instances)
- playbooks
- topics and rules
- notifications
- devices
This will also remove the tables and views listed in the file python_input.yml
$ python ./delete_healthbot_configuration.py