{ "info": { "author": "Nitin Kumar", "author_email": "", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Networking" ], "description": "[![Documentation Status](https://readthedocs.org/projects/hbez/badge/?version=latest)](http://hbez.readthedocs.io)\n[![UnitTest Status](https://travis-ci.org/Juniper/healthbot-py-client.svg?branch=master)](https://travis-ci.org/Juniper/healthbot-py-client)\n\n# HealthBot Python Client\n\nThis repo contains a Python package to control HealthBot\n\nThe purpose of this package is to provide a Python library that \nautomates the provisioning of the HealthBot server.\n\n# Examples\n\n\n\n\n# Import HbEZ library\n\n\n```python\nfrom jnpr.healthbot import HealthBotClient\nfrom pprint import pprint\n```\n\n\n```python\nhb = HealthBotClient('xx.xx.xx.xxx', 'xxxxx', 'xxxxx', port=nnnn)\n```\n\n# Use Case: Device\n\n\n```python\npprint(hb.device.get_ids())\n```\n\n ['edge', 'srx', 'qfx', 'mx-edge', 'core', 'node', 'demo']\n\n\n### Getting help for any given function\n\n\n```python\nhelp(hb.device.get_ids)\n```\n\n Help on method get_ids in module jnpr.healthbot.modules.devices:\n\n get_ids() method of jnpr.healthbot.modules.devices.Device instance\n Return Device IDs for all the devices in HealthBot system\n\n :return: list of device IDs\n\n Example:\n ::\n\n from jnpr.healthbot import HealthBotClient\n hb = HealthBotClient('xx.xxx.x.xx', 'xxxx', 'xxxx', port=nnnn)\n print(hb.device.get_ids())\n\n\n\n### Get config related to given device-id\n\n\n```python\n# Get config related to given device-id\nobj = hb.device.get('demo')\n```\n\n\n```python\nobj.host\n```\n\n\n\n\n 'xx.xxx.x.xx'\n\n\n\n\n```python\npprint(obj)\n```\n\n {'authentication': {'password': {'password': 'xxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'demo',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': None,\n 'open_config': None,\n 'snmp': None,\n 'system_id': 'test:HbEZ',\n 'variable': None,\n 'vendor': None}\n\n\n### get facts for the given device id\n\n\n```python\n# Get device facts of a given device id\npprint(hb.device.get_facts('demo'))\n```\n\n {'device-id': 'demo',\n 'facts': {'fpc': [],\n 'hostname': 'R1_re0',\n 'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n 'normal shutdown.',\n 'mastership-state': 'master',\n 'model': 'RE-VMX',\n 'name': 're0',\n 'status': 'OK',\n 'up-time': '98 days, 3 minutes, 49 seconds',\n 'version-info': {'build': '0',\n 'major': [19, 3],\n 'minor': ['20190421_dev_common'],\n 'type': 'I'}}],\n 'platform': 'MX960',\n 'platform-info': [{'name': 're0', 'platform': 'MX960'}],\n 'product': 'MX',\n 'release': '19.3-20190421_dev_common.0.84473',\n 'serial-number': 'xxxx'}}\n\n\n### Add a new device\n\n\n```python\nfrom jnpr.healthbot import DeviceSchema\n\nds = DeviceSchema(device_id='demo', host='xx.xxx.x.xx',\n authentication={\"password\": {\"password\": \"xxxx\", \"username\": \"xxxx\"}})\nprint(hb.device.add(schema=ds))\n```\n\n True\n\n\n\n```python\nhelp(DeviceSchema)\n```\n\n Help on class DeviceSchema in module jnpr.healthbot.swagger.models.device_schema:\n\n class DeviceSchema(builtins.object)\n | NOTE: This class is auto generated by the swagger code generator program.\n | \n | Do not edit the class manually.\n | \n | Methods defined here:\n | \n | __eq__(self, other)\n | Returns true if both objects are equal\n | \n | __init__(self, authentication=None, description=None, device_id=None, host=None, i_agent=None, open_config=None, snmp=None, system_id=None, variable=None, vendor=None)\n | DeviceSchema - a model defined in Swagger\n | \n | __ne__(self, other)\n | Returns true if both objects are not equal\n | \n | __repr__(self)\n | For `print` and `pprint`\n | \n | to_dict(self)\n | Returns the model properties as a dict\n | \n | to_str(self)\n | Returns the string representation of the model\n | \n | ----------------------------------------------------------------------\n | Data descriptors defined here:\n | \n | __dict__\n | dictionary for instance variables (if defined)\n | \n | __weakref__\n | list of weak references to the object (if defined)\n | \n | authentication\n | Gets the authentication of this DeviceSchema. # noqa: E501\n | \n | \n | :return: The authentication of this DeviceSchema. # noqa: E501\n | :rtype: DeviceSchemaAuthentication\n | \n | description\n | Gets the description of this DeviceSchema. # noqa: E501\n | \n | Description about the device # noqa: E501\n | \n | :return: The description of this DeviceSchema. # noqa: E501\n | :rtype: str\n | \n | device_id\n | Gets the device_id of this DeviceSchema. # noqa: E501\n | \n | Identifier for the device. Should be of pattern [a-zA-Z][a-zA-Z0-9_-]* # noqa: E501\n | \n | :return: The device_id of this DeviceSchema. # noqa: E501\n | :rtype: str\n | \n | host\n | Gets the host of this DeviceSchema. # noqa: E501\n | \n | Name or IP the device # noqa: E501\n | \n | :return: The host of this DeviceSchema. # noqa: E501\n | :rtype: str\n | \n | i_agent\n | Gets the i_agent of this DeviceSchema. # noqa: E501\n | \n | \n | :return: The i_agent of this DeviceSchema. # noqa: E501\n | :rtype: DeviceSchemaIAgent\n | \n | open_config\n | Gets the open_config of this DeviceSchema. # noqa: E501\n | \n | \n | :return: The open_config of this DeviceSchema. # noqa: E501\n | :rtype: DeviceSchemaOpenconfig\n | \n | snmp\n | Gets the snmp of this DeviceSchema. # noqa: E501\n | \n | \n | :return: The snmp of this DeviceSchema. # noqa: E501\n | :rtype: DeviceSchemaSnmp\n | \n | system_id\n | Gets the system_id of this DeviceSchema. # noqa: E501\n | \n | ID which is sent in the JTI UDP messages # noqa: E501\n | \n | :return: The system_id of this DeviceSchema. # noqa: E501\n | :rtype: str\n | \n | variable\n | Gets the variable of this DeviceSchema. # noqa: E501\n | \n | Playbook variable configuration # noqa: E501\n | \n | :return: The variable of this DeviceSchema. # noqa: E501\n | :rtype: list[DeviceSchemaVariable]\n | \n | vendor\n | Gets the vendor of this DeviceSchema. # noqa: E501\n | \n | \n | :return: The vendor of this DeviceSchema. # noqa: E501\n | :rtype: DeviceSchemaVendor\n | \n | ----------------------------------------------------------------------\n | Data and other attributes defined here:\n | \n | __hash__ = None\n | \n | attribute_map = {'authentication': 'authentication', 'description': 'd...\n | \n | swagger_types = {'authentication': 'DeviceSchemaAuthentication', 'desc...\n\n\n\n\n```python\ndev = hb.device.get('demo')\npprint(dev)\n```\n\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'demo',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': None,\n 'open_config': None,\n 'snmp': None,\n 'system_id': None,\n 'variable': None,\n 'vendor': None}\n\n\n### By default, get() returns uncommited data (from candidate DB)\n\n\n```python\npprint(hb.device.get('demo', uncommitted=False))\n```\n\n {\n \"detail\": \"Device id demo not found\",\n \"status\": 404\n }\n\n\n\n\n ---------------------------------------------------------------------------\n\n HTTPError Traceback (most recent call last)\n\n in \n ----> 1 pprint(hb.device.get('demo', uncommitted=False))\n\n\n ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/modules/devices.py in get(self, device_id, uncommitted)\n 217 if response.status_code != 200:\n 218 logger.error(response.text)\n --> 219 response.raise_for_status()\n 220 return self.hbot._create_schema(response, DeviceSchema)\n 221 else:\n\n\n /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/models.py in raise_for_status(self)\n 933 \n 934 if http_error_msg:\n --> 935 raise HTTPError(http_error_msg, response=self)\n 936 \n 937 def close(self):\n\n\n HTTPError: 404 Client Error: NOT FOUND for url: https://10.209.7.33:8080/api/v1/device/demo\n\n\n### Why we choose to go with Schema. We can easily access and edit any attribute. \n\n\n```python\n# Existing system_id\nprint (dev.system_id)\n```\n\n None\n\n\n\n```python\n# Editing system_id\ndev.system_id = \"Demo:HbEZ\"\n```\n\n\n```python\nprint(hb.device.update(dev))\n```\n\n True\n\n\n### HealthBot API provide commit and rollback config\n\n\n```python\nhb.commit()\n```\n\n\n\n\n True\n\n\n\n\n```python\ndev = hb.device.get('demo')\npprint(dev)\n```\n\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'demo',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': None,\n 'open_config': None,\n 'snmp': None,\n 'system_id': 'Demo:HbEZ',\n 'variable': None,\n 'vendor': None}\n\n\n\n```python\nprint(dev.system_id)\n```\n\n Demo:HbEZ\n\n\n\n```python\n# To delete a device\nhb.device.delete('demo')\n\n# if a device is part of device group, to make sure we delete it first from device group\nhb.device.delete('demo', force=True)\n```\n\n# Use Case: Devices\n\n### Get details of all devices in System\n\n\n```python\n# Get config details of all the device\nobj = hb.device.get()\n```\n\n\n```python\nobj\n```\n\n\n\n\n [{'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'xxxx',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': None,\n 'open_config': {'port': 32767},\n 'snmp': None,\n 'system_id': None,\n 'variable': [],\n 'vendor': {'juniper': {'operating-system': 'junos'}}},\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'xxx',\n 'host': 'xx.xxx.x.xx9',\n 'i_agent': {'port': 830},\n 'open_config': {'port': 32767},\n 'snmp': None,\n 'system_id': None,\n 'variable': [],\n 'vendor': {'juniper': {'operating-system': 'junos'}}},\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'xxx',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': {'port': 830},\n 'open_config': {'port': 32767},\n 'snmp': None,\n 'system_id': 'changed description',\n 'variable': [],\n 'vendor': {'juniper': {'operating-system': 'junos'}}},\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'demo',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': None,\n 'open_config': None,\n 'snmp': None,\n 'system_id': 'Demo:HbEZ',\n 'variable': None,\n 'vendor': None},\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'vmx_db',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': {'port': 830},\n 'open_config': {'port': 32767},\n 'snmp': None,\n 'system_id': None,\n 'variable': [],\n 'vendor': {'juniper': {'operating-system': 'junos'}}},\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'core_db',\n 'host': 'xx.xxx.x.xx',\n 'i_agent': {'port': 830},\n 'open_config': {'port': 32767},\n 'snmp': None,\n 'system_id': None,\n 'variable': [],\n 'vendor': {'juniper': {'operating-system': 'junos'}}},\n {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_id': 'node1',\n 'host': 'node1',\n 'i_agent': None,\n 'open_config': {'port': 32767},\n 'snmp': None,\n 'system_id': None,\n 'variable': None,\n 'vendor': {'juniper': {'operating-system': 'junos'}}}]\n\n\n\n### Get device facts for all the devices in HB\n\n\n```python\npprint(hb.device.get_facts())\n```\n\n [{'device-id': 'edge', 'facts': {}},\n {'device-id': 'EVO',\n 'facts': {'fpc': [{'description': 'FPC-JNP10003-LOGICAL',\n 'model-number': None,\n 'name': 'FPC 1',\n 'part-number': 'BUILTIN',\n 'serial-number': 'BUILTIN',\n 'version': None}],\n 'hostname': None,\n 'junos-info': [{'last-reboot-reason': 'Unknown',\n 'mastership-state': 'Master',\n 'model': 'Control Board',\n 'name': 're0',\n 'status': 'OK',\n 'up-time': '0 second',\n 'version-info': {'build': None,\n 'major': [19, 4],\n 'minor': ['20190731122440-EVO_soumikd'],\n 'type': 'I'}}],\n 'platform': 'PTX10003-160C',\n 'platform-info': [{'name': 're0', 'platform': 'PTX10003-160C'}],\n 'product': 'PTX',\n 'release': '19.4I20190731122440-EVO_soumikd',\n 'serial-number': 'xxxx'}},\n {'device-id': 'vmx',\n 'facts': {'fpc': [],\n 'hostname': 'R1_re0',\n 'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n 'normal shutdown.',\n 'mastership-state': 'master',\n 'model': 'RE-VMX',\n 'name': 're0',\n 'status': 'OK',\n 'up-time': '80 days, 1 hour, 20 minutes, 9 seconds',\n 'version-info': {'build': '0',\n 'major': [19, 3],\n 'minor': ['20190421_dev_common'],\n 'type': 'I'}}],\n 'platform': 'MX960',\n 'platform-info': [{'name': 're0', 'platform': 'MX960'}],\n 'product': 'MX',\n 'release': '19.3-20190421_dev_common.0.84473',\n 'serial-number': 'xxxx'}},\n {'device-id': 'demo',\n 'facts': {'fpc': [],\n 'hostname': 'R1_re0',\n 'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n 'normal shutdown.',\n 'mastership-state': 'master',\n 'model': 'RE-VMX',\n 'name': 're0',\n 'status': 'OK',\n 'up-time': '98 days, 38 minutes, 25 seconds',\n 'version-info': {'build': '0',\n 'major': [19, 3],\n 'minor': ['20190421_dev_common'],\n 'type': 'I'}}],\n 'platform': 'MX960',\n 'platform-info': [{'name': 're0', 'platform': 'MX960'}],\n 'product': 'MX',\n 'release': '19.3-20190421_dev_common.0.84473',\n 'serial-number': 'xxxx'}},\n {'device-id': 'vmx_db',\n 'facts': {'hostname': 'riad001-g',\n 'junos-info': [],\n 'platform': 'MX480',\n 'platform-info': [{'name': 're0', 'platform': 'MX480'}],\n 'product': None,\n 'release': '19.4I20190809_0730_madhus',\n 'serial-number': None}},\n {'device-id': 'core_db',\n 'facts': {'fpc': [{'description': 'MPC Type 2 3D',\n 'model-number': 'MX-MPC2-3D',\n 'name': 'FPC 1',\n 'part-number': '750-031089',\n 'serial-number': 'xxxx',\n 'version': 'REV 31'}],\n 'hostname': 'choc-mx480-b',\n 'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n 'normal shutdown.',\n 'mastership-state': 'master',\n 'model': 'RE-S-2000',\n 'name': 're0',\n 'status': 'OK',\n 'up-time': '5 hours, 27 minutes, 15 seconds',\n 'version-info': {'build': None,\n 'major': [19, 4],\n 'minor': ['20190809_0730_madhus'],\n 'type': 'I'}},\n {'last-reboot-reason': '0x1:power cycle/failure',\n 'mastership-state': 'backup',\n 'model': 'RE-S-2000',\n 'name': 're1',\n 'status': 'OK',\n 'up-time': '14 days, 22 hours, 34 minutes, 13 '\n 'seconds',\n 'version-info': {'build': 7,\n 'major': [15, 1],\n 'minor': ['6'],\n 'type': 'R'}}],\n 'platform': 'MX480',\n 'platform-info': [{'name': 're0', 'platform': 'MX480'},\n {'name': 're1', 'platform': 'MX480'}],\n 'product': 'MX',\n 'release': '19.4I20190809_0730_madhus',\n 'serial-number': 'xxxx'}},\n {'device-id': 'node1', 'facts': {}}]\n\n\n### Add device group using DevicegroupSchema and APIs provided\n\n\n```python\nfrom jnpr.healthbot import DeviceGroupSchema\n```\n\n\n```python\ndgs = DeviceGroupSchema(device_group_name=\"edge\", devices=['demo'])\n```\n\n### We can also set any param/attribute after creating schema object\n\n\n```python\ndgs.description=\"All devices on the edge\"\n```\n\n### Now add device group using provided API\n\n\n```python\nprint(hb.device_group.add(dgs))\n```\n\n True\n\n\n### Let see whats the plus point of using Schema\n\n 1> Helps with any missing paramters\n 2> Checks for any rule associated with given params\n\n\n```python\n# Error for missing mandatory parameters\n\ndgs = DeviceGroupSchema()\n```\n\n\n ---------------------------------------------------------------------------\n\n ValueError Traceback (most recent call last)\n\n in \n 1 # Error for missing mandatory parameters\n 2 \n ----> 3 dgs = DeviceGroupSchema()\n\n\n ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in __init__(self, authentication, description, device_group_name, devices, logging, native_gpb, notification, playbooks, reports, retention_policy, variable)\n 85 if description is not None:\n 86 self.description = description\n ---> 87 self.device_group_name = device_group_name\n 88 if devices is not None:\n 89 self.devices = devices\n\n\n ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in device_group_name(self, device_group_name)\n 168 \"\"\"\n 169 if device_group_name is None:\n --> 170 raise ValueError(\"Invalid value for `device_group_name`, must not be `None`\") # noqa: E501\n 171 if device_group_name is not None and len(device_group_name) > 64:\n 172 raise ValueError(\"Invalid value for `device_group_name`, length must be less than or equal to `64`\") # noqa: E501\n\n\n ValueError: Invalid value for `device_group_name`, must not be `None`\n\n\n\n```python\n# Error for not following rule for give parameter\n\ndgs = DeviceGroupSchema(device_group_name=\"edge group\")\n```\n\n\n ---------------------------------------------------------------------------\n\n ValueError Traceback (most recent call last)\n\n in \n 1 # Error for not following rule for give parameter\n 2 \n ----> 3 dgs = DeviceGroupSchema(device_group_name=\"edge group\")\n\n\n ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in __init__(self, authentication, description, device_group_name, devices, logging, native_gpb, notification, playbooks, reports, retention_policy, variable)\n 85 if description is not None:\n 86 self.description = description\n ---> 87 self.device_group_name = device_group_name\n 88 if devices is not None:\n 89 self.devices = devices\n\n\n ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in device_group_name(self, device_group_name)\n 172 raise ValueError(\"Invalid value for `device_group_name`, length must be less than or equal to `64`\") # noqa: E501\n 173 if device_group_name is not None and not re.search('^[a-zA-Z][a-zA-Z0-9_-]*$', device_group_name): # noqa: E501\n --> 174 raise ValueError(\"Invalid value for `device_group_name`, must be a follow pattern or equal to `/^[a-zA-Z][a-zA-Z0-9_-]*$/`\") # noqa: E501\n 175 \n 176 self._device_group_name = device_group_name\n\n\n ValueError: Invalid value for `device_group_name`, must be a follow pattern or equal to `/^[a-zA-Z][a-zA-Z0-9_-]*$/`\n\n\n\n```python\n# Now we are in compliance with rules\n\ndgs = DeviceGroupSchema(device_group_name=\"edge\")\n```\n\n\n```python\ndgs.devices = ['demo']\n```\n\n### We can also pass all Schema params to add_ APIs, internally it will use these params to create Schema\n\n\n```python\nprint(hb.device_group.add(device_group_name=\"edge\", description=\"All devices on the edge\", devices=['demo']))\nhb.commit()\n```\n\n True\n\n\n\n\n\n True\n\n\n\n\n```python\n# Get details for a given device group\nhb.device_group.get('real')\n```\n\n\n\n\n {'authentication': None,\n 'description': None,\n 'device_group_name': 'real',\n 'devices': ['edge'],\n 'logging': None,\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': ['phyport'],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1563348601},\n 'instance-id': 'ge-1-0-0',\n 'playbook': 'phyport',\n 'rule': 'external/interface-info',\n 'variable-value': [{'name': 'interface_name',\n 'value': 'ge-1/0/0'}]},\n {'@': {'changed-seconds': 1563348601},\n 'instance-id': 'ge-1-0-1',\n 'playbook': 'phyport',\n 'rule': 'external/interface-info',\n 'variable-value': [{'name': 'interface_name',\n 'value': 'ge-1/0/1'}]}]}\n\n\n\n\n```python\nhb.device_group.delete('edge', force=True)\n```\n\n\n\n\n\n\n\n True\n\n\n\n### Add an existing device to existing group\n\n\n```python\nhb.device_group.add_device_in_group('vmx', 'edge')\n```\n\n\n\n\n True\n\n\n\n\n```python\nobj = hb.device_group.get('edge')\nprint (obj)\n```\n\n {'authentication': None,\n 'description': 'All devices on the edge',\n 'device_group_name': 'edge',\n 'devices': ['vmx', 'demo'],\n 'logging': {'log-level': 'warn'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1565668543},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'forwarding-table-summary',\n 'rule': 'protocol.routesummary/check-fib-summary'},\n {'@': {'changed-seconds': 1565669467},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\nobj.devices\n```\n\n\n\n\n ['vmx', 'demo']\n\n\n\n### Get details of all the device groups\n\n\n```python\nprint(hb.device_group.get())\n```\n\n [{'authentication': None,\n 'description': None,\n 'device_group_name': 'real',\n 'devices': ['edge'],\n 'logging': None,\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': ['phyport'],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1563348601},\n 'instance-id': 'ge-1-0-0',\n 'playbook': 'phyport',\n 'rule': 'external/interface-info',\n 'variable-value': [{'name': 'interface_name',\n 'value': 'ge-1/0/0'}]},\n {'@': {'changed-seconds': 1563348601},\n 'instance-id': 'ge-1-0-1',\n 'playbook': 'phyport',\n 'rule': 'external/interface-info',\n 'variable-value': [{'name': 'interface_name',\n 'value': 'ge-1/0/1'}]}]}, {'authentication': None,\n 'description': 'UBS Demo',\n 'device_group_name': 'QFabric',\n 'devices': ['node1'],\n 'logging': None,\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': []}, {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_group_name': 'EVO_CORE',\n 'devices': ['EVO'],\n 'logging': None,\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': []}, {'authentication': {'password': {'password': 'xxxx',\n 'username': 'xxxx'}},\n 'description': None,\n 'device_group_name': 'vmx_db',\n 'devices': ['core_db'],\n 'logging': {'log-level': 'critical'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': []}, {'authentication': None,\n 'description': 'All devices on the edge',\n 'device_group_name': 'edge',\n 'devices': ['vmx', 'demo'],\n 'logging': {'log-level': 'warn'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1565668543},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'forwarding-table-summary',\n 'rule': 'protocol.routesummary/check-fib-summary'},\n {'@': {'changed-seconds': 1565669467},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics'}]}, {'authentication': None,\n 'description': 'learning',\n 'device_group_name': 'Core',\n 'devices': ['vmx'],\n 'logging': None,\n 'native_gpb': {'ports': [22000]},\n 'notification': {},\n 'playbooks': ['icmp-probe', 'rca-ospf-playbook'],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'interface.statistics/check-host-loopback-status',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.fpc/check-fpc-memory',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.ospf/check-ddos-statistics',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-center-chip-host-path',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-cm-error-table',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-fpc-cpu-scheduler-info',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-fpc-threads',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-fpc-utilization-information',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-ithrottle',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-ithrottle-statistics',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-jnh-exceptions',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-jnh-interface-statistics',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-linecard-ethernet-statistics',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-pci-error-counters',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-pfe-traffic-statistics',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-pre-classifier-dropped-packets',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'linecard.statistics/check-traffic-offload-engine-status',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.infra/check-task-io-drops',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.infra/check-task-memory-usage',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.ospf/check-ospf-forwarding-table',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.ospf/check-ospf-io-statistics-information',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.ospf/check-ospf-neighbor-information',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.ospf/check-ospf-statistics-information',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.ospf/fpc-link-stats',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'protocol.ospf/pfe-ddos-policer',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-routing-engine-cpu-utilization',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-system-input-queues',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-system-output-queues',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-system-statistics-ip',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-system-storage-capacity',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-system-virtual-memory-information',\n 'variable-value': []},\n {'@': {'changed-seconds': 1564722219},\n 'instance-id': 'test1',\n 'playbook': 'rca-ospf-playbook',\n 'rule': 'system.statistics/check-version',\n 'variable-value': []},\n {'@': {'changed-seconds': 1565263889},\n 'instance-id': 'set1',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics',\n 'variable-value': [{'name': 'host-var', 'value': '10.221.11.11'},\n {'name': 'count-var', 'value': '2'}]}]}]\n\n\n### We can also update any given device group\n\n\n```python\nprint(hb.device_group.get('edge'))\n```\n\n {'authentication': None,\n 'description': 'All devices on the edge',\n 'device_group_name': 'edge',\n 'devices': ['vmx', 'demo'],\n 'logging': {'log-level': 'warn'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1565668543},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'forwarding-table-summary',\n 'rule': 'protocol.routesummary/check-fib-summary'},\n {'@': {'changed-seconds': 1565669467},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\ndgs = hb.device_group.get('edge')\ndgs.devices.append('vmx')\nhb.device_group.update(dgs)\n```\n\n\n\n\n True\n\n\n\n\n```python\n# Check for devices list\ndgs = hb.device_group.get('edge')\nprint(dgs)\n```\n\n {'authentication': None,\n 'description': 'All devices on the edge',\n 'device_group_name': 'edge',\n 'devices': ['vmx', 'demo'],\n 'logging': {'log-level': 'warn'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1565668543},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'forwarding-table-summary',\n 'rule': 'protocol.routesummary/check-fib-summary'},\n {'@': {'changed-seconds': 1565669467},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\ndgs.devices = ['edge']\nhb.device_group.update(dgs)\n```\n\n\n\n\n True\n\n\n\n\n```python\ndgs = hb.device_group.get('edge')\nprint(dgs)\n```\n\n {'authentication': None,\n 'description': 'All devices on the edge',\n 'device_group_name': 'edge',\n 'devices': ['edge'],\n 'logging': {'log-level': 'warn'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1565668543},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'forwarding-table-summary',\n 'rule': 'protocol.routesummary/check-fib-summary'},\n {'@': {'changed-seconds': 1565669467},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\n# can also update by passing Device Group Schema kwargs\ndgs = hb.device_group.get('edge')\npprint(dgs)\nfrom jnpr.healthbot import DevicegroupSchemaLogging\nlogSchema = DevicegroupSchemaLogging('warn')\nhb.device_group.update(device_group_name='edge', logging=logSchema)\n```\n\n {'authentication': None,\n 'description': 'All devices on the edge',\n 'device_group_name': 'edge',\n 'devices': ['edge'],\n 'logging': {'log-level': 'warn'},\n 'native_gpb': None,\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'retention_policy': None,\n 'variable': [{'@': {'changed-seconds': 1565668543},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'forwarding-table-summary',\n 'rule': 'protocol.routesummary/check-fib-summary'},\n {'@': {'changed-seconds': 1565669467},\n 'instance-id': 'HbEZ-instance',\n 'playbook': 'icmp-probe',\n 'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n\n\n True\n\n\n\n\n```python\n### Delete device and device group\n```\n\n\n```python\nhb.device_group.delete('edge')\n\n```\n\n\n\n\n\n\n\n True\n\n\n\n\n```python\nhb.device.delete('demo')\n```\n\n\n\n\n True\n\n\n\n\n```python\n# Lets commit all the changes\nhb.commit()\n```\n\n\n\n\n True\n\n\n\n### Add Network Group\n\n\n```python\nhb.network_group.add(network_group_name=\"HbEZ\")\n```\n\n\n\n\n True\n\n\n\n\n```python\nprint(hb.network_group.get(network_group_name=\"HbEZ\"))\nhb.network_group.delete(network_group_name=\"HbEZ\")\n```\n\n\n\n\n {'description': None,\n 'network_group_name': 'HbEZ',\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'variable': None}\n\n\n\n\n\n True\n\n\n\n### Add Network Group using Schema\n\n\n```python\nfrom jnpr.healthbot import NetworkGroupSchema\n```\n\n\n```python\nngs = NetworkGroupSchema(network_group_name=\"HbEZ\")\n```\n\n\n```python\nhb.network_group.add(ngs)\n```\n\n\n\n\n True\n\n\n\n\n```python\nhb.network_group.get(network_group_name=\"HbEZ\")\n```\n\n\n\n\n {'description': None,\n 'network_group_name': 'HbEZ',\n 'notification': {},\n 'playbooks': [],\n 'reports': [],\n 'variable': None}\n\n\n\n# Use Case: Rules\n\n\n```python\nhb.rule.get('linecard.ospf', 'check-ddos-statistics')\n```\n\n\n\n\n {'description': 'Monitors ospf related distributed denial of service '\n 'statistics',\n 'field': [{'constant': {'value': '{{ddos-arrival-rate-threshold}}'},\n 'description': 'This field is for ddos arive rate threshold',\n 'field-name': 'ddos-arrival-rate-threshold'},\n {'constant': {'value': '{{ddos-drop-count-threshold}}'},\n 'description': 'This field is for ddos drop count threshold',\n 'field-name': 'ddos-drop-count-threshold'},\n {'constant': {'value': '{{ddos-drop-rate-threshold}}'},\n 'description': 'This field is for ddos drop rate threshold',\n 'field-name': 'ddos-drop-rate-threshold'}],\n 'function': None,\n 'keys': ['group-name', 'protocol-states-locale'],\n 'network_rule': None,\n 'rule_frequency': None,\n 'rule_name': 'check-ddos-statistics',\n 'rule_properties': {'catalogue': {'tier': '1'},\n 'contributor': 'juniper',\n 'helper-files': [{'file-type': 'other',\n 'list-of-files': ['ddos-statistics.yml']}],\n 'supported-devices': {'juniper': {'operating-system': [{'os-name': 'junos',\n 'products': [{'product-name': 'ACX',\n 'releases': [{'platform': ['All'],\n 'release-name': '15.2R1',\n 'release-support': 'min-supported-release'}]},\n {'product-name': 'EX',\n 'releases': [{'platform': ['All'],\n 'release-name': '15.2R1',\n 'release-support': 'min-supported-release'}]},\n {'product-name': 'MX',\n 'releases': [{'platform': ['All'],\n 'release-name': '15.2R1',\n 'release-support': 'min-supported-release'}]},\n {'product-name': 'PTX',\n 'releases': [{'platform': ['All'],\n 'release-name': '15.2R1',\n 'release-support': 'min-supported-release'}]},\n {'product-name': 'QFX',\n 'releases': [{'platform': ['All'],\n 'release-name': '15.2R1',\n 'release-support': 'min-supported-release'}]},\n {'product-name': 'SRX',\n 'releases': [{'platform': ['All'],\n 'release-name': '15.2R1',\n 'release-support': 'min-supported-release'}]}]}]}},\n 'supported-healthbot-version': '1.0.1',\n 'version': 2},\n 'sensor': [{'description': 'Netconf rpc get-ddos-ospf-information iAgent '\n 'sensor to collect telemetry data from network '\n 'device',\n 'iAgent': {'file': 'ddos-statistics.yml',\n 'frequency': '60s',\n 'table': 'ddosStats'},\n 'sensor-name': 'ddosstats',\n 'synopsis': 'ddos statistics sensor definition'}],\n 'synopsis': 'OSPF distributed denial of service statistics analyzer',\n 'trigger': [{'description': 'Sets health based on DDOS packet drop rate',\n 'frequency': '60s',\n 'synopsis': 'DDOS packet drops kpi',\n 'term': [{'term-name': 'is-ddos-drops-increasing',\n 'then': {'status': {'color': 'red',\n 'message': 'DDOS packet drops '\n '($dropped-packets) '\n 'increasing'}},\n 'when': {'min-rate-of-increase': [{'field-name': '$dropped-packets',\n 'rate': '$ddos-drop-rate-threshold',\n 'time-range': '5m'}]}},\n {'term-name': 'are-ddos-drops-over-threshold',\n 'then': {'status': {'color': 'yellow',\n 'message': 'DDOS packet drops '\n '($dropped-packets) '\n 'over threshold '\n '($ddos-drop-count-threshold)'}},\n 'when': {'greater-than': [{'left-operand': '$dropped-packets',\n 'right-operand': '$ddos-drop-count-threshold'}]}},\n {'term-name': 'ddos-drops-not-increasing',\n 'then': {'status': {'color': 'green'}}}],\n 'trigger-name': 'ddos-drops'},\n {'description': 'Sets health based on DDOS packet arrival rate',\n 'frequency': '60s',\n 'synopsis': 'DDOS packet arrival kpi',\n 'term': [{'term-name': 'is-max-packet-arrival-rate-greater-than-threshold',\n 'then': {'status': {'color': 'yellow',\n 'message': 'DDOS packet max '\n 'arrival rate is over '\n 'threshold '\n '($ddos-arrival-rate-threshold)'}},\n 'when': {'greater-than-or-equal-to': [{'left-operand': '$packet-arrival-rate-max',\n 'right-operand': '$ddos-arrival-rate-threshold'}]}},\n {'term-name': 'max-packet-arrival-rate-less-than-threshold',\n 'then': {'status': {'color': 'green'}}}],\n 'trigger-name': 'ddos-packet-arrival-rate'},\n {'description': 'Sets health based on DDOS packet drop others',\n 'frequency': '60s',\n 'synopsis': 'DDOS packet drop other kpi',\n 'term': [{'term-name': 'is-ddos-packet-dropped-others-increasing',\n 'then': {'status': {'color': 'red',\n 'message': 'DDOS packet dropped '\n 'others '\n '($dropped-packets-others) '\n 'increasing'}},\n 'when': {'min-rate-of-increase': [{'field-name': '$dropped-packets-others',\n 'rate': '$ddos-drop-rate-threshold',\n 'time-range': '5m'}]}},\n {'term-name': 'is-ddos-packet-drop-others-over-threshold',\n 'then': {'status': {'color': 'yellow',\n 'message': 'DDOS packet dropped '\n 'others '\n '($dropped-packets-others) '\n 'over threshold '\n '($ddos-drop-count-threshold)'}},\n 'when': {'greater-than': [{'left-operand': '$dropped-packets-others',\n 'right-operand': '$ddos-drop-count-threshold'}]}},\n {'term-name': 'ddos-packet-drop-others-not-increasing',\n 'then': {'status': {'color': 'green'}}}],\n 'trigger-name': 'ddos-packet-dropped-others'}],\n 'variable': [{'description': 'DDOS arrival rate threshold value',\n 'name': 'ddos-arrival-rate-threshold',\n 'type': 'int',\n 'value': '1000'},\n {'description': 'DDOS drop count threshold value',\n 'name': 'ddos-drop-count-threshold',\n 'type': 'int',\n 'value': '0'},\n {'description': 'DDOS drop rate threshold value',\n 'name': 'ddos-drop-rate-threshold',\n 'type': 'int',\n 'value': '1'}],\n 'vector': None}\n\n\n\n### Add new rule\n\n\n```python\nfrom jnpr.healthbot.modules.rules import RuleSchema\nrs = RuleSchema(rule_name=\"hbez-fpc-heap-utilization\")\n```\n\n### setting rule schema params\n\n\n```python\nrs.description = \"HealthBot EZ example\"\nrs.synopsis = \"Using python client for demo\"\nrs.sensor = [{'description': 'Monitors FPC buffer, heap and cpu utilization',\n 'iAgent': {'file': 'fpc-utilization.yml',\n 'frequency': '30s',\n 'table': 'FPCCPUHEAPutilizationTable'},\n 'sensor_name': 'fpccpuheaputilization'}]\n```\n\n\n```python\nrs.field = [{'constant': {'value': '{{fpc-buffer-usage-threshold}}'},\n 'description': 'This field is for buffer usage threshold',\n 'field_name': 'linecard-buffer-usage-threshold'},\n {'constant': {'value': '{{fpc-cpu-usage-threshold}}'},\n 'description': 'This field is for linecard cpu usage threshold',\n 'field_name': 'linecard-cpu-usage-threshold'},\n {'constant': {'value': '{{fpc-heap-usage-threshold}}'},\n 'description': 'This field is for linecard heap usage threshold',\n 'field_name': 'linecard-heap-usage-threshold'}]\nrs.keys = ['slot']\n```\n\n\n```python\nrs.variable = [{'description': 'Linecard Buffer Memory usage threshold value',\n 'name': 'fpc-buffer-usage-threshold',\n 'type': 'int',\n 'value': '80'},\n {'description': 'Linecard CPU usage threshold value',\n 'name': 'fpc-cpu-usage-threshold',\n 'type': 'int',\n 'value': '80'},\n {'description': 'Linecard Heap Memory usage threshold value',\n 'name': 'fpc-heap-usage-threshold',\n 'type': 'int',\n 'value': '80'}]\n```\n\n\n```python\nrs.trigger = [{'description': 'Sets health based on linecard buffer memory',\n 'frequency': '60s',\n 'synopsis': 'Linecard buffer memory kpi',\n 'term': [{'term_name': 'is-buffer-memory-utilization-greater-than-threshold',\n 'then': {'status': {'color': 'red',\n 'message': 'FPC buffer memory '\n 'utilization '\n '($memory-buffer-utilization) '\n 'is over threshold '\n '($linecard-buffer-usage-threshold)'}},\n 'when': {'greater_than': [{'left_operand': '$memory-buffer-utilization',\n 'right_operand': '$linecard-buffer-usage-threshold'}]}},\n {'term_name': 'buffer-utilization-less-than-threshold',\n 'then': {'status': {'color': 'green'}}}],\n 'trigger_name': 'fpc-buffer-memory-utilization'},\n {'description': 'Sets health based on linecard cpu utilization',\n 'frequency': '60s',\n 'synopsis': 'Linecard cpu utilization kpi',\n 'term': [{'term_name': 'is-cpu-utilization-greater-than-80',\n 'then': {'status': {'color': 'red',\n 'message': 'FPC CPU utilization '\n '($cpu-total) is over '\n 'threshold '\n '($linecard-cpu-usage-threshold)'}},\n 'when': {'greater_than': [{'left_operand': '$cpu-total',\n 'right_operand': '$linecard-cpu-usage-threshold',\n 'time_range': '180s'}]}},\n {'term_name': 'cpu-utilization-less-than-threshold',\n 'then': {'status': {'color': 'green'}}}],\n 'trigger_name': 'fpc-cpu-utilization'},\n {'description': 'Sets health based on linecard heap memory '\n 'utilization',\n 'frequency': '60s',\n 'synopsis': 'Linecard heap memory kpi',\n 'term': [{'term_name': 'is-heap-memory-utilization-greater-than-threshold',\n 'then': {'status': {'color': 'red',\n 'message': 'FPC heap memory '\n 'utilization '\n '($memory-heap-utilization) '\n 'is over threshold '\n '($linecard-heap-usage-threshold)'}},\n 'when': {'greater_than': [{'left_operand': '$memory-heap-utilization',\n 'right_operand': '$linecard-heap-usage-threshold'}]}},\n {'term_name': 'heap-memory-utilization-less-than-threshold',\n 'then': {'status': {'color': 'green'}}}],\n 'trigger_name': 'fpc-heap-memory-utilization'}]\n```\n\n### If the topic name is not present, first it will create given topic\n\n\n```python\nhb.rule.add('hbez', schema=rs)\n```\n\n\n\n\n True\n\n\n\n\n```python\n# hb.rules.delete_rule(topic_name='external', rule_name=\"hbez-fpc-heap-utilization\")\n```\n\n# Use Case: Playbooks\n\n\n```python\npprint(hb.playbook.get('linecard-kpis-playbook'))\n```\n\n {'description': 'Playbook checks linecard health i.e. cpu, memory and CM '\n 'errors',\n 'playbook_name': 'linecard-kpis-playbook',\n 'rules': ['linecard.cm-events/check-cm-events',\n 'linecard.fpc/check-fpc-cpu',\n 'linecard.fpc/check-fpc-memory'],\n 'synopsis': 'Linecards key performance indicators'}\n\n\n\n```python\nfrom jnpr.healthbot.modules.playbooks import PlaybookSchema\n```\n\n\n```python\npbs = PlaybookSchema(playbook_name=\"HbEZ-example\")\n```\n\n\n```python\npbs.description = \"HbEZ Demo Examples\"\npbs.synopsis = 'fpc status'\n```\n\n\n```python\npbs.rules = ['hbez/hbez-fpc-heap-utilization']\n```\n\n\n```python\nhb.playbook.add(pbs)\n```\n\n\n\n\n True\n\n\n\n\n```python\nhb.playbook.delete(playbook_name=\"HbEZ-example\")\n```\n\n\n\n\n\n\n\n True\n\n\n\n# Use Case: Health\n\n\n```python\npprint(hb.health.get_device_health('edge'))\n```\n\n {'children': [{'children': [{'children': [], 'name': 'external'}],\n 'name': 'real'}],\n 'color': None,\n 'data': None,\n 'name': 'edge',\n 'timestamp': None}\n\n\n\n```python\npprint(hb.health.get_device_group_health('real'))\n```\n\n {'children': [{'children': [{'children': [], 'name': 'external'}],\n 'name': 'edge'}],\n 'color': None,\n 'data': None,\n 'name': 'real',\n 'timestamp': None}\n\n\n# Use Case: Database\n This we might need to take it off\n\n\n```python\nprint (hb.tsdb.query(\"show databases\"))\n```\n\n ResultSet({'('databases', None)': [{'name': 'health'}, {'name': '_internal'}, {'name': 'Core:vmx'}, {'name': 'real:edge'}, {'name': 'Core:demo'}, {'name': 'EVO_Core:EVO'}, {'name': 'EVO_CORE:EVO'}, {'name': 'vmx_db:vmx_db'}, {'name': 'vmx_db:core_db'}]})\n\n\n\n```python\nobj = hb.tsdb.query('select * from \"protocol-eventd-host/check-host-traffic/packet-loss\" limit 10', database='Core:vmx')\npprint(obj.raw)\n```\n\n {'statement_id': 0}\n\n\n\n```python\nprint(hb.version)\n```\n\n 2.0.1\n\n\n\n```python\n### Load any helper file\n```\n\n\n```python\nhb.upload_helper_file('/Users/nitinkr/xxx/xyz.rule')\n\n```\n\n# Use Case: Notification\n\n\n```python\nfrom jnpr.healthbot import NotificationSchema\nfrom jnpr.healthbot import NotificationSchemaSlack\n\n\nns = NotificationSchema(notification_name='HbEZ-notification')\nns.description = \"example of adding notification via API\"\nnss = NotificationSchemaSlack(channel=\"HbEZ\", url='http://testing')\nns.slack = nss\nhb.settings.notification.add(ns)\n```\n\n\n\n\n True\n\n\n\n\n```python\nprint(hb.settings.notification.get())\n```\n\n [{'description': 'example of adding notification via API',\n 'http_post': None,\n 'kafka_publish': None,\n 'notification_name': 'HbEZ-notification',\n 'slack': {'channel': 'HbEZ', 'url': 'http://testing'}}]\n\n\n\n```python\npprint(hb.settings.notification.delete('HbEZ-notification'))\n```\n\n\n\n\n True\n\n\n# Use Case: Settings\n\n\n```python\nfrom jnpr.healthbot import RetentionPolicySchema\n\nrps = RetentionPolicySchema(retention_policy_name='HbEZ-testing')\nhb.settings.retention_policy.add(rps)\n```\n\n\n\n\n True\n\n\n\n\n```python\nprint(hb.settings.retention_policy.get())\n```\n\n [{'duration': None, 'replication': None, 'retention_policy_name': 'HbEZ-testing'}, {'duration': None,\n 'replication': None,\n 'retention_policy_name': 'HbEZ-testing1'}, {'duration': None,\n 'replication': None,\n 'retention_policy_name': 'HbEZ-testing2'}]\n\n\n\n```python\nfrom jnpr.healthbot import SchedulerSchema\nsc = SchedulerSchema(name='HbEZ-schedule', repeat={'every': 'week'}, start_time=\"2019-07-22T05:32:23Z\")\nhb.settings.scheduler.add(sc)\n\nfrom jnpr.healthbot import DestinationSchema\nds = DestinationSchema(name='HbEZ-destination', email={'id': 'nitinkr@juniper.net'})\nhb.settings.destination.add(ds)\n\nfrom jnpr.healthbot import ReportSchema\nrs = ReportSchema(name=\"HbEZ-report\", destination=['HbEZ-destination'], format=\"html\", schedule=[\"HbEZ-schedule\"])\nhb.settings.report.add(rs)\n```\n\n\n\n\n True\n\n\n\n# Use Case: PlayBook Instance\n\n\n```python\nfrom jnpr.healthbot.modules.playbooks import PlayBookInstanceBuilder\n\n# case where we dont need to set any variable\npbb = PlayBookInstanceBuilder(hb, 'forwarding-table-summary', 'HbEZ-instance', 'Core')\npbb.apply()\n\n#hb.commit()\n```\n\n\n\n\n True\n\n\n\n### when we need to set any rule variable for given device/group in playbook instance\n\n\n```python\nfrom jnpr.healthbot.modules.playbooks import PlayBookInstanceBuilder\n\npbb = PlayBookInstanceBuilder(hb, 'forwarding-table-summary', 'HbEZ-instance', 'Core')\n\nvariable = pbb.rule_variables[\"protocol.routesummary/check-fib-summary\"]\n\n\nvariable.route_address_family = 'pqr'\nvariable.route_count_threshold = 100\n\n# Apply variable to given device(s)\npbb.apply(device_ids=['vmx'])\n\n#clear all the variable if you want to set it something else for group or other device(s)\npbb.clear()\n\nvariable = pbb.rule_variables[\"protocol.routesummary/check-fib-summary\"]\nvariable.route_address_family = 'abc'\nvariable.route_count_threshold = 200\n\npbb.apply()\n\n#hb.commit()\n```\n\n\n\n\n True\n\n\n\n# LICENSE\n\nApache 2.0\n\n# CONTRIBUTORS\n\nJuniper Networks is actively contributing to and maintaining this repo. Please contact healthbot-hackers at juniper.net for any queries.\n\n*Contributors:*\n\n* v1.0.0: [Nitin Kumar](https://github.com/vnitinv)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "Juniper HealthBot", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "hbez", "package_url": "https://pypi.org/project/hbez/", "platform": "", "project_url": "https://pypi.org/project/hbez/", "project_urls": null, "release_url": "https://pypi.org/project/hbez/1.0.0/", "requires_dist": [ "requests", "first", "influxdb", "marshmallow", "jinja2", "PyYAML", "aiohttp", "certifi (>=14.05.14)", "six (>=1.10)", "python-dateutil (>=2.5.3)", "setuptools (>=21.0.0)", "urllib3 (>=1.15.1)" ], "requires_python": ">=3.4", "summary": "Healthbot Python Client", "version": "1.0.0" }, "last_serial": 5906599, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "146075522538e62b9740e6491eb374e9", "sha256": "b76ff984ffd972ec6929fab1dbf9f79265460c66b3e2dbb8548a8a5c357eaf61" }, "downloads": -1, "filename": "hbez-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "146075522538e62b9740e6491eb374e9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.4", "size": 364661, "upload_time": "2019-09-30T11:46:58", "url": "https://files.pythonhosted.org/packages/ac/a6/e067dfeddef371677294c9b2f34c346555140dafd9bd1d83b0fdc65cf7bf/hbez-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c5377fb97917d9c5f54bdef7956a9fb2", "sha256": "464b62e2886634866beb3b327266e243b354d14b63a9b92184a8e469b83a497a" }, "downloads": -1, "filename": "hbez-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c5377fb97917d9c5f54bdef7956a9fb2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 167378, "upload_time": "2019-09-30T11:47:03", "url": "https://files.pythonhosted.org/packages/3c/44/f4fd84789f02ccc40af2eac81d4da90319c6b035521ca02aa51965d62da6/hbez-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "146075522538e62b9740e6491eb374e9", "sha256": "b76ff984ffd972ec6929fab1dbf9f79265460c66b3e2dbb8548a8a5c357eaf61" }, "downloads": -1, "filename": "hbez-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "146075522538e62b9740e6491eb374e9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.4", "size": 364661, "upload_time": "2019-09-30T11:46:58", "url": "https://files.pythonhosted.org/packages/ac/a6/e067dfeddef371677294c9b2f34c346555140dafd9bd1d83b0fdc65cf7bf/hbez-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c5377fb97917d9c5f54bdef7956a9fb2", "sha256": "464b62e2886634866beb3b327266e243b354d14b63a9b92184a8e469b83a497a" }, "downloads": -1, "filename": "hbez-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c5377fb97917d9c5f54bdef7956a9fb2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 167378, "upload_time": "2019-09-30T11:47:03", "url": "https://files.pythonhosted.org/packages/3c/44/f4fd84789f02ccc40af2eac81d4da90319c6b035521ca02aa51965d62da6/hbez-1.0.0.tar.gz" } ] }