jnpr.healthbot¶
jnpr.healthbot.modules¶
HealthBotClient¶
-
class
jnpr.healthbot.healthbot.
HealthBotClient
(server: str, user: str, password: str, *args, **kwargs)[source]¶ Bases:
object
-
apiopt_candidate
= '/?working=true'¶
-
__init__
(server: str, user: str, password: str, *args, **kwargs)[source]¶ An instance of this class represents the HealthBot Service
Parameters: - server (str) – HealthBot Server IP Address
- user (str) – HealthBot Server (not the Linux user) UserName
- password (str) – HealthBot Server (not the Linux user) password
- port (int) – OPTIONAL HealthBot Server port (defaults to 8080)
Example:
from jnpr.healthbot import HealthBotClient from pprint import pprint with HealthBotClient('xx.xxx.x.xx', 'xxxx', 'xxxx', port=8000) as hb: # Get list of all existing devices print(hb.device.get_ids()) # Get config details of a given device id pprint(hb.device.get('core-01')) # Get config details of all the device pprint(hb.device.get()) # Get device facts of a given device id pprint(hb.device.get_facts('avro')) # Get device facts for all the devices in HB pprint(hb.device.get_facts()) # Add a device from jnpr.healthbot import DeviceSchema ds = DeviceSchema(device_id='xyz', host='xx.xxx.xxx.xxx', authentication={"password": {"password": "xxxxx", "username": "xxxxx"}}) # we can also later assign values like this ds.description = "HbEZ testing" # This will add device in candidate DB hb.device.add(schema=ds) # Add device group print(hb.device_group.add(device_group_name="edge", description="All devices on the edge", devices=['demo'])) # commit changes to master DB hb.commit() # get details of a given topic/rule pprint(hb.rule.get('linecard.ospf', 'check-ddos-statistics'))
-
open
()[source]¶ Open session with HealthBot server. First sets user token (for healthbot 3.0.0 and above) and check a top level URL for confirmation of API to be working.
-
login
()¶ Open session with HealthBot server. First sets user token (for healthbot 3.0.0 and above) and check a top level URL for confirmation of API to be working.
-
set_user_token
()[source]¶ From HealthBot 3.0.0 APIs will be token based. This function helps in setting user based token. This token will be used in header of any REST API calls.
-
tenant
¶
-
hbot_session
¶ Property provides requests module session object. Also help in updating Access token key when expires. Any call to hbot_session.apis should go through this property to keep a check on token key expiry.
-
user_token
¶
-
tsdb
¶ Connection to the tsdb
Returns: InfluxDBClient
-
config_url
¶ This function will give config URL
-
url
¶ Initials of URL to be used for API call. :returns:
str: Initials of URL to be used for API call.
-
grafana_url
¶
-
version
¶ TO get the version of Healthbot Server
Returns: str: API server version.
-
api
¶
-
commit
()[source]¶ Commit any candidate configuration
Example:
from jnpr.healthbot import HealthBotClient from jnpr.healthbot import DeviceSchema with HealthBotClient('xx.xxx.x.xx', 'xxxx', 'xxxx') as hb: ds = DeviceSchema(device_id='xyz', host='xx.xxx.xxx.xxx', authentication={"password": {"password": "xxxxx", "username": "xxxxx"}}) # we can also later assign values like this ds.description = "HbEZ testing" # This will add device in candidate DB hb.device.add(schema=ds) # commit changes to master DB hb.commit()
Raises: Any requests exception Returns: True when OK
-
rollback
()[source]¶ Rollback any candidate configuration
Example:
from jnpr.healthbot import HealthBotClient with HealthBotClient('xx.xxx.x.xx', 'xxxx', 'xxxx') as hb: # This will delete device in candidate DB hb.device.delete('xyz') # rollback candidate configuration hb.rollback()
Raises: Any requests exception Returns: True when OK
-
upload_helper_file
(filename)[source]¶ - Upload a “helper-file” to the server. A helper-file, cab be
- YAML/.py/.rule/.playbook file.
Parameters: filename (str) – The name of the file to be uploaded.
-
health
()[source]¶ Returns health of network-groups and devices in device-groups HealthSchema
Example:
from jnpr.healthbot import HealthBotClient with HealthBotClient('xx.xxx.x.xx', 'xxxx', 'xxxx') as hb: print(hb.health())
Returns: HealthSchema
-