lib/gaptool-api.rb in gaptool-api-0.3.6 vs lib/gaptool-api.rb in gaptool-api-0.3.7

- old
+ new

@@ -3,13 +3,17 @@ module GTAPI class GaptoolServer include HTTParty default_timeout 600 + DEFAULT_AWS_AZ = 'us-west-2c' - def initialize(user, apikey, uri) + def initialize(user, apikey, uri, default_aws_az=DEFAULT_AWS_AZ) @auth = { 'X-GAPTOOL-USER' => user, 'X-GAPTOOL-KEY' => apikey} + default_aws_az = default_aws_az || DEFAULT_AWS_AZ + @default_aws_az = default_aws_az + @default_aws_region = default_aws_az[0..-2] GaptoolServer.base_uri uri end def mongocollectioncount(hash) options = {:body => hash, :headers => @auth} @@ -47,11 +51,11 @@ JSON::parse self.class.get("/hosts/#{role}/#{environment}", options) end def addnode(zone, itype, role, environment, mirror=0, security_group=nil) @body = { - 'zone' => zone, + 'zone' => zone || @default_aws_az, 'itype' => itype, 'role' => role, 'environment' => environment } unless mirror == 0 or mirror.nil? @@ -64,10 +68,10 @@ options = { :body => @body, :headers => @auth} JSON::parse self.class.post("/init", options) end def terminatenode(id, zone) - @body = {'id' => id, 'zone' => zone}.to_json + @body = {'id' => id, 'zone' => zone || @default_aws_region}.to_json options = {:body => @body, :headers => @auth} JSON::parse self.class.post("/terminate", options) end def getappnodes(app, environment)