require "support" describe Rubineti::Compute do describe Rubineti::Instances do describe "#instance_activate_disks" do it "is not implemented" do out, err = capture_io { Connection.instance_activate_disks(:invalid_instance_name) } err.must_match Not_Implemented_Matcher end end describe "#instance_create" do it "returns a job_id" do params = { :__version__ => Ganeti::Version, :name => "compute1", :pnode => "node1", :snode => "node2", :disk_template => "drbd8", :disks => [4096], :beparams => { :vcpus => 1, :memory => 512 }, :os => "debootstrap+default" } VCR.use_cassette "instance_create" do response = Connection.instance_create :body => params, :query => "dry-run=1" response.must_match Job_Matcher end end end describe "#instance_deactivate_disks" do it "is not implemented" do out, err = capture_io { Connection.instance_deactivate_disks :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_delete" do it "returns a job_id" do VCR.use_cassette "instance_delete" do response = Connection.instance_delete :invalid_instance_name, :query => "dry-run=1" response.must_match Job_Matcher end end end describe "#instance_export" do it "is not implemented" do out, err = capture_io { Connection.instance_export :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_info" do it "returns a job_id" do instance_name = cassette_for("instances").first["name"] VCR.use_cassette "instance_info" do response = Connection.instance_info instance_name response.must_match Job_Matcher end end end describe "#instance_list" do it "returns a Hash" do instance_name = cassette_for("instances").first["name"] VCR.use_cassette "instance_list" do response = Connection.instance_list instance_name response.must_be_kind_of Hash end end end describe "#instance_migrate" do it "is not implemented" do out, err = capture_io { Connection.instance_migrate :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_modify" do it "is not implemented" do out, err = capture_io { Connection.instance_modify :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_prepare_export" do it "is not implemented" do out, err = capture_io { Connection.instance_prepare_export :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_reboot" do it "returns a job_id" do VCR.use_cassette "instance_reboot" do response = Connection.instance_reboot :invalid_instance_name, :query => "dry-run=1" response.must_match Job_Matcher end end end describe "#instance_reinstall" do it "returns a job_id" do instance_name = cassette_for("instances").first["name"] params = { :os => "debootstrap+default" } VCR.use_cassette "instance_reinstall" do response = Connection.instance_reinstall instance_name, :body => params response.must_match Job_Matcher end end end describe "#instance_rename" do it "is not implemented" do lambda { Connection.instance_rename :invalid_instance_name }.must_output(nil, nil).must_equal true end end describe "#instance_replace_disks" do it "is not implemented" do out, err = capture_io { Connection.instance_replace_disks :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_shutdown" do it "returns a job_id" do VCR.use_cassette "instance_shutdown" do response = Connection.instance_shutdown :invalid_instance_name, :query => "dry-run=1" response.must_match Job_Matcher end end end describe "#instances_list" do it "returns an Array of Hashes" do VCR.use_cassette "instances" do response = Connection.instances_list :query => "bulk=1" response.size.must_equal 1 end end end describe "#instance_startup" do it "returns a job_id" do VCR.use_cassette "instance_startup" do response = Connection.instance_startup :invalid_instance_name, :query => "dry-run=1" response.must_match Job_Matcher end end end describe "#instance_tag_create" do it "is not implemented" do out, err = capture_io { Connection.instance_tag_create :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_tag_delete" do it "is not implemented" do out, err = capture_io { Connection.instance_tag_delete :invalid_instance_name } err.must_match Not_Implemented_Matcher end end describe "#instance_tag_list" do it "is not implemented" do out, err = capture_io { Connection.instance_tag_list :invalid_instance_name } err.must_match Not_Implemented_Matcher end end end end