Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Closed loop automation (demo with interfaces admin status enforcement)

Khelil Sator edited this page Mar 10, 2019 · 1 revision

You can use Heathbot to:

  • collect data from the network
  • store the data collected
  • process the data collected

The then clause in Healtboth rules is used to set actions to be taken.
These actions can be:

  • pre-defined-actions (ex: text message to show, color to show, ...)
  • User-Defined-Actions (UDA).

UDA invoke functions. These functions are implemented in Python.
So you create your own python code, and healthbot will execute it automatically based on the data collected and the rules you defined.

This directory has python functions.
These python functions can be triggered by Healthbot rules.

end-to-end demo

Here's an end-to-end demo:

  • Healthbot will collect interfaces state
  • If you disable an interface on a device, healthbot will automatically re-enable it

This healthbot rule uses openconfig telemetry to monitor interfaces state (admin state, op state, ...) of Junos devices.
If an interface is DOWN/DOWN, this rule triggers a User-Defined-Actions.
This UDA invokes this python code.

The python code invoked:

  • makes REST calls to healthbot to get the ip address and credentials of the "faulty" device
  • uses pyez to connect to the "faulty" device and to enable the disabled interface, i.e configuring the "faulty" device with delete interfaces {{ interface }} disable

This healtboth playbook uses the above healthbot rule.

So, to run this demo, you need to:

  • load this python UDA code to healthbot
  • load this healthbot rule to healthbot
  • load this healthbot playbook to healthbot
  • configure healthbot with devices and a devices group
    • make sure your devices support openconfig
  • instantiate this playbook for a device group

The script enforce_interfaces_admin_status.py executes the above tasks.
Update this script with your healthbot and devices ip address and credentials

$ vi enforce_interfaces_admin_status.py

Run this command to execute this script

$ python ./enforce_interfaces_admin_status.py
loaded healthbot function enable_a_disabled_interface.py
loaded healthbot rule enforce-interfaces-state.rule
loaded healthbot playbook enforce-int-state.playbook
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
loaded healthbot configuration for the device group: vmx
healthbot configuration commited!

This script configured healthbot to subscribe to the openconfig path /interfaces on devices vMX1 to vMX7 with a frequency of 15s.
To Display information about sensors, run this command on a Junos device:

jcluser@vMX1> show agent sensors

To verify if there is an established connection between healthbot and a Junos device, run this command on a Junos device:

jcluser@vMX1> show system connections | grep 32768
tcp4       0      0  100.123.1.0.32768                             100.123.35.0.53404                            ESTABLISHED
tcp46      0      0  *.32768                                       *.*                                           LISTEN

Healthbot is collecting interfaces state using openconfig telemetry.

Dashbboard OCdashboard.png

health of vMX1 OCvMX1.png

health of vMX4 OCvMX4.png

If you disable an interface on a device (set interfaces {{ interface }} disable), healthbot will automatically re-enable it (delete interfaces {{ interface }} disable).

Disable interface ge-0/0/0 on vMX1:

jcluser@vMX1> show interfaces terse ge-0/0/0
Interface               Admin Link Proto    Local                 Remote
ge-0/0/0                up    up
ge-0/0/0.0              up    up   inet     192.168.1.0/31
jcluser@vMX1> edit
Entering configuration mode

[edit]
jcluser@vMX1# set interfaces ge-0/0/0 disable

[edit]
jcluser@vMX1# commit and-quit
commit complete
Exiting configuration mode

Verify:

jcluser@vMX1> show interfaces terse ge-0/0/0
Interface               Admin Link Proto    Local                 Remote
ge-0/0/0                down  down
ge-0/0/0.0              up    down inet     192.168.1.0/31
jcluser@vMX1> show system commit
0   2018-12-07 00:27:00 UTC by jcluser via cli

Healthbot automatically re-enabled it

jcluser@vMX1> show interfaces terse ge-0/0/0
Interface               Admin Link Proto    Local                 Remote
ge-0/0/0                up    up
ge-0/0/0.0              up    up   inet     192.168.1.0/31
jcluser@vMX1> show system commit
0   2018-12-07 00:27:38 UTC by jcluser via netconf
1   2018-12-07 00:27:00 UTC by jcluser via cli
jcluser@vMX1> show configuration | compare rollback 1
[edit interfaces ge-0/0/0]
-   disable;
Clone this wiki locally