solidfire_api 0.0.12 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dd4c4ceeeb281e08951d3a17604e6c63cb26b81
4
- data.tar.gz: a79ee13994f5dc19b0b702e832405d21e1294d11
3
+ metadata.gz: 7e24e28a0b3dbd6e7819577a63e314ca0292d905
4
+ data.tar.gz: 29cb47ffa9726237313b86d24d00244db8cfb2dd
5
5
  SHA512:
6
- metadata.gz: 6156442bcf340e699a7b0ab3edbd310e530925e649f50e8d66c0b1c9a3625a88300e91ec2ce142ef5e8e57347bf8fce2e559efc68033912600dabfc3a939f3b1
7
- data.tar.gz: 6ee8a856b9d487a56a66c11e644ff1bbe86a76fd86bf30d7a69310c98bdbc8614b32aba11e074a25f5105364d4775d4cb2b3ed2eca7392bb7ee2f6afe27573d3
6
+ metadata.gz: a93fc7ce2b85ae1e4ecf6e75959c99d9753df6f4c8d024eae821c87b30ffc2866cbe61846b7d785be268b4c13f71f563f41e49f9a1c91066de0eff6aceab2861
7
+ data.tar.gz: f5d9b335f4a4d377a83c6acc93e1f889599b6239c322c283157867737df106a4ddcf3f3038c036479992080810d93ee7c224e460cac917541937351b11a7fc52
@@ -1,3 +1,3 @@
1
1
  module SolidfireApi
2
- VERSION = '0.0.12'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,51 +1,84 @@
1
1
  module Volume
2
-
3
- ##
2
+
3
+ ##
4
4
  # list active volumes, return Array of Hash
5
5
  #
6
6
  # Arguments:
7
- # state: (String, active or deleted, default = active)
8
- # limit: (Integer, default = 1000)
7
+ # name: (String, Volume name)
8
+ # accountid: (integer, accountID)
9
+ # enable512e: (boolean, default = true)
10
+ # minIOPS: (integer, default = 100)
11
+ # maxIOPS: (integer, default = 1000)
12
+ # burstIOPS: (integer, default = 10000)
9
13
  #
10
- def volumes_create()
14
+ def volumes_create(name, accountid, size, enable512e = true, minIOPS = 100, maxIOPS = 1000, burstIOPS = 10000)
11
15
  api_call = {
12
16
  :method => "CreateVolume",
13
17
  :params => {
14
- :startVolumeID => 0,
15
- :limit => limit
18
+ :name => name,
19
+ :accountID => accountid,
20
+ :totalSize => size,
21
+ :enable512e => enable512e,
22
+ :qos => {
23
+ :minIOPS => minIOPS,
24
+ :maxIOPS => maxIOPS,
25
+ :burstIOPS => burstIOPS
26
+ }
16
27
  }
17
28
  }
18
29
  answer = query_sf(api_call)
19
- return answer["volumes"]
30
+ return answer["volumeID"]
20
31
  end
21
32
 
22
- ##
33
+ ##
23
34
  # list active volumes, return Array of Hash
24
35
  #
25
36
  # Arguments:
26
37
  # state: (String, active or deleted, default = active)
38
+ # startid: (Integer, default = 0)
27
39
  # limit: (Integer, default = 1000)
40
+ # accountid: (Integer, or Array of accountID)
41
+ # name: (String, Volume name)
28
42
  #
29
- def volumes_list(state = "active", limit = "1000")
30
- case state
31
- when "active"
43
+ def volumes_list(options = {})
44
+ state = options.fetch(:state, 'active')
45
+ startid = options.fetch(:startid, 0)
46
+ limit = options.fetch(:limit, 1000)
47
+ accounts = options.fetch(:accountid, nil)
48
+ name = options.fetch(:name, nil)
49
+
50
+ if name
51
+ api_call = {
52
+ :method => "ListVolumes",
53
+ :params => {
54
+ :VolumeName => name,
55
+ :limit => 1
56
+ }
57
+ }
58
+ elsif accounts
59
+ accounts = [ accounts ] if accounts.class == String || Integer
32
60
  api_call = {
33
- :method => "ListActiveVolumes",
61
+ :method => "ListVolumes",
34
62
  :params => {
35
- :startVolumeID => 0,
63
+ :accounts => accounts,
36
64
  :limit => limit
37
65
  }
38
66
  }
39
- when "deleted"
67
+ else
40
68
  api_call = {
41
- :method => "ListDeletedVolumes",
42
- :params => {}
69
+ :method => "ListVolumes",
70
+ :params => {
71
+ :VolumeStatus => state,
72
+ :startVolumeID => startid,
73
+ :limit => limit
74
+ }
43
75
  }
44
76
  end
77
+
45
78
  answer = query_sf(api_call)
46
79
  return answer["volumes"]
47
80
  end
48
-
81
+
49
82
  ##
50
83
  # return volume performance metrics as Hash
51
84
  #
@@ -81,25 +114,25 @@ module Volume
81
114
  answer = query_sf(api_call)
82
115
  return answer
83
116
  end
84
-
117
+
85
118
  ##
86
119
  # Return volumes list per account
87
- #
120
+ #
88
121
  # Arguments:
89
122
  # accountid: (Integer)
90
- #
123
+ #
91
124
  def volumes_for_account(accountid)
92
125
  api_call = {
93
126
  :method => "ListVolumesForAccount",
94
127
  :params => {
95
- :volumeID => accountid
128
+ :accountID => accountid
96
129
  }
97
130
  }
98
131
  answer = query_sf(api_call)
99
132
  return answer
100
- end
101
-
102
-
133
+ end
134
+
135
+
103
136
  def volumes_stats_by_account()
104
137
  api_call = {
105
138
  :method => "ListVolumeStatsByAccount",
@@ -108,5 +141,5 @@ module Volume
108
141
  }
109
142
  answer = query_sf(api_call)
110
143
  return answer
111
- end
144
+ end
112
145
  end
@@ -2,7 +2,7 @@
2
2
  # Volume Access Group api calls
3
3
  #
4
4
  module VolumeAccessGroup
5
-
5
+
6
6
 
7
7
  ##
8
8
  # list VolumeAccessGroups
@@ -40,27 +40,50 @@ module VolumeAccessGroup
40
40
  answer = query_sf(api_call)
41
41
  return answer["volumeAccessGroupID"]
42
42
  end
43
-
43
+
44
44
  ##
45
- # Add iSCSI initiator to VolumeAccessGroup
45
+ # Add iSCSI initiator(s) to VolumeAccessGroup
46
46
  #
47
47
  # Arguments:
48
- # initiator: (String)
48
+ # initiator: (String or Array)
49
49
  # group_id: (Integer)
50
50
  #
51
51
  # Require Admin credential
52
52
  #
53
53
  def vag_add_initiator(initiator, group_id)
54
+ initiator = [ initiator ] if initiator.class == String
54
55
  api_call = {
55
56
  :method => "AddInitiatorsToVolumeAccessGroup",
56
57
  :params => {
57
58
  :volumeAccessGroupID => group_id,
58
- :initiators => [ initiator ]
59
+ :initiators => initiator
60
+ }
61
+ }
62
+ answer = query_sf(api_call)
63
+ return answer
64
+ end
65
+
66
+ ##
67
+ # Remove iSCSI initiator(s) from VolumeAccessGroup
68
+ #
69
+ # Arguments:
70
+ # initiator: (String or Array)
71
+ # group_id: (Integer)
72
+ #
73
+ # Require Admin credential
74
+ #
75
+ def vag_remove_initiator(initiator, group_id)
76
+ initiator = [ initiator ] if initiator.class == String
77
+ api_call = {
78
+ :method => "RemoveInitiatorsFromVolumeAccessGroup",
79
+ :params => {
80
+ :volumeAccessGroupID => group_id,
81
+ :initiators => initiator
59
82
  }
60
83
  }
61
84
  answer = query_sf(api_call)
62
85
  return answer
63
- end
86
+ end
64
87
 
65
88
  ##
66
89
  # Add Volume to VolumeAccessGroup
@@ -72,25 +95,26 @@ module VolumeAccessGroup
72
95
  # Require Admin credential
73
96
  #
74
97
  def vag_add_volume_id(volume_id, group_id)
98
+ volume_id = [ volume_id ] if volume_id.class == String
75
99
  api_call = {
76
100
  :method => "AddVolumesToVolumeAccessGroup",
77
101
  :params => {
78
102
  :volumeAccessGroupID => group_id,
79
- :volumes => [ volume_id ]
103
+ :volumes => volume_id
80
104
  }
81
105
  }
82
106
  answer = query_sf(api_call)
83
107
  return answer
84
- end
85
-
108
+ end
109
+
86
110
  ##
87
111
  # Add Volume to VolumeAccessGroup using names
88
112
  #
89
113
  #
90
114
  def vag_add_volume(volume_name, vag_name)
91
- volume_id = volumes_list().select {|s| s["name"] == volume_name }.first["volumeID"]
115
+ volume_id = volumes_list(name: volume_name).first["volumeID"]
92
116
  vag_id = vag_list().select {|s| s["name"] == vag_name }.first["volumeAccessGroupID"]
93
117
  vag_add_volume_id(volume_id, vag_id)
94
118
  end
95
-
119
+
96
120
  end
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.12
4
+ version: 0.1.0
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: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler