solidfire_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b56e12283613e5ad515ff8fa602ee2621d05e667
4
- data.tar.gz: a26152c4bc5b7e02815429bd39effe2afb9b4d52
3
+ metadata.gz: 197ba47760fa5e1508dde1f6cce7cd7c50db5250
4
+ data.tar.gz: 8568fef138ef8ed357416bcbe2f4ce575336cc72
5
5
  SHA512:
6
- metadata.gz: 57e5d7d74e05594c9e52327cd8da9bafe33dbfb1b9629d739057715b817424a057ab1237de9b4b031eba9c35f57167de8b4d1303e1dd78b7f78e16c4bb47bf65
7
- data.tar.gz: b094d68e567cce18e33b961ff36f08de7327d7b407f902749be3d752a9e895a6a8e68bcfab973558b52195abf78d67dce4efd6d524357f8cf449bea7b0ec890e
6
+ metadata.gz: bf73a214def5e614ba5e69352d9fbd8d0a3320131c3f51a832f426d0554272b7ebda99810f6c375f12cfdf3c31c74e541300ce12e2608a9f4c5f4b8d6c63ab97
7
+ data.tar.gz: 948996a996ca3e1e9e72bda4fceeb2dac98d6dceb6ae8e68ecd91910e1b9f9f3c3034459ba3325acdf38b040d24d9ab963958452d6686ae95b26ac6f1d018b31
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
1
  # SolidfireApi
2
2
 
3
- Ruby Gem to connect on Solidfire storage Array API to collect stats. Currently support Simple Authentication and very basic functionality.
3
+ Ruby Gem to connect on Solidfire storage Array API to collect stats. Currently support Simple Authentication and very basic functionalities.
4
+
5
+ Use gem: RestClient to interract with Solidfire API.
4
6
 
5
7
  ## Installation
6
8
 
9
+ Gems requirements:
10
+
11
+ * rest_client
12
+ * net/http
13
+ * json
14
+
7
15
  Install it:
8
16
 
9
17
  $ gem install solidfire_api
@@ -20,6 +28,8 @@ Install it:
20
28
  :username => "monitor",
21
29
  :password => "patate"
22
30
  })
31
+
32
+ # Some method examples:
23
33
  my_sf.name
24
34
  my_sf.mvip
25
35
  my_sf.svip
@@ -27,12 +37,12 @@ Install it:
27
37
 
28
38
  ```
29
39
 
30
- Currently supporting volumes and cluster listing and stats API call's to collect perf metric for monitoring usage. Nothing for managing cluster yet.
40
+ Currently supporting volumes and cluster listing and stats API call's to collect performance metrics for monitoring usage. Nothing for managing cluster yet.
31
41
 
32
42
 
33
43
  ## Contributing
34
44
 
35
- 1. Fork it ( http://github.com/<my-github-username>/solidfire_api/fork )
45
+ 1. Fork it ( http://github.com/pdion891/solidfire_api/fork )
36
46
  2. Create your feature branch (`git checkout -b my-new-feature`)
37
47
  3. Commit your changes (`git commit -am 'Add some feature'`)
38
48
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/solidfire_api.rb CHANGED
@@ -4,6 +4,7 @@ require 'json'
4
4
 
5
5
  Dir[File.join(File.dirname(__FILE__), 'solidfire_api/*.rb')].sort.each { |lib| require lib }
6
6
 
7
+
7
8
  module SolidfireApi
8
9
 
9
10
  end
@@ -1,7 +1,14 @@
1
-
1
+ ##
2
+ # Cluster
3
+ #
4
+ # Cluster related API calls
5
+ #
2
6
 
3
7
  module Cluster
4
8
 
9
+ ##
10
+ # cluster_state: require administrative account.
11
+ #
5
12
  def cluster_state()
6
13
  api_call = {
7
14
  :method => "GetClusterState",
@@ -11,7 +18,10 @@ module Cluster
11
18
  answer = query_sf(api_call)
12
19
  return answer
13
20
  end
14
-
21
+
22
+ ##
23
+ # Cluster Information such as hostname, mvip,svip,...
24
+ #
15
25
  def cluster_info()
16
26
  api_call = {
17
27
  :method => "GetClusterInfo",
@@ -22,27 +32,52 @@ module Cluster
22
32
  return answer["clusterInfo"]
23
33
  end
24
34
 
25
- def drives_list()
35
+ ##
36
+ # Cluster firmware version including nodes
37
+ #
38
+ def cluster_version()
26
39
  api_call = {
27
- :method => "ListDrives",
40
+ :method => "GetClusterVersionInfo",
28
41
  :params => {
29
42
  }
30
43
  }
31
44
  answer = query_sf(api_call)
32
- return answer["drives"]
33
- end
34
-
35
- def drive_stats(drive_id)
45
+ return answer["clusterVersion"]
46
+ end
47
+ ##
48
+ # Cluster performance metrics, overall IOPS,..
49
+ #
50
+ def cluster_stats()
36
51
  api_call = {
37
- :method => "GetDriveStats",
52
+ :method => "GetClusterStats",
38
53
  :params => {
39
- :driveID => drive_id
40
54
  }
41
55
  }
42
56
  answer = query_sf(api_call)
43
- return answer["result"]
44
- end
57
+ return answer["clusterStats"]
58
+ end
59
+
60
+ ##
61
+ # Cluster capacity
62
+ #
63
+ def cluster_capacity()
64
+ api_call = {
65
+ :method => "GetClusterCapacity",
66
+ :params => {
67
+ }
68
+ }
69
+ answer = query_sf(api_call)
70
+ return answer["clusterCapacity"]
71
+ end
72
+
73
+
45
74
 
75
+ ##
76
+ # List all account, return Array of Hash
77
+ #
78
+ # Arguments:
79
+ # limit: (integer, default=1000)
80
+ #
46
81
  def accounts_list(limit = 1000)
47
82
  api_call = {
48
83
  :method => "ListAccounts",
@@ -55,5 +90,25 @@ module Cluster
55
90
  return answer["accounts"]
56
91
  end
57
92
 
93
+ ##
94
+ # List Cluster Faults
95
+ #
96
+ # Arguments:
97
+ # fault_type: (node,drive,cluster,service, default=all)
98
+ # node: Fault affecting an entire node
99
+ # drive: Fault affecting an individual drive
100
+ # cluster: Fault affecting the entire cluster
101
+ # service: Fault affecting a service on the cluster
102
+ def faults_list(fault_type = "all")
103
+ api_call = {
104
+ :method => "ListClusterFaults",
105
+ :params => {
106
+ :faultTypes => fault_type
107
+ }
108
+ }
109
+ answer = query_sf(api_call)
110
+ return answer["faults"]
111
+ end
112
+
58
113
  end
59
114
 
@@ -1,10 +1,24 @@
1
+ # Load libraries
1
2
  require 'solidfire_api/volume'
3
+ require 'solidfire_api/node'
4
+ require 'solidfire_api/cluster'
2
5
 
3
6
  module SolidfireApi
4
7
 
8
+ ##
9
+ # Object connection
10
+ #
11
+ # Call using: SolidfireApi::Connection.new({...})
12
+ #
13
+ # Arguments:
14
+ # mvip: (String)
15
+ # username: (String)
16
+ # password: (String)
17
+ #
5
18
  class Connection
6
19
  include Cluster
7
20
  include Volume
21
+ include Node
8
22
 
9
23
  def self.data
10
24
  @data ||= Hash.new do |hash, key|
@@ -16,6 +30,25 @@ module SolidfireApi
16
30
  @data = nil
17
31
  end
18
32
 
33
+ ##
34
+ #
35
+ # Used by all other methods to connect at the SolidFire API
36
+ # require RestClient gem to handle Rest API calls.
37
+ # the input is the complete API query as Hash, the method will
38
+ # send the query as json request to the Solidfire API.
39
+ #
40
+ # Example:
41
+ # >> api_call = {
42
+ # >> :method => "GetClusterInfo",
43
+ # >> :params => {
44
+ # >> }
45
+ # >> }
46
+ # >> query_sf(api_call)
47
+ #
48
+ #
49
+ # Arguments:
50
+ # query: (Hash)
51
+ # must include the complete Solidfire API query string.
19
52
  def query_sf(query)
20
53
  # query is a hash that is post in json format to SolidFire API.
21
54
  solidfire_rest_url = "https://#{@username}:#{@password}@#{@mvip}/json-rpc/5.0"
@@ -0,0 +1,81 @@
1
+ ##
2
+ # Node
3
+ #
4
+ # API call related to cluster nodes
5
+ #
6
+ module Node
7
+
8
+ ##
9
+ #
10
+ # List cluster nodes
11
+ #
12
+ # Arguments:
13
+ #
14
+ # state: (String, default = active)
15
+ # active
16
+ # all
17
+ def nodes_list(state = "active")
18
+ case state
19
+ when "all"
20
+ api_call = {
21
+ :method => "ListAllNodes",
22
+ :params => {}
23
+ }
24
+ when "active"
25
+ api_call = {
26
+ :method => "ListActiveNodes",
27
+ :params => {}
28
+ }
29
+ end
30
+ answer = query_sf(api_call)
31
+ return answer["nodes"]
32
+ end
33
+ ##
34
+ # node performance metrics
35
+ #
36
+ # Arguments:
37
+ # node_id: (Integer)
38
+ #
39
+ def node_stats(node_id)
40
+ api_call = {
41
+ :method => "GetNodeStats",
42
+ :params => {
43
+ :nodeID => node_id
44
+ }
45
+ }
46
+ answer = query_sf(api_call)
47
+ return answer["nodeStats"]
48
+ end
49
+
50
+ ##
51
+ # provide list of disks in a Array of hash.
52
+ #
53
+ def drives_list()
54
+ api_call = {
55
+ :method => "ListDrives",
56
+ :params => {
57
+ }
58
+ }
59
+ answer = query_sf(api_call)
60
+ return answer["drives"]
61
+ end
62
+
63
+ ##
64
+ # hard drive performance metric, return in Hash.
65
+ #
66
+ # Arguments:
67
+ # drive_id: (Integer)
68
+ #
69
+ def drive_stats(drive_id)
70
+ api_call = {
71
+ :method => "GetDriveStats",
72
+ :params => {
73
+ :driveID => drive_id
74
+ }
75
+ }
76
+ answer = query_sf(api_call)
77
+ return answer["driveStats"]
78
+ end
79
+
80
+
81
+ end
@@ -1,3 +1,3 @@
1
1
  module SolidfireApi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,17 +1,40 @@
1
1
  module Volume
2
2
 
3
- def volumes_list(limit = 1000)
4
- api_call = {
5
- :method => "ListActiveVolumes",
6
- :params => {
7
- :startVolumeID => 0,
8
- :limit => limit
3
+
4
+ ##
5
+ # list active volumes, return Array of Hash
6
+ #
7
+ # Arguments:
8
+ # state: (String, active or deleted, default = active)
9
+ # limit: (Integer, default = 1000)
10
+ #
11
+ def volumes_list(state = "active", limit = "1000")
12
+ case state
13
+ when "active"
14
+ api_call = {
15
+ :method => "ListActiveVolumes",
16
+ :params => {
17
+ :startVolumeID => 0,
18
+ :limit => 1000
19
+ }
9
20
  }
10
- }
21
+ when "deleted"
22
+ api_call = {
23
+ :method => "ListDeletedVolumes",
24
+ :params => {}
25
+ }
26
+ end
11
27
  answer = query_sf(api_call)
12
28
  return answer["volumes"]
13
29
  end
14
30
 
31
+ ##
32
+ # return volume performance metrics as Hash
33
+ #
34
+ # Arguments:
35
+ # vol_id: (Integer)
36
+ # Volume ID from the Solidfire Cluster.
37
+ #
15
38
  def volume_stats(vol_id)
16
39
  api_call = {
17
40
  :method => "GetVolumeStats",
@@ -23,6 +46,12 @@ module Volume
23
46
  return answer["volumeStats"]
24
47
  end
25
48
 
49
+ ##
50
+ # Return volumes list per account
51
+ #
52
+ # Arguments:
53
+ # accountid: (Integer)
54
+ #
26
55
  def volumes_for_account(accountid)
27
56
  api_call = {
28
57
  :method => "ListVolumesForAccount",
@@ -34,6 +63,7 @@ module Volume
34
63
  return answer["result"]
35
64
  end
36
65
 
66
+
37
67
  def volumes_stats_by_account()
38
68
  api_call = {
39
69
  :method => "ListVolumeStatsByAccount",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidfire_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre-Luc Dion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-09 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,10 +51,10 @@ files:
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
- - lib/.DS_Store
55
54
  - lib/solidfire_api.rb
56
55
  - lib/solidfire_api/cluster.rb
57
56
  - lib/solidfire_api/connection.rb
57
+ - lib/solidfire_api/node.rb
58
58
  - lib/solidfire_api/version.rb
59
59
  - lib/solidfire_api/volume.rb
60
60
  - solidfire_api.gemspec
data/lib/.DS_Store DELETED
Binary file