stoarray 0.0.1 → 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: e616c083bad446dea88b8f3d71991e75a9432c2b
4
- data.tar.gz: 03bf4f4add6a12a951644e83452d923fee3553ff
3
+ metadata.gz: a7d21238eeab121c6b16db40cef11da6eeabba05
4
+ data.tar.gz: 33ea290c4163b4675cba2c1ea6e522b8a8812893
5
5
  SHA512:
6
- metadata.gz: 21c60fade6d3203cc142d0b6b55fccbf9acd0cf9949e203771aec4bbdfe901a5a089106581204fb8f15db9c6dd7c867833ab5a7f763f81652f1efcee1bf6400e
7
- data.tar.gz: fae4807504694e38208efda4e0993f3986933944d05e6a9a4400252c5e356bf3ce9f97791cc3a1943fb7e339492685b8ce1aed9890e0d2caf6538b199706ed5f
6
+ metadata.gz: 385a3ccc6f2f69be5e63a489d61a5037a1d0d0176207b2df19479b5399de3d1c00d5e8b8e053339ef64a872910a89db1e235d2a43a14a5649df3e8728aeabcfc
7
+ data.tar.gz: b37bf21898851ed4b22c7bba53a83b1439a6c7ba3e68e0f2170ed65e20e02ee2e15d0c2c93ddabab81e35cecca798a6ca3938c2dd6218d72067bc3c21b3689a5
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ /Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.1.2
@@ -0,0 +1,46 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating
5
+ documentation, submitting pull requests or patches, and other activities.
6
+
7
+ We are committed to making participation in this project a harassment-free
8
+ experience for everyone, regardless of level of experience, gender, gender
9
+ identity and expression, sexual orientation, disability, personal appearance,
10
+ body size, race, ethnicity, age, religion, or nationality.
11
+
12
+ Examples of unacceptable behavior by participants include:
13
+
14
+ * The use of sexualized language or imagery
15
+ * Personal attacks
16
+ * Trolling or insulting/derogatory comments
17
+ * Public or private harassment
18
+ * Publishing other's private information, such as physical or electronic
19
+ addresses, without explicit permission
20
+ * Other unethical or unprofessional conduct
21
+
22
+ Project maintainers have the right and responsibility to remove, edit, or
23
+ reject comments, commits, code, wiki edits, issues, and other contributions
24
+ that are not aligned to this Code of Conduct, or to ban temporarily or
25
+ permanently any contributor for other behaviors that they deem inappropriate,
26
+ threatening, offensive, or harmful.
27
+
28
+ By adopting this Code of Conduct, project maintainers commit themselves to
29
+ fairly and consistently applying these principles to every aspect of managing
30
+ this project. Project maintainers who do not follow or enforce the Code of
31
+ Conduct may be permanently removed from the project team.
32
+
33
+ This code of conduct applies both within project spaces and in public spaces
34
+ when an individual is representing the project or its community.
35
+
36
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
37
+ reported by contacting a project maintainer at kodywilson@gmail.com. All
38
+ complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an
39
+ incident.
40
+
41
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
42
+ version 1.3.0, available at
43
+ [http://contributor-covenant.org/version/1/3/0/][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stoarray.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kody
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,149 @@
1
+ stoarray
2
+ ========
3
+
4
+ Library for making api calls to storage arrays with Ruby
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'stoarray'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install stoarray
21
+
22
+ ## Usage
23
+
24
+ In your script:
25
+
26
+ require 'stoarray'
27
+
28
+ EMC's Xtremio and Pure's storage arrays are currently supported.
29
+
30
+ Both api's use json for parameters and my examples below follow suit.
31
+ I prefer to set variables that will not change in a json configuration file.
32
+ It is very easy to then build from there.
33
+
34
+ Examples using Pure:
35
+ --------------------
36
+
37
+ ###First the json configuration file:
38
+ {
39
+ "authorization":"123li123o90yourapitoken2h1hi3",
40
+ "base_url":"https://purearray01/api/1.4/",
41
+ "headers": { "Content-Type": "application/json" },
42
+ "newhost": "testsrv01",
43
+ "new_luns_testsrv01": [
44
+ "testsrv01_u23_1_src",
45
+ "testsrv01_u23_2_src",
46
+ "testsrv01_u23_3_src",
47
+ "testsrv01_u23_4_src",
48
+ "testsrv01_u23_5_src"
49
+ ],
50
+ "params_host_testsrv01": {
51
+ "wwnlist": [
52
+ "10:00:00:00:C1:A3:BG:16",
53
+ "10:00:00:00:C1:A3:BG:17"
54
+ ]
55
+ }
56
+ }
57
+
58
+ The top three likely will not change between api calls.
59
+ authorization - This is your api token.
60
+ base_url - URL for your array and api
61
+ headers - Pass the content type (JSON in this case)
62
+
63
+ ###Back to your script, after the require 'stoarray'
64
+
65
+ # Location of json configuration file and api token
66
+ conf = JSON.parse(File.read('/Users/yourid/pure.json'))
67
+ token = conf['authorization']
68
+
69
+ Pure uses cookies. You get one with your api token and then it uses the cookie
70
+ while your session persists (30 mins max unless you destroy it early).
71
+
72
+ # Get a cookie for our session
73
+ url = conf['base_url'] + 'auth/session'
74
+ headers = conf['headers']
75
+ params = { api_token: token }
76
+ cookies = Stoarray.new(headers: headers, meth: 'Post', params: params, url: url).cookie
77
+
78
+ # After we get a cookie, update headers to include it
79
+ headers['Cookie'] = cookies
80
+
81
+ Now we will send application type json and the cookie with each call.
82
+
83
+ # Create host and set list of WWN's
84
+ params = conf['params_host_testsrv01']
85
+ url_host = conf['base_url'] + 'host/' + conf['newhost']
86
+ host = Stoarray.new(headers: headers, meth: 'Post', params: params, url: url_host).host
87
+ puts host['response']
88
+
89
+ # Create volumes and map them to new host
90
+ conf['new_luns_testsrv01'].each do |vol|
91
+ url_vol = conf['base_url'] + 'volume/' + vol
92
+ voly = Stoarray.new(headers: headers, meth: 'Post', params: { :size => "10G" }, url: url_vol).volume
93
+ puts JSON.parse(voly.body) if verbose == true
94
+ url_map = url_host + '/volume/' + vol
95
+ mappy = Stoarray.new(headers: headers, meth: 'Post', params: {}, url: url_map).host
96
+ puts mappy['response'] if verbose == true
97
+ end
98
+
99
+ In this example, you end up with a new host on the array, named testsrv01, including WWN's, and 5 10GB volumes mapped to the host.
100
+
101
+ ###Now for Xtremio, json first:
102
+ {
103
+ "base_url":"https://xmsserver01/api/json/v2/types/",
104
+ "headers": {
105
+ "Content-Type": "application/json",
106
+ "authorization":"Basic alsdkjfsldakjflkdsjflkasdj=="
107
+ },
108
+ "params_refresh_u04": {
109
+ "cluster-id": "xtrmcluster01",
110
+ "from-consistency-group-id": "x0319t186_u04_src",
111
+ "to-snapshot-set-id": "x0319t186_u04_des"
112
+ }
113
+ }
114
+
115
+ base_url - URL for your array and api
116
+ headers - Content type and authorization
117
+ authorization - "Basic 'Base64 hash of your username and password'"
118
+
119
+ ###Now for your script - this one does a clone refresh
120
+
121
+ #!/usr/bin/env ruby
122
+
123
+ require 'stoarray'
124
+
125
+ # Location of json configuration file
126
+ conf = JSON.parse(File.read('/path/to/config/file/xtremioclone.json'))
127
+
128
+ headers = conf['headers']
129
+
130
+ # Refresh the snap set
131
+ url = conf['base_url'] + 'snapshots'
132
+ params = conf['params_refresh_u04']
133
+ refresh = Stoarray.new(headers: headers, meth: 'Post', params: params, url: url).refresh
134
+ puts "Status: " + refresh['status'].to_s
135
+ puts "Response: " + refresh['response'].to_s
136
+
137
+ ## Development
138
+
139
+ 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.
140
+
141
+ To install this gem onto your local machine, run `bundle exec rake install` or follow the instructions at the top of the readme.
142
+
143
+ ## Contributing
144
+
145
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kodywilson/stoarray. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
146
+
147
+ ## License
148
+
149
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "testy"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/arraycalls.rb CHANGED
@@ -34,7 +34,7 @@ class Stoarray
34
34
  "ERROR: Wrong url for the #{method_name} method.\n"\
35
35
  "Sent: #{url}\n"\
36
36
  "Expected: \"#{wanted}\" as part of the url.",
37
- "status" => "DORKED!"
37
+ "status" => 400
38
38
  }
39
39
  end
40
40
 
@@ -65,17 +65,21 @@ class Stoarray
65
65
  case @url.to_s
66
66
  when /snapshot/ # Xtremio
67
67
  @call.body = flippy(JSON.parse(@call.body)).to_json
68
+ refreshy = @request.start { |http| http.request(@call) }
69
+ responder(refreshy)
68
70
  when /volume/ # Pure, handle the interim snap automagically
69
71
  # obviously not implemented yet :)
72
+ refreshy = @request.start { |http| http.request(@call) }
73
+ responder(refreshy)
74
+ else
75
+ error_text("refresh", @url.to_s, "snapshot or volume")
70
76
  end
71
- refreshy = @request.start { |http| http.request(@call) }
72
- responder(refreshy)
73
77
  end
74
78
 
75
79
  def responder(response) # combine into one method? with error_text
76
80
  response = {
77
81
  "response" => JSON.parse(response.body),
78
- "status" => response.code
82
+ "status" => response.code.to_i
79
83
  }
80
84
  end
81
85
 
@@ -0,0 +1,3 @@
1
+ class Stoarray
2
+ VERSION = "0.1.0"
3
+ end
data/stoarray.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stoarray/version'
5
+ dev_deps = %w{bundler coveralls guard guard-rspec pry pry-nav pry-remote rake rspec}
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "stoarray"
9
+ spec.version = Stoarray::VERSION
10
+ spec.date = "2015-12-28"
11
+ spec.authors = ["Kody Wilson"]
12
+ spec.email = ["kodywilson@gmail.com"]
13
+ spec.summary = %q{Storage array Ruby sdk}
14
+ spec.description = %q{Interact with storage array api using Ruby}
15
+ spec.homepage = "https://github.com/kodywilson/stoarray"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ dev_deps.each do |deppy|
24
+ spec.add_development_dependency deppy
25
+ end
26
+
27
+ end
metadata CHANGED
@@ -1,23 +1,164 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stoarray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kody Wilson
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-nav
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-remote
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
13
139
  description: Interact with storage array api using Ruby
14
- email: kodywilson@gmail.com
140
+ email:
141
+ - kodywilson@gmail.com
15
142
  executables: []
16
143
  extensions: []
17
144
  extra_rdoc_files: []
18
145
  files:
146
+ - ".coveralls.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
150
+ - CODE_OF_CONDUCT.md
151
+ - Gemfile
152
+ - Guardfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - bin/console
157
+ - bin/setup
19
158
  - lib/arraycalls.rb
20
159
  - lib/stoarray.rb
160
+ - lib/stoarray/version.rb
161
+ - stoarray.gemspec
21
162
  homepage: https://github.com/kodywilson/stoarray
22
163
  licenses:
23
164
  - MIT
@@ -38,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
179
  version: '0'
39
180
  requirements: []
40
181
  rubyforge_project:
41
- rubygems_version: 2.4.8
182
+ rubygems_version: 2.5.1
42
183
  signing_key:
43
184
  specification_version: 4
44
185
  summary: Storage array Ruby sdk