Revision 01ffb230
Added by Timo Goebel over 7 years ago
lib/proxy_api/bmc.rb | ||
---|---|---|
response.is_a?(Hash) ? response['result'] : response
|
||
when "on", "off", "cycle", "soft"
|
||
res = parse put(args, bmc_url_for('power',args[:action]))
|
||
# This is a simple action, just return the result of the action
|
||
res && res['result'] == true
|
||
res && (res['result'] == true || res['result'] == "#{@target}: ok\n")
|
||
else
|
||
raise NoMethodError
|
||
end
|
test/unit/proxy_api/bmc_test.rb | ||
---|---|---|
@testbmc.expects(:get).with(expected_path, data).at_least_once
|
||
@testbmc.lan_mac(@options)
|
||
end
|
||
|
||
context '#power' do
|
||
test "should return true when result was true" do
|
||
data = stub_bmc_power_response('cycle', true)
|
||
assert_equal true, @testbmc.power(data)
|
||
end
|
||
|
||
test "should return true when result was ok" do
|
||
data = stub_bmc_power_response('cycle', "127.0.0.1: ok\n")
|
||
assert_equal true, @testbmc.power(data)
|
||
end
|
||
|
||
test "should return false when result was not ok" do
|
||
data = stub_bmc_power_response('cycle', 'error')
|
||
assert_equal false, @testbmc.power(data)
|
||
end
|
||
end
|
||
|
||
private
|
||
|
||
def stub_bmc_power_response(action, result)
|
||
data = @options.merge({:action => action})
|
||
@testbmc.stubs(:put).returns(
|
||
fake_rest_client_response(
|
||
{
|
||
'action' => action,
|
||
'result' => result
|
||
}
|
||
)
|
||
)
|
||
data
|
||
end
|
||
end
|
Also available in: Unified diff
fixes #17476 - bmc power actions have correct status