stoarray 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -38
- data/lib/arraycalls.rb +75 -5
- data/lib/stoarray/version.rb +1 -1
- data/stoarray.gemspec +4 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53326d24d57ffb7ff0dfb2d411eba1a8ef69e4a
|
4
|
+
data.tar.gz: 403071201cf86e546061ca8803cd2c7be16fc357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0b004540bc61a3bd412b1b480c056bcfadf70b84ead88fffe33c6d0e7b7eb3628ae9d0c8332c33a6045c8cbfc7b426685eb997ae22c9d583b846dc81893a0ca
|
7
|
+
data.tar.gz: f073c3e361096a7a1752ccf4b3c32b2428d8553339a6d3dfd8b03c892242a9fe84d860f3e1d3755d487d9f5d3fa0d01cf777ecccd24355c1fc64924a5cc35d72
|
data/README.md
CHANGED
@@ -19,7 +19,9 @@ And then execute:
|
|
19
19
|
|
20
20
|
In your script:
|
21
21
|
|
22
|
-
|
22
|
+
```ruby
|
23
|
+
require 'stoarray'
|
24
|
+
```
|
23
25
|
|
24
26
|
EMC's Xtremio and Pure's storage arrays are currently supported.
|
25
27
|
|
@@ -27,41 +29,46 @@ Both api's use json for parameters and the examples below follow suit.
|
|
27
29
|
I prefer to set variables that will not change in a json configuration file.
|
28
30
|
It is very easy to then build from there.
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
## Clone refresh using Pure
|
33
|
+
---------------------------
|
32
34
|
|
33
35
|
###First the json configuration file:
|
36
|
+
|
34
37
|
{
|
35
38
|
"authorization":"123li123o90yourapitoken2h1hi3",
|
36
|
-
"base_url":"https
|
39
|
+
"base_url":"https:///purearray01.something.net/api/1.4/",
|
37
40
|
"headers": { "Content-Type": "application/json" },
|
38
|
-
"
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
"10:00:00:00:C1:A3:BG:17"
|
50
|
-
]
|
41
|
+
"params_snap_u23": {
|
42
|
+
"snap_pairs": {
|
43
|
+
"x0319t186_u23_1_src": "x0319t186_u23_1_des",
|
44
|
+
"x0319t186_u23_2_src": "x0319t186_u23_2_des",
|
45
|
+
"x0319t186_u23_3_src": "x0319t186_u23_3_des",
|
46
|
+
"x0319t186_u23_4_src": "x0319t186_u23_4_des",
|
47
|
+
"x0319t186_u23_5_src": "x0319t186_u23_5_des"
|
48
|
+
},
|
49
|
+
"source": [
|
50
|
+
"x0319t186u23"
|
51
|
+
]
|
51
52
|
}
|
52
53
|
}
|
53
54
|
|
54
55
|
The top three likely will not change between api calls.
|
55
56
|
|
56
57
|
+ authorization - This is your api token.
|
57
|
-
+ base_url - URL for your array and api
|
58
|
+
+ base_url - URL for your array and api version
|
58
59
|
+ headers - Pass the content type (JSON in this case)
|
59
60
|
|
61
|
+
These are what you need to set for clone refreshes. In this example,
|
62
|
+
they are nested under "params_snap_u23".
|
63
|
+
|
64
|
+
+ snap_pairs - Map source volume(s) to target volume(s).
|
65
|
+
+ source - This is the name of the source protection group.
|
66
|
+
|
60
67
|
###Back to your script, after the require 'stoarray'
|
61
68
|
|
62
69
|
```ruby
|
63
70
|
# Location of json configuration file and api token
|
64
|
-
conf = JSON.parse(File.read('/
|
71
|
+
conf = JSON.parse(File.read('/Some/path/pure.json'))
|
65
72
|
token = conf['authorization']
|
66
73
|
```
|
67
74
|
|
@@ -69,7 +76,7 @@ Pure uses cookies. You trade one for your api token and then you can use the coo
|
|
69
76
|
while your session persists (30 minute inactivity timeout, unless you destroy it early).
|
70
77
|
|
71
78
|
```ruby
|
72
|
-
# Get a cookie for our session
|
79
|
+
# Get a cookie for our session - required by Pure.
|
73
80
|
url = conf['base_url'] + 'auth/session'
|
74
81
|
headers = conf['headers']
|
75
82
|
params = { api_token: token }
|
@@ -82,27 +89,19 @@ headers['Cookie'] = cookies
|
|
82
89
|
Now we will send application type json and the cookie with each call.
|
83
90
|
|
84
91
|
```ruby
|
85
|
-
#
|
86
|
-
params
|
87
|
-
|
88
|
-
|
89
|
-
puts
|
90
|
-
|
91
|
-
# Create volumes and map them to new host
|
92
|
-
conf['new_luns_testsrv01'].each do |vol|
|
93
|
-
url_vol = conf['base_url'] + 'volume/' + vol
|
94
|
-
voly = Stoarray.new(headers: headers, meth: 'Post', params: { :size => "10G" }, url: url_vol).volume
|
95
|
-
puts JSON.parse(voly.body) if verbose == true
|
96
|
-
url_map = url_host + '/volume/' + vol
|
97
|
-
mappy = Stoarray.new(headers: headers, meth: 'Post', params: {}, url: url_map).host
|
98
|
-
puts mappy['response'] if verbose == true
|
99
|
-
end
|
100
|
-
|
92
|
+
# Now refresh the clones
|
93
|
+
params = conf['params_snap_u23']
|
94
|
+
refresh = Stoarray.new(headers: headers, meth: 'Post', params: params, url: conf['base_url']).refresh
|
95
|
+
puts "Status: " + refresh['status'].to_s
|
96
|
+
puts "Response: " + refresh['response'].to_s
|
101
97
|
```
|
102
98
|
|
103
|
-
In the above example,
|
99
|
+
In the above example, the source protection group is first snapped.
|
100
|
+
Next, each target volume is overwritten with the source snapshot (snap_pairs).
|
101
|
+
Any error along the way will cause the gem to return all status codes
|
102
|
+
and all array responses. Success gives a 201, SUCCESS.
|
104
103
|
|
105
|
-
|
104
|
+
## Xtremio clone refresh, json first
|
106
105
|
{
|
107
106
|
"base_url":"https://xmsserver01/api/json/v2/types/",
|
108
107
|
"headers": {
|
@@ -140,6 +139,11 @@ puts "Status: " + refresh['status'].to_s
|
|
140
139
|
puts "Response: " + refresh['response'].to_s
|
141
140
|
```
|
142
141
|
|
142
|
+
## Troubleshooting
|
143
|
+
|
144
|
+
error 307 - Enter fully qualified domain name (FQDN) for the array to fix.
|
145
|
+
purearray01.something.net instead of just purearray01
|
146
|
+
|
143
147
|
## Development
|
144
148
|
|
145
149
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/arraycalls.rb
CHANGED
@@ -79,18 +79,88 @@ class Stoarray
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
def pgroup
|
83
|
+
if @url.to_s =~ /pgroup/
|
84
|
+
response = @request.start { |http| http.request(@call) }
|
85
|
+
responder(response)
|
86
|
+
else
|
87
|
+
error_text("pgroup", @url.to_s, "pgroup")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
82
91
|
def refresh
|
83
92
|
case @url.to_s
|
84
93
|
when /snapshot/ # Xtremio
|
85
94
|
@call.body = flippy(JSON.parse(@call.body)).to_json
|
86
95
|
refreshy = @request.start { |http| http.request(@call) }
|
87
96
|
responder(refreshy)
|
88
|
-
when /
|
89
|
-
|
90
|
-
|
91
|
-
|
97
|
+
when /1.4/ # Pure, handle the interim snap automagically
|
98
|
+
error_state = false
|
99
|
+
url = 'https://' + @url.host + '/api/1.4/pgroup'
|
100
|
+
source = (JSON.parse(@call.body))['source']
|
101
|
+
suffix = Time.new.strftime("%A") # Day of the week.
|
102
|
+
pam = { :snap => true, :source => source, :suffix => suffix }
|
103
|
+
snap = Stoarray.new(headers: @headers, meth: 'Post', params: pam, url: url).pgroup
|
104
|
+
respond = {
|
105
|
+
"response" => {
|
106
|
+
"snap" => {
|
107
|
+
"response" => snap['response']
|
108
|
+
}
|
109
|
+
},
|
110
|
+
"status" => {
|
111
|
+
"snap" => {
|
112
|
+
"status" => snap['status']
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
if snap['status'] >= 200 && snap['status'] <= 299
|
117
|
+
pairs = (JSON.parse(@call.body))['snap_pairs']
|
118
|
+
pairs.each do |key, val|
|
119
|
+
tgt = 'clone_' + val
|
120
|
+
src = source[0] + '.' + suffix + '.' + key
|
121
|
+
pam = { :overwrite => true, :source => src }
|
122
|
+
url = 'https://' + @url.host + '/api/1.4/volume/' + val
|
123
|
+
clone = Stoarray.new(headers: @headers, meth: 'Post', params: pam, url: url).volume
|
124
|
+
respond['response'][tgt] = {
|
125
|
+
"response" => clone['response']
|
126
|
+
}
|
127
|
+
respond['status'][tgt] = {
|
128
|
+
"status" => clone['status']
|
129
|
+
}
|
130
|
+
end
|
131
|
+
url = 'https://' + @url.host + '/api/1.4/pgroup/' + source[0] + '.' + suffix
|
132
|
+
zappy = Stoarray.new(headers: @headers, meth: 'Delete', params: {}, url: url).pgroup
|
133
|
+
respond['response']['destroy'] = {
|
134
|
+
"response" => zappy['response']
|
135
|
+
}
|
136
|
+
respond['status']['destroy'] = {
|
137
|
+
"status" => zappy['status']
|
138
|
+
}
|
139
|
+
pam = { :eradicate => true }
|
140
|
+
disintegrate = Stoarray.new(headers: @headers, meth: 'Delete', params: pam, url: url).pgroup
|
141
|
+
respond['response']['eradicate'] = {
|
142
|
+
"response" => disintegrate['response']
|
143
|
+
}
|
144
|
+
respond['status']['eradicate'] = {
|
145
|
+
"status" => disintegrate['status']
|
146
|
+
}
|
147
|
+
else
|
148
|
+
respond
|
149
|
+
end
|
150
|
+
respond['status'].each do |key, val|
|
151
|
+
error_state = true if val.any? { |status, code| code.to_i < 200 || code.to_i > 299 }
|
152
|
+
end
|
153
|
+
if error_state == true
|
154
|
+
respond
|
155
|
+
else
|
156
|
+
response = {
|
157
|
+
"response" =>
|
158
|
+
"SUCCESS: Refresh completed for #{source[0]} protection group.\n",
|
159
|
+
"status" => 201
|
160
|
+
}
|
161
|
+
end
|
92
162
|
else
|
93
|
-
error_text("refresh", @url.to_s, "snapshot or
|
163
|
+
error_text("refresh", @url.to_s, "snapshot or 1.4")
|
94
164
|
end
|
95
165
|
end
|
96
166
|
|
data/lib/stoarray/version.rb
CHANGED
data/stoarray.gemspec
CHANGED
@@ -7,7 +7,7 @@ dev_deps = %w{bundler coveralls guard guard-rspec pry pry-nav pry-remote rake rs
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "stoarray"
|
9
9
|
spec.version = Stoarray::VERSION
|
10
|
-
spec.date = "
|
10
|
+
spec.date = "2016-02-02"
|
11
11
|
spec.authors = ["Kody Wilson"]
|
12
12
|
spec.email = ["kodywilson@gmail.com"]
|
13
13
|
spec.summary = %q{Storage array Ruby sdk}
|
@@ -15,6 +15,9 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = "https://github.com/kodywilson/stoarray"
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
18
|
+
# This gem will work with 2.0.0 or greater...
|
19
|
+
spec.required_ruby_version = '>= 2.0.0'
|
20
|
+
|
18
21
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
22
|
spec.bindir = "exe"
|
20
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stoarray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kody Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
171
|
requirements:
|
172
172
|
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version:
|
174
|
+
version: 2.0.0
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - ">="
|