Hello Everyone,
I'm looking for a way to execute a batch of API commands at once, as oposed to sending each one at a time. For example zexplore generates the following code:
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;
import netapp.manage.NaElement;
import netapp.manage.NaException;
import netapp.manage.NaServer;
public class ApiClient {
public static void main(String[] args) {
try {
NaServer s = new NaServer("<server name or IP address>", 1 , 21);
s.setServerType(NaServer.SERVER_TYPE_FILER);
s.setTransportType(NaServer.TRANSPORT_TYPE_HTTPS);
s.setPort(443);
s.setStyle(NaServer.STYLE_LOGIN_PASSWORD);
s.setAdminUser("<user name>", "<password>");
NaElement api = new NaElement("snapshot-delete");
api.addNewChild("ignore-owners","<ignore-owners>");
api.addNewChild("snapshot","<snapshot>");
api.addNewChild("snapshot-instance-uuid","<snapshot-instance-uuid>");
api.addNewChild("volume","<volume>");
NaElement xo = s.invokeElem(api);
System.out.println(xo.toPrettyString(""));
NaElement api1 = new NaElement("snapshot-delete");
api1.addNewChild("ignore-owners","<ignore-owners>");
api1.addNewChild("snapshot","<snapshot>");
api1.addNewChild("snapshot-instance-uuid","<snapshot-instance-uuid>");
api1.addNewChild("volume","<volume>");
NaElement xo1 = s.invokeElem(api1);
System.out.println(xo1.toPrettyString(""));
NaElement api2 = new NaElement("snapshot-delete");
api2.addNewChild("ignore-owners","<ignore-owners>");
api2.addNewChild("snapshot","<snapshot>");
api2.addNewChild("snapshot-instance-uuid","<snapshot-instance-uuid>");
api2.addNewChild("volume","<volume>");
NaElement xo2 = s.invokeElem(api2);
System.out.println(xo2.toPrettyString(""));
NaElement api3 = new NaElement("snapshot-delete");
api3.addNewChild("ignore-owners","<ignore-owners>");
api3.addNewChild("snapshot","<snapshot>");
api3.addNewChild("snapshot-instance-uuid","<snapshot-instance-uuid>");
api3.addNewChild("volume","<volume>");
NaElement xo3 = s.invokeElem(api3);
System.out.println(xo3.toPrettyString(""));
} catch (NaException e) {
handleException(e);
} catch (UnknownHostException e) {
handleException(e);
} catch (IOException e) {
handleException(e);
}
}
private static void handleException(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
This just reaches out to the filer each time you call an invokeEmem. I would like to minimize the times I have to do this and wait for a response.
Unless I'm mistaken, you can't set a >x variable in the query fields, otherwise I could use that. So for now I'm getting a result, filtering it on my end and then generating a new NaElement for each volume or snapshot I want to change.
Instead of calling a bunch of.
NaElement xo3 = s.invokeElem(api3);
I'd like to do something like:
{
... construct NaElements
}
NaBatch x = s.getBatch();
x.addNaElement(api);
x.addNaElement(api);
x.addNaElement(api);
x.addNaElement(api);
s.invokeBatch(x);
Is there some way to do something like this, or is there a way to add this feature?