Get All Network Elements Examples (Bulk Information Transfer)

Overview

GET /networkinventory/networkelements request shall be used to retrieve list of all Network Elements stored in OMS

Here described is an example of Get All Network Elements

GET All Network Elements

Below is code snippet to retrieve all the network elements.


public class BulkUplaodService extends Service {
	/**Retrieve all the nodes */
	public List<String> getAllNetworkElements(OMSRestTemplate restTemplate) {
		return retrieveData (restTemplate, "/networkinventory/networkelements");
	}

	/**
	*
	* retrieves list of json files to be download
	*
	* */
	public List<String> retrieveData (OMSRestTemplate restTemplate, String urlSuffix) {
		List<String> retData = new ArrayList <String>();

		/** Url to retrieve networkelement json file*/
		String custUrl = restTemplate.getUrlPrefix() + urlSuffix; //"/networkinventory/networkelements";
		//?userid=ECmdKGhCKVqxOwMqdli62w==&password=zGwL2f+0s44QqnRUAhJSKQ==";

		/**retrieve json file path*/
		JsonNode networkDataFileList = restTemplate.getForObject(custUrl, JsonNode.class);

		downloadFiles(restTemplate, retData, networkDataFileList, restTemplate.getUrlPrefix()); 

		return retData;
	}
	/**
	*

JSON Request


/oms1350/networkinventory/networkelements

JSON Response


/oms1350/web/eqm/data/1459243450910GetAllNEResponse.json

Download the JSON Response files

Below is code snippet to download the response json files.


/**
*
* Download all the json files.
*
* @param restTemplate - Spring Rest Template
* @param retData - Response data which is returned
* @param networkDataFileList - JSON Response files to be downloaded
* @param urlPrefix - OMS base path
*
*/
private void downloadFiles(OMSRestTemplate restTemplate, List<String> retData, JsonNode networkDataFileList, String urlPrefix) {
	String url;
	Iterator<JsonNode> it = networkDataFileList.iterator();

	/** Iterato over all the files and download*/
	while (it.hasNext ()) {
		String filePath = it.next().textValue();
		url = urlPrefix + filePath.replace("oms1350/", "") ;	//+ "?userid=ECmdKGhCKVqxOwMqdli62w==&password=zGwL2f+0s44QqnRUAhJSKQ==";
		System.out.println( "URL : " + url);
		String jsonResp = restTemplate.getForObject(url, String.class);
		retData.add(jsonResp);
	}
}

JSON Request


/oms1350/web/eqm/data/1459243450910GetAllNEResponse.json

JSON Response


[
 {
	"userLabel": "NODE1_C-1",
	"version": "8.2",
	"productName": "UNV32",
	"nodeType": "1830PSS-32",
	"location": "NPT-NJOY",
	"communicationState": "ENABLED",
	"supervisionState": "SUPERVISED",
	"nodeName": "NODE1_C-1",
	"attributeNameValue": {
		"TID": "NODE1_C-1",
		"IpAddress": "10.100.54.217",
		"neTypeDescription": "Alcatel-Lucent 1830 PSS v8.2 SDH ADM (Simulator)",
		"EMLNeId": "13",
		"EMLNeGroupId": "1201"
	}
}
]

Main Class

Following shows the client code snippet in main class retrieve all the network elements.


public class OmsRestClientApplication {
	public static void main(String[] args) {
		AuthInfo authInfo = new AuthInfo();
		authInfo.setServerIP("135.250.184.42");
		authInfo.setServerPort("8443");
		authInfo.setServerUser("alcatel");
		authInfo.setServerPwd("Lucent1.!");
		authInfo.setPresentationIP("135.250.184.43");

		/**create OMSRestTemplate instance**/
		OMSRestTemplate omsRestTemplate = new OMSRestTemplate ();

		/**authenticate*/
		omsRestTemplate.authenticate(authInfo);

		BulkUplaodService bSvc = new BulkUplaodService ();
		List<String> resp = bSvc.getAllNetworkElements(omsRestTemplate);
	}
}