Instance
Last Updated:2020-07-20
Query Instance Lists
The following code is used to query the instance of the specified cluster and instance group:
public void listInstances(BmrClient client, String clusterId, String instanceGroupId) {
try {
ListInstancesResponse response = client.listInstances(clusterId, instanceGroupId);
for (Instance instance : response.getIntances()) {
System.out.println(instance.getId() + "," + instance.getPrivateIpAddress()
+ "," + instance.getPublicIpAddress());
}
} catch (BceServiceException e) {
System.out.println("List instance failed: " + e.getErrorMessage());
}
}
The ListInstancesResponse object returned under request contains the instance object array List
public class Instance {
private String id;
private String privateIpAddress;
private String publicIpAddress;
}