Using the REST API to put models into Maintenance mode in CA Spectrum
search cancel

Using the REST API to put models into Maintenance mode in CA Spectrum

book

Article ID: 123462

calendar_today

Updated On: 08-06-2024

Products

Spectrum Network Observability

Issue/Introduction

Can device models in Spectrum be placed in Maintenance via the REST API?

Sometimes when network outages are scheduled, large numbers of devices need to be placed in maintenance mode as they're brought down to be worked on/upgraded etc. In such cases, its good to automate the process. This can be via CLI but another method is to use REST API calls which can also be called in a script.

Environment

All Supported Releases

Resolution

First, you can check the isManaged attribute (0x1295d) of the particular device model by using its MODEL_HANDLE in the following GET request:

http://<ONECLICK_HOST_IP>:<PORT>/spectrum/restful/model/<MODEL_HANDLE>?attr=0x1295d

This should return something similar to:

<model-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response" total-models="1" throttle="1" error="EndOfResults">
  <model-responses>
    <model mh="<MODEL_HANDLE>"
      <attribute id="0x1295d">1</attribute>
    </model>
  </model-responses>
</model-response-list>


If the model is Normal (GREEN), then the value returned for attribute id 0x1295d should be 1 as per the above example.

Then to change the model to maintenance mode, you would have to change the value of the isManaged (0x1295d) attribute from Yes (1) to No (0) using a PUT call:

http://<ONECLICK_HOST_IP>:<PORT>/spectrum/restful/model/<MODEL_HANDLE>?attr=0x1295d&val=0

Additional Information

How to get the device's model_handle via RESTful:
 
The following example sends the specified action (0x10093) to the SearchManager model (0x1000018), where 0x1000000 is the model_handle of the VNM model:
ttp://<OC_host>:<port>/spectrum/restful/action/0x10093?mh=0x1000018&attr=0&val= <IP Address>&attr=1&val=<IP Address>
The <IP Address> and <IP Address> are the IP addresses of the devices
 
If the VNM model_handle is 0x2000000, then the SearchManager model_handle is: 0x2000018.
 
The value of the 0x129fa attribute ID is the device's model_handle
<action-response xmlns="http://www.ca.com/spectrum/restful/schema/response" error="Success">
<attribute id="0x129fa">0x1000502</attribute>
<attribute id="0x129fa">0x10005cb</attribute>
</action-response>