How to read the NCM Host Configuration from Spectrum using the REST API
search cancel

How to read the NCM Host Configuration from Spectrum using the REST API

book

Article ID: 115246

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

How to read the Host Configuration from the SpectroSERVER database using the Spectrum REST API. 

The customer was looking to use the Spectrum REST API to read the Host Configuration for a device. 

Resolution

Use the following URL to read the Host Configuration model for a device:
 

http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>[?attr=<attr_ID>]

The model handle in the above URL will be HostConfiguration model associated with the device and the attribute will be (0x822002b).

Once you make the above REST call with the HostConfiguration model handle and 0x82002b attribute the web service will return the response in the below format:

 



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response" error="EndOfResults" throttle="1" total-models="1">
<model-responses>
<model mh="0x100160">
<attribute id="0x82002b">33.67.111.109.109.97.110.100.58.32.115.104.111.119.32.114.117.110.110.105.110.103.45.99.111.110.102.105.103.10.33.84.105.109.101.58.32.84.117</attribute>
</model>
</model-responses>
</model-response-list>T

The XML will need to be parsed to get the attribute value. Once you get the attribute value the following code can be used to get the actual configuration file text:
 



String contents = new String("33.67.111.109.109.97.110.100.58.32.115.104.111.119.32.114.117.110.110.105.110.103.45.99.111.110.102.105.103.10.33.84.105.109.101.58.32.84.117");
String dataArray[] = contents.split("\\.");
byte[] bytes = new byte[dataArray.length];
int count = 0;
for(String str : dataArray)
{
bytes[count++] = Byte.parseByte(str);
}

System.out.println(new String(bytes));

Note: The actual value of the attribute will be much bigger. Part of the value in the above example has been stripped to keep it short.