try {
BufferedReader r = new BufferedReader(new StringReader(string));
String line;
ImmutableList.Builder<VM> resultBuilder = ImmutableList.builder();
while ((line = r.readLine()) != null) {
VM vm = VM.builder().fromVmadmString(line).build();
Map<String, String> ipAddresses;
RateLimiter limiter = RateLimiter.create(1.0);
for (int i = 0; i < 30; i++) {
ipAddresses = getVMIpAddresses(vm.getUuid());
if (!ipAddresses.isEmpty()) {
// Got some
String ip = ipAddresses.get("net0");
if (ip != null && !ip.equals("0.0.0.0")) {
vm = vm.toBuilder().publicAddress(ip).build();
break;
}
}
limiter.acquire();