zenossapi Routers
routers Base Class
CMDB Router
Zenoss CMDBIntegrationNGRouter
- class zenossapi.routers.cmdb.CmdbRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss cmdb router
- do_cmdb_run(uid, type='')[source]
Schedules an immediate run of the specified type for the given UID. If type isn’t given a regular run is performed.
- Parameters:
uid (str) – The UID of the CMDB configuration to run
type (str) – Type of CMDB sync job to schedule, not needed for regular, “Full” for full.
- Returns:
none
- get_active_config()[source]
Return object of the currently active config (Zenoss only allows one active config) (calls list_configs and returns only active config)
- Returns:
Dictionary of active config data (if any)
- Return type:
dict
- get_cmdb_fields(uid=None, name=None)[source]
Return list of cmdb fields for the given uid or name Note: instantiantes a DeviceRouter object to get the uid for a device name
- Parameters:
uid (str) – UID of the cmdb config to get fields for
name (str) – Name of the cmdb config to get fields for
- Returns:
List of dicts containing cmdb fields for the given uid or name
- Return type:
list[dict]
Device Router
Zenoss device_router
- class zenossapi.routers.device.DeviceRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss device router
- add_comment_by_uid(device_uid, comment)[source]
Append a new comment to a device
- Parameters:
device_uid (str) – The uid of the device to comment on
comment (str) – Text of the desired comment
- Returns:
Response message
- Return type:
str
- add_device_class(new_class, parent, description='', connection_info=None)[source]
Add a new device class under a parent path
- Parameters:
new_class (str) – Name of the device class to add
parent (str) – Device class to place the new class under
description (str) – Description for the new class
connection_info (list) – zProperties that are the credentials for accessing this device class, e.g. zCommandUsername, zCommandPassword
- Return type:
- add_node(type, contextUid, id, description='')[source]
Adds a node to the node tree :param type: Class, Group or System :param contextUid: The existing node to add the new node to :param id: name of the node :param description: optional description
Returns: (bool) success
- delete_devices_by_uid(devices, action, del_events=False, del_perf=False, **kwargs)[source]
Remove a list of devices from their organizer UID, or delete them from Zenoss altogether.
- Parameters:
devices (list) – Uids of devices to remove/delete
action (str) – ‘remove’ to remove the devices from their organizer(see ‘uid’ below), ‘delete’ to delete them from Zenoss
del_events (bool) – Remove all events for the devices
del_perf (bool) – Remove all perf data for the devices
Optional Arguments: uid (str): If using the ‘remove’ action this option must be included and should be the uid of the organizer you wish to remove the device from. ie “/zport/dmd/Groups/SOMEGROUP”
- Return type:
dict
- delete_node(uid)[source]
Removes a node from the node tree :param uid: (str) UID of node to delte from tree
Returns: (bool) success
- get_device_by_name(device_name)[source]
Get a device by its name
- Parameters:
device_name (str) – Name of the device to get
- Return type:
- get_device_by_uid(device_uid)[source]
Get a device by its full UID
- Parameters:
device_uid (str) – The uid of the device to get
- Return type:
- get_device_class(device_class)[source]
Get a device class
- Parameters:
device_class (str) – The name of the device class
- Return type:
- get_device_uid_by_name(device_name)[source]
Get the UID for a device by its name
- Parameters:
device_name (str) – Name of the device to get the UID for
- Returns:
UID for the device
- Return type:
str
- get_info_by_uid(uid)[source]
Get object properties by the full UID
- Parameters:
uid (str) – UID for the object
- Return type:
dict
- get_tree(device_class, climb_tree=False, include_details=False)[source]
Get the tree structure of a device class.
- Parameters:
device_class (str) – Device class to use as the top of the tree
climb_tree (bool) – If true will return a different dictionary structure where each branch is a dictionary and contains helpful metadata as well as dictionaries for any branches of the tree. This version ONLY uses dicts. Leaving this to ‘False’ will return a dictionary with a structure similar to that found in the standard getTree API call.
include_details (bool) – If the climb_tree option is used then the include_details option may also be specified. If True, the function returns all data provided by the getTree API method. If False, the function returns only the tree structure as a dict of dicts.
- Return type:
dict
- list_devices(uid=None, params=None, start=0, limit=50, sort='name', dir='ASC')[source]
Get the devices contained in a device class. Supports pagination.
- Parameters:
uid (str) – The uid of the organizer to get devices from
params (dict) – Key/value filters for the search, options are name, ipAddress, deviceClass, or productionState
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘name’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘ASC’
- Returns:
{ 'total': Total number of devices found 'hash': Hashcheck to determine if any devices have changed, 'devices': ZenossDevice objects, }
- Return type:
dict(int, str, list(ZenossDevice))
- list_devices_by_uid(uid, keys=None, **kwargs)[source]
Returns a list of all devices under a specified UID. UID could be a device class, group, system, location, etc. :param uid: (str) Device organizer to list devices under :param keys: (list) List of keys to return in results, otherwise returns all :param **kwargs: Additional optional arguments (sort, start, limit, params, page, dir)
Returns: (list) List of all devices in the group organizer and its properties
- lock_devices_by_uid(devices, updates=False, deletion=False, send_event=False)[source]
Lock devices from changes.
- Parameters:
devices (list) – Uids of the devices to lock
updates (bool) – Lock devices from updates
deletion (bool) – Lock devices from deletion
send_event (bool) – Send an event when an action is blocked by locking
- Returns:
Response message
- Return type:
str
- move_devices_by_uid(devices, device_class)[source]
Move the devices in the list to a new device class.
- Parameters:
devices (list) – List of device uids to move
device_class (str) – Target device class for the move
- Returns:
List of Job manager info for each device move
[{ 'uuid': Job manager uuid for the device move, 'description': Description of the move job, }]
- Return type:
list(dict(str, str))
- reset_device_ip_addresses_by_uid(devices, ip_address='')[source]
Reset IP addresses of devices, either by DNS lookup or manually specified address
- Parameters:
devices (list) – Uids of devices to reset IP address for
ip_address (str) – IP address to set device to
- set_collector_by_uids(devices, collector)[source]
Sets the collector for a list of devices.
- Parameters:
devices (list) – Uids of the devices to set collector for
collector (str) – The collector to set devices to use
- Returns:
List of Job manager info for each device move
[{ 'uuid': Job manager uuid for the device move 'description': Description of the move job }]
- Return type:
list(dict(str, str))
- class zenossapi.routers.device.ZenossComponent(url, headers, ssl_verify, device_data)[source]
Bases:
DeviceRouterClass for Zenoss component objects
- lock(updates=False, deletion=False, send_event=False)[source]
Lock the component for changes.
- Parameters:
updates (bool) – Lock for updates
deletion (bool) – Lock for deletion
send_event (bool) – Send an event when an action is blocked by locking
- Returns:
Response message
- Return type:
str
- lock_for_deletion(send_event=False)[source]
Lock the component for updates.
- Parameters:
send_event (bool) – Send an event when deletion is blocked by locking
- Returns:
Response message
- Return type:
str
- class zenossapi.routers.device.ZenossDevice(url, headers, ssl_verify, device_data)[source]
Bases:
DeviceRouterClass for Zenoss device objects
- add_comment(comment)[source]
Append a comment to a device.
- Parameters:
comment (str) – Desired comment text
- Returns:
Reponse message
- Return type:
str
- add_local_template(template)[source]
Add a local template to the device.
- Parameters:
template (str) – Name of the new local template
- bind_or_unbind_template(path, template)[source]
Binds a template to the device if it’s unbound, or unbinds it if it’s bound.
- Parameters:
path (str) – Template’s path, as given in the display label
template (str) – Name of the template to bind/unbind
- delete(action, del_events=False, del_perf=True, **kwargs)[source]
Remove a device from its organizer, or delete it from Zenoss altogether.
- Parameters:
action (str) – ‘remove’ to remove the devices from their organizer(see ‘uid’ below), ‘delete’ to delete them from Zenoss
del_events (bool) – Remove all events for the devices
del_perf (bool) – Remove all perf data for the devices
- Optional Arguments:
uid (str): If using the ‘remove’ action this option must be included and should be the uid of the organizer you wish to remove the device from. ie “/zport/dmd/Groups/SOMEGROUP”
- Return type:
bool
- delete_local_template(template)[source]
Remove a local template from the device.
- Parameters:
template (str) – Name of the template to remove
- delete_property(zproperty)[source]
Delete the locally set value of a property for a device
- Parameters:
zproperty (str) – ID of the property to delete.
- Return type:
bool
- get_active_templates()[source]
Get ZenossTemplate objects for all active templates on a device.
- Return type:
list(ZenossTemplate)
- get_bound_templates()[source]
Get ZenossTemplate objects templates that are bound to the device.
- Return type:
list(ZenosTemplate)
- get_component(component)[source]
Get a component object.
- Parameters:
component (str) – Name of the component, e.g. ‘hw/cpus/0’
- Return type:
- get_components(meta_type=None, start=0, limit=50, sort='name', dir='ASC')[source]
Get component objects for all components on the device. Supports Pagination.
- Parameters:
meta_type (str) – Meta type of components to list
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘name’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘ASC’
- Return type:
list(ZenossComponent)
- get_custom_properties(params=None)[source]
Get the cProperties for the device
- Parameters:
params (dict) – Search parameters for filter the properties on.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossCustomProperty objects. }
- Return type:
dict(int, list(ZenossCustomProperty))
- get_custom_property(cproperty)[source]
Get a custom property for the device
- Parameters:
cproperty (str) – ID of the property to get.
- Return type:
- get_local_templates()[source]
Get ZenossTemplate objects for all locally defined templates.
- Return type:
list(ZenossTemplate)
- get_overridable_templates()[source]
Get ZenossTemplate objects for templates that can be overridden.
- Return type:
list(ZenossTemplate)
- get_properties(params=None)[source]
Get the configuration properties for the device
- Parameters:
params (dict) – Search parameters for filter the properties on.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossProperty objects. }
- Return type:
dict(int, list(ZenossProperty))
- get_property(zproperty)[source]
Get a configuration property
- Parameters:
zproperty (str) – The id of the property to get
- Return type:
- get_unbound_templates()[source]
Get ZenossTemplate objects for available templates that are not bound to the device.
- Return type:
list(ZenossTemplate)
- list_active_templates()[source]
Get the list of templates active on a device, both bound and local.
- Returns:
{ 'name': Template name, 'label': Display label for the template, }
- Return type:
list(dict(str, str))
- list_bound_templates()[source]
Get the list of templates bound to a device, does not include local templates.
- Returns:
{ 'name': Template name, 'label': Display label for the template, }
- Return type:
list(dict(str, str))
- list_components(meta_type=None, start=0, limit=50, sort='name', dir='ASC', keys=None, name=None)[source]
Get a list of all the components on a device. Supports pagination.
- Parameters:
meta_type (str) – Meta type of components to list
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘name’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘ASC’
keys (list) – Keys to include in the returned data
name (str) – Regular expression pattern to filter on, requries the keys parameter
- Returns:
{ 'total': Total number of components found. 'hash': Hash check to determine if components have changed 'components': List of components found }
- Return type:
dict(int, str, list)
- list_custom_properties()[source]
List the custom properties for the device
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_local_properties()[source]
List the locally defined configuration properties for the device
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_local_templates()[source]
Get the list of monitoring templates defined locally on a device.
- Return type:
list
- list_overridable_templates()[source]
Get the list of available templates on a device that can be overridden.
- Returns:
{ 'name': Template name, 'label': Display label for the template, }
- Return type:
list(dict(str, str))
- list_properties(params=None, sort=None, sort_dir='ASC')[source]
List the configuration properties for the device
- Parameters:
params (dict) – Search parameters to filter the properties list on.
sort (str) – Sort key for the properties list.
sort_dir (str) – Sort direction, either ASC or DESC
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_unbound_templates()[source]
Get the list of available templates that are not bound to the device.
- Returns:
{ 'name': Template name, 'label': Display label for the template, }
- Return type:
list(dict(str, str))
- list_user_commands()[source]
Get the list of user commands for a device.
- Returns:
{ name: Name of the user command description: Command description }
- Return type:
dict(str, str)
- lock(updates=False, deletion=False, send_event=False)[source]
Lock the device for changes.
- Parameters:
updates (bool) – Lock for updates
deletion (bool) – Lock for deletion
send_event (bool) – Send an event when an action is blocked by locking
- Returns:
Response message
- Return type:
str
- lock_for_deletion(send_event=False)[source]
Lock the device for updates.
- Parameters:
send_event (bool) – Send an event when deletion is blocked by locking
- Returns:
Response message
- Return type:
str
- lock_for_updates(send_event=False)[source]
Lock the device for updates.
- Parameters:
send_event (bool) – Send an event when updates are blocked by locking
- Returns:
Response message
- Return type:
str
- move(device_class)[source]
Move the device to a different device class
- Parameters:
device_class (str) – Name of the device class to move the device into
- Returns:
uuid of the Job Manager job for the move
- Return type:
str
- reidentify(new_id)[source]
Change the device’s id in Zenoss. Note that changing the device id will cause the loss of all graph data for the device.
- Parameters:
new_id (str) – New ID for the device
- remodel()[source]
Remodel the device.
- Returns:
uuid of the Job Manager job for the remodel
- Return type:
str
- reset_ip_address(ip_address='')[source]
Reset the IP address of the device to ip_address if specified or to the result of a DNS lookup if not.
- Parameters:
ip_address (str) – IP address to set device to
- Returns:
Response message
- Return type:
str
- set_bound_templates(templates)[source]
Set a list of templates as bound to a device.
- Parameters:
templates (list) – List of template names
- set_collector(collector)[source]
Set the collector for the device.
- Parameters:
collector (str) – The collector to use for the device
- Returns:
uuid of the Job Manager job for the change
- Return type:
str
- set_priority(priority)[source]
Set the priority for the device.
- Parameters:
priority (int) – Numeric value for the desired priority
- Returns:
Reponse message
- Return type:
str
- class zenossapi.routers.device.ZenossDeviceClass(url, headers, ssl_verify, device_class_data)[source]
Bases:
DeviceRouterClass for Zenoss device class objects
- add_device(device_name, title='', ip_address='', location=None, systems=None, groups=None, model=False, collector='localhost', production_state=500, comments='', priority=3, snmp_community='', snmp_port=161, rack_slot='', hw_manufacturer='', hw_product_name='', os_manufacturer='', os_product_name='', asset_tag='', serial_number='', windows_user='', windows_password='', zcommand_user='', zcommand_password='', configuration_properties=None, custom_properties=None)[source]
Add a new device to the device class.
- Parameters:
device_name (str) – Name of the new device, will be the device id
title (str) – Optional title for the device, default is to match the device_name
ip_address (str) – Ip address for the device, default is to derive this from DNS based on device_name
location (str) – Location for the device
systems (list[(str) – List of systems for the device
groups (list[(str) – List of groups for the device
model (bool) – Set to True to model the device automatically after creation
collector (str) – Collector to use for the device
production_state (int) – Numerical production state for the device, default is 500 (Pre-Production)
comments (str) – Comments for the device
priority (int) – Numerical priority for the device, default is 3 (Normal)
snmp_community (str) – SNMP community string for the device
snmp_port (int) – SNMP port for the device
rack_slot (str) – Rack slot description
hw_manufacturer (str) – Hardware manufacturer name, default is to derive by modeling
hw_product_name (str) – Hardware product name, default is to derive by modeling
os_manufacturer (str) – Operating system developer, default is to derive by modeling
os_product_name (str) – Operating system name, default is to derive by modeling
asset_tag (str) – Device’s inventory asset tag
serial_number (str) – Device’s serial number
windows_user (str) – Username for Windows device monitoring
windows_password (str) – Password for the windows_user
zcommand_user (str) – Username for SSH-based monitoring user
zcommand_password (str) – Password for the zcommand_user
configuration_properties (dict) – Key/value pairs for setting Configuration Properties for the device
custom_properties (dict) – Key/value pairs for setting Custom Properties for the device
- Returns:
ID of the add device job
- Return type:
str
- add_subclass(name, description='', connection_info=None)[source]
Add a new subclass to the device class.
- Parameters:
name (str) – Name of the new subclass
description (str) – Description for the new subclass
connection_info (list) – zProperties that represent the credentials for access in the subclass
- delete_property(zproperty)[source]
Delete the locally set value of a property for a device class
- Parameters:
zproperty (str) – ID of the property to delete.
- Return type:
bool
- get_custom_properties(params=None)[source]
Get the cProperties for the device class
- Parameters:
params (dict) – Search parameters for filter the properties on.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossCustomProperty objects. }
- Return type:
dict(int, list(ZenossCustomProperty))
- get_custom_property(cproperty)[source]
Get a custom property for the device class
- Parameters:
cproperty (str) – ID of the property to get.
- Return type:
- get_device(device_name)[source]
Get a device from the device class
- Parameters:
device_name (str) – The name of the device to get
- Return type:
- get_devices(params=None, start=0, limit=50, sort='name', dir='ASC')[source]
Get the devices contained in a device class. Supports pagination.
- Parameters:
params (dict) – Key/value filters for the search, options are name, ipAddress, deviceClass, or productionState
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘name’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘ASC’
- Returns:
{ 'total': Total number of devices found 'hash': Hashcheck to determine if any devices have changed, 'devices': ZenossDevice objects, }
- Return type:
dict(int, str, list(ZenossDevice))
- get_properties(params=None)[source]
Get the configuration properties for the device class
- Parameters:
params (dict) – Search parameters for filter the properties on.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossProperty objects. }
- Return type:
dict(int, list(ZenossProperty))
- get_property(zproperty)[source]
Get a configuration property
- Parameters:
zproperty (str) – The id of the property to get
- Return type:
- list_custom_properties()[source]
List the custom properties for the device class
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_devices(params=None, keys=None, start=0, limit=50, sort='name', dir='ASC')[source]
List the devices contained in a device class. Supports pagination.
- Parameters:
params (dict) – Key/value filters for the search, options are name, ipAddress, deviceClass, or productionState
keys (list) – List of keys to return for the devices found
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘name’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘ASC’
- Return type:
dict
- list_local_properties()[source]
List the locally defined configuration properties for the device class
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_properties(params=None, sort=None, sort_dir='ASC')[source]
List the configuration properties for the device class
- Parameters:
params (dict) – Search parameters to filter the properties list on.
sort (str) – Sort key for the properties list.
sort_dir (str) – Sort direction, either ASC or DESC
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
DeviceManagement Router
Zenoss devicemanagement_router
- class zenossapi.routers.devicemanagement.DeviceManagementRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss devicemanagement router
- add_admin(uid, name, role=None)[source]
Add an admin user to a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
name (str) – The name of the user to add
role (str) – The role to associate with the user for this device or device class
- Return type:
- add_maintenance_window(uid, name, start, duration, enabled=False, start_state=300, repeat='Never', occurrence='1st', days='Sunday')[source]
Add a new maintenance window for device or device class.
- Parameters:
uid (str) – The UID of the device or device class
start (str) – Window start time in UNIX epoch timestamp format, e.g. “1511290393”
duration (str) – Duration of the window in HH:MM:SS format
start_state (int) – Production state for the maintenance window, default is 300 (Maintenance)
repeat (str) – Maintenance window repeat interval, default is ‘Never’. Other valid choices are: ‘Daily’, ‘Every Weekday’, ‘Weekly’, ‘Monthly: day of month’, ‘Monthly: day of week’
occurrence (str) – For ‘Monthly: day of week’ repeats, options are ‘1st’, ‘2nd’, ‘3rd’, ‘4th’, ‘5th’, ‘Last’
days (str) – For ‘Monthly: day of week’ repeats, options are ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’
- Return type:
- add_user_command(uid, name, description, command, password)[source]
Add a new user command to a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
name (str) – Name for the new command
description (str) – Description of the new command
command (str) – Command line of the new command, can include TALES expressions
password (str) – Password of the user adding the command.
- get_admin_by_id(uid, admin_id)[source]
Get and admin user for a device or device class by id.
- Parameters:
uid (str) – The UID of the device or device class
admin_id (str) – The ID of the admin user
- Return type:
- get_admin_by_name(uid, name)[source]
Get an admin user for a device or device class by name.
- Parameters:
uid (str) – The UID of the device or device class
name (str) – The name of the admin user
- Return type:
- get_admins(uid)[source]
Get ZenossDeviceManagementAdmin objects for the configured admin users for a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
- get_admins_by_role(uid, role)[source]
Get ZenossDeviceManagementAdmin objects for the configured admin users of a device or device class by role.
- Parameters:
uid (str) – The UID of the device or device class
role (str) – The role to filter on
- Return type:
- get_maintenance_window(uid, name)[source]
Get a maintenance window object for the named window.
- Parameters:
uid (str) – The UID of the device or device class
name (str) – Name of the maintenance window
- Return type:
- get_maintenance_windows(uid)[source]
Returns a list of ZenossMaintenanceWindow objects for the maintenance windows configured for a device or device class
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
list(ZenossMaintenanceWindow)
- get_user_command_by_id(uid, command_id)[source]
Get a configured user command by its id
- Parameters:
uid (str) – The UID of the device or device class
command_id (str) – The ID of the user command
- get_user_command_by_name(uid, command_name)[source]
Get a configured user command by its id
- Parameters:
uid (str) – The UID of the device or device class
command_name (str) – The name of the user command
- get_user_commands(uid)[source]
Get a list of user commands objects configured for a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
list(ZenossUserCommand)
- list_admin_roles(uid)[source]
List the admin roles associated with a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
list(dict)
- list_admins_by_role(uid, role)[source]
List configured admin users for a device or device class by role.
- Parameters:
uid (str) – The UID of the device or device class
role (str) – The role to filter on
- Return type:
list(dict)
- list_available_roles(uid)[source]
List the admin roles available to associate with a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
list(str)
- list_maintenance_windows(uid)[source]
Returns the list of maintenance windows configured for a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
list(dict)
- list_user_commands(uid)[source]
Get the list of user commands configured for a device or device class.
- Parameters:
uid (str) – The UID of the device or device class
- Return type:
list(dict)
- class zenossapi.routers.devicemanagement.ZenossDeviceManagementAdmin(url, headers, ssl_verify, admin_data)[source]
Bases:
DeviceManagementRouterClass for Zenoss user command objects
- class zenossapi.routers.devicemanagement.ZenossMaintenanceWindow(url, headers, ssl_verify, window_data, parent=None)[source]
Bases:
DeviceManagementRouterClass for Zenoss maintenance window objects
- update(start_timestamp=None, start_datetime=None, start_date=None, start_hours=None, start_minutes=None, duration_days=None, duration_time=None, duration_hours=None, duration_minutes=None, production_state=None, enabled=None, repeat=None, occurrence=None, days=None)[source]
Update the settings for a maintenance window, with flexible options for specifying the start date/time and duration.
- Parameters:
start_timestamp (float) – Start date and time in UNIX timestamp format
start_datetime (datetime) – Start date and time as a datetime.datetime object
start_date (str) – Start date as a string
start_hours (str) – Start hours as a string
start_minutes (str) – Start minutes as a string
duration_days (str) – Duration days
duration_time (str) – Duration time in “HH:MM” format
duration_hours (str) – Duration hours
duration_minutes (str) – Duration minutes
production_state (int) – Production state for the window
enabled (bool) – Enabled state of the window
occurrence (str) – Repeat occurrence
days (str) – Repeat days
- Return type:
bool
- class zenossapi.routers.devicemanagement.ZenossUserCommand(url, headers, ssl_verify, command_data, parent=None)[source]
Bases:
DeviceManagementRouterClass for Zenoss user command objects
Events Router
Zenoss evconsole_router
- class zenossapi.routers.events.EventsRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with Zenoss events.
- add_event(summary, device, severity, component=None, event_class_key='', event_class='/Status', return_event=True, **kwargs)[source]
Create a new Zenoss event.
- Parameters:
summary (str) – Summary for the new event
device (str) – Device ID for the new event
component (str) – Component UID for the new event
severity (str) – Severity to assign the new event, must be one of Critical, Error, Warning, Info, Debug, or Clear
event_class_key (str) – The Event Class Key to assign to the event
event_class (str) – Event Class for the event
return_event (bool) – By default the function will return the event details but this can be expensive and usually not needed. Pass in False to disable this behavior
- Return type:
- clear_heartbeat(collector, daemon)[source]
Clear a heartbeat event for a specific daemon.
- Parameters:
collector (str) – Collector the daemon is running in, e.g. slvcollector
daemon (str) – Monitoring daemon to clear the heartbeat event for, e.g. zencommand
- event_actions(action, evids=None, exclude_ids=None, params=None, context=None, last_change=None, limit=None, timeout=60)[source]
Close events by either passing a list of event ids or by a query.
- Parameters:
action (str) – The action to take on the event - close, ack, or reopen
evids (list) – List of event IDs to close
exclude_ids (list) – List of event IDs to exclude from the close
params (dict) – Key/value pairs for filtering the events to close
context (str) – Device or device class uid as context for the query
last_change (float) – Timestamp - only close events if there has been no change since this time
limit (int) – Maximum number of events to return in the query
timeout (int) – Number of seconds before the query times out
- get_details_by_evid(evid)[source]
Get the details of an event by the event ID.
- Parameters:
evid (str) – The event ID
- Returns:
Event details
- Return type:
dict
- get_event_by_evid(evid)[source]
Get an event by its event id
- Parameters:
evid (str) – The event id
- Return type:
- get_open_events(limit=10, start=0, sort='lastTime', sort_dir='DESC')[source]
Get all open events (new or acknowledged state)
- Parameters:
limit (int) – Maximum number of events to return
start (int) – Minimum index of events to get
sort (str) – Sort key for events list
sort_dir (str) – Sort direction, ASC or DESC
- Return type:
list(ZenossEvent)
- get_open_production_events(limit=10, start=0, sort='lastTime', sort_dir='DESC')[source]
Get all open events (new or acknowledged state) for devices with a production state of Production
- Parameters:
limit (int) – Maximum number of events to return
start (int) – Minimum index of events to get
sort (str) – Sort key for events list
sort_dir (str) – Sort direction, ASC or DESC
- Return type:
list(ZenossEvent)
- list_open_events(limit=10, start=0, sort='lastTime', sort_dir='DESC')[source]
Get a list of all open events (new or acknowledged state)
- Parameters:
limit (int) – Maximum number of events to return
start (int) – Minimum index of events to get
sort (str) – Sort key for events list
sort_dir (str) – Sort direction, ASC or DESC
- Return type:
dict
- list_open_production_events(limit=10, start=0, sort='lastTime', sort_dir='DESC')[source]
Get a list of all open events (new or acknowledged state) for devices with a production state of Production
- Parameters:
limit (int) – Maximum number of events to return
start (int) – Minimum index of events to get
sort (str) – Sort key for events list
sort_dir (str) – Sort direction, ASC or DESC
- Return type:
dict
- query_events(limit=10, start=0, sort='lastTime', sort_dir='DESC', params=None, exclude=None, keys=None, context=None, archive=False, validate_params=True, detail_format=False)[source]
Get a list of events based on query parameters.
Some search parameter examples:
- Find New events:
params=dict(eventState=[0])
- Find open events (in New or Acknowledged state):
params=dict(eventState=[0,1])
- Find open events for Production servers:
params=dict(eventState=[0,1], prodState=[1000])
Other handy search keys: agent, count, DevicePriority, firstTime, lastTime, monitor, message, severity, summary
- Parameters:
limit (int) – Maximum number of events to get
start (int) – Minimum index of events to get
sort (str) – Sort key for events list
sort_dir (str) – Sort direction, ASC or DESC
params (dict) – Key/value pairs for filtering the events to include
exclude (dict) – Key/value pairs to filter out of the found events
keys (list) – List of keys to include in the return event data
context (str) – Device or device class uid as context for the query
archive (bool) – Search the events archive instead of active events
validate_params (bool) – Check input params against known param list
detail_format (bool) – Request detail format of return parameters
- Returns:
{ 'total': Total count of events matched by the query, 'ts': Timestamp for the search, 'events': List of events found, }
- Return type:
dict(int, float, list(dict))
- class zenossapi.routers.events.ZenossEvent(url, headers, ssl_verify, event_data)[source]
Bases:
EventsRouterClass for Zenoss event objects
Incident Management Router
Zenoss Events/IncidentManagementRouter
- class zenossapi.routers.incidentmanagement.IncidentManagementRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss incidentmanagement router
Jobs Router
Zenoss jobs_router
- class zenossapi.routers.jobs.JobsRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss device router
- abort_jobs_by_uuid(jobs)[source]
Aborts the jobs specified in the uuid list.
- Parameters:
jobs (list) – List of job uuids
- Return type:
bool
- delete_jobs_by_uuid(jobs)[source]
Deletes the jobs specified in the uuid list.
- Parameters:
jobs (list) – List of jobs uuids
- Returns:
List of uuids deleted
- Return type:
list
- get_job(job)[source]
Get a ZenossJob object by the job’s uuid
- Parameters:
job (str) – uuid of the job
- Return type:
- get_jobs(start=0, limit=50, sort='scheduled', dir='ASC')[source]
Get ZenossJob objects for Job Manager jobs. Supports pagination.
- Parameters:
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘scheduled’. Other sort keys are ‘started, ‘finished’, ‘status’, ‘type’ and ‘user’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘ASC’
- Return type:
list(ZenossJob)
- list_jobs(start=0, limit=50, sort='scheduled', dir='DESC')[source]
List all Job Manager jobs, supports pagination.
- Parameters:
start (int) – Offset to start device list from, default 0
limit (int) – The number of results to return, default 50
sort (str) – Sort key for the list, default is ‘scheduled’. Other sort keys are ‘started, ‘finished’, ‘status’, ‘type’ and ‘user’
dir (str) – Sort order, either ‘ASC’ or ‘DESC’, default is ‘DESC’
- Returns:
{ 'total': (int) Total number of jobs, 'jobs': { 'description': (str) Job description, 'finished': (int) Time the job finished in timestamp format, 'scheduled': (int) Time the job was scheduled in timestamp format, 'started': (int) Time the job started in timestamp format, 'status': (str) Status of the job, 'type': (str) Job type, 'uid': (str) JobManager UID - /zport/dmd/JobManager, 'user': (str) User who scheduled the job, 'uuid': (str) UUID of the job, } }
- Return type:
dict(int, dict(str, int, int, int, str, str, str, str, str))
- class zenossapi.routers.jobs.ZenossJob(url, headers, ssl_verify, job_data)[source]
Bases:
JobsRouterClass for Zenoss job objects
Monitor Router
Zenoss monitor_router
- class zenossapi.routers.monitor.MonitorRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss monitor router
- class zenossapi.routers.monitor.ZenossCollector(url, headers, ssl_verify, collector_data, collector_params=None)[source]
Bases:
MonitorRouterClass for Zenoss collector objects
- class zenossapi.routers.monitor.ZenossHub(url, headers, ssl_verify, hub_data)[source]
Bases:
MonitorRouterClass for Zenoss hub objects
- add_collector(name, source=None, pool=None)[source]
Add a new collector to the hub.
- Parameters:
name (str) – Name of the new collector
source (str) – Name of the existing collector to use as a template
pool (str) – The resource pool to place the collector in
- Return type:
- get_collector(name)[source]
Get a ZenossCollector object
- Parameters:
name (str) – Name of the collector to get
- Return type:
- get_collectors()[source]
Get the hub’s collectors as objects.
- Return type:
list(ZenossCollector)
Properties Router
Zenoss properties_router
- class zenossapi.routers.properties.PropertiesRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with Zenoss properties.
- delete_property(uid, zproperty)[source]
Delete a ZenProperty.
- Parameters:
uid (str) – UID to delete the property from
zproperty (str) – ID of the property to delete.
- Return type:
bool
- get_custom_properties(uid, params=None)[source]
Get ZenossCustomProperties objects for the cProperties of a uid context.
- Parameters:
uid (str) – UID of the object to get properties for.
params (dict) – Search parameters for filter the properties on.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossCustomProperty objects. }
- Return type:
dict(int, list(ZenossCustomProperty))
- get_custom_property(uid, cproperty)[source]
Get a single ZenossCustomProperty
- Parameters:
uid (str) – UID to get the property of.
cproperty (str) – ID of the property to get.
- Return type:
- get_local_properties(uid)[source]
Get ZenossProperty objects for the local properties of a specified uid.
- Parameters:
uid (str) – UID to get local properties for.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossProperty objects. }
- Return type:
dict(int, list(ZenossProperty))
- get_properties(uid, params=None)[source]
Get ZenossProperties objects for the properties of a uid context.
- Parameters:
uid (str) – UID of the object to get properties for.
params (dict) – Search parameters for filter the properties on.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of ZenossProperty objects. }
- Return type:
dict(int, list(ZenossProperty))
- get_property(uid, zproperty)[source]
Get a single ZenossProperty
- Parameters:
uid (str) – UID to get the property of.
zproperty (str) – ID of the property to get.
- Return type:
- list_custom_properties(uid, params=None, sort=None, sort_dir='ASC')[source]
Get a list of cProperties for the uid context.
- Parameters:
uid (str) – UID of the object to list properties for.
params (dict) – Search parameters to filter the properties list on.
sort (str) – Sort key for the properties list.
sort_dir (str) – Sort direction, either ASC or DESC
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_local_properties(uid)[source]
Get a list of properties set locally to the specified UID.
- Parameters:
uid (str) – UID to get local properties for.
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- list_properties(uid, params=None, sort=None, sort_dir='ASC')[source]
Get a list of ZenProperties for the uid context.
- Parameters:
uid (str) – UID of the object to list properties for.
params (dict) – Search parameters to filter the properties list on.
sort (str) – Sort key for the properties list.
sort_dir (str) – Sort direction, either ASC or DESC
- Returns:
{ 'total': Total count of properties returned. 'properties': List of properties found. }
- Return type:
dict(int, list(dict))
- class zenossapi.routers.properties.ZenossCustomProperty(url, headers, ssl_verify, property_data)[source]
Bases:
PropertiesRouterClass for Zenoss CustomProperties
- class zenossapi.routers.properties.ZenossProperty(url, headers, ssl_verify, property_data)[source]
Bases:
PropertiesRouterClass for ZenProperties
Template Router
Zenoss template_router
- class zenossapi.routers.template.TemplateRouter(url, headers, ssl_verify)[source]
Bases:
ZenossRouterClass for interacting with the Zenoss template router
- add_data_point_to_graph(datapoint, graph, include_thresholds=False)[source]
Adds a data point to a graph.
- Parameters:
datapoint (str) – Uid of the data point to add
graph (str) – Uid of the graph to add the data point to
include_thresholds (bool) – Set to True to include the related thresholds for the data point
- Return type:
dict
- add_local_template(zenoss_object, name)[source]
Adds a local template to an object.
- Parameters:
zenoss_object (str) – Uid of the object to add the local template to
name – Unique name for the new local template
- add_template(target, name)[source]
Adds a template to a device class.
- Parameters:
target (str) – The uid of the target device class
name (str) – Unique name of the template to add
- Return type:
- delete_local_template(zenoss_object, name)[source]
Builds the request data for deleting a local template to an object.
- Parameters:
object (str) – Uid of the object to remove the local template from
name – Unique name of the new local template
- delete_template(device_class, template)[source]
Removes a template.
- Parameters:
device_class (str) – Name of the device class where the template is defined
template (str) – Name of the template to remove
- Return type:
dict
- get_all_templates()[source]
Returns all defined templates.
- Return type:
list(ZenossTemplate)
- get_device_class_templates(device_class)[source]
Gets the defined templates for a device class
- Parameters:
device_class (str) – Device class to get templates for
- Return type:
list(ZenossTemplate)
- get_object_templates(zenoss_object)[source]
Gets the templates bound to a specific object (monitored resource or component)
- Parameters:
zenoss_object (str) – The uid of the object, e.g. Devices/Server/Zuora/Aspose/devices/10.aspose.prod.slv.zuora
- Return type:
list(ZenossTemplate)
- get_template(device_class, template)[source]
Get a Zenoss template
- Parameters:
device_class (str) – Name of the device class where the template is defined
template (str) – Name of the template to get
- Return type:
- list_all_templates()[source]
Returns all defined templates as a list of tuples containing the template UID and description.
- Return type:
list(ZenossTemplate)
- class zenossapi.routers.template.ZenossDataPoint(url, headers, ssl_verify, dp_data)[source]
Bases:
TemplateRouterClass for Zenoss data points
- add_to_graph(graph, include_thresholds=False)[source]
Adds a data point to a graph.
- Parameters:
graph (str) – Name of the graph to add the data point to
include_thresholds (bool) – Set to True to include the related thresholds for the data point
- Return type:
dict
- class zenossapi.routers.template.ZenossDataSource(url, headers, ssl_verify, ds_data)[source]
Bases:
TemplateRouterClass for Zenoss template data sources
- add_data_point(datapoint)[source]
Adds a data point to a data source.
- Parameters:
datapoint (str) – Name of the new data point
- Return type:
- delete_data_point(datapoint)[source]
Deletes a data point from a template.
- Parameters:
datapoint (str) – Name of the data point to remove
- Return type:
dict
- get_data_point(datapoint)[source]
Get a particular data point.
- Parameters:
datapoint (str) – Name of the data point to get details for
- Return type:
- get_data_points()[source]
Get all the data points for a datasource.
- Return type:
list(ZenossDataPoint)
- class zenossapi.routers.template.ZenossGraph(url, headers, ssl_verify, graph_data)[source]
Bases:
TemplateRouterClass for Zenoss graphs
- add_graph_threshold(threshold)[source]
Adds a threshold to a graph.
- Parameters:
threshold (str) – Uid of the threshold to add
- Return type:
dict
- add_point(datasource, datapoint, include_thresholds=False)[source]
Adds a data point to a graph.
- Parameters:
datasource (str) – Name of the data source holding the data point
datapoint (str) – Name of the data point to add
include_thresholds (bool) – Set to True to include the related thresholds for the data point
- Return type:
dict
- delete_point(datapoint)[source]
Deletes a data point from a graph.
- Parameters:
datapoint (str) – Name of the data point to remove
- Return type:
dict
- get_points()[source]
Gets the data points of a graph.
- Return type:
list(ZenossDataPoint)
- set_graph_properties(properties)[source]
Set the properties for a graph.
- Parameters:
properties (dict) – Properties and values to set
- Return type:
dict
- class zenossapi.routers.template.ZenossTemplate(url, headers, ssl_verify, template_data)[source]
Bases:
TemplateRouterClass for Zenoss Template objects
- add_data_source(datasource, type)[source]
Adds a data source to a template.
- Parameters:
datasource (str) – Name of the new data source
type (str) – Type of the new data source, must be one of the types returned by get_data_source_types()
- Return type:
- add_graph(graph)[source]
Add a new graph to a template.
- Parameters:
graph (str) – Name for the new graph
- Return type:
- add_threshold(threshold, threshold_type, datapoints)[source]
Adds a threshold to a template.
- Parameters:
threshold (str) – Name of the new threshold
threshold_type (str) – Type of the new threshold, must be one of the types returned by get_threshold_types()
datapoints (list) – List of datapoints to select for the threshold
- Return type:
- copy(target)[source]
Copy a template to another device or device class.
- Parameters:
target (str) – Uid of the device or device class to copy to
- Return type:
- delete_data_source(datasource)[source]
Deletes a data source from a template.
- Parameters:
datasource (str) – Name the data source to remove
- Return type:
dict
- delete_graph(graph)[source]
Delete a particular graph.
- Parameters:
graph (str) – The name of the graph to delete.
- Return type:
dict
- delete_threshold(threshold)[source]
Deletes a threshold.
- Parameters:
threshold (str) – Name of the threshold to remove
- Return type:
dict
- get_data_points()[source]
Get all the data points in a template.
- Return type:
list(ZenossDataPoint)
- get_data_source(datasource)[source]
Get a particular data source.
- Parameters:
datasource (str) – Name of the data source to get
- Return type:
- get_data_sources()[source]
Gets data sources configured for a template.
- Return type:
list(ZenossDataSource)
- get_graph(graph)[source]
Get a particular graph.
- Parameters:
graph (str) – Name of the graph to get the definition of
- Return type:
- get_graphs()[source]
Get the graphs defined for a template.
- Return type:
list(ZenossGraph)
- get_threshold(threshold)[source]
Get a particular threshold.
- Parameters:
threshold (str) – Name of the threshold to get details on
- Return type:
- list_data_points()[source]
Returns all the data points in a template as a list.
- Return type:
list(str)
- class zenossapi.routers.template.ZenossThreshold(url, headers, ssl_verify, threshold_data)[source]
Bases:
TemplateRouterClass for Zenoss thresholds