beautypg.com

Sample discoverfabricrequest.xml file contents, Sample san fabric discovery code (java) – Brocade Network Advisor REST API Guide (Supporting Network Advisor 12.3.0) User Manual

Page 59

background image

Brocade Network Advisor REST API Guide

45

53-1003160-01

SAN fabric discovery

4

XML file (DiscoverFabricRequest.xml) containing the payload DiscoverFabricRequest object.

The payload object specifies the parameters that are needed for FC fabric discovery
(for example, user name, password, and the seed switch IP address. For more information
about the parameters defined by the DiscoverFabricRequest object, refer to

DiscoverFabricRequest

.

NOTE

The REST XML schema for

DiscoverFabricRequest

is published in the directory

/conf/rest-schema, where is the installation directory of Network
Advisor. The schema for DiscoverFabricRequest provides more details on the default values for
some of the properties.

Sample DiscoverFabricRequest.xml file contents

The following is an example of XML payload for SAN fabric discovery.

xmlns:tns="http://www.brocade.com/networkadvisor/webservices/v1/discoveryservice/

request">

10.24.45.92

admin

password

ApsFabric

Sample SAN fabric discovery code (Java)

The following is an example of Java code for SAN fabric discovery. This sample code assumes that
some tool has been used to generate the required code for the requests (refer to

“Binding the

schema”

)

HttpURLConnection con = null;

try {

/**

* Create the HTTP connection object with the URI, method, and headers

*/

URL obj = new

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

con = (HttpURLConnection) obj.openConnection();

con.setRequestMethod("POST");

con.addRequestProperty("WStoken", "wppCy/NGdC4o5gGFJjXRMv7blhc=");

con.addRequestProperty("Accept",

"application/vnd.brocade.networkadvisor+json;version=v1");

con.addRequestProperty("Content-type",

"application/vnd.brocade.networkadvisor+xml;version=v1");

/**

* Unmarshal the XML data into the Java content object

*/

JAXBContext jaxbContext = JAXBContext.newInstance(DiscoverFabricRequest.class);

Unmarshaller u = jaxbContext.createUnmarshaller();

Object element = u.unmarshal(new File("./DiscoverFabricRequest.xml"));

/**

* Marshal the java object into the connection o/p stream

*/