Is it possible to override the speed of an interface via REST?

Document ID : KB000093510
Last Modified Date : 24/08/2018
Show Technical Document Details
Question:
Is there any way to automate the creation or modification of an interface's speed?
Answer:
This process can be accomplished by utilizing the Data Aggregator REST web service.  https://docops.ca.com/ca-performance-management/3-5/en/apis/data-aggregator-rest-webservices

To perform this process you will need to utilize a 3rd party program to perform the PUT and POST requests needed.  Some examples are Postman and Advanced REST Client (ARC).

First you need to obtain the interface ID for the interface you would like to modify and for that you need to obtain the parent device ID.  Lets start in the CAPC GUI under Administration -> Monitored Devices.  Find your target device and access the details page where you can find the device's Item ID:

Device Item ID

Take this ID to your chosen REST client and issue the following POST to get all interfaces for the selected device:

Method: POST
URL: http://daHostname:8581/rest/ports/filtered
Body content type: application/xml
Body:
<FilterSelect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="filter.xsd">
    <Filter>
        <DeviceComponent.DeviceItemID type="CONTAINS">4810</DeviceComponent.DeviceItemID>
    </Filter>
    <Select use="exclude"  isa="exclude">
        <Item use="include">
            <Name use="include"/>
        </Item>
    </Select>
</FilterSelect>

For example, using a parent device of 4810 in the Advanced Rest Client:

Obtain interface id for modification

From this request I was able to obtain the ID for my selected interface, FastEthernet0/0.  This ID is 4830.  Now taking that ID you will issue a PUT with the following details:

Method: PUT
URL: http://daHostname:8581/rest/ports/portID
Body content type: application/xml
Body:
<Port version="1.0.0">
     <SpeedOutOverride>1.2E8</SpeedOutOverride>
     <SpeedInOverride>1.2E8</SpeedInOverride>
</Port>

In the example we are Overriding the speed to set a speed of 120000000 bps (120 Mbps) instead of the discovered 100000000 bps (100 Mbps):

Final PUT to modify the speed

You can check the results in CAPC by going to: Administration -> Monitored Devices -> Find the original Device -> Polled Metric Families tab.  Then click in the white space next to the Interface Metric Family and the Interface components will display at the bottom.  Take note of the triangles to the top left of the Speed In and Out column entries for the modified device.  This signifies the discovered speed has been overridden.

Validation or work 1

And if you right click that interface and click edit:

User-added image
Additional Information:
Now that you can modify a singular device, you can spread this methodology out using scripting and CURL or Postman depending on your needs.

An example of a CURL command to acquire the Interface list in the example above:
 
curl --header "Content-Type: application/xml" --request POST --data '<FilterSelect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="filter.xsd"><Filter><DeviceComponent.DeviceItemID type="CONTAINS">4810</DeviceComponent.DeviceItemID></Filter><Select use="exclude"  isa="exclude"><Item use="include"><Name use="include"/></Item></Select></FilterSelect>' --url http://DAhostname:8581/rest/ports/filtered

An example of a CURL command to make the change in the example above:
 
curl --header "Content-Type: application/xml" --request PUT --data '<Port version="1.0.0"><SpeedOutOverride>1.2E8</SpeedOutOverride><SpeedInOverride>1.2E8</SpeedInOverride></Port>' --url http://DAhostname:8581/rest/ports/4830