Creating a network resource
The creating a network resource example shows how to create a network resource. Note that this example only creates a “staged” network resource, and that the network resource must later be “imported” prior to managing its configuration.
Use this example as a model for creating a network resource.
ApiSession session;
NetworkResourceManager nrMgr;
ResourceContainerKey containerKey;//realm in which to create the NR
String hostname;//hostname (or IP address) of the device
String vendor;//device vendor
String type;//device type
String model;//device model
String os;//device os
.
.
.
//it is assumed the session has been established
nrMgr = session. networkResourceManager ();
.
.
.
//it is assumed that the variables have been set
NetworkResource nr = nrMgr.dataFactory().newNetworkResource();
nr.setHostname(hostname);
nr.setVendor(vendor);
nr.setType(type);
nr.setModel(model);
nr.setActualOsVersion(os);
nr.setRealmKey(containerKey);
nr.validate();
String cfgName = "Blank Configuration";
NetworkResourceKey nrKey = nrMgr.create(containerKey, nr, cfgName);