Software Development Kit (SDK) and API Discussions

8.3.0 NMSDK Unable to find API: aggr-list-info

howd
3,132 Views

Ultimately, I want a list of volumes on the cluster.  I've tried using several of the classes available in the ontap-api-8.3.jar, but with mixed results.  Here is snippet of code I've tried using to get a list of AggrInfo objects from a cluster:

Protocol protocol = Protocol.HTTP;
try { ApiRunner runner = new ApiRunner(ApiTarget.builder() .withHost("192.168.0.10") .withUserName("admin") .withPassword("password1!") .withTargetType(TargetType.FILER) .useProtocol(protocol) .build()); AggrListInfoRequest aggrLiInReq = new AggrListInfoRequest(); AggrListInfoResponse aggrLiInResp = runner.run(aggrLiInReq); List<AggrInfo> aggrInfoList = aggrLiInResp.getAggregates(); for (AggrInfo aggrInfo : aggrInfoList){ aggrInfo.getVolumeCount(); } } catch(Exception e) {; e.printStackTrace(); }

Here is the error I am encountering

com.netapp.nmsdk.ApiExecutionException: Unable to find API: aggr-list-info

I'm confused.  The AggrListInfoResponse class is in the ontap-api-8.3.jar.  How can the api not be avaliable?

 

Can someone please help me with this?

1 REPLY 1

michael_england
2,994 Views

I'm no using APIRunner but here are a couple of code snippets for you:

 

Aggregate List (needs to be done at the cluster level)

 

private NaElement request, response;

NaServer server = new NaServer("cluster_ip");
server.setTransportType(NaServer.TRANSPORT_TYPE_HTTPS);
server.setPort(443);
server.setStyle(NaServer.STYLE_LOGIN_PASSWORD);
server.setAdminUser("username", "password");

request = new NaElement("aggr-get-iter");
response = server.invokeElem(request);
NaElement aggrAttributes = response.getChildByName("attributes-list");

@SuppressWarnings("unchecked")
List<NaElement> aggrList = aggrAttributes.getChildren();
for (NaElement aggr : aggrList) {
     String aggrName = aggr.getChildContent("aggregate-name");
}

 

Volume List (needs to be done at the vserver level)

 

private NaElement request, response;

NaServer server = new NaServer("vserver_ip");
server.setTransportType(NaServer.TRANSPORT_TYPE_HTTPS);
server.setPort(443);
server.setStyle(NaServer.STYLE_LOGIN_PASSWORD);
server.setAdminUser("username", "password");

ArrayList<String> volumeList = new ArrayList<String>();
request = new NaElement("volume-get-iter");
request.addNewChild("max-records",  "4294967295");
NaElement desiredAttributes = new NaElement("desired-attributes");
NaElement volAttributes = new NaElement("volume-attributes");
NaElement volIDAttributes = new NaElement("volume-id-attributes");
NaElement name = new NaElement("name");
volIDAttributes.addChildElem(name);
volAttributes.addChildElem(volIDAttributes);
desiredAttributes.addChildElem(volAttributes);
request.addChildElem(desiredAttributes);
response = server.invokeElem(request);

@SuppressWarnings("unchecked")
List<NaElement> attributes = response.getChildByName("attributes-list").getChildren();
for (NaElement attribute : attributes) {
        // because the response is nested within volume-id-attributes, we need to get children again
	@SuppressWarnings("unchecked")
	List<NaElement> volIDs = attribute.getChildren();
	for (NaElement id : volIDs) {
		volumeList.add(id.getChildContent("name"));
	}
}

 

I'm splicing those together from other bits of code so no promises it'll just run but it should be close.

 

 

Public