|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe ILORb::ILO do |
| 4 | + let(:hostname) { "10.200.0.1" } |
| 5 | + let(:login) { "Admin" } |
| 6 | + let(:password) { "SECRET" } |
| 7 | + let(:ilo) { ILORb::ILO.new(hostname: hostname, login: login, password: password) } |
| 8 | + |
| 9 | + describe "#get_network_settings" do |
| 10 | + before do |
| 11 | + stub_request(:post, "https://10.200.0.1/ribcl"). |
| 12 | + with(:body => "<?xml version=\"1.0\"?>\n<ribcl version=\"2.0\">\n <login password=\"SECRET\" user_login=\"Admin\">\n <rib_info mode=\"read\">\n <get_network_settings/>\n </rib_info>\n </login>\n</ribcl>\n"). |
| 13 | + to_return(:status => 200, :body => asset_file('get_network_settings_response.xml')) |
| 14 | + end |
| 15 | + |
| 16 | + subject { ilo.get_network_settings } |
| 17 | + |
| 18 | + its([:status]) { should include(code: 0, message: 'No error') } |
| 19 | + its([:get_network_settings]) { should_not be_empty } |
| 20 | + end |
| 21 | + |
| 22 | + describe "#set_one_time_boot" do |
| 23 | + before do |
| 24 | + stub_request(:post, "https://10.200.0.1/ribcl"). |
| 25 | + with(:body => "<?xml version=\"1.0\"?>\n<ribcl version=\"2.0\">\n <login password=\"SECRET\" user_login=\"Admin\">\n <server_info mode=\"write\">\n <set_one_time_boot value=\"FLOPPY\"/>\n </server_info>\n </login>\n</ribcl>\n"). |
| 26 | + to_return(:status => 200, :body => asset_file('basic_response.xml')) |
| 27 | + end |
| 28 | + |
| 29 | + subject { ilo.set_one_time_boot(value: "FLOPPY") } |
| 30 | + |
| 31 | + its([:status]) { should include(code: 0, message: 'No error') } |
| 32 | + end |
| 33 | + |
| 34 | + describe "#set_pwreg" do |
| 35 | + before do |
| 36 | + stub_request(:post, "https://10.200.0.1/ribcl"). |
| 37 | + with(:body => "<?xml version=\"1.0\"?>\n<ribcl version=\"2.0\">\n <login password=\"SECRET\" user_login=\"Admin\">\n <server_info mode=\"write\">\n <set_pwreg>\n <pwralert type=\"PEAK\"/>\n <pwralert_settings threshold=\"200\" duration=\"35\"/>\n </set_pwreg>\n </server_info>\n </login>\n</ribcl>\n"). |
| 38 | + to_return(:status => 200, :body => asset_file('basic_response.xml')) |
| 39 | + end |
| 40 | + |
| 41 | + subject { ilo.set_pwreg pwralert_type: "PEAK", |
| 42 | + pwralert_settings_threshold: 200, |
| 43 | + pwralert_settings_duration: 35 } |
| 44 | + |
| 45 | + its([:status]) { should include(code: 0, message: 'No error') } |
| 46 | + end |
| 47 | + |
| 48 | + describe "#set_one_time_boot" do |
| 49 | + before do |
| 50 | + stub_request(:post, "https://10.200.0.1/ribcl"). |
| 51 | + with(:body => "<?xml version=\"1.0\"?>\n<ribcl version=\"2.0\">\n <login password=\"SECRET\" user_login=\"Admin\">\n <server_info mode=\"write\">\n <set_one_time_boot value=\"FLOPPY\"/>\n </server_info>\n </login>\n</ribcl>\n"). |
| 52 | + to_return(:status => 200, :body => asset_file('basic_response.xml')) |
| 53 | + end |
| 54 | + |
| 55 | + subject { ilo.set_one_time_boot(value: "FLOPPY") } |
| 56 | + |
| 57 | + its([:status]) { should include(code: 0, message: 'No error') } |
| 58 | + end |
| 59 | + |
| 60 | + describe "#set_persistent_boot" do |
| 61 | + before do |
| 62 | + stub_request(:post, "https://10.200.0.1/ribcl"). |
| 63 | + with(:body => "<?xml version=\"1.0\"?>\n<ribcl version=\"2.0\">\n <login password=\"SECRET\" user_login=\"Admin\">\n <server_info mode=\"write\">\n <set_persistent_boot>\n <device value=\"FLOPPY\"/>\n <device value=\"CDROM\"/>\n </set_persistent_boot>\n </server_info>\n </login>\n</ribcl>\n"). |
| 64 | + to_return(:status => 200, :body => asset_file('basic_response.xml')) |
| 65 | + end |
| 66 | + |
| 67 | + subject { ilo.set_persistent_boot([{ device_value: "FLOPPY" }, |
| 68 | + { device_value: "CDROM" }]) } |
| 69 | + |
| 70 | + its([:status]) { should include(code: 0, message: 'No error') } |
| 71 | + end |
| 72 | + |
| 73 | + private |
| 74 | + |
| 75 | + def asset_file(asset) |
| 76 | + path = File.join(File.dirname(__FILE__), 'assets', asset) |
| 77 | + File.new(path) |
| 78 | + end |
| 79 | +end |
0 commit comments