DX NetOps

 View Only
Expand all | Collapse all

How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

  • 1.  How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Sep 08, 2016 05:38 PM

    I have been able to use REST calls to check the status of the “isManaged” property once I query the Model Handle #.

    GET: http://<spectrum_server:port>/spectrum/rest/model/<0xModel_handle#>?attr=0x1295d"

    Which returns a True or False for that Device.

     

    I want to:

    1. Create a Schedule for Maintenance
    2. Add (or Remove) some Devices to that Schedule

    I’m trying to reproduce the TEC1301311 [http://www.ca.com/us/support/ca-support-online/product-content/knowledgebase-articles/tec1301311.aspx] using REST instead of CLI.

     

    I tried to convert the TEC doc instructions from CLI to REST using something like this POST:

    http://<spectrum_server:port>/spectrum/restful/model?mtypeid=0x10456&attr_id=0x12bbc&val=ScheduleTest1&attr_id=0x1298f&val=19&attr_id=0x12993&val=3600&attr_id=0x129e4&val=12&attr_id=0x12992&val=10&attr_id=0x129e3&val=116&attr_id=0x12994&val=6

    [See TEC1301311 for Full details on the Attributes & Values I picked for this Maintenance Schedule.]

    0x12bbc Description : "ScheduleTest1"
    0x1298f SCHED_Start_Hour : 19 ==> 7 pm
    0x12993 SCHED_Duration : 3600 ==> 3600 sec = 1 hour, so from 7pm to 8pm
    0x129e4 SCHED_Start_Day : 12
    0x12992 SCHED_Start_Month : 10 ==> Oct
    0x129e3 SCHED_Start_Year : 116 ==> 2016 (117 means 2017, 118 means 2018 etc.)
    0x12994 SCHED_Recurrence : 6 ==> Once (2 means daily, 3 means weekly, 4 means monthly, 5 means yearly)

    I get errors like: attr and val parameters are not proportionate

     

    Once I get this part working, then I need to figure out the Web call to create the association to Add the Devices to the Maintenance Window.

     

    I’ve been trying both via a Rest Client & via a PowerShell script. The other RESTFUL calls I make work with getting the Model Handle and getting various properties of individual devices. I just haven't figured out how to get this schedule created.

     

    I only see general docs on CA Spectrum Web Services API (RESTFUL), but nothing specific to creating Schedules for Maintenance Mode.

     

    Anyone know how to do this correctly via the Spectrum Web Services API? (I'm using 10.1.1)



  • 2.  Re: Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum

    Posted Sep 08, 2016 08:01 PM

    I've never created/associated maintenance schedules through the API, but I was able to create a model using your parameters with the following URL

     

    http://localhost/spectrum/restful/model?landscapeid=0xf00000&mtypeid=0x10456&attr=0x1298f&val=19&attr=0x129e4&val=12&attr=0x12993&val=3600&attr=0x12994&val=6&attr=0x129e3&val=116&attr=0x12bbc&val=ScheduleTest1&attr=0x12992&val=10

     

    If you associate the model correctly after creation it will probably work.



  • 3.  Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Nov 30, 2016 08:49 AM

    Hi, will be good have a web interface to set schedule maintenance, like a web calendar. all with rest.   

    Diego



  • 4.  Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Feb 17, 2017 10:34 AM

    I just had a similar error with using curl to change the value of an attribute. 

     

    [spectrum@spectrum ~]$ /usr/bin/curl -X PUT -u spectrum:spectrum http://spectrum:8080/spectrum/restful/model/0x100060?attr=0x67600d9&val=2
    [1] 64320
    [spectrum@spectrum ~]$ attr and val parameters are not proportionate

     

    The resolution was to enclose the http in double quotes:

     

    /usr/bin/curl -X PUT -u spectrum:spectrum "http://spectrum:8080/spectrum/restful/model/0x100060?attr=0x67600d9&val=2"

     

    Joe



  • 5.  Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Feb 25, 2017 07:36 PM

    I believe REST can only be used to modify attributes that are type String



  • 6.  Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Feb 17, 2017 02:29 PM

    Is it possible that the order of the items matters?

    http://<spectrum_server:port>/spectrum/restful/model?mtypeid=0x10456&attr_id=0x12bbc&val=ScheduleTest1&attr_id=0x1298f&val=19&attr_id=0x12993&val=3600&attr_id=0x129e4&val=12&attr_id=0x12992&val=10&attr_id=0x129e3&val=116&attr_id=0x12994&val=6

    Vs.

    http://<spectrum_server:port>/spectrum/restful/model?mtypeid=0x10456&attr=0x1298f&val=19&attr=0x129e4&val=12&attr=0x12993&val=3600&attr=0x12994&val=6&attr=0x129e3&val=117&attr=0x12bbc&val=ScheduleTest1&attr=0x12992&val=10



  • 7.  Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Feb 25, 2017 07:38 PM

    You have "attr_id=" in the first vs "attr=" in the second.



  • 8.  RE: Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?
    Best Answer

    Posted Nov 29, 2019 02:27 AM
    I'm able to create schedule using b

    headers = {'Content-Type': 'application/xml'}

    sched_url = "http://host:port/spectrum/restful/model?mtypeid=0x10456&attr=0x12bbc&val=ScheduleTestByPankaj&attr=0x1006e&val=ScheduleTestByPankaj&attr=0x1298f&val=19&attr=0x12993&val=3600&attr=0x129e4&val=12&attr=0x12992&val=10&attr=0x129e3&val=116"
    response = requests.post(sched_url, headers=headers)


  • 9.  RE: Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Jan 08, 2020 01:24 PM
    Hi Pankaj,

    i am not able to create a schedule.    i followed your url  and  keep getting the error 
    Invalid mtypeid parameter : 0x1160088
    could you help ?

    Thanks,
    Srinivas.


  • 10.  Re: How to Create a Maintenance Schedule via RESTful services/Web Services API in Spectrum ?

    Posted Jan 03, 2019 06:53 AM

    Hello Mike.Arnone,

     

    Based on More RESTful questions I was able to associate devices to Maintenence Schedule using below POST method:

     

    curl -k -w -H "Content-type: application/xml" -X POST -u "<USER>:<PASS>" "https://<OC_IPADDRESS>:8443/spectrum/restful/associations/relation/0x10034/leftmodel/$DEVMH/rightmodel/$MAINTMH"

     

    0x10034 = Relation MaintenenceScheduledBy

    $DEVMH = Model_Handle from device you want associate with Maintenence Schedule

    $MAINTMH = Model_Handle from Maintenance Schedule

     

    Hope it helps.