Discussion:
Maintenance Windows API
steve stoltz
2012-11-28 14:03:00 UTC
Permalink
steve stoltz [http://community.zenoss.org/people/sstoltz] created the discussion

"Maintenance Windows API"

To view the discussion, visit: http://community.zenoss.org/message/70198#70198

--------------------------------------------------------------
I am currently working on creating an app and I would like to be able to retrieve all groups or devices and under one click be able to set them into maintenance mode.  I have been trying to follow the JSON calls using firebug but cant seem to understand it.  Is there any documentation on how to programmically set maintenance mode through JSON or web REST calls?

Thanks for any help.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70198#70198]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
steve stoltz
2012-11-28 19:09:11 UTC
Permalink
steve stoltz [http://community.zenoss.org/people/sstoltz] created the discussion

"Re: Maintenance Windows API"

To view the discussion, visit: http://community.zenoss.org/message/70204#70204

--------------------------------------------------------------
Well I have been able to find a few pieces of information but it seems to be missing some importat parts.

To create a window:
     <path_to_device>/manage_addMaintenanceWindow?newId=<id>

To Edit a window:
     <path_to_device>/maintenanceWindows/<id>/manage_editMaintenanceWindow
     This is where I seem to be missing a bit of info, what variables are needed to append to the url to cause the window to update?

To Delete window:
     <path_to_device>/manage_deleteMaintenanceWindow?maintenanceIds=<List of ids>

Also the examples I found to retrieve all windows available for a device seems to get a 404 error, so they pages no longer exist, does anyone know the updated or changed or maybe I have the URL wrong, but any help would be great.
   
     <path_to_device>/getMaintenanceWindows/getProperty?id=<id>


<path_to_device>/getMaintenanceWindows/ isActive
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70204#70204]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Chet Luther
2012-11-28 21:23:58 UTC
Permalink
Chet Luther [http://community.zenoss.org/people/cluther] created the discussion

"Re: Maintenance Windows API"

To view the discussion, visit: http://community.zenoss.org/message/70215#70215

--------------------------------------------------------------
You probably just want to set the production state directly rather than going through maintenance windows.

I used Chrome's developer tools to capture the following JSON API request. This request was made when I selected two devices (damsel and localhost) from the infrastructure page and chose "Change Production State" from the Action menu. I chose the Maintenance (300) production state.
{
    "action": "DeviceRouter",
    "method": "setProductionState",
    "data": [{
        "uids": ["/zport/dmd/Devices/Discovered/devices/damsel", "/zport/dmd/Devices/Server/Linux/devices/localhost"],
        "hashcheck": null,
        "prodState": 300
    }]
That's the type of call you need to make. You can find more information of the JSON API mechanics on the following pages.


http://wiki.zenoss.org/Extending_Zenoss#Zenoss_JSON_API http://wiki.zenoss.org/Extending_Zenoss#Zenoss_JSON_API
http://wiki.zenoss.org/Working_with_the_JSON_API http://wiki.zenoss.org/Working_with_the_JSON_API
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70215#70215]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
steve stoltz
2012-12-13 14:32:08 UTC
Permalink
steve stoltz [http://community.zenoss.org/people/sstoltz] created the discussion

"Re: Maintenance Windows API"

To view the discussion, visit: http://community.zenoss.org/message/70534#70534

--------------------------------------------------------------
I have been working on getting the Maintance Windows to update through the URL and I have finally figured out how to do it and I thought I would share how to do it incase anyone else ever wants to do it.  There is zero information about this on the internet or really anywhere.. I dont know why.. it seems like it would be important to know how to change the Maintance setting of a Group or Device programically.  Here is a detailed overview of how to use the different commands. 

To decrease the text and redundandcy, lets assume that all command entered will have this appened to the front.
<Hostname/IP>:<Port>/zport/dmd/

When adding a Maintance Window to a Device, we must have the path:
Devices/Server/SSH/Linux/devices/<DeviceName>/

When adding a Maintance Window to a Group, we can use the path:
Groups/<GroupName>/

*To Create a Maintance Window:*
Groups/<GroupName>/manage_addMaintenanceWindow?newId=<Name_of_Maint_Window>

*Get a list of all Maintance Windows:*
Groups/<GroupName>/getMaintenanceWindows/

*Edit Maintenace Window:*
Groups/maintenanceWindows/<Name_of_Maint_Window>/manage_editMaintenanceWindow?startHours=12&startDate=12/12/2012&durationHours=12

In order to edit a window, we must have a startHours, StartDate, and durationHours. 
Total List of options are:
startDate, startHours, startMinutes=00, durationDays=0, durationHours=00, durationMinutes=00, repeat=Never, enabled=True, startProductionState=300, stopProductionState=0, skip=1

When editing the window, the enable option does not seem to work.  No matter what is set the window will be enabled.  I have just begun testing and useing these so I may have missed a step or setting somewhere.


*Delete Maintenance Window:*
Groups/manage_deleteMaintenanceWindow?maintenanceIds=<Name_of_Maint_Window>


An example of the whole URL:
<Hostname/IP>:<Port>/zport/dmd/Groups/manage_deleteMaintenanceWindow?maintenanceIds=<Name_of_Maint_Window>


All of these commands where tested on Zenoss 4.  I am sure there are a few more command out there to view and maybe validate some maint windows, but I have not gotten them to work yet.  I hope to have these features added to our Zenstamon Desktray App to allow maintance options through it.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70534#70534]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...