solidfire_api 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b56e12283613e5ad515ff8fa602ee2621d05e667
4
+ data.tar.gz: a26152c4bc5b7e02815429bd39effe2afb9b4d52
5
+ SHA512:
6
+ metadata.gz: 57e5d7d74e05594c9e52327cd8da9bafe33dbfb1b9629d739057715b817424a057ab1237de9b4b031eba9c35f57167de8b4d1303e1dd78b7f78e16c4bb47bf65
7
+ data.tar.gz: b094d68e567cce18e33b961ff36f08de7327d7b407f902749be3d752a9e895a6a8e68bcfab973558b52195abf78d67dce4efd6d524357f8cf449bea7b0ec890e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in solidfire_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Pierre-Luc Dion
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # SolidfireApi
2
+
3
+ Ruby Gem to connect on Solidfire storage Array API to collect stats. Currently support Simple Authentication and very basic functionality.
4
+
5
+ ## Installation
6
+
7
+ Install it:
8
+
9
+ $ gem install solidfire_api
10
+ $ irb
11
+ > require 'solidfire_api'
12
+
13
+
14
+ ## Usage
15
+
16
+ ```ruby
17
+ require 'solidfire_api'
18
+ my_sf = SolidfireApi::Connection.new({
19
+ :mvip => "192.168.0.1",
20
+ :username => "monitor",
21
+ :password => "patate"
22
+ })
23
+ my_sf.name
24
+ my_sf.mvip
25
+ my_sf.svip
26
+ my_sf.volumes_list
27
+
28
+ ```
29
+
30
+ Currently supporting volumes and cluster listing and stats API call's to collect perf metric for monitoring usage. Nothing for managing cluster yet.
31
+
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( http://github.com/<my-github-username>/solidfire_api/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,59 @@
1
+
2
+
3
+ module Cluster
4
+
5
+ def cluster_state()
6
+ api_call = {
7
+ :method => "GetClusterState",
8
+ :params => {},
9
+ :id => 1
10
+ }
11
+ answer = query_sf(api_call)
12
+ return answer
13
+ end
14
+
15
+ def cluster_info()
16
+ api_call = {
17
+ :method => "GetClusterInfo",
18
+ :params => {
19
+ }
20
+ }
21
+ answer = query_sf(api_call)
22
+ return answer["clusterInfo"]
23
+ end
24
+
25
+ def drives_list()
26
+ api_call = {
27
+ :method => "ListDrives",
28
+ :params => {
29
+ }
30
+ }
31
+ answer = query_sf(api_call)
32
+ return answer["drives"]
33
+ end
34
+
35
+ def drive_stats(drive_id)
36
+ api_call = {
37
+ :method => "GetDriveStats",
38
+ :params => {
39
+ :driveID => drive_id
40
+ }
41
+ }
42
+ answer = query_sf(api_call)
43
+ return answer["result"]
44
+ end
45
+
46
+ def accounts_list(limit = 1000)
47
+ api_call = {
48
+ :method => "ListAccounts",
49
+ :params => {
50
+ :startAccountID => 0,
51
+ :limit => limit
52
+ }
53
+ }
54
+ answer = query_sf(api_call)
55
+ return answer["accounts"]
56
+ end
57
+
58
+ end
59
+
@@ -0,0 +1,60 @@
1
+ require 'solidfire_api/volume'
2
+
3
+ module SolidfireApi
4
+
5
+ class Connection
6
+ include Cluster
7
+ include Volume
8
+
9
+ def self.data
10
+ @data ||= Hash.new do |hash, key|
11
+ hash[key] = {}
12
+ end
13
+ end
14
+
15
+ def self.reset
16
+ @data = nil
17
+ end
18
+
19
+ def query_sf(query)
20
+ # query is a hash that is post in json format to SolidFire API.
21
+ solidfire_rest_url = "https://#{@username}:#{@password}@#{@mvip}/json-rpc/5.0"
22
+ result = JSON.parse(RestClient.post solidfire_rest_url, query.to_json)
23
+ if result["result"].nil?
24
+ return result["error"]
25
+ else
26
+ return result["result"]
27
+ end
28
+ end
29
+
30
+ def initialize(options={})
31
+ @mvip = options[:mvip]
32
+ @username = options[:username]
33
+ @password = options[:password]
34
+
35
+ api_call = {
36
+ :method => "GetClusterInfo",
37
+ :params => {
38
+ }
39
+ }
40
+ array = query_sf(api_call)
41
+ @name = array["clusterInfo"]["name"]
42
+ @mvip = array["clusterInfo"]["mvip"]
43
+ @svip = array["clusterInfo"]["svip"]
44
+ end
45
+
46
+ def name
47
+ @name
48
+ end
49
+
50
+ def mvip
51
+ @mvip
52
+ end
53
+
54
+ def svip
55
+ @svip
56
+ end
57
+
58
+
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module SolidfireApi
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,46 @@
1
+ module Volume
2
+
3
+ def volumes_list(limit = 1000)
4
+ api_call = {
5
+ :method => "ListActiveVolumes",
6
+ :params => {
7
+ :startVolumeID => 0,
8
+ :limit => limit
9
+ }
10
+ }
11
+ answer = query_sf(api_call)
12
+ return answer["volumes"]
13
+ end
14
+
15
+ def volume_stats(vol_id)
16
+ api_call = {
17
+ :method => "GetVolumeStats",
18
+ :params => {
19
+ :volumeID => vol_id
20
+ }
21
+ }
22
+ answer = query_sf(api_call)
23
+ return answer["volumeStats"]
24
+ end
25
+
26
+ def volumes_for_account(accountid)
27
+ api_call = {
28
+ :method => "ListVolumesForAccount",
29
+ :params => {
30
+ :volumeID => accountid
31
+ }
32
+ }
33
+ answer = query_sf(api_call)
34
+ return answer["result"]
35
+ end
36
+
37
+ def volumes_stats_by_account()
38
+ api_call = {
39
+ :method => "ListVolumeStatsByAccount",
40
+ :params => { },
41
+ :id => 1
42
+ }
43
+ answer = query_sf(api_call)
44
+ return answer["result"]
45
+ end
46
+ end
@@ -0,0 +1,9 @@
1
+ require 'rest_client'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ Dir[File.join(File.dirname(__FILE__), 'solidfire_api/*.rb')].sort.each { |lib| require lib }
6
+
7
+ module SolidfireApi
8
+
9
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'solidfire_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "solidfire_api"
8
+ spec.version = SolidfireApi::VERSION
9
+ spec.authors = ["Pierre-Luc Dion"]
10
+ spec.email = ["pdion@cloudops.com"]
11
+ spec.summary = %q{Solidfire Storage API Ruby Libraries}
12
+ spec.description = %q{Ruby client for Solidfire Storage API. Usefull for metric collection of Volumes and cluster status}
13
+ spec.homepage = "https://github.com/pdion891/solidfire_api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidfire_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Pierre-Luc Dion
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Ruby client for Solidfire Storage API. Usefull for metric collection
42
+ of Volumes and cluster status
43
+ email:
44
+ - pdion@cloudops.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/.DS_Store
55
+ - lib/solidfire_api.rb
56
+ - lib/solidfire_api/cluster.rb
57
+ - lib/solidfire_api/connection.rb
58
+ - lib/solidfire_api/version.rb
59
+ - lib/solidfire_api/volume.rb
60
+ - solidfire_api.gemspec
61
+ homepage: https://github.com/pdion891/solidfire_api
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.1.11
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Solidfire Storage API Ruby Libraries
85
+ test_files: []