class SolidfireApi::Connection
Object connection
Call using: SolidfireApi::Connection.new
({…})
Arguments:
mvip: (String) username: (String) password: (String)
Public Class Methods
data()
click to toggle source
# File lib/solidfire_api/connection.rb, line 25 def self.data @data ||= Hash.new do |hash, key| hash[key] = {} end end
new(options={})
click to toggle source
# File lib/solidfire_api/connection.rb, line 77 def initialize(options={}) @mvip = options[:mvip] @username = options[:username] @password = options[:password] @verify_ssl = options[:verify_ssl] if @verify_ssl.nil? @verify_ssl = false end api_call = { :method => "GetClusterInfo", :params => { } } array = query_sf(api_call) @name = array["clusterInfo"]["name"] @mvip = array["clusterInfo"]["mvip"] @svip = array["clusterInfo"]["svip"] end
reset()
click to toggle source
# File lib/solidfire_api/connection.rb, line 31 def self.reset @data = nil end
Public Instance Methods
mvip()
click to toggle source
# File lib/solidfire_api/connection.rb, line 102 def mvip @mvip end
name()
click to toggle source
# File lib/solidfire_api/connection.rb, line 98 def name @name end
query_sf(query)
click to toggle source
Used by all other methods to connect at the SolidFire API require RestClient gem to handle Rest API calls. the input is the complete API query as Hash, the method will send the query as json request to the Solidfire API.
Example:
>> api_call = { >> :method => "GetClusterInfo", >> :params => { >> } >> } >> query_sf(api_call)
Arguments:
query: (Hash) must include the complete Solidfire API query string.
# File lib/solidfire_api/connection.rb, line 54 def query_sf(query) # query is a hash that is post in json format to SolidFire API. solidfire_rest_url = "https://#{@mvip}/json-rpc/8.0" conn = RestClient::Resource.new( solidfire_rest_url, :verify_ssl => @verify_ssl, :user => @username, :password => @password ) result = JSON.parse(conn.post query.to_json) if result["result"].nil? if result["error"].nil? return result else return result["error"] end else return result["result"] end end
svip()
click to toggle source
# File lib/solidfire_api/connection.rb, line 106 def svip @svip end