rhc 1.2.7 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rhc +6 -8
- data/bin/rhc-chk +23 -10
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper.rb +3 -2
- data/features/lib/rhc_helper/api.rb +7 -0
- data/features/lib/rhc_helper/app.rb +8 -10
- data/features/lib/rhc_helper/domain.rb +2 -1
- data/features/lib/rhc_helper/runnable.rb +2 -24
- data/features/sshkey.feature +3 -3
- data/features/step_definitions/cartridge_steps.rb +6 -6
- data/features/step_definitions/client_steps.rb +0 -1
- data/features/step_definitions/sshkey_steps.rb +2 -2
- data/features/support/before_hooks.rb +0 -1
- data/features/support/env.rb +5 -3
- data/lib/rhc-common.rb +1 -1
- data/lib/rhc.rb +9 -8
- data/lib/rhc/auth.rb +3 -0
- data/lib/rhc/auth/basic.rb +54 -0
- data/lib/rhc/cartridge_helpers.rb +11 -5
- data/lib/rhc/cli.rb +4 -2
- data/lib/rhc/command_runner.rb +35 -30
- data/lib/rhc/commands.rb +127 -18
- data/lib/rhc/commands/account.rb +24 -0
- data/lib/rhc/commands/alias.rb +1 -1
- data/lib/rhc/commands/app.rb +210 -209
- data/lib/rhc/commands/apps.rb +22 -0
- data/lib/rhc/commands/base.rb +10 -77
- data/lib/rhc/commands/cartridge.rb +35 -35
- data/lib/rhc/commands/domain.rb +20 -13
- data/lib/rhc/commands/git_clone.rb +30 -0
- data/lib/rhc/commands/{port-forward.rb → port_forward.rb} +3 -3
- data/lib/rhc/commands/server.rb +28 -16
- data/lib/rhc/commands/setup.rb +18 -1
- data/lib/rhc/commands/snapshot.rb +4 -4
- data/lib/rhc/commands/sshkey.rb +4 -18
- data/lib/rhc/commands/tail.rb +32 -9
- data/lib/rhc/config.rb +168 -99
- data/lib/rhc/context_helper.rb +22 -9
- data/lib/rhc/core_ext.rb +41 -1
- data/lib/rhc/exceptions.rb +21 -5
- data/lib/rhc/git_helpers.rb +81 -0
- data/lib/rhc/help_formatter.rb +21 -1
- data/lib/rhc/helpers.rb +222 -87
- data/lib/rhc/output_helpers.rb +94 -110
- data/lib/rhc/rest.rb +15 -198
- data/lib/rhc/rest/api.rb +88 -0
- data/lib/rhc/rest/application.rb +29 -30
- data/lib/rhc/rest/attributes.rb +27 -0
- data/lib/rhc/rest/base.rb +29 -33
- data/lib/rhc/rest/cartridge.rb +42 -20
- data/lib/rhc/rest/client.rb +351 -89
- data/lib/rhc/rest/domain.rb +7 -13
- data/lib/rhc/rest/gear_group.rb +1 -1
- data/lib/rhc/rest/key.rb +7 -2
- data/lib/rhc/rest/mock.rb +609 -0
- data/lib/rhc/rest/user.rb +6 -2
- data/lib/rhc/{ssh_key_helpers.rb → ssh_helpers.rb} +58 -28
- data/lib/rhc/{targz.rb → tar_gz.rb} +0 -0
- data/lib/rhc/usage_templates/command_help.erb +4 -1
- data/lib/rhc/usage_templates/help.erb +24 -11
- data/lib/rhc/usage_templates/options_help.erb +14 -0
- data/lib/rhc/wizard.rb +283 -213
- data/spec/keys/example.pem +23 -0
- data/spec/keys/example_private.pem +27 -0
- data/spec/keys/server.pem +19 -0
- data/spec/rest_spec_helper.rb +3 -371
- data/spec/rhc/auth_spec.rb +226 -0
- data/spec/rhc/cli_spec.rb +41 -14
- data/spec/rhc/command_spec.rb +44 -15
- data/spec/rhc/commands/account_spec.rb +41 -0
- data/spec/rhc/commands/alias_spec.rb +16 -15
- data/spec/rhc/commands/app_spec.rb +115 -92
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/cartridge_spec.rb +134 -112
- data/spec/rhc/commands/domain_spec.rb +31 -86
- data/spec/rhc/commands/git_clone_spec.rb +56 -0
- data/spec/rhc/commands/{port-forward_spec.rb → port_forward_spec.rb} +27 -32
- data/spec/rhc/commands/server_spec.rb +28 -3
- data/spec/rhc/commands/setup_spec.rb +29 -11
- data/spec/rhc/commands/snapshot_spec.rb +4 -3
- data/spec/rhc/commands/sshkey_spec.rb +24 -56
- data/spec/rhc/commands/tail_spec.rb +26 -9
- data/spec/rhc/commands/threaddump_spec.rb +12 -11
- data/spec/rhc/config_spec.rb +211 -164
- data/spec/rhc/context_spec.rb +2 -0
- data/spec/rhc/helpers_spec.rb +242 -46
- data/spec/rhc/rest_application_spec.rb +42 -28
- data/spec/rhc/rest_client_spec.rb +110 -93
- data/spec/rhc/rest_spec.rb +220 -131
- data/spec/rhc/targz_spec.rb +1 -1
- data/spec/rhc/wizard_spec.rb +435 -624
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +140 -6
- data/spec/wizard_spec_helper.rb +326 -0
- metadata +163 -143
- data/lib/rhc/client.rb +0 -17
- data/lib/rhc/git_helper.rb +0 -59
@@ -0,0 +1,23 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIID4DCCAsgCCQDLI3UAX4mf4DANBgkqhkiG9w0BAQUFADCBsTELMAkGA1UEBhMC
|
3
|
+
VVMxFzAVBgNVBAgMDk5vcnRoIENhcm9saW5hMRAwDgYDVQQHDAdSYWxlaWdoMRAw
|
4
|
+
DgYDVQQKDAdSZWQgSGF0MRcwFQYDVQQLDA5PcGVuU2hpZnQgVGVzdDEiMCAGA1UE
|
5
|
+
AwwZdGVzdC5vcGVuc2hpZnQucmVkaGF0LmNvbTEoMCYGCSqGSIb3DQEJARYZdGVz
|
6
|
+
dEBvcGVuc2hpZnQucmVkaGF0LmNvbTAeFw0xMjEyMjIyMTI1MDFaFw0xMzEyMjIy
|
7
|
+
MTI1MDFaMIGxMQswCQYDVQQGEwJVUzEXMBUGA1UECAwOTm9ydGggQ2Fyb2xpbmEx
|
8
|
+
EDAOBgNVBAcMB1JhbGVpZ2gxEDAOBgNVBAoMB1JlZCBIYXQxFzAVBgNVBAsMDk9w
|
9
|
+
ZW5TaGlmdCBUZXN0MSIwIAYDVQQDDBl0ZXN0Lm9wZW5zaGlmdC5yZWRoYXQuY29t
|
10
|
+
MSgwJgYJKoZIhvcNAQkBFhl0ZXN0QG9wZW5zaGlmdC5yZWRoYXQuY29tMII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5
|
require 'base64'
|
5
6
|
|
@@ -21,377 +22,8 @@ if RUBY_VERSION.to_f == 1.8
|
|
21
22
|
end
|
22
23
|
|
23
24
|
module RestSpecHelper
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def stub_api_request(method, uri, with_auth=true)
|
29
|
-
stub_request(method, mock_href(uri, with_auth)).
|
30
|
-
with(&user_agent_header)
|
31
|
-
end
|
32
|
-
|
33
|
-
def mock_pass
|
34
|
-
"test pass"
|
35
|
-
end
|
36
|
-
|
37
|
-
def mock_uri
|
38
|
-
"test.domain.com"
|
39
|
-
end
|
40
|
-
|
41
|
-
# Creates consistent hrefs for testing
|
42
|
-
def mock_href(relative="", with_auth=false)
|
43
|
-
uri_string = mock_uri
|
44
|
-
if (with_auth == true)
|
45
|
-
uri_string = mock_user + ":" + mock_pass + "@" + mock_uri
|
46
|
-
end
|
47
|
-
"https://#{uri_string}/#{relative}"
|
48
|
-
end
|
49
|
-
|
50
|
-
# This formats link lists for JSONification
|
51
|
-
def mock_response_links(links)
|
52
|
-
link_set = {}
|
53
|
-
links.each do |link|
|
54
|
-
operation = link[0]
|
55
|
-
href = link[1]
|
56
|
-
method = link[2]
|
57
|
-
# Note that the 'relative' key/value pair below is a convenience for testing;
|
58
|
-
# this is not used by the API classes.
|
59
|
-
link_set[operation] = { 'href' => mock_href(href), 'method' => method, 'relative' => href }
|
60
|
-
end
|
61
|
-
return link_set
|
62
|
-
end
|
63
|
-
|
64
|
-
def mock_app_links(domain_id='test_domain',app_id='test_app')
|
65
|
-
[['ADD_CARTRIDGE', "domains/#{domain_id}/apps/#{app_id}/carts/add", 'post'],
|
66
|
-
['LIST_CARTRIDGES', "domains/#{domain_id}/apps/#{app_id}/carts/", 'get' ],
|
67
|
-
['GET_GEAR_GROUPS', "domains/#{domain_id}/apps/#{app_id}/gear_groups", 'get' ],
|
68
|
-
['START', "domains/#{domain_id}/apps/#{app_id}/start", 'post'],
|
69
|
-
['STOP', "domains/#{domain_id}/apps/#{app_id}/stop", 'post'],
|
70
|
-
['RESTART', "domains/#{domain_id}/apps/#{app_id}/restart", 'post'],
|
71
|
-
['THREAD_DUMP', "domains/#{domain_id}/apps/#{app_id}/event", 'post'],
|
72
|
-
['ADD_ALIAS', "domains/#{domain_id}/apps/#{app_id}/event", 'post'],
|
73
|
-
['REMOVE_ALIAS', "domains/#{domain_id}/apps/#{app_id}/event", 'post'],
|
74
|
-
['DELETE', "domains/#{domain_id}/apps/#{app_id}/delete", 'post']]
|
75
|
-
end
|
76
|
-
|
77
|
-
def mock_cart_links(domain_id='test_domain',app_id='test_app',cart_id='test_cart')
|
78
|
-
[['START', "domains/#{domain_id}/apps/#{app_id}/carts/#{cart_id}/start", 'post'],
|
79
|
-
['STOP', "domains/#{domain_id}/apps/#{app_id}/carts/#{cart_id}/stop", 'post'],
|
80
|
-
['RESTART', "domains/#{domain_id}/apps/#{app_id}/carts/#{cart_id}/restart", 'post'],
|
81
|
-
['DELETE', "domains/#{domain_id}/apps/#{app_id}/carts/#{cart_id}/delete", 'post']]
|
82
|
-
end
|
83
|
-
|
84
|
-
def mock_client_links
|
85
|
-
[['GET_USER', 'user/', 'get' ],
|
86
|
-
['ADD_DOMAIN', 'domains/add', 'post'],
|
87
|
-
['LIST_DOMAINS', 'domains/', 'get' ],
|
88
|
-
['LIST_CARTRIDGES', 'cartridges/', 'get' ]]
|
89
|
-
end
|
90
|
-
|
91
|
-
def mock_domain_links(domain_id='test_domain')
|
92
|
-
[['ADD_APPLICATION', "domains/#{domain_id}/apps/add", 'post'],
|
93
|
-
['LIST_APPLICATIONS', "domains/#{domain_id}/apps/", 'get' ],
|
94
|
-
['UPDATE', "domains/#{domain_id}/update", 'post'],
|
95
|
-
['DELETE', "domains/#{domain_id}/delete", 'post']]
|
96
|
-
end
|
97
|
-
|
98
|
-
def mock_key_links(key_id='test_key')
|
99
|
-
[['UPDATE', "user/keys/#{key_id}/update", 'post'],
|
100
|
-
['DELETE', "user/keys/#{key_id}/delete", 'post']]
|
101
|
-
end
|
102
|
-
|
103
|
-
def mock_user_links
|
104
|
-
[['ADD_KEY', 'user/keys/add', 'post'],
|
105
|
-
['LIST_KEYS', 'user/keys/', 'get' ]]
|
106
|
-
end
|
107
|
-
|
108
|
-
def mock_cartridge_response(cart_count=1)
|
109
|
-
carts = []
|
110
|
-
while carts.length < cart_count
|
111
|
-
carts << {
|
112
|
-
:name => "mock_cart_#{carts.length}",
|
113
|
-
:type => "mock_cart_#{carts.length}_type",
|
114
|
-
:base_gear_storage => 1,
|
115
|
-
:additional_gear_storage => 0,
|
116
|
-
:links => mock_response_links(mock_cart_links('mock_domain','mock_app',"mock_cart_#{carts.length}"))
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
carts = carts[0] if cart_count == 1
|
121
|
-
type = cart_count == 1 ? 'cartridge' : 'cartridges'
|
122
|
-
|
123
|
-
return {
|
124
|
-
:body => {
|
125
|
-
:type => type,
|
126
|
-
:data => carts
|
127
|
-
}.to_json,
|
128
|
-
:status => 200
|
129
|
-
}
|
130
|
-
end
|
131
|
-
|
132
|
-
def mock_gear_groups_response()
|
133
|
-
groups = [{}]
|
134
|
-
type = 'gear_groups'
|
135
|
-
|
136
|
-
return {
|
137
|
-
:body => {
|
138
|
-
:type => type,
|
139
|
-
:data => groups
|
140
|
-
}.to_json,
|
141
|
-
:status => 200
|
142
|
-
}
|
143
|
-
end
|
144
|
-
|
145
|
-
def mock_cart_properties
|
146
|
-
{:cart_data => {:connection_url => {'name' => 'connection_url', 'value' => "http://fake.url" }}}
|
147
|
-
end
|
148
|
-
|
149
|
-
class MockRestClient < RHC::Rest::Client
|
150
|
-
def initialize
|
151
|
-
RHC::Rest::Client.stub(:new) { self }
|
152
|
-
@domains = []
|
153
|
-
@user = MockRestUser.new(RHC::Config.username)
|
154
|
-
@__json_args__= {:links => mock_response_links(mock_client_links)}
|
155
|
-
end
|
156
|
-
|
157
|
-
def user
|
158
|
-
@user
|
159
|
-
end
|
160
|
-
|
161
|
-
def domains
|
162
|
-
@domains
|
163
|
-
end
|
164
|
-
|
165
|
-
def cartridges
|
166
|
-
[MockRestCartridge.new("mock_cart-1", "embedded"), # code should sort this to be after standalone
|
167
|
-
MockRestCartridge.new("mock_standalone_cart-1", "standalone"),
|
168
|
-
MockRestCartridge.new("mock_standalone_cart-2", "standalone"),
|
169
|
-
MockRestCartridge.new("mock_unique_standalone_cart-1", "standalone"),
|
170
|
-
MockRestCartridge.new("jenkins-1.4", "standalone"),
|
171
|
-
MockRestCartridge.new("mock_cart-2", "embedded"),
|
172
|
-
MockRestCartridge.new("unique_mock_cart-1", "embedded"),
|
173
|
-
MockRestCartridge.new("jenkins-client-1.4", "embedded")]
|
174
|
-
end
|
175
|
-
|
176
|
-
def add_domain(id)
|
177
|
-
d = MockRestDomain.new(id, self)
|
178
|
-
@domains << d
|
179
|
-
d
|
180
|
-
end
|
181
|
-
|
182
|
-
def sshkeys
|
183
|
-
@user.keys
|
184
|
-
end
|
185
|
-
|
186
|
-
def add_key(name, type, content)
|
187
|
-
@user.add_key(name, type, content)
|
188
|
-
end
|
189
|
-
|
190
|
-
def delete_key(name)
|
191
|
-
@user.keys.delete_if { |key| key.name == name }
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
class MockRestUser < RHC::Rest::User
|
196
|
-
def initialize(login)
|
197
|
-
@login = login
|
198
|
-
@keys = [
|
199
|
-
MockRestKey.new('mockkey1', 'ssh-rsa', 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDNK8xT3O+kSltmCMsSqBfAgheB3YFJ9Y0ESJnFjFASVxH70AcCQAgdQSD/r31+atYShJdP7f0AMWiQUTw2tK434XSylnZWEyIR0V+j+cyOPdVQlns6D5gPOnOtweFF0o18YulwCOK8Q1H28GK8qyWhLe0FcMmxtKbbQgaVRvQdXZz4ThzutCJOyJm9xVb93+fatvwZW76oLLvfFJcJSOK2sgW7tJM2A83bm4mwixFDF7wO/+C9WA+PgPKJUIjvy1gZjBhRB+3b58vLOnYhPOgMNruJwzB+wJ3pg8tLJEjxSbHyyoi6OqMBs4BVV7LdzvwTDxEjcgtHVvaVNXgO5iRX'),
|
200
|
-
MockRestKey.new('mockkey2', 'ssh-dsa', 'AAAAB3NzaC1kc3MAAACBAPaaFj6Xjrjd8Dc4AAkJe0HigqaXMxj/87xHoV+nPgerHIceJWhPUWdW40lSASrgpAV9Eq4zzD+L19kgYdbMw0vSX5Cj3XtNOsow9MmMxFsYjTxCv4eSs/rLdGPaYZ5GVRPDu8tN42Bm8lj5o+ky3HzwW+mkQMZwcADQIgqtn6QhAAAAFQCirDfIMf/JoMOFf8CTnsTKWw/0zwAAAIAIQp6t2sLIp1d2TBfd/qLjOJA10rPADcnhBzWB/cd/oFJ8a/2nmxeSPR5Ov18T6itWqbKwvZw2UC0MrXoYbgcfVNP/ym1bCd9rB5hu1sg8WO4JIxA/47PZooT6PwTKVxHuENEzQyJL2o6ZJq+wuV0taLvm6IaM5TAZuEJ2p4TC/gAAAIBpLcVXZREa7XLY55nyidt/+UC+PxpjhPHOHbzL1OvWEaumN4wcJk/JZPppgXX9+WDkTm1SD891U0cXnGMTP0OZOHkOUHF2ZcfUe7p9kX4WjHs0OccoxV0Lny6MC4DjalJyaaEbijJHSUX3QlLcBOlPHJWpEpvWQ9P8AN4PokiGzA==')
|
201
|
-
]
|
202
|
-
end
|
203
|
-
|
204
|
-
def keys
|
205
|
-
@keys
|
206
|
-
end
|
207
|
-
|
208
|
-
def add_key(name, type, content)
|
209
|
-
@keys << MockRestKey.new(name, type, content)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
class MockRestDomain < RHC::Rest::Domain
|
214
|
-
def initialize(id, client)
|
215
|
-
@id = id
|
216
|
-
@client = client
|
217
|
-
@applications = []
|
218
|
-
@__json_args__= {:links => mock_response_links(mock_domain_links('mock_domain_0'))}
|
219
|
-
end
|
220
|
-
|
221
|
-
def update(id)
|
222
|
-
@id = id
|
223
|
-
self
|
224
|
-
end
|
225
|
-
|
226
|
-
def destroy
|
227
|
-
raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty?
|
228
|
-
@client.domains.delete_if { |d| d.id == @id }
|
229
|
-
|
230
|
-
@client = nil
|
231
|
-
@applications = nil
|
232
|
-
end
|
233
|
-
|
234
|
-
def add_application(name, type=nil, scale=nil, gear_profile='default')
|
235
|
-
if type.is_a?(Hash)
|
236
|
-
scale = type[:scale]
|
237
|
-
gear_profile = type[:gear_profile]
|
238
|
-
type = type[:cartridge]
|
239
|
-
end
|
240
|
-
a = MockRestApplication.new(name, type, self, scale, gear_profile)
|
241
|
-
@applications << a
|
242
|
-
a.add_message("Success")
|
243
|
-
a
|
244
|
-
end
|
245
|
-
|
246
|
-
def applications
|
247
|
-
@applications
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
class MockRestGearGroup < RHC::Rest::GearGroup
|
252
|
-
def initialize
|
253
|
-
@cartridges = [{'name' => 'fake_geargroup_cart-0.1'}]
|
254
|
-
@gears = [{'state' => 'started', 'id' => 'fakegearid'}]
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
class MockRestApplication < RHC::Rest::Application
|
259
|
-
def fakeuuid
|
260
|
-
"fakeuuidfortests#{@name}"
|
261
|
-
end
|
262
|
-
|
263
|
-
def initialize(name, type, domain, scale=nil, gear_profile='default')
|
264
|
-
@name = name
|
265
|
-
@domain = domain
|
266
|
-
@cartridges = []
|
267
|
-
@creation_time = "now"
|
268
|
-
@uuid = fakeuuid
|
269
|
-
@git_url = "git:fake.foo/git/#{@name}.git"
|
270
|
-
@app_url = "https://#{@name}-#{@domain.id}.fake.foo/"
|
271
|
-
@ssh_url = "ssh://#{@uuid}@127.0.0.1"
|
272
|
-
@embedded = {}
|
273
|
-
@aliases = []
|
274
|
-
@gear_profile = gear_profile
|
275
|
-
if scale
|
276
|
-
@scalable = true
|
277
|
-
@embedded = {"haproxy-1.4" => {:info => ""}}
|
278
|
-
end
|
279
|
-
@__json_args__= {:links => mock_response_links(mock_app_links('mock_domain_0', 'mock_app_0'))}
|
280
|
-
cart = add_cartridge(type, false) if type
|
281
|
-
if scale
|
282
|
-
cart.scales_to = -1
|
283
|
-
cart.scales_from = 2
|
284
|
-
cart.current_scale = 2
|
285
|
-
cart.scales_with = "haproxy-1.4"
|
286
|
-
end
|
287
|
-
@framework = type
|
288
|
-
@messages = []
|
289
|
-
end
|
290
|
-
|
291
|
-
def destroy
|
292
|
-
@domain.applications.delete self
|
293
|
-
end
|
294
|
-
|
295
|
-
def add_cartridge(name, embedded=true, additional_storage=0)
|
296
|
-
type = embedded ? "embedded" : "standalone"
|
297
|
-
c = MockRestCartridge.new(name, type, self, mock_cart_properties, additional_storage)
|
298
|
-
@cartridges << c
|
299
|
-
c
|
300
|
-
end
|
301
|
-
|
302
|
-
def gear_groups
|
303
|
-
# we don't have heavy interaction with gear groups yet so keep this simple
|
304
|
-
@gear_groups ||= [MockRestGearGroup.new]
|
305
|
-
end
|
306
|
-
|
307
|
-
def cartridges
|
308
|
-
@cartridges
|
309
|
-
end
|
310
|
-
|
311
|
-
def start
|
312
|
-
@app
|
313
|
-
end
|
314
|
-
|
315
|
-
def stop(*args)
|
316
|
-
@app
|
317
|
-
end
|
318
|
-
|
319
|
-
def restart
|
320
|
-
@app
|
321
|
-
end
|
322
|
-
|
323
|
-
def reload
|
324
|
-
@app
|
325
|
-
end
|
326
|
-
|
327
|
-
def tidy
|
328
|
-
@app
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
class MockRestCartridge < RHC::Rest::Cartridge
|
333
|
-
attr_accessor :scales_to, :scales_from, :current_scale, :scales_with, :display_name, :base_gear_storage, :additional_gear_storage
|
334
|
-
def initialize(name, type, app=nil, properties=mock_cart_properties, additional_storage=0)
|
335
|
-
@name = name
|
336
|
-
@display_name = name
|
337
|
-
@type = type
|
338
|
-
@app = app
|
339
|
-
@properties = properties
|
340
|
-
@status_messages = [{"message" => "started", "gear_id" => "123"}]
|
341
|
-
@scales_from = 1
|
342
|
-
@scales_to = 1
|
343
|
-
@current_scale = 1
|
344
|
-
@base_gear_storage = 1
|
345
|
-
@additional_gear_storage = additional_storage
|
346
|
-
end
|
347
|
-
|
348
|
-
def destroy
|
349
|
-
@app.cartridges.delete self
|
350
|
-
end
|
351
|
-
|
352
|
-
def status
|
353
|
-
@status_messages
|
354
|
-
end
|
355
|
-
|
356
|
-
def start
|
357
|
-
@status_messages = [{"message" => "started", "gear_id" => "123"}]
|
358
|
-
@app
|
359
|
-
end
|
360
|
-
|
361
|
-
def stop
|
362
|
-
@status_messages = [{"message" => "stopped", "gear_id" => "123"}]
|
363
|
-
@app
|
364
|
-
end
|
365
|
-
|
366
|
-
def restart
|
367
|
-
@status_messages = [{"message" => "started", "gear_id" => "123"}]
|
368
|
-
@app
|
369
|
-
end
|
370
|
-
|
371
|
-
def reload
|
372
|
-
@app
|
373
|
-
end
|
374
|
-
|
375
|
-
def set_scales(values)
|
376
|
-
values.delete_if{|k,v| v.nil? }
|
377
|
-
@scales_from = values[:scales_from] if values[:scales_from]
|
378
|
-
@scales_to = values[:scales_to] if values[:scales_to]
|
379
|
-
self
|
380
|
-
end
|
381
|
-
|
382
|
-
def set_storage(values)
|
383
|
-
@additional_gear_storage = values[:additional_storage]
|
384
|
-
self
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
class MockRestKey < RHC::Rest::Key
|
389
|
-
def initialize(name, type, content)
|
390
|
-
@name = name
|
391
|
-
@type = type
|
392
|
-
@content = content
|
393
|
-
end
|
394
|
-
end
|
25
|
+
include RHC::Rest::Mock::Helpers
|
26
|
+
include RHC::Rest::Mock
|
395
27
|
end
|
396
28
|
|
397
29
|
Spec::Runner.configure do |configuration|
|