TECHZEN Zenoss User Community ARCHIVE  

ZenApiLib updates

Subject: ZenApiLib updates
Author: Steve Aiello
Posted: 2018-11-02 15:03

A quick note that an update was pushed to ZenApiLib repo. Included in this update:
- Minor fixes to ZenApiLib.py.
- New script, examples/APIGetDocumentation.py
$ examples/APIGetDocumentation.py -h
usage: APIGetDocumentation.py [-h] [-v LOGLEVEL] [-p credsFilePath]
                              [-c credsSection] [-o OUTFILENAME] -i
                              routerName.methodName [-s]

Poll & display API Router & Method information. Wildcards can be used to
"search" for methodNames across routers.

optional arguments:
  -h, --help            show this help message and exit
  -v LOGLEVEL           Set script logging level (DEBUG=10, INFO=20, WARN=30,
                        *ERROR=40, CRTITICAL=50
  -p credsFilePath      Default location being the same directory as the
                        zenApiLib.pyfile
  -c credsSection       zenApiLib credential configuration section (default)
  -o OUTFILENAME        Output to file instead of stdout.
  -i routerName.methodName
                        API router & method name separated by a period. '*'
                        can be used as a wildcard, ex: 'DeviceRouter.*'
  -s                    Silence missing router/method messages
$ examples/APIGetDocumentation.py -i DeviceRouter.getDevices
ROUTER NAME: DeviceRouter
METHOD NAME: getDevices
METHOD DOCUMENTATION: Retrieves a list of devices. This method supports pagination.

        @type  uid: string
        @param uid: Unique identifier of the organizer to get devices from
        @type  start: integer
        @param start: (optional) Offset to return the results from; used in
                      pagination (default: 0)
        @type  params: dictionary
        @param params: (optional) Key-value pair of filters for this search.
                       Can be one of the following: name, ipAddress,
                       deviceClass, or productionState (default: None)
        @type  limit: integer
        @param limit: (optional) Number of items to return; used in pagination
                      (default: 50)
        @type  sort: string
        @param sort: (optional) Key on which to sort the return results (default:
                     'name')
        @type  dir: string
        @param dir: (optional) Sort order; can be either 'ASC' or 'DESC'
                    (default: 'ASC')
        @rtype:   DirectResponse
        @return:  B{Properties}:
             - devices: (list) Dictionaries of device properties
             - totalCount: (integer) Number of devices returned
             - hash: (string) Hashcheck of the current device state (to check
             whether devices have changed since last query)
METHOD ARGS: []
METHOD KWARGS: {u'sort': u'name', u'uid': None, u'keys': None, u'start': 0, u'limit': 50, u'params': None, u'page': None, u'dir': u'ASC'}
---------------------------------------
​

- New script, examples/DeviceRouter_remodel.py

$ examples/DeviceRouter_remodel.py -h
usage: DeviceRouter_remodel.py [-h] [-v LOGLEVEL] [-p credsFilePath]
                               [-c credsSection] [-o OUTFILENAME] -d
                               DEVICENAMES [-m MODELERPLUGINS] [-s] [-w]

Remodel Device

optional arguments:
  -h, --help         show this help message and exit
  -v LOGLEVEL        Set script logging level (DEBUG=10, INFO=20, WARN=30,
                     *ERROR=40, CRTITICAL=50
  -p credsFilePath   Default location being the same directory as the
                     zenApiLib.pyfile
  -c credsSection    zenApiLib credential configuration section (default)
  -o OUTFILENAME     Output to file instead of stdout.
  -d DEVICENAMES     Device name. Specify multiple times to spawn remodels for
                     more than one device.
  -m MODELERPLUGINS  Override default modeler plugins to use. Takes a regular
                     expression.
  -s                 Do not check if '-p' are valid plugin names. Useful when
                     using a complex regular expression.
  -w                 Wait on remodel job(s) to exit script.

$ examples/DeviceRouter_remodel.py -d harry2 -d oraDckr -d test1
harry2 - 8f180d83-7b49-4625-9e4c-9a02b37321dc
oraDckr - 09303b1a-0069-41ba-a9f7-a50bce9640d8
test1 - 0d55ded7-6ac6-42d5-8263-8b80f6694186

- New script, examples/DeviceModelAgeReport.py

$ examples/DeviceModelAgeReport.py -h
usage: DeviceModelAgeReport.py [-h] [-v LOGLEVEL] [-p credsFilePath]
                               [-c credsSection] [-o OUTFILENAME]

Create a comma delimited report of device model status with other related
data.

optional arguments:
  -h, --help        show this help message and exit
  -v LOGLEVEL       Set script logging level (DEBUG=10, INFO=20, WARN=30,
                    *ERROR=40, CRTITICAL=50
  -p credsFilePath  Default location being the same directory as the
                    zenApiLib.pyfile
  -c credsSection   zenApiLib credential configuration section (default)
  -o OUTFILENAME    Output to file instead of stdout.

$ examples/DeviceModelAgeReport.py -o devModelingSnapshot.csv​


------------------------------
Steve Aiello
Zenoss
------------------------------


< Previous
JSON API - addMaintWindow - Paramaters
  Next
Zenoss API 6.2 addDevice() return BUG?
>