solidfire_api 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/lib/solidfire_api/cluster.rb +31 -2
- data/lib/solidfire_api/connection.rb +8 -2
- data/lib/solidfire_api/version.rb +1 -1
- data/lib/solidfire_api/volume_access_group.rb +96 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bb1882b6f1d24c2b4a1be22c65c247dec99c559
|
4
|
+
data.tar.gz: cb8172512eccefc3eeaa6918eff4543c7190048b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce4159b95897f71ec240dc96d2b983a5fd4408c958e5748ab04f0329eb28bfb8bf491c287d964c7c295511c835ee5102339e8b79e80809ffc68bbd114921269
|
7
|
+
data.tar.gz: 9943e27ef488a441eca7cd1b784d2a4ce837131c3e1fd13f20100e20cad53274140b498f1d04d005ac2cb4a332e54b8c350026f3c27dbb1797a4b0e624b57337
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
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 functionalities.
|
3
|
+
Ruby Gem to connect on [Solidfire](http://www.solidfire.com/) storage Array API to collect stats. Currently support Simple Authentication and very basic functionalities.
|
4
|
+
|
5
|
+
Currently supporting volumes, cluster and disks listing and stats API call's to collect performance metrics for monitoring usage. Nothing for managing cluster yet.
|
6
|
+
|
7
|
+
Creation of VolumeAccessGroup, map volumes and iSCSI initiator.
|
4
8
|
|
5
9
|
Use gem: RestClient to interract with Solidfire API.
|
6
10
|
|
@@ -21,6 +25,8 @@ Install it:
|
|
21
25
|
|
22
26
|
## Usage
|
23
27
|
|
28
|
+
### Get some cluster informations
|
29
|
+
|
24
30
|
```ruby
|
25
31
|
require 'solidfire_api'
|
26
32
|
my_sf = SolidfireApi::Connection.new({
|
@@ -37,8 +43,25 @@ Install it:
|
|
37
43
|
|
38
44
|
```
|
39
45
|
|
40
|
-
Currently supporting volumes and cluster listing and stats API call's to collect performance metrics for monitoring usage. Nothing for managing cluster yet.
|
41
46
|
|
47
|
+
### Map Volume to a Volume Access Group
|
48
|
+
|
49
|
+
If you don't want to use CHAP authentication for iSCSI LUN access from initiator, you have to attach Volume to Volume Access Group that include iSCSI initiators.
|
50
|
+
|
51
|
+
Administrator privileges required.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
require 'solidfire_api'
|
55
|
+
my_sf = SolidfireApi::Connection.new({
|
56
|
+
:mvip => "192.168.0.1",
|
57
|
+
:username => "admin",
|
58
|
+
:password => "admin_password"
|
59
|
+
})
|
60
|
+
|
61
|
+
my_sf.vag_add_volume("volumename", "group_name")
|
62
|
+
=> {}
|
63
|
+
|
64
|
+
```
|
42
65
|
|
43
66
|
## Contributing
|
44
67
|
|
@@ -47,3 +70,7 @@ Currently supporting volumes and cluster listing and stats API call's to collect
|
|
47
70
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
71
|
4. Push to the branch (`git push origin my-new-feature`)
|
49
72
|
5. Create new Pull Request
|
73
|
+
|
74
|
+
## Todo
|
75
|
+
|
76
|
+
* Everything else
|
@@ -66,8 +66,37 @@ module Cluster
|
|
66
66
|
:params => {
|
67
67
|
}
|
68
68
|
}
|
69
|
-
answer = query_sf(api_call)
|
70
|
-
|
69
|
+
answer = query_sf(api_call)["clusterCapacity"]
|
70
|
+
|
71
|
+
# thinProvisioningFactor metric, calculated based on document instructions.
|
72
|
+
# if condition to avoid divide by 0.
|
73
|
+
if answer["nonZeroBlocks"] == 0
|
74
|
+
answer["thinProvisioningFactor"] = 0
|
75
|
+
else
|
76
|
+
answer["thinProvisioningFactor"] = (answer["nonZeroBlocks"] + answer["zeroBlocks"]) / answer["nonZeroBlocks"]
|
77
|
+
end
|
78
|
+
|
79
|
+
# deDuplicationFactor metric, calculated based on document instructions.
|
80
|
+
# if condition to avoid divide by 0.
|
81
|
+
if answer["uniqueBlocks"] == 0
|
82
|
+
answer["deDuplicationFactor"] = 0
|
83
|
+
else
|
84
|
+
answer["deDuplicationFactor"] = answer["nonZeroBlocks"] / answer["uniqueBlocks"]
|
85
|
+
end
|
86
|
+
|
87
|
+
# compressionFactor metric, calculated based on document instructions.
|
88
|
+
# if condition to avoid divide by 0.
|
89
|
+
if answer["uniqueBlocksUsedSpace"] == 0
|
90
|
+
answer["compressionFactor"] = 0
|
91
|
+
else
|
92
|
+
answer["compressionFactor"] = (answer["uniqueBlocks"] * 4096) / answer["uniqueBlocksUsedSpace"]
|
93
|
+
end
|
94
|
+
|
95
|
+
# efficiencyFactor metric, calculated based on document instructions.
|
96
|
+
# efficiencyFactor = thinProvisioningFactor * deDuplicationFactor * compressionFactor
|
97
|
+
answer["efficiencyFactor"] = answer["thinProvisioningFactor"] * answer["deDuplicationFactor"] * answer["compressionFactor"]
|
98
|
+
|
99
|
+
return answer
|
71
100
|
end
|
72
101
|
|
73
102
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'solidfire_api/volume'
|
3
3
|
require 'solidfire_api/node'
|
4
4
|
require 'solidfire_api/cluster'
|
5
|
+
require 'solidfire_api/volume_access_group'
|
5
6
|
|
6
7
|
module SolidfireApi
|
7
8
|
|
@@ -19,6 +20,7 @@ module SolidfireApi
|
|
19
20
|
include Cluster
|
20
21
|
include Volume
|
21
22
|
include Node
|
23
|
+
include VolumeAccessGroup
|
22
24
|
|
23
25
|
def self.data
|
24
26
|
@data ||= Hash.new do |hash, key|
|
@@ -53,8 +55,12 @@ module SolidfireApi
|
|
53
55
|
# query is a hash that is post in json format to SolidFire API.
|
54
56
|
solidfire_rest_url = "https://#{@username}:#{@password}@#{@mvip}/json-rpc/5.0"
|
55
57
|
result = JSON.parse(RestClient.post solidfire_rest_url, query.to_json)
|
56
|
-
if result["result"].nil?
|
57
|
-
|
58
|
+
if result["result"].nil?
|
59
|
+
if result["error"].nil?
|
60
|
+
return result
|
61
|
+
else
|
62
|
+
return result["error"]
|
63
|
+
end
|
58
64
|
else
|
59
65
|
return result["result"]
|
60
66
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
##
|
2
|
+
# Volume Access Group api calls
|
3
|
+
#
|
4
|
+
module VolumeAccessGroup
|
5
|
+
|
6
|
+
|
7
|
+
##
|
8
|
+
# list VolumeAccessGroups
|
9
|
+
#
|
10
|
+
# Arguments:
|
11
|
+
# state: (String, active or deleted, default = active)
|
12
|
+
# limit: (Integer, default = 1000)
|
13
|
+
#
|
14
|
+
def vag_list()
|
15
|
+
api_call = {
|
16
|
+
:method => "ListVolumeAccessGroups",
|
17
|
+
:params => {}
|
18
|
+
}
|
19
|
+
answer = query_sf(api_call)
|
20
|
+
return answer["volumeAccessGroups"]
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# create VolumeAccessGroup
|
25
|
+
# return groupID
|
26
|
+
#
|
27
|
+
# Arguments:
|
28
|
+
# group_name: (String, name of group)
|
29
|
+
#
|
30
|
+
# Require Admin credential
|
31
|
+
#
|
32
|
+
def vag_create(group_name)
|
33
|
+
api_call = {
|
34
|
+
:method => "CreateVolumeAccessGroup",
|
35
|
+
:params => {
|
36
|
+
:name => group_name,
|
37
|
+
:attributes => {}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
answer = query_sf(api_call)
|
41
|
+
return answer["volumeAccessGroupID"]
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Add iSCSI initiator to VolumeAccessGroup
|
46
|
+
#
|
47
|
+
# Arguments:
|
48
|
+
# initiator: (String)
|
49
|
+
# group_id: (Integer)
|
50
|
+
#
|
51
|
+
# Require Admin credential
|
52
|
+
#
|
53
|
+
def vag_add_initiator(initiator, group_id)
|
54
|
+
api_call = {
|
55
|
+
:method => "AddInitiatorsToVolumeAccessGroup",
|
56
|
+
:params => {
|
57
|
+
:volumeAccessGroupID => group_id,
|
58
|
+
:initiators => [ initiator ]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
answer = query_sf(api_call)
|
62
|
+
return answer
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Add Volume to VolumeAccessGroup
|
67
|
+
#
|
68
|
+
# Arguments:
|
69
|
+
# volume_id: (Integer)
|
70
|
+
# group_id: (Integer)
|
71
|
+
#
|
72
|
+
# Require Admin credential
|
73
|
+
#
|
74
|
+
def vag_add_volume_id(volume_id, group_id)
|
75
|
+
api_call = {
|
76
|
+
:method => "AddVolumesToVolumeAccessGroup",
|
77
|
+
:params => {
|
78
|
+
:volumeAccessGroupID => group_id,
|
79
|
+
:volumes => [ volume_id ]
|
80
|
+
}
|
81
|
+
}
|
82
|
+
answer = query_sf(api_call)
|
83
|
+
return answer
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Add Volume to VolumeAccessGroup using names
|
88
|
+
#
|
89
|
+
#
|
90
|
+
def vag_add_volume(volume_name, vag_name)
|
91
|
+
volume_id = volumes_list().select {|s| s["name"] == volume_name }.first["volumeID"]
|
92
|
+
vag_id = vag_list().select {|s| s["name"] == vag_name }.first["volumeAccessGroupID"]
|
93
|
+
vag_add_volume_id(volume_id, vag_id)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidfire_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Luc Dion
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/solidfire_api/node.rb
|
58
58
|
- lib/solidfire_api/version.rb
|
59
59
|
- lib/solidfire_api/volume.rb
|
60
|
+
- lib/solidfire_api/volume_access_group.rb
|
60
61
|
- solidfire_api.gemspec
|
61
62
|
homepage: https://github.com/pdion891/solidfire_api
|
62
63
|
licenses:
|