Skip to content

Commit

Permalink
Optionally fetch the zone when generating ping responses from Tiltyard
Browse files Browse the repository at this point in the history
request farm backends.
  • Loading branch information
samschreiber committed Nov 24, 2013
1 parent 1ba33d0 commit a6fde11
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/org/ggp/base/apps/tiltyard/TiltyardRequestFarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ static EncodedKeyPair getKeyPair(String keyPairString) {
}
public static final EncodedKeyPair theBackendKeys = getKeyPair(FileUtils.readFileAsString(new File("src/org/ggp/base/apps/tiltyard/BackendKeys.json")));
public static String generateSignedPing() {
String zone = null;
try {
zone = RemoteResourceLoader.loadRaw("http://metadata/computeMetadata/v1beta1/instance/zone");
} catch (IOException e1) {
// If we can't acquire the request farm zone, just silently drop it.
}

JSONObject thePing = new JSONObject();
try {
if (zone != null) thePing.put("zone", zone);
thePing.put("lastTimeBlock", (System.currentTimeMillis() / 3600000));
thePing.put("nextTimeBlock", (System.currentTimeMillis() / 3600000)+1);
SignableJSON.signJSON(thePing, theBackendKeys.thePublicKey, theBackendKeys.thePrivateKey);
Expand Down

0 comments on commit a6fde11

Please sign in to comment.