> +               public String call() {
> +                  String serialPortContents = "";
> +                  Map<String, String> passwordDict = ImmutableMap.of();
> +                  while (!serialPortContents.startsWith("{\"ready\":true") 
> || passwordDict.get("encryptedPassword") == null) {
> +                     try {
> +                        Thread.sleep(30 * 1000);
> +                     } catch (InterruptedException e) {
> +                        Throwables.propagate(e);
> +                     }
> +                     serialPortContents = 
> instanceApi.getSerialPortOutput(instance.get().name(), 4).contents();
> +                     String[] contentEntries = 
> serialPortContents.split("\n");
> +                     passwordDict = new 
> Gson().fromJson(contentEntries[contentEntries.length - 1], Map.class);
> +                  }
> +                  return passwordDict.get("encryptedPassword");
> +               }
> +            }, 5, TimeUnit.MINUTES, false); // Notice that timeoutDuration 
> should be less than EXPIRE_DURATION

Instead of manually doing this and calling Thread.sleep, use the jclouds 
`Predicates2.retry`.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/170/files/5d3a5e2ddeb7bd774eb6640c798939ffd957b5fd#r60573489

Reply via email to