engineyard-cloud-client 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/ChangeLog.md +5 -0
- data/README.md +4 -0
- data/lib/engineyard-cloud-client/models/app.rb +4 -0
- data/lib/engineyard-cloud-client/models/environment.rb +40 -0
- data/lib/engineyard-cloud-client/version.rb +1 -1
- data/spec/engineyard-cloud-client/integration/environment_spec.rb +82 -3
- data/spec/engineyard-cloud-client/models/app_spec.rb +1 -0
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjViMTczODE3OGU1ZTdjMTE1NTI4NmJiYmI2NmVkOGI3NTU1NzI4MQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTBiYWNjYjM1ZTc2Yjg5NDI3ZjcxYmY0ODA3Y2M5MTg5YTAxYTgxZg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjA0NDkyYjdhMWYzNjNkOWYxNDMwYzk0ODg3MGZiNGE5ZGNiZTUxMDI0YjIy
|
10
|
+
ZjQ0ODExNzQxOGE2Njk2YjZjMDk2NDY1ZGJkMTBhODZiM2ZkYzM3ZGZmOTk0
|
11
|
+
NzY4MzJmMGE0MWEzMGY2ODYyY2Q1OTljMDhkZjI4YmJhNTVjYTg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjI1M2YxYTljMGE0NGQ2MjFkZjUxOTRhNzg4NmFjMjJmODE1NTUzOTE1ODVi
|
14
|
+
ZjdkZWQ4NWVkNzgyMmJmYjdiZjEwZDdhN2MwMWQwZjQxMTljNzU0ODg2ZDcy
|
15
|
+
NGVjNzhkYzczZGExYWJlMzk2ZTZmNjJlM2VlNTUxZjkxYzRhZGE=
|
data/ChangeLog.md
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
|
5
5
|
*
|
6
6
|
|
7
|
+
## v2.1.0 (2014-04-16)
|
8
|
+
|
9
|
+
* `Environment#instances_by_role` and `Environment#select_instances` for filtering instances by role and name.
|
10
|
+
* Add `App#hierarchy_name` which returns a nice string representation of the application hierchy: `account / app`
|
11
|
+
|
7
12
|
## v2.0.1 (2013-11-21)
|
8
13
|
|
9
14
|
* Fix RbConfig deprecation warning
|
data/README.md
CHANGED
@@ -136,6 +136,10 @@ Valid `app_server_stack_name` values: `nginx_unicorn, nginx_passenger3, nginx_no
|
|
136
136
|
|
137
137
|
Instances:
|
138
138
|
|
139
|
+
# filtering by roles and roles with names
|
140
|
+
env.instances_by_role(:app_master, :app, :util) # => [EY::CloudClient::Instance, ...]
|
141
|
+
env.select_instances(util: %w[resque1 resque2 redis]) # => [EY::CloudClient::Instance, ...]
|
142
|
+
|
139
143
|
instance = env.instances.first
|
140
144
|
instance.class # => EY::CloudClient::Instance
|
141
145
|
instance.id # => 12345
|
@@ -170,6 +170,46 @@ module EY
|
|
170
170
|
bridge
|
171
171
|
end
|
172
172
|
|
173
|
+
# Select instances by role, with optional name constraints.
|
174
|
+
#
|
175
|
+
# Select the "master" app instance:
|
176
|
+
# select_instances(app_master: true)
|
177
|
+
#
|
178
|
+
# Select the "master" db instance on a solo or multi-instance env:
|
179
|
+
# select_instances(solo: true, db_master: true)
|
180
|
+
#
|
181
|
+
# Select app, app_master, or utils (only if they are named resque or redis):
|
182
|
+
# select_instances(app_master: true, app: true, util: %w[resque redis])
|
183
|
+
#
|
184
|
+
# Select all instances (same as the method #instances):
|
185
|
+
# select_instances(all: true)
|
186
|
+
#
|
187
|
+
# See #instances_by_role for a simpler interface.
|
188
|
+
def select_instances(options)
|
189
|
+
instances_by_role(options.keys).select do |inst|
|
190
|
+
# get the value of the string/symbol key that matches without losing nil/false values
|
191
|
+
val = options.fetch(inst.role.to_sym) { options.fetch(inst.role.to_s, false) }
|
192
|
+
|
193
|
+
case val
|
194
|
+
when true, false then val
|
195
|
+
when inst.name then true
|
196
|
+
when nil, '' then [nil, ''].include?(inst.name)
|
197
|
+
when Array then val.include?(inst.name)
|
198
|
+
else false
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Simple version of select_instances that only selects roles, not names
|
204
|
+
# instances_by_role(:app_master, :app) # same
|
205
|
+
# instances_by_role(%w[app_master app]) # same
|
206
|
+
# select_instances(app_master: true, app: true) # same
|
207
|
+
#
|
208
|
+
def instances_by_role(*roles)
|
209
|
+
roles = roles.flatten.map(&:to_s)
|
210
|
+
instances.select { |inst| roles.include?(inst.role.to_s) }
|
211
|
+
end
|
212
|
+
|
173
213
|
def update
|
174
214
|
api.put("/environments/#{id}/update_instances")
|
175
215
|
true # raises on failure
|
@@ -100,10 +100,12 @@ describe EY::CloudClient::Environment do
|
|
100
100
|
@env.deploy_to_instances.map(&:role).should =~ %w[app_master app util util]
|
101
101
|
end
|
102
102
|
|
103
|
+
def expect_instances(instances)
|
104
|
+
expect(instances.map { |i| [i.role, i.name, i.public_hostname] })
|
105
|
+
end
|
106
|
+
|
103
107
|
it "sorts instances" do
|
104
|
-
|
105
|
-
[i.role, i.name, i.public_hostname]
|
106
|
-
end).to eq([
|
108
|
+
expect_instances(@env.instances).to eq([
|
107
109
|
["app_master", nil, "app_master_hostname.compute-1.amazonaws.com"],
|
108
110
|
["app", nil, "app_hostname.compute-1.amazonaws.com"],
|
109
111
|
["db_master", nil, "db_master_hostname.compute-1.amazonaws.com"],
|
@@ -114,6 +116,83 @@ describe EY::CloudClient::Environment do
|
|
114
116
|
])
|
115
117
|
end
|
116
118
|
|
119
|
+
it "finds no instances by role solo" do
|
120
|
+
expect(@env.select_instances(solo: true)).to be_empty
|
121
|
+
end
|
122
|
+
|
123
|
+
it "selects instances by solo, app, app_master" do
|
124
|
+
expect_instances(@env.select_instances(solo: true, app: true, app_master: true)).to eq([
|
125
|
+
["app_master", nil, "app_master_hostname.compute-1.amazonaws.com"],
|
126
|
+
["app", nil, "app_hostname.compute-1.amazonaws.com"],
|
127
|
+
])
|
128
|
+
end
|
129
|
+
|
130
|
+
it "selects instances by solo, app, app_master, util" do
|
131
|
+
expect_instances(@env.select_instances(solo: true, app: true, app_master: true, util: true)).to eq([
|
132
|
+
["app_master", nil, "app_master_hostname.compute-1.amazonaws.com"],
|
133
|
+
["app", nil, "app_hostname.compute-1.amazonaws.com"],
|
134
|
+
["util" , "fluffy", "util_fluffy_hostname.compute-1.amazonaws.com"],
|
135
|
+
["util", "rocky", "util_rocky_hostname.compute-1.amazonaws.com"],
|
136
|
+
])
|
137
|
+
end
|
138
|
+
|
139
|
+
it "selects instances by util with name string" do
|
140
|
+
expect_instances(@env.select_instances(util: "rocky")).to eq([
|
141
|
+
["util", "rocky", "util_rocky_hostname.compute-1.amazonaws.com"],
|
142
|
+
])
|
143
|
+
end
|
144
|
+
|
145
|
+
it "selects instances by util with name array" do
|
146
|
+
expect_instances(@env.select_instances(util: %w[fluffy rocky])).to eq([
|
147
|
+
["util" , "fluffy", "util_fluffy_hostname.compute-1.amazonaws.com"],
|
148
|
+
["util", "rocky", "util_rocky_hostname.compute-1.amazonaws.com"],
|
149
|
+
])
|
150
|
+
end
|
151
|
+
|
152
|
+
it "selects instances by solo, app, or util with name string" do
|
153
|
+
expect_instances(@env.select_instances(solo: true, app: true, util: "rocky")).to eq([
|
154
|
+
["app", nil, "app_hostname.compute-1.amazonaws.com"],
|
155
|
+
["util", "rocky", "util_rocky_hostname.compute-1.amazonaws.com"],
|
156
|
+
])
|
157
|
+
end
|
158
|
+
|
159
|
+
it "selects instances by solo, db_master, db_slave" do
|
160
|
+
expect_instances(@env.select_instances(solo: true, db_master: true, db_slave: true)).to eq([
|
161
|
+
["db_master", nil, "db_master_hostname.compute-1.amazonaws.com"],
|
162
|
+
["db_slave", "Slave I", "db_slave_1_hostname.compute-1.amazonaws.com"],
|
163
|
+
["db_slave", nil, "db_slave_2_hostname.compute-1.amazonaws.com"],
|
164
|
+
])
|
165
|
+
end
|
166
|
+
|
167
|
+
it "finds instances by role solo, db_master, or db_slave with the specified name only" do
|
168
|
+
expect_instances(@env.select_instances(solo: true, db_master: true, db_slave: "Slave I")).to eq([
|
169
|
+
["db_master", nil, "db_master_hostname.compute-1.amazonaws.com"],
|
170
|
+
["db_slave", "Slave I", "db_slave_1_hostname.compute-1.amazonaws.com"],
|
171
|
+
])
|
172
|
+
end
|
173
|
+
|
174
|
+
it "finds instances by role solo, db_master, or db_slave with blank name only" do
|
175
|
+
expect_instances(@env.select_instances(solo: true, db_master: true, db_slave: "")).to eq([
|
176
|
+
["db_master", nil, "db_master_hostname.compute-1.amazonaws.com"],
|
177
|
+
["db_slave", nil, "db_slave_2_hostname.compute-1.amazonaws.com"],
|
178
|
+
])
|
179
|
+
end
|
180
|
+
|
181
|
+
it "selects instances by app, excluding app_master" do
|
182
|
+
expect_instances(@env.select_instances(app: true, app_master: false)).to eq([
|
183
|
+
["app", nil, "app_hostname.compute-1.amazonaws.com"],
|
184
|
+
])
|
185
|
+
end
|
186
|
+
|
187
|
+
it "finds solo, app, app_master, util" do
|
188
|
+
expect_instances(@env.instances_by_role(:solo, :app, :app_master, :util)).to eq([
|
189
|
+
["app_master", nil, "app_master_hostname.compute-1.amazonaws.com"],
|
190
|
+
["app", nil, "app_hostname.compute-1.amazonaws.com"],
|
191
|
+
["util" , "fluffy", "util_fluffy_hostname.compute-1.amazonaws.com"],
|
192
|
+
["util", "rocky", "util_rocky_hostname.compute-1.amazonaws.com"],
|
193
|
+
])
|
194
|
+
end
|
195
|
+
|
117
196
|
it "updates the environment" do
|
118
197
|
@env.update.should be_true
|
119
198
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-cloud-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EY Cloud Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -56,56 +56,56 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeweb
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - '>='
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - '>='
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: fakeweb-matcher
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '>='
|
87
|
+
- - ! '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - '>='
|
94
|
+
- - ! '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sinatra
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - '>='
|
101
|
+
- - ! '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - '>='
|
108
|
+
- - ! '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
@@ -140,56 +140,56 @@ dependencies:
|
|
140
140
|
name: dm-migrations
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - '>='
|
143
|
+
- - ! '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - '>='
|
150
|
+
- - ! '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: dm-aggregates
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - '>='
|
157
|
+
- - ! '>='
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - '>='
|
164
|
+
- - ! '>='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: dm-timestamps
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - '>='
|
171
|
+
- - ! '>='
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - '>='
|
178
|
+
- - ! '>='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: dm-sqlite-adapter
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - '>='
|
185
|
+
- - ! '>='
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - '>='
|
192
|
+
- - ! '>='
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
@@ -210,14 +210,14 @@ dependencies:
|
|
210
210
|
name: rabl
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- - '>='
|
213
|
+
- - ! '>='
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- - '>='
|
220
|
+
- - ! '>='
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
@@ -238,28 +238,28 @@ dependencies:
|
|
238
238
|
name: oj
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
|
-
- - '>='
|
241
|
+
- - ! '>='
|
242
242
|
- !ruby/object:Gem::Version
|
243
243
|
version: '0'
|
244
244
|
type: :development
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
|
-
- - '>='
|
248
|
+
- - ! '>='
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: pry
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
254
254
|
requirements:
|
255
|
-
- - '>='
|
255
|
+
- - ! '>='
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
|
-
- - '>='
|
262
|
+
- - ! '>='
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
265
|
description: This gem connects to the EY Cloud API
|
@@ -345,17 +345,17 @@ require_paths:
|
|
345
345
|
- lib
|
346
346
|
required_ruby_version: !ruby/object:Gem::Requirement
|
347
347
|
requirements:
|
348
|
-
- - '>='
|
348
|
+
- - ! '>='
|
349
349
|
- !ruby/object:Gem::Version
|
350
350
|
version: 1.9.3
|
351
351
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
352
352
|
requirements:
|
353
|
-
- - '>='
|
353
|
+
- - ! '>='
|
354
354
|
- !ruby/object:Gem::Version
|
355
355
|
version: '0'
|
356
356
|
requirements: []
|
357
357
|
rubyforge_project:
|
358
|
-
rubygems_version: 2.1.
|
358
|
+
rubygems_version: 2.1.10
|
359
359
|
signing_key:
|
360
360
|
specification_version: 4
|
361
361
|
summary: EY Cloud API Client
|