rhcp 0.2.20 → 0.2.21
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.
- data/lib/rhcp.rb +1 -1
- data/lib/rhcp/command.rb +36 -37
- data/lib/rhcp/rhcp_exception.rb +8 -1
- metadata +4 -4
data/lib/rhcp.rb
CHANGED
data/lib/rhcp/command.rb
CHANGED
@@ -177,11 +177,7 @@ module RHCP
|
|
177
177
|
get_param(key).check_param_is_valid(request, value)
|
178
178
|
end
|
179
179
|
rescue Exception => ex
|
180
|
-
|
181
|
-
raise RHCP::RhcpException.new(ex.message) unless @accepts_extra_params or @ignores_extra_params
|
182
|
-
else
|
183
|
-
raise ex
|
184
|
-
end
|
180
|
+
raise unless /undefined\sparameter/.match(ex.message)
|
185
181
|
end
|
186
182
|
|
187
183
|
# check that we've got all mandatory params
|
@@ -199,9 +195,6 @@ module RHCP
|
|
199
195
|
response.mark_as_error(ex.to_s, ex.backtrace.join("\n"))
|
200
196
|
end
|
201
197
|
|
202
|
-
# the command has been executed, so we should clear the store of collected param values
|
203
|
-
#request.context.collected_values = {}
|
204
|
-
|
205
198
|
response
|
206
199
|
end
|
207
200
|
|
@@ -210,7 +203,40 @@ module RHCP
|
|
210
203
|
execute_request(req)
|
211
204
|
end
|
212
205
|
|
213
|
-
def
|
206
|
+
def execute_from_ruby_args(args, additional_params, block)
|
207
|
+
# args is an array - but we need the (optional) hash on index 0
|
208
|
+
param_values = {}
|
209
|
+
if args.length > 0
|
210
|
+
param_values = args.first
|
211
|
+
if param_values.class == String && default_param != nil
|
212
|
+
$logger.debug "autoboxing for #{default_param.name}"
|
213
|
+
param_values = {
|
214
|
+
default_param.name => param_values
|
215
|
+
}
|
216
|
+
end
|
217
|
+
end
|
218
|
+
if defined?(block) and self.params.select { |p| p.name == "block" }.size > 0
|
219
|
+
param_values["block"] = block
|
220
|
+
end
|
221
|
+
|
222
|
+
# we need to carry along the context
|
223
|
+
the_broker = Thread.current['broker']
|
224
|
+
|
225
|
+
param_values.merge! additional_params
|
226
|
+
|
227
|
+
request = RHCP::Request.new(self, param_values, the_broker.context)
|
228
|
+
response = the_broker.execute(request)
|
229
|
+
|
230
|
+
if (response.status != RHCP::Response::Status::OK) then
|
231
|
+
#$logger.error("#{response.error_text}\n#{response.error_detail}")
|
232
|
+
e = RhcpException.new(response.error_text)
|
233
|
+
e.set_backtrace(response.error_detail)
|
234
|
+
raise e
|
235
|
+
end
|
236
|
+
response.data
|
237
|
+
end
|
238
|
+
|
239
|
+
def add_as_instance_method(the_instance, additional_params = {})
|
214
240
|
rhcp_command = self
|
215
241
|
command_name = rhcp_command.name
|
216
242
|
|
@@ -219,34 +245,7 @@ module RHCP
|
|
219
245
|
the_instance.class.send(:remove_method, command_name.to_sym)
|
220
246
|
end
|
221
247
|
the_instance.class.send(:define_method, command_name.to_sym) do |*args|
|
222
|
-
|
223
|
-
param_values = {}
|
224
|
-
if args.length > 0
|
225
|
-
param_values = args.first
|
226
|
-
end
|
227
|
-
|
228
|
-
# we need to carry along the context
|
229
|
-
the_broker = Thread.current['broker']
|
230
|
-
|
231
|
-
param_values.merge! additional_param_values
|
232
|
-
|
233
|
-
#param_values["host"] = @hostname if self.class.to_s == "HostController"
|
234
|
-
|
235
|
-
request = RHCP::Request.new(rhcp_command, param_values, the_broker.context)
|
236
|
-
|
237
|
-
response = the_broker.execute(request)
|
238
|
-
|
239
|
-
if (response.status != RHCP::Response::Status::OK) then
|
240
|
-
# TODO actually, it would be nice if we could log the details into a file and show only the message
|
241
|
-
filtered_error_detail = response.error_detail.split("\n").select do |line|
|
242
|
-
/lib\/plugins\//.match(line)
|
243
|
-
end.join("\n")
|
244
|
-
|
245
|
-
$logger.error("#{response.error_text}\n#{response.error_detail}")
|
246
|
-
#$logger.error("#{response.error_text}")
|
247
|
-
raise RuntimeError.new(response.error_text)
|
248
|
-
end
|
249
|
-
response.data
|
248
|
+
execute_from_ruby_args(args, additional_params)
|
250
249
|
end
|
251
250
|
end
|
252
251
|
|
data/lib/rhcp/rhcp_exception.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 21
|
10
|
+
version: 0.2.21
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philipp T.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-03-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|