purest 1.0.5 → 1.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 +86 -13
- data/lib/purest.rb +2 -2
- data/lib/purest/physical_array.rb +3 -3
- data/lib/purest/pod.rb +35 -0
- data/lib/purest/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b9bc40dfa4b5fa4f92dc47d2aa2baf3cbeffd38b9434a991e662baad326ead
|
4
|
+
data.tar.gz: 73f43e4915de161ed262dcea5726f23591bda7981c55352ffe3775a4d7627166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c507950e26c18e36e6c987015cdf5e274c7dcb7d160d7dccb6d4459696dad65897bf122bac75a9d03362a2c5dc149271e86ce81aa16752b1cfca8c43215f015
|
7
|
+
data.tar.gz: fadd1f0cb52a565eabe0be8e68149d65b1b6643c19453deb321a0c16da68877ae6513e4ccc1a72a2fb311eda887be7f17a5f4b24e658973ad7bcc5ef661e4d42
|
data/README.md
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
A simple to use library for Ruby, inspired by the WeAreFarmGeek's Diplomat gem (seriously, those guys are awesome), allowing for easy interaction with Pure Storage's FlashArray REST API.
|
4
4
|
|
5
5
|
## Disclaimer
|
6
|
-
This started as
|
6
|
+
This started as a labor of love/learning exercise, and sort of blossomed into this. That being said, it means a few things:
|
7
7
|
|
8
8
|
1) I may have made some stupid mistakes in here, if so..so be it. Raise them in issues or submit PRs, and I'll gladly fix/merge if I feel the code submitted carries the spirit of my little project. Odds are I won't reject a PR unless you try to rewrite everything for some obtuse reason I don't agree with.
|
9
9
|
|
10
|
-
2) I am not
|
10
|
+
2) I am not an employee of Pure Storage, just a random nerd.
|
11
11
|
|
12
|
-
3) While all of the classes exist, currently only up to API version 1.
|
12
|
+
3) While all of the classes exist, currently only up to API version 1.16 is 'officially' supported- meaning it may work on newer versions, but I can't verify since I've only been able to develop against versions 1.16 and lower.
|
13
13
|
|
14
14
|
Table of contents
|
15
15
|
=================
|
@@ -17,6 +17,7 @@ Table of contents
|
|
17
17
|
<!--ts-->
|
18
18
|
* [Requirements](#requirements)
|
19
19
|
* [Installation](#installation)
|
20
|
+
* [Authentication](#authentication)
|
20
21
|
* [Configuration](#configuration)
|
21
22
|
* [Usage](#usage)
|
22
23
|
* [Alerts](#alerts)
|
@@ -31,6 +32,7 @@ Table of contents
|
|
31
32
|
* [Messages](#messages)
|
32
33
|
* [Network](#network)
|
33
34
|
* [Physical Arrays](#physical-arrays)
|
35
|
+
* [Pods](#pod)
|
34
36
|
* [Ports](#port)
|
35
37
|
* [Protection Groups](#protection-groups)
|
36
38
|
* [SNMP](#snmp)
|
@@ -38,11 +40,12 @@ Table of contents
|
|
38
40
|
* [Users](#users)
|
39
41
|
* [Volumes](#volumes)
|
40
42
|
* [Specs](#specs)
|
43
|
+
* [License](#license)
|
41
44
|
<!--te-->
|
42
45
|
|
43
46
|
## Requirements
|
44
47
|
|
45
|
-
To be captain obvious, this does require you have access to a Pure Storage
|
48
|
+
To be captain obvious, this does require you have access to a Pure Storage FlashArray.
|
46
49
|
|
47
50
|
This library requires you use Ruby 2.3 or above.
|
48
51
|
|
@@ -52,7 +55,7 @@ gem install purest
|
|
52
55
|
```
|
53
56
|
|
54
57
|
## Authentication
|
55
|
-
Purest allows you to authenticate using two different methods, either username and password OR using your API key (you don't need both). See "
|
58
|
+
Purest allows you to authenticate using two different methods, either username and password OR using your API key (you don't need both). See "Configuration" below for examples. We recommend using the API key method as it is - slightly - more secure.
|
56
59
|
|
57
60
|
## Configuration
|
58
61
|
There are now two ways to configure Purest, the first is directly in your ruby code like so:
|
@@ -61,11 +64,23 @@ require 'purest'
|
|
61
64
|
|
62
65
|
Purest.configure do |config|
|
63
66
|
config.api_key = '1234-567-89'
|
64
|
-
config.api_version = '1.
|
67
|
+
config.api_version = '1.16'
|
65
68
|
config.options = {ssl: { verify: true }}
|
66
|
-
config.password = 'password'
|
67
69
|
config.url = "https://purehost.yourdomain.com"
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
or with the user credentials method:
|
74
|
+
|
75
|
+
```rb
|
76
|
+
require 'purest'
|
77
|
+
|
78
|
+
Purest.configure do |config|
|
68
79
|
config.username = 'api-enabled-user'
|
80
|
+
config.password = 'password'
|
81
|
+
config.api_version = '1.16'
|
82
|
+
config.options = {ssl: { verify: true }}
|
83
|
+
config.url = "https://purehost.yourdomain.com"
|
69
84
|
end
|
70
85
|
```
|
71
86
|
|
@@ -73,10 +88,20 @@ The second method is to create a .purest.yaml file in your home directory (~/.pu
|
|
73
88
|
```yaml
|
74
89
|
---
|
75
90
|
api_key: '1234-567-89'
|
76
|
-
api_version: '1.
|
77
|
-
password: 'password'
|
91
|
+
api_version: '1.16'
|
78
92
|
url: 'https://purehost.yourdomain.com'
|
93
|
+
options:
|
94
|
+
ssl:
|
95
|
+
verify: true
|
96
|
+
```
|
97
|
+
or with the user credentials method:
|
98
|
+
|
99
|
+
```yaml
|
100
|
+
---
|
79
101
|
username: 'api-enabled-user'
|
102
|
+
password: 'password'
|
103
|
+
api_version: '1.16'
|
104
|
+
url: 'https://purehost.yourdomain.com'
|
80
105
|
options:
|
81
106
|
ssl:
|
82
107
|
verify: true
|
@@ -89,11 +114,11 @@ First: Authentication and session management are handled behind the scenes, you
|
|
89
114
|
|
90
115
|
Second: The various class methods of this gem turn the provided options into HTTP parameters, and are
|
91
116
|
named accordingly. For instance, ```Purest::Volume.get({:snap: true})``` translates
|
92
|
-
to http://purehost.yourdomain.com/api/1.
|
117
|
+
to http://purehost.yourdomain.com/api/1.16/volume?snap=true. For a full list
|
93
118
|
of options for a given class, Pure provides good documentation at:
|
94
119
|
https://purehost.yourdomain.com/static/0/help/rest/.
|
95
120
|
|
96
|
-
Below I'll provide a large group of examples
|
121
|
+
Below I'll provide a large group of examples but I won't be detailing every single method call with all of its possible options, for that I will again refer you to Pure's REST API docs.
|
97
122
|
|
98
123
|
# Usage
|
99
124
|
|
@@ -394,6 +419,51 @@ Disconnect the current array from a specified array:
|
|
394
419
|
Purest::PhysicalArray.delete(name: 'purehost2.yourdomain.com')
|
395
420
|
```
|
396
421
|
|
422
|
+
## Pod
|
423
|
+
Getting attributes or displaying performance metrics for pods
|
424
|
+
```ruby
|
425
|
+
# Get a list of pods and their details
|
426
|
+
Purest::Pod.get
|
427
|
+
|
428
|
+
# Show space information for each pod
|
429
|
+
Purest::Pod.get(space: true)
|
430
|
+
|
431
|
+
# Get a list of attributes for a specific pod
|
432
|
+
Purest::Pod.get(name: 'superpod')
|
433
|
+
```
|
434
|
+
|
435
|
+
Creating a new pod
|
436
|
+
```ruby
|
437
|
+
# Basic pod creation
|
438
|
+
Purest::Pod.create(name: 'superpod2')
|
439
|
+
|
440
|
+
# Create a pod with a failover preference
|
441
|
+
Purest::Pod.create(name: 'superpod2', failover_preference: ['array1'])
|
442
|
+
```
|
443
|
+
|
444
|
+
Stretching a pod to a peer array
|
445
|
+
```ruby
|
446
|
+
Purest::Pod.create(name: 'superpod2', array: 'array1')
|
447
|
+
```
|
448
|
+
|
449
|
+
Updating a pod
|
450
|
+
```ruby
|
451
|
+
Purest::Pod.update(name: 'superpod2', failover_preference: ['array2'])
|
452
|
+
```
|
453
|
+
|
454
|
+
Unstretching a pod from a peer array
|
455
|
+
```ruby
|
456
|
+
Purest::Pod.delete(name: 'superpod2', array: 'array1')
|
457
|
+
```
|
458
|
+
|
459
|
+
Deleting a pod
|
460
|
+
```ruby
|
461
|
+
Purest::Pod.delete(name: 'superpod2')
|
462
|
+
|
463
|
+
# Eradicating a pod
|
464
|
+
Purest::Pod.delete(name: 'superpod2', eradicate: true)
|
465
|
+
```
|
466
|
+
|
397
467
|
## Port
|
398
468
|
Getting information about ports, 'cause that's all you get to do
|
399
469
|
```ruby
|
@@ -628,7 +698,7 @@ url: 'https://yoursuperawesomepurehost.com'
|
|
628
698
|
|
629
699
|
There are a few ways you can execute the integration tests:
|
630
700
|
```
|
631
|
-
# This will execute against the latest API version the gem is aware of, right now that is 1.
|
701
|
+
# This will execute against the latest API version the gem is aware of, right now that is 1.16
|
632
702
|
rspec -t integration
|
633
703
|
|
634
704
|
# This will execute against a specific version
|
@@ -642,4 +712,7 @@ ALL_VERSIONS=true rspec -t integration
|
|
642
712
|
```
|
643
713
|
|
644
714
|
|
645
|
-
It is worth mentioning
|
715
|
+
It is worth mentioning that this generates a fair bit of work for your Pure array so...you've been warned. All of that being said, the integration testing is somewhat sparse at the moment.
|
716
|
+
|
717
|
+
## License
|
718
|
+
Purest is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/purest.rb
CHANGED
@@ -32,8 +32,8 @@ module Purest
|
|
32
32
|
|
33
33
|
require_libs 'rest', 'api_methods', 'configuration', 'alerts', 'app', 'cert',
|
34
34
|
'directory_service', 'dns', 'drive', 'hardware', 'host',
|
35
|
-
'host_group', 'messages', 'network', 'physical_array', '
|
36
|
-
'protection_group', 'snmp', 'subnet', 'users', 'volume'
|
35
|
+
'host_group', 'messages', 'network', 'physical_array', 'pod',
|
36
|
+
'port', 'protection_group', 'snmp', 'subnet', 'users', 'volume'
|
37
37
|
|
38
38
|
self.configuration ||= Purest::Configuration.new
|
39
39
|
|
@@ -70,9 +70,9 @@ module Purest
|
|
70
70
|
|
71
71
|
private
|
72
72
|
|
73
|
-
GET_PARAMS.each do |
|
74
|
-
define_method :"use_#{
|
75
|
-
options ? use_named_parameter(
|
73
|
+
GET_PARAMS.each do |param|
|
74
|
+
define_method :"use_#{param}" do |options|
|
75
|
+
options ? use_named_parameter(param, options[param]) : []
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
data/lib/purest/pod.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Purest
|
4
|
+
class Pod < Purest::APIMethods
|
5
|
+
@access_methods = %i[get create update delete]
|
6
|
+
|
7
|
+
GET_PARAMS = %i[action failover_preferance footprint historical
|
8
|
+
latency mediator names on pending pending_only
|
9
|
+
space].freeze
|
10
|
+
|
11
|
+
def get(options = nil)
|
12
|
+
super(options, 'pod', GET_PARAMS)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(options = nil)
|
16
|
+
if options[:array]
|
17
|
+
super(options, 'pod', "array/#{options[:array]}")
|
18
|
+
else
|
19
|
+
super(options, 'pod')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def update(options = nil)
|
24
|
+
super(options, 'pod')
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete(options = nil)
|
28
|
+
if options[:array]
|
29
|
+
super(options, 'pod', "array/#{options[:array]}")
|
30
|
+
else
|
31
|
+
super(options, 'pod')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/purest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean McKinley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/purest/messages.rb
|
187
187
|
- lib/purest/network.rb
|
188
188
|
- lib/purest/physical_array.rb
|
189
|
+
- lib/purest/pod.rb
|
189
190
|
- lib/purest/port.rb
|
190
191
|
- lib/purest/protection_group.rb
|
191
192
|
- lib/purest/rest.rb
|
@@ -213,8 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
214
|
- !ruby/object:Gem::Version
|
214
215
|
version: '0'
|
215
216
|
requirements: []
|
216
|
-
|
217
|
-
rubygems_version: 2.7.6
|
217
|
+
rubygems_version: 3.0.6
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: A ruby gem for interacting with PURE storage's REST API
|