stoarray 0.0.1
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 +7 -0
- data/lib/arraycalls.rb +100 -0
- data/lib/stoarray.rb +7 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e616c083bad446dea88b8f3d71991e75a9432c2b
|
4
|
+
data.tar.gz: 03bf4f4add6a12a951644e83452d923fee3553ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21c60fade6d3203cc142d0b6b55fccbf9acd0cf9949e203771aec4bbdfe901a5a089106581204fb8f15db9c6dd7c867833ab5a7f763f81652f1efcee1bf6400e
|
7
|
+
data.tar.gz: fae4807504694e38208efda4e0993f3986933944d05e6a9a4400252c5e356bf3ce9f97791cc3a1943fb7e339492685b8ce1aed9890e0d2caf6538b199706ed5f
|
data/lib/arraycalls.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
class Stoarray
|
2
|
+
|
3
|
+
VERBS = {
|
4
|
+
'get' => Net::HTTP::Get,
|
5
|
+
'post' => Net::HTTP::Post,
|
6
|
+
'put' => Net::HTTP::Put,
|
7
|
+
'delete' => Net::HTTP::Delete
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(headers: {}, meth: 'Get', params: {}, url: 'https://array/')
|
11
|
+
@url = URI.parse(url) # URL of the call
|
12
|
+
@headers = headers
|
13
|
+
@call = VERBS[meth.downcase].new(@url.path, initheader = @headers)
|
14
|
+
@call.body = params.to_json # Pure and Xtremio expect json parameters
|
15
|
+
@request = Net::HTTP.new(@url.host, @url.port)
|
16
|
+
@request.read_timeout = 30
|
17
|
+
@request.use_ssl = true if @url.to_s =~ /https/
|
18
|
+
@request.verify_mode = OpenSSL::SSL::VERIFY_NONE # parameterize?
|
19
|
+
end
|
20
|
+
|
21
|
+
def cookie
|
22
|
+
@response = @request.start { |http| http.request(@call) }
|
23
|
+
all_cookies = @response.get_fields('set-cookie')
|
24
|
+
cookies_array = Array.new
|
25
|
+
all_cookies.each { | cookie |
|
26
|
+
cookies_array.push(cookie.split('; ')[0])
|
27
|
+
}
|
28
|
+
cookies = cookies_array.join('; ')
|
29
|
+
end
|
30
|
+
|
31
|
+
def error_text(method_name, url, wanted)
|
32
|
+
response = {
|
33
|
+
"response" =>
|
34
|
+
"ERROR: Wrong url for the #{method_name} method.\n"\
|
35
|
+
"Sent: #{url}\n"\
|
36
|
+
"Expected: \"#{wanted}\" as part of the url.",
|
37
|
+
"status" => "DORKED!"
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def flippy(temp_hash)
|
42
|
+
flippy = temp_hash['to-snapshot-set-id'] + '_347'
|
43
|
+
url = 'https://sa0319xms01/api/json/v2/types/snapshot-sets'
|
44
|
+
x = Stoarray.new(headers: @headers, meth: 'Get', params: {}, url: url).snap
|
45
|
+
if x['response']['snapshot-sets'].any? { |y| y['name'].include?(flippy) }
|
46
|
+
temp_hash['snapshot-set-name'] = temp_hash['to-snapshot-set-id']
|
47
|
+
temp_hash['to-snapshot-set-id'] = flippy
|
48
|
+
else
|
49
|
+
temp_hash['snapshot-set-name'] = flippy
|
50
|
+
end
|
51
|
+
temp_hash['no-backup'] = true
|
52
|
+
temp_hash
|
53
|
+
end
|
54
|
+
|
55
|
+
def host
|
56
|
+
if @url.to_s =~ /host/
|
57
|
+
response = @request.start { |http| http.request(@call) }
|
58
|
+
responder(response)
|
59
|
+
else
|
60
|
+
error_text("host", @url.to_s, "host")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def refresh
|
65
|
+
case @url.to_s
|
66
|
+
when /snapshot/ # Xtremio
|
67
|
+
@call.body = flippy(JSON.parse(@call.body)).to_json
|
68
|
+
when /volume/ # Pure, handle the interim snap automagically
|
69
|
+
# obviously not implemented yet :)
|
70
|
+
end
|
71
|
+
refreshy = @request.start { |http| http.request(@call) }
|
72
|
+
responder(refreshy)
|
73
|
+
end
|
74
|
+
|
75
|
+
def responder(response) # combine into one method? with error_text
|
76
|
+
response = {
|
77
|
+
"response" => JSON.parse(response.body),
|
78
|
+
"status" => response.code
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def snap
|
83
|
+
if @url.to_s =~ /snapshot/
|
84
|
+
response = @request.start { |http| http.request(@call) }
|
85
|
+
responder(response)
|
86
|
+
else
|
87
|
+
error_text("snap", @url.to_s, "snapshot")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def volume
|
92
|
+
if @url.to_s =~ /volume/
|
93
|
+
response = @request.start { |http| http.request(@call) }
|
94
|
+
responder(response)
|
95
|
+
else
|
96
|
+
error_text("volume", @url.to_s, "volume")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
data/lib/stoarray.rb
ADDED
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stoarray
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kody Wilson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Interact with storage array api using Ruby
|
14
|
+
email: kodywilson@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/arraycalls.rb
|
20
|
+
- lib/stoarray.rb
|
21
|
+
homepage: https://github.com/kodywilson/stoarray
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.8
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Storage array Ruby sdk
|
45
|
+
test_files: []
|