beautypg.com

Sample san fabric discovery json response – Brocade Network Advisor REST API Guide (Supporting Network Advisor 12.3.0) User Manual

Page 60

background image

46

Brocade Network Advisor REST API Guide

53-1003160-01

SAN fabric discovery

4

Marshaller m = jaxbContext.createMarshaller();

m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

m.marshal(element, con.getOutputStream());

System.out.println("CALLING POST

http://10.24.48.103/rest/resourcegroups/All/discoverfabric");

/**

* Make the HTTP call

*/

int responseCode = con.getResponseCode();

System.out.println("Response code is " + responseCode);

if (responseCode != HttpURLConnection.HTTP_OK

&& responseCode != HttpURLConnection.HTTP_NO_CONTENT

&& responseCode != HttpURLConnection.HTTP_PARTIAL

&& responseCode != HttpURLConnection.HTTP_ACCEPTED) {

PRINT_ERROR(con);

assert false : "Fabric Discovery FAILED, responseCode = " + responseCode;

}

if (responseCode == HttpURLConnection.HTTP_PARTIAL) {

String location = con.getHeaderField("Location");

if (null != location) {

System.out.println("URI FOR NEXT PAGE = " + location);

}

}

PRINT_RESPONSE(con);

} catch (IOException ie) {

System.out.println(ie.toString());

} finally {

if (null != con) {

con.disconnect();

}

}

Sample SAN fabric discovery JSON response

The following is an example of a SAN fabric discovery JSON response.

/**

* Establishing REST Session

*/

CALLING POST http://10.24.41.138/rest/login

Response code is 200

GOT TOKEN FROM RS RESPONSE = Yh8veQHgxR6v6KgNR9Eioeg7168=

{"serverName":"W2K8R2-41-138","serverIp":"10.24.41.138"}

/**

* Getting FC fabrics list BEFORE discoverfabric operation, it is empty

*/

CALLING GET http://10.24.41.138/rest/resourcegroups/All/fcfabrics

REQUEST HTTPSTATUS = 200

{"fcFabrics":[]}

/**

* Executing discoverfabric, all virtual fabrics if any have been discovered

*/

CALLING POST http://10.24.48.103/rest/resourcegroups/All/discoverfabric