Spectrum REST API: Retrieve devices in maintenance
search cancel

Spectrum REST API: Retrieve devices in maintenance

book

Article ID: 444670

calendar_today

Updated On:

Products

Network Observability Spectrum

Issue/Introduction

In DX NetOps Spectrum, Device models and Maintenance Schedule models are separate objects. While the device model indicates if maintenance is active via the isManaged attribute (0x1295d), it does not store schedule metadata such as the schedule description, schedule name, or duration. This article provides the REST API workflow to retrieve a list of devices along with their specific maintenance schedule details.

Environment

  • Product: DX NetOps Spectrum
  • Component: REST API / Maintenance Scheduling

Resolution

To retrieve the complete list of devices in maintenance including their schedule description, use a two-step API process to bridge the device and schedule models.

Step 1: Retrieve Maintenance Schedules and Metadata Perform a POST request to find all models of type 0x10456 (Maintenance Schedule).

  • Endpoint: https://<OC_HOST>:<PORT>/spectrum/restful/models
  • Payload:  Save the following payload in a xml file like schedule_request.xml. 
xml
<?xml version="1.0" encoding="UTF-8"?>
<rs:model-request throttlesize="1000"
                  xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">
    <rs:target-models>
        <rs:models-search>
            <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter">
                <filtered-models>
                    <equals>
                        <attribute id="0x10001">
                            <value>0x10456</value>
                        </attribute>
                    </equals>
                </filtered-models>
            </rs:search-criteria>
        </rs:models-search>
    </rs:target-models>

    <rs:requested-attribute id="0x1006e" />
    <rs:requested-attribute id="0x12bbc" />
    <rs:requested-attribute id="0x12993" />
</rs:model-request>

Example Curl Command:

bash
curl -k -X POST -u "your_username:your_password" -H "Content-Type: application/xml" -H "Accept: application/xml" -d @schedule_request.xml "https://<OC_Host>:<Port>/spectrum/restful/models" | xmllint --format -

Example of the curl output:

    <model mh="0x10b2fce">
      <attribute id="0x1006e">Every week on Sun, Mon, Tue, Wed, Thu, Fri and Sat  from 9 AM for 8 hours</attribute>
      <attribute id="0x12bbc">"Schedule Description"</attribute>
      <attribute id="0x12993">28800</attribute>
    </model>

 

Step 2: Identify Associated Devices For each Schedule Model Handle (mh) returned in Step 1, query the MAINT_SCHEDULE relation (0x10034) to find the linked devices.

  • Endpoint: GET https://<OC_HOST>:<PORT>/spectrum/restful/associations/relation/0x10034/model/<SCHEDULE_MH>?side=right

Example Curl Command:

bash
curl -k -u "your_username:your_password" -H "Accept: application/xml" "https://<OC_Host>:<Port>/spectrum/restful/associations/relation/0x10034/model/0x10b2fce?side=right" | xmllint --format -

The left_model_handle in the response represents the device(s) currently tied to that specific maintenance task.

Example of the curl output:

  <association-responses>
    <association rh="0x10034" leftmh="0x10b1956" rightmh="0x10b2fce"/>
  </association-responses>
</association-response-list>

Where 0x10b1956 is the model_handle of the device associated with the Schedule description model_handle: 0x10b2fce 

 

 Run the following syntax to get the schedule associated with a particular device (0x10b1956):

curl -k -u "your_username:your_password" -H "Accept: application/xml" "https://<OC_Host>:<Port>/spectrum/restful/associations/relation/0x10034/model/0x10b1956?side=left" | xmllint --format -

Example of the curl output:

  <association-responses>
    <association rh="0x10034" leftmh="0x10b1956" rightmh="0x10b2fce"/>
  </association-responses>
</association-response-list>

Where 0x10b2fce is the model_handle of the schedule associated with device model_handle: 0x10b1956

Additional Information