Instance(实例)
更新时间:2022-04-18
查询实例列表
如下代码可查询指定集群和实例组的实例:
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());
}
}
请求返回的ListInstancesResponse对象包含了相关的实例对象数组List
public class Instance {
private String id;
private String bccInstanceId;
private String instanceName;
private String privateIpAddress;
private String publicIpAddress;
private Status status;
private String privateDnsName;
private String publicDnsName;
private int sshPort;
}