Sha256: 0707b8a7431db5a9d6a23b0db0b725b934fdc8a8a505efc44a185212c33ce292
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'rest-client' require 'addressable/uri' require 'json' require 'silver_spurs/knife_interface' require 'silver_spurs/client/exceptions' module SilverSpurs class Client def initialize(host_url, options={}) @host_url = host_url @timeout = options[:timeout] || 60 * 60 end def bootstrap(ip, node_name, options = {}) params = extract_extra_params(options).merge({:node_name => node_name}) payload = parameterize_hash params headers = {:accept => :json, :content_type=> 'application/x-www-form-urlencoded'} response = spur_host["bootstrap/#{ip}"].put(payload, headers) throw ClientException("unexpected response", response) unless response.code == 201 JSON.parse response.body end private def parameterize_hash(param_hash) uri = Addressable::URI.new uri.query_values = param_hash uri.query end def extract_extra_params(options) supported_arguments = KnifeInterface.supported_arguments options.select {|k,v| supported_arguments.include? k} end def spur_host RestClient::Resource.new(@host_url, :timeout => @timeout) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
silver_spurs-0.0.8 | lib/silver_spurs/client.rb |