How to Maintenance Schedule for a device model using the Spectrum Command Line Interface (CLI) and Restful API
search cancel

How to Maintenance Schedule for a device model using the Spectrum Command Line Interface (CLI) and Restful API

book

Article ID: 42493

calendar_today

Updated On:

Products

CA Spectrum DX NetOps

Issue/Introduction

The following are the details on how to create a Maintenance Schedule using the Spectrum Command Line Interface (CLI) and the Restful API and then associate the schedule to a device model int he Spectrum database using the same.

Environment

Release: Any version of Spectrum
Component: CLI and Restful API

Resolution

Before creating a Schedule model of Model Type Handle 0x10456 using CLI or the API, we need to be aware of the attribute involved. 

0x12bbc Description : This is a text value describing the Schedule. If the Description value has spaces:

  • CLI - This value should be enclosed in double quotes. Example "This is the description"
  • API - Replace the space with %20 which is the URL encoding for a space. Example This%20is%20the%20description

0x1298f SCHED_Start_Hour : This is the hour the Schedule should start. This needs to be entered in the 24 hour format. For example, "02" for 2:00 AM and "19" for 7:00 PM. 

0x12993 SCHED_Duration : This is the duration of the Schedule in seconds. For example, if the Schedule is to run 1 hour, then the value would be 3600.
 
0x129e4 SCHED_Start_Day : This is the start day of the month the Schedule is to run.

0x12992 SCHED_Start_Month : This is the start month the Schedule is to run. It is important to note this does not correlate to the standard "1" = January, "2" = February etc. For the Schedule, "0" = January, "1" = February etc.

0x129e3 SCHED_Start_Year : This is the year the Schedule is to run. You cannot use 2024 for the year. You must use 124 for 2024, 125 for 2025 etc. 

0x12994 SCHED_Recurrence : This is the recurrence of the Schedule (2 for Daily, 3 for Weekly, 4 for Monthly, 5 for Yearly, 6 for Once)

0x1298e SCHED_Start_Minute : This is the minute of the hour the Schedule should start. 

You will not need to specify a value of all Schedules. It depends on the type of Schedule created.

Creating a Schedule using CLI:

When creating a Schedule using CLI, you will use the CLI "create model" command. The basic syntax of the command will be as follows:

./create model mth=<MTH> attr=<attrid>,val=<val> attr=<attrid>,val=<value> ...

The following is an example of creating a Daily Schedule that will start daily at 9:15 AM for a duration of 1 hour:

./create model mth=0x10456 attr=0x12bbc,val="Daily starting at 9:15 AM" attr=0x1298f,val=09 attr=0x12993,val=3600 attr=0x12994,val=2 attr=0x1298e,val=15

Notice in the above it was not required to use the SCHED_Start_Day, SCHED_Start_Month and SCHED_Start_Year attributes. However they can be used if you wish this schedule to start on a specific day of a specific month of a specific year. 

The following is an example of creating a Once Schedule that will start at 9:15 AM on December 12, 2024 for a duration of 1 hour:

./create model mth=0x10456 attr=0x12bbc,val="Once starting at 9:15 AM on December 12, 2024 for 1 hour" attr=0x1298f,val=09 attr=0x12993,val=3600 attr=0x12994,val=6 attr=0x1298e,val=15 attr=0x129e3,val=124 attr=0x12992,val=11 attr=0x129e4,val=12

After creating the schedule, you can use OneClick to apply the schedule to a model or CLI to create the association between the device model and the Schedule model using the CLI "create association" command. The following is the format of the command.

./create association rel=MAINT_SCHEDULE lmh=<device model model handle> rmh=<Schedule model model handle>

Creating a Schedule using API:

The following is an example of using curl to create the same Daily Schedule as the example using CLI above:

curl -kv -X 'POST' -u username:password 'https://OneClick:8443/spectrum/restful//model?landscapeid=0x1000000&mtypeid=0x10456&attr=0x12bbc&val=Daily%20starting%20at%209:15%20AM&attr=0x1298f&val=09&attr=0x12993&val=3600&attr=0x12994&val=2&attr=0x1298e&val=15'-H 'accept: application/xml; charset=UTF-8'

The following is an example of using curl to create the same Once Schedule as the example using CLI above:

curl -kv -X 'POST' -u username:password 'https://OneClick:8443/spectrum/restful//model?landscapeid=0x1000000&mtypeid=0x10456&attr=0x12bbc&val=Once%20starting%20at%209:15%20AM%20on%20December%2012,%202024%20for%201%20hour&attr=0x1298f&val=09&attr=0x12993&val=3600&attr=0x129e4&val=09&attr=0x12992&val=11&attr=0x129e3&val=124&attr=0x12994&val=6&attr=0x1298e&val=15&attr=0x1298d&val=1'-H 'accept: application/xml; charset=UTF-8'

Notice in the above curl statements, for the Description attribute id 0x12bbc, the spaces are replaced by %20.

You can then use the API to create the association between the device model and the Schedule model. The following is the format of the command:

curl -kv -X 'POST' -u username:password 'https://OneClick:8443/spectrum/restful/associations/relation/0x00010034/leftmodel/<device model model handle>/rightmodel/<Schedule model model handle>' -H 'accept: application/xml; charset=UTF-8'

Daily Schedule:

Once Schedule:

 

Additional Information

Reference the link below for a complete list of the schedule models attributes.

Schedule documentation topic