mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
feature #192 Added OCA Tests
This commit is contained in:
parent
e16827443b
commit
943e0d2578
BIN
src/oca/ruby/test.zip
Normal file
BIN
src/oca/ruby/test.zip
Normal file
Binary file not shown.
97
src/oca/ruby/test/HostPool_spec.rb
Normal file
97
src/oca/ruby/test/HostPool_spec.rb
Normal file
@ -0,0 +1,97 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "Host using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
client = MockClient.new()
|
||||
@host_pool = HostPool.new(client)
|
||||
end
|
||||
|
||||
it "should update the HOST_POOL info" do
|
||||
rc = @host_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the HOST_POOL elements and get info from them" do
|
||||
rc = @host_pool.each{ |host|
|
||||
host.class.to_s.should eql("OpenNebula::Host")
|
||||
if host.id == 0
|
||||
host.name.should eql('dummyhost')
|
||||
elsif host.id == 1
|
||||
host.name.should eql('thost')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the HOST_POOL" do
|
||||
host_hash = @host_pool.to_hash
|
||||
host_hash['HOST_POOL']['HOST'][0]['ID'].should eql('0')
|
||||
host_hash['HOST_POOL']['HOST'][0]['NAME'].should eql('dummyhost')
|
||||
host_hash['HOST_POOL']['HOST'][0]['STATE'].should eql('2')
|
||||
host_hash['HOST_POOL']['HOST'][0]['IM_MAD'].should eql('im_dummy')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['CPU_USAGE'].should eql('300')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['RUNNING_VMS'].should eql('3')
|
||||
host_hash['HOST_POOL']['HOST'][1]['ID'].should eql('1')
|
||||
host_hash['HOST_POOL']['HOST'][1]['NAME'].should eql('thost')
|
||||
host_hash['HOST_POOL']['HOST'][1]['STATE'].should eql('2')
|
||||
host_hash['HOST_POOL']['HOST'][1]['IM_MAD'].should eql('im_dummy')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['MEM_USAGE'].should eql('0')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['CPU_USAGE'].should eql('0')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['RUNNING_VMS'].should eql('0')
|
||||
end
|
||||
end
|
||||
|
||||
describe "Host using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
client = MockClient.new()
|
||||
@host_pool = HostPool.new(client)
|
||||
end
|
||||
|
||||
it "should update the HOST_POOL info" do
|
||||
rc = @host_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the HOST_POOL elements and get info from them" do
|
||||
rc = @host_pool.each{ |host|
|
||||
host.class.to_s.should eql("OpenNebula::Host")
|
||||
if host.id == 0
|
||||
host.name.should eql('dummyhost')
|
||||
elsif host.id == 1
|
||||
host.name.should eql('thost')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the HOST_POOL" do
|
||||
host_hash = @host_pool.to_hash
|
||||
host_hash['HOST_POOL']['HOST'][0]['ID'].should eql('0')
|
||||
host_hash['HOST_POOL']['HOST'][0]['NAME'].should eql('dummyhost')
|
||||
host_hash['HOST_POOL']['HOST'][0]['STATE'].should eql('2')
|
||||
host_hash['HOST_POOL']['HOST'][0]['IM_MAD'].should eql('im_dummy')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['CPU_USAGE'].should eql('300')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
|
||||
host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['RUNNING_VMS'].should eql('3')
|
||||
host_hash['HOST_POOL']['HOST'][1]['ID'].should eql('1')
|
||||
host_hash['HOST_POOL']['HOST'][1]['NAME'].should eql('thost')
|
||||
host_hash['HOST_POOL']['HOST'][1]['STATE'].should eql('2')
|
||||
host_hash['HOST_POOL']['HOST'][1]['IM_MAD'].should eql('im_dummy')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['MEM_USAGE'].should eql('0')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['CPU_USAGE'].should eql('0')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
|
||||
host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['RUNNING_VMS'].should eql('0')
|
||||
end
|
||||
end
|
||||
end
|
251
src/oca/ruby/test/Host_spec.rb
Normal file
251
src/oca/ruby/test/Host_spec.rb
Normal file
@ -0,0 +1,251 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "Host using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = Host.build_xml(7)
|
||||
|
||||
client = MockClient.new()
|
||||
@host = Host.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should allocate the new HOST" do
|
||||
@host.allocate(nil,nil,nil,nil)
|
||||
|
||||
@host.id.should eql(7)
|
||||
end
|
||||
|
||||
it "should update the HOST info" do
|
||||
@host.info()
|
||||
|
||||
@host.id.should eql(7)
|
||||
@host.name.should eql('dummyhost')
|
||||
@host.state.should eql(2)
|
||||
@host.state_str.should eql('MONITORED')
|
||||
@host.short_state_str.should eql('on')
|
||||
end
|
||||
|
||||
it "should enable the HOST" do
|
||||
rc = @host.enable()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should disable the HOST" do
|
||||
rc = @host.disable()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should delete the HOST" do
|
||||
rc = @host.delete()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@host['ID'].should eql('7')
|
||||
@host['NAME'].should eql('dummyhost')
|
||||
@host['STATE'].should eql('2')
|
||||
@host['IM_MAD'].should eql('im_dummy')
|
||||
@host['LAST_MON_TIME'].should eql('1277733596')
|
||||
@host['HOST_SHARE/MEM_USAGE'].should eql('1572864')
|
||||
@host['HOST_SHARE/CPU_USAGE'].should eql('300')
|
||||
@host['HOST_SHARE/FREE_CPU'].should eql('800')
|
||||
@host['HOST_SHARE/RUNNING_VMS'].should eql('3')
|
||||
@host['TEMPLATE/CPUSPEED'].should eql('2.2GHz')
|
||||
@host['TEMPLATE/HYPERVISOR'].should eql('dummy')
|
||||
@host['TEMPLATE/TOTALMEMORY'].should eql('16777216')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the HOST" do
|
||||
host_hash = @host.to_hash
|
||||
host_hash['HOST']['ID'].should eql('7')
|
||||
host_hash['HOST']['NAME'].should eql('dummyhost')
|
||||
host_hash['HOST']['STATE'].should eql('2')
|
||||
host_hash['HOST']['IM_MAD'].should eql('im_dummy')
|
||||
host_hash['HOST']['LAST_MON_TIME'].should eql('1277733596')
|
||||
host_hash['HOST']['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
|
||||
host_hash['HOST']['HOST_SHARE']['CPU_USAGE'].should eql('300')
|
||||
host_hash['HOST']['HOST_SHARE']['FREE_CPU'].should eql('800')
|
||||
host_hash['HOST']['HOST_SHARE']['RUNNING_VMS'].should eql('3')
|
||||
host_hash['HOST']['TEMPLATE']['CPUSPEED'].should eql('2.2GHz')
|
||||
host_hash['HOST']['TEMPLATE']['HYPERVISOR'].should eql('dummy')
|
||||
host_hash['HOST']['TEMPLATE']['TOTALMEMORY'].should eql('16777216')
|
||||
end
|
||||
end
|
||||
|
||||
describe "Host using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = Host.build_xml(7)
|
||||
|
||||
client = MockClient.new()
|
||||
@host = Host.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should allocate the new HOST" do
|
||||
@host.allocate(nil,nil,nil,nil)
|
||||
|
||||
@host.id.should eql(7)
|
||||
end
|
||||
|
||||
it "should update the HOST info" do
|
||||
@host.info()
|
||||
|
||||
@host.id.should eql(7)
|
||||
@host.name.should eql('dummyhost')
|
||||
@host.state.should eql(2)
|
||||
@host.state_str.should eql('MONITORED')
|
||||
@host.short_state_str.should eql('on')
|
||||
end
|
||||
|
||||
it "should enable the HOST" do
|
||||
rc = @host.enable()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should disable the HOST" do
|
||||
rc = @host.disable()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should delete the HOST" do
|
||||
rc = @host.delete()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@host['ID'].should eql('7')
|
||||
@host['NAME'].should eql('dummyhost')
|
||||
@host['STATE'].should eql('2')
|
||||
@host['IM_MAD'].should eql('im_dummy')
|
||||
@host['LAST_MON_TIME'].should eql('1277733596')
|
||||
@host['HOST_SHARE/MEM_USAGE'].should eql('1572864')
|
||||
@host['HOST_SHARE/CPU_USAGE'].should eql('300')
|
||||
@host['HOST_SHARE/FREE_CPU'].should eql('800')
|
||||
@host['HOST_SHARE/RUNNING_VMS'].should eql('3')
|
||||
@host['TEMPLATE/CPUSPEED'].should eql('2.2GHz')
|
||||
@host['TEMPLATE/HYPERVISOR'].should eql('dummy')
|
||||
@host['TEMPLATE/TOTALMEMORY'].should eql('16777216')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the HOST" do
|
||||
host_hash = @host.to_hash
|
||||
host_hash['HOST']['ID'].should eql('7')
|
||||
host_hash['HOST']['NAME'].should eql('dummyhost')
|
||||
host_hash['HOST']['STATE'].should eql('2')
|
||||
host_hash['HOST']['IM_MAD'].should eql('im_dummy')
|
||||
host_hash['HOST']['LAST_MON_TIME'].should eql('1277733596')
|
||||
host_hash['HOST']['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
|
||||
host_hash['HOST']['HOST_SHARE']['CPU_USAGE'].should eql('300')
|
||||
host_hash['HOST']['HOST_SHARE']['FREE_CPU'].should eql('800')
|
||||
host_hash['HOST']['HOST_SHARE']['RUNNING_VMS'].should eql('3')
|
||||
host_hash['HOST']['TEMPLATE']['CPUSPEED'].should eql('2.2GHz')
|
||||
host_hash['HOST']['TEMPLATE']['HYPERVISOR'].should eql('dummy')
|
||||
host_hash['HOST']['TEMPLATE']['TOTALMEMORY'].should eql('16777216')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "Host using NOKOGIRI without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = Host.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@host = Host.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @host.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
@host.id.should eql(nil)
|
||||
@host.name.should eql(nil)
|
||||
end
|
||||
|
||||
it "should enable the HOST" do
|
||||
rc = @host.enable()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should disable the HOST" do
|
||||
rc = @host.disable()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should get Error deleting the HOST" do
|
||||
rc = @host.delete()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "Host using REXML without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = Host.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@host = Host.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @host.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
@host.id.should eql(nil)
|
||||
@host.name.should eql(nil)
|
||||
end
|
||||
|
||||
it "should enable the HOST" do
|
||||
rc = @host.enable()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should disable the HOST" do
|
||||
rc = @host.disable()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should get Error deleting the HOST" do
|
||||
rc = @host.delete()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
49
src/oca/ruby/test/MockClient.rb
Normal file
49
src/oca/ruby/test/MockClient.rb
Normal file
@ -0,0 +1,49 @@
|
||||
class MockClient
|
||||
|
||||
def call(action, *args)
|
||||
xmlrpc_action = "one."+action
|
||||
|
||||
case xmlrpc_action
|
||||
when "one.vn.info"
|
||||
return File.read("xml_test/vnet.xml")
|
||||
when "one.vn.allocate"
|
||||
return 3
|
||||
when "one.vn.delete"
|
||||
return nil
|
||||
when "one.vm.info"
|
||||
return File.read("xml_test/vm.xml")
|
||||
when "one.vm.allocate"
|
||||
return 6
|
||||
when "one.vm.delete"
|
||||
return nil
|
||||
when "one.vm.action"
|
||||
return nil
|
||||
when "one.vm.deploy"
|
||||
return nil
|
||||
when "one.vm.migrate"
|
||||
return nil
|
||||
when "one.host.info"
|
||||
return File.read("xml_test/host.xml")
|
||||
when "one.host.allocate"
|
||||
return 7
|
||||
when "one.host.delete"
|
||||
return nil
|
||||
when "one.host.enable"
|
||||
return nil
|
||||
when "one.user.allocate"
|
||||
return 3
|
||||
when "one.user.info"
|
||||
return File.read("xml_test/user.xml")
|
||||
when "one.user.delete"
|
||||
return nil
|
||||
when "one.vnpool.info"
|
||||
return File.read("xml_test/vnetpool.xml")
|
||||
when "one.vmpool.info"
|
||||
return File.read("xml_test/vmpool.xml")
|
||||
when "one.hostpool.info"
|
||||
return File.read("xml_test/hostpool.xml")
|
||||
when "one.userpool.info"
|
||||
return File.read("xml_test/userpool.xml")
|
||||
end
|
||||
end
|
||||
end
|
81
src/oca/ruby/test/UserPool_spec.rb
Normal file
81
src/oca/ruby/test/UserPool_spec.rb
Normal file
@ -0,0 +1,81 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "User using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
client = MockClient.new()
|
||||
@user_pool = UserPool.new(client)
|
||||
end
|
||||
|
||||
it "should update the USER_POOL info" do
|
||||
rc = @user_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the USER_POOL elements and get info from them" do
|
||||
rc = @user_pool.each{ |user|
|
||||
user.class.to_s.should eql("OpenNebula::User")
|
||||
if user.id == 0
|
||||
user.name.should eql('oneadmin')
|
||||
elsif user.id == 1
|
||||
user.name.should eql('dan')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the USER_POOL" do
|
||||
user_hash = @user_pool.to_hash
|
||||
user_hash['USER_POOL']['USER'][0]['ID'].should eql('0')
|
||||
user_hash['USER_POOL']['USER'][0]['NAME'].should eql('oneadmin')
|
||||
user_hash['USER_POOL']['USER'][0]['PASSWORD'].should eql('f13a1234833436f71ab846572d251c0d40391e72')
|
||||
user_hash['USER_POOL']['USER'][0]['ENABLED'].should eql('True')
|
||||
user_hash['USER_POOL']['USER'][1]['ID'].should eql('1')
|
||||
user_hash['USER_POOL']['USER'][1]['NAME'].should eql('dan')
|
||||
user_hash['USER_POOL']['USER'][1]['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
|
||||
user_hash['USER_POOL']['USER'][1]['ENABLED'].should eql('False')
|
||||
end
|
||||
end
|
||||
|
||||
describe "User using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
client = MockClient.new()
|
||||
@user_pool = UserPool.new(client)
|
||||
end
|
||||
|
||||
it "should update the USER_POOL info" do
|
||||
rc = @user_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the USER_POOL elements and get info from them" do
|
||||
rc = @user_pool.each{ |user|
|
||||
user.class.to_s.should eql("OpenNebula::User")
|
||||
if user.id == 0
|
||||
user.name.should eql('oneadmin')
|
||||
elsif user.id == 1
|
||||
user.name.should eql('dan')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the USER_POOL" do
|
||||
user_hash = @user_pool.to_hash
|
||||
user_hash['USER_POOL']['USER'][0]['ID'].should eql('0')
|
||||
user_hash['USER_POOL']['USER'][0]['NAME'].should eql('oneadmin')
|
||||
user_hash['USER_POOL']['USER'][0]['PASSWORD'].should eql('f13a1234833436f71ab846572d251c0d40391e72')
|
||||
user_hash['USER_POOL']['USER'][0]['ENABLED'].should eql('True')
|
||||
user_hash['USER_POOL']['USER'][1]['ID'].should eql('1')
|
||||
user_hash['USER_POOL']['USER'][1]['NAME'].should eql('dan')
|
||||
user_hash['USER_POOL']['USER'][1]['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
|
||||
user_hash['USER_POOL']['USER'][1]['ENABLED'].should eql('False')
|
||||
end
|
||||
end
|
||||
end
|
161
src/oca/ruby/test/User_spec.rb
Normal file
161
src/oca/ruby/test/User_spec.rb
Normal file
@ -0,0 +1,161 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "User using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = User.build_xml(3)
|
||||
|
||||
client = MockClient.new()
|
||||
@user = User.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should allocate the new USER" do
|
||||
@user.allocate(nil,nil)
|
||||
|
||||
@user.id.should eql(3)
|
||||
end
|
||||
|
||||
it "should update the USER info" do
|
||||
@user.info()
|
||||
|
||||
@user.id.should eql(3)
|
||||
@user.name.should eql('dan')
|
||||
end
|
||||
|
||||
it "should delete the USER" do
|
||||
rc = @user.delete()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@user['ID'].should eql('3')
|
||||
@user['NAME'].should eql('dan')
|
||||
@user['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
|
||||
@user['ENABLED'].should eql('False')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the USER" do
|
||||
user_hash = @user.to_hash
|
||||
user_hash['USER']['ID'].should eql('3')
|
||||
user_hash['USER']['NAME'].should eql('dan')
|
||||
user_hash['USER']['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
|
||||
user_hash['USER']['ENABLED'].should eql('False')
|
||||
end
|
||||
end
|
||||
|
||||
describe "User using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = User.build_xml(3)
|
||||
|
||||
client = MockClient.new()
|
||||
@user = User.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should allocate the new USER" do
|
||||
@user.allocate(nil,nil)
|
||||
|
||||
@user.id.should eql(3)
|
||||
end
|
||||
|
||||
it "should update the USER info" do
|
||||
@user.info()
|
||||
|
||||
@user.id.should eql(3)
|
||||
@user.name.should eql('dan')
|
||||
end
|
||||
|
||||
it "should delete the USER" do
|
||||
rc = @user.delete()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@user['ID'].should eql('3')
|
||||
@user['NAME'].should eql('dan')
|
||||
@user['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
|
||||
@user['ENABLED'].should eql('False')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the USER" do
|
||||
user_hash = @user.to_hash
|
||||
user_hash['USER']['ID'].should eql('3')
|
||||
user_hash['USER']['NAME'].should eql('dan')
|
||||
user_hash['USER']['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
|
||||
user_hash['USER']['ENABLED'].should eql('False')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "User using NOKOGIRI without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = User.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@user = User.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @user.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should get Error deleting the USER" do
|
||||
rc = @user.delete()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "User using REXML without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = User.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@user = User.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @user.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should get Error deleting the USER" do
|
||||
rc = @user.delete()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
105
src/oca/ruby/test/VirtualMachinePool_spec.rb
Normal file
105
src/oca/ruby/test/VirtualMachinePool_spec.rb
Normal file
@ -0,0 +1,105 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "VirtualMachinePool using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
client = MockClient.new()
|
||||
@vm_pool = VirtualMachinePool.new(client)
|
||||
end
|
||||
|
||||
it "should update the VM_POOL info" do
|
||||
rc = @vm_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the VM_POOL elements and get info from them" do
|
||||
rc = @vm_pool.each{ |vm|
|
||||
vm.class.to_s.should eql("OpenNebula::VirtualMachine")
|
||||
if vm.id == 6
|
||||
vm.name.should eql('vm-example')
|
||||
vm.state.should eql(3)
|
||||
vm.state_str.should eql('ACTIVE')
|
||||
elsif vm.id == 8
|
||||
vm.name.should eql('vmext')
|
||||
vm.state.should eql(4)
|
||||
vm.state_str.should eql('STOPPED')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VM_POOL" do
|
||||
vm_hash = @vm_pool.to_hash
|
||||
vm_hash['VM_POOL']['VM'][0]['ID'].should eql('6')
|
||||
vm_hash['VM_POOL']['VM'][0]['UID'].should eql('0')
|
||||
vm_hash['VM_POOL']['VM'][0]['USERNAME'].should eql('oneadmin')
|
||||
vm_hash['VM_POOL']['VM'][0]['NAME'].should eql('vm-example')
|
||||
vm_hash['VM_POOL']['VM'][0]['LAST_POLL'].should eql('1277910006')
|
||||
vm_hash['VM_POOL']['VM'][0]['HISTORY']['HOSTNAME'].should eql('dummyhost')
|
||||
vm_hash['VM_POOL']['VM'][0]['HISTORY']['STIME'].should eql('1277375186')
|
||||
vm_hash['VM_POOL']['VM'][0]['HISTORY']['REASON'].should eql('0')
|
||||
vm_hash['VM_POOL']['VM'][2]['ID'].should eql('8')
|
||||
vm_hash['VM_POOL']['VM'][2]['UID'].should eql('0')
|
||||
vm_hash['VM_POOL']['VM'][2]['USERNAME'].should eql('oneadmin')
|
||||
vm_hash['VM_POOL']['VM'][2]['NAME'].should eql('vmext')
|
||||
vm_hash['VM_POOL']['VM'][2]['LAST_POLL'].should eql('1277910006')
|
||||
vm_hash['VM_POOL']['VM'][2]['HISTORY']['HOSTNAME'].should eql('thost')
|
||||
vm_hash['VM_POOL']['VM'][2]['HISTORY']['STIME'].should eql('1277377556')
|
||||
vm_hash['VM_POOL']['VM'][2]['HISTORY']['REASON'].should eql('0')
|
||||
end
|
||||
end
|
||||
|
||||
describe "VirtualMachinePool using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
client = MockClient.new()
|
||||
@vm_pool = VirtualMachinePool.new(client)
|
||||
end
|
||||
|
||||
it "should update the VM_POOL info" do
|
||||
rc = @vm_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the VM_POOL elements and get info from them" do
|
||||
rc = @vm_pool.each{ |vm|
|
||||
vm.class.to_s.should eql("OpenNebula::VirtualMachine")
|
||||
if vm.id == 6
|
||||
vm.name.should eql('vm-example')
|
||||
vm.state.should eql(3)
|
||||
vm.state_str.should eql('ACTIVE')
|
||||
elsif vm.id == 8
|
||||
vm.name.should eql('vmext')
|
||||
vm.state.should eql(4)
|
||||
vm.state_str.should eql('STOPPED')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VM_POOL" do
|
||||
vm_hash = @vm_pool.to_hash
|
||||
vm_hash['VM_POOL']['VM'][0]['ID'].should eql('6')
|
||||
vm_hash['VM_POOL']['VM'][0]['UID'].should eql('0')
|
||||
vm_hash['VM_POOL']['VM'][0]['USERNAME'].should eql('oneadmin')
|
||||
vm_hash['VM_POOL']['VM'][0]['NAME'].should eql('vm-example')
|
||||
vm_hash['VM_POOL']['VM'][0]['LAST_POLL'].should eql('1277910006')
|
||||
vm_hash['VM_POOL']['VM'][0]['HISTORY']['HOSTNAME'].should eql('dummyhost')
|
||||
vm_hash['VM_POOL']['VM'][0]['HISTORY']['STIME'].should eql('1277375186')
|
||||
vm_hash['VM_POOL']['VM'][0]['HISTORY']['REASON'].should eql('0')
|
||||
vm_hash['VM_POOL']['VM'][2]['ID'].should eql('8')
|
||||
vm_hash['VM_POOL']['VM'][2]['UID'].should eql('0')
|
||||
vm_hash['VM_POOL']['VM'][2]['USERNAME'].should eql('oneadmin')
|
||||
vm_hash['VM_POOL']['VM'][2]['NAME'].should eql('vmext')
|
||||
vm_hash['VM_POOL']['VM'][2]['LAST_POLL'].should eql('1277910006')
|
||||
vm_hash['VM_POOL']['VM'][2]['HISTORY']['HOSTNAME'].should eql('thost')
|
||||
vm_hash['VM_POOL']['VM'][2]['HISTORY']['STIME'].should eql('1277377556')
|
||||
vm_hash['VM_POOL']['VM'][2]['HISTORY']['REASON'].should eql('0')
|
||||
end
|
||||
end
|
||||
end
|
464
src/oca/ruby/test/VirtualMachine_spec.rb
Normal file
464
src/oca/ruby/test/VirtualMachine_spec.rb
Normal file
@ -0,0 +1,464 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "VirtualMachine using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = VirtualMachine.build_xml(6)
|
||||
|
||||
client = MockClient.new()
|
||||
@vm = VirtualMachine.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should allocate the new VM" do
|
||||
@vm.allocate(nil)
|
||||
|
||||
@vm.id.should eql(6)
|
||||
end
|
||||
|
||||
it "should update the VM info" do
|
||||
@vm.info()
|
||||
|
||||
@vm.id.should eql(6)
|
||||
@vm.name.should eql('vm-example')
|
||||
@vm.state.should eql(3)
|
||||
@vm.state_str.should eql('ACTIVE')
|
||||
@vm.lcm_state.should eql(3)
|
||||
@vm.lcm_state_str.should eql('RUNNING')
|
||||
@vm.status.should eql('runn')
|
||||
end
|
||||
|
||||
it "should deploy the VNET" do
|
||||
rc = @vm.deploy(nil)
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should migrate the VNET" do
|
||||
rc = @vm.migrate(nil)
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should live_migrate the VNET" do
|
||||
rc = @vm.live_migrate(nil)
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should shutdown the VNET" do
|
||||
rc = @vm.shutdown()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should cancel the VNET" do
|
||||
rc = @vm.cancel()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should hold the VNET" do
|
||||
rc = @vm.hold()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should release the VNET" do
|
||||
rc = @vm.release()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should stop the VNET" do
|
||||
rc = @vm.stop()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should suspend the VNET" do
|
||||
rc = @vm.suspend()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should resume the VNET" do
|
||||
rc = @vm.resume()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should finalize the VNET" do
|
||||
rc = @vm.finalize()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should restart the VNET" do
|
||||
rc = @vm.restart()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@vm['NAME'].should eql('vm-example')
|
||||
@vm['DEPLOY_ID'].should eql('dummy')
|
||||
@vm['TEMPLATE/MEMORY'].should eql('512')
|
||||
@vm['ID'].should eql('6')
|
||||
@vm['NAME'].should eql('vm-example')
|
||||
@vm['LCM_STATE'].should eql('3')
|
||||
@vm['DEPLOY_ID'].should eql('dummy')
|
||||
@vm['TEMPLATE/MEMORY'].should eql('512')
|
||||
@vm['TEMPLATE/CONTEXT/DNS'].should eql('192.169.1.4')
|
||||
@vm['TEMPLATE/DISK/SIZE'].should eql('1024')
|
||||
@vm['HISTORY/HOSTNAME'].should eql('dummyhost')
|
||||
@vm['HISTORY/PSTIME'].should eql('1277375186')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VM" do
|
||||
vm_hash = @vm.to_hash
|
||||
vm_hash['VM']['ID'].should eql('6')
|
||||
vm_hash['VM']['NAME'].should eql('vm-example')
|
||||
vm_hash['VM']['LCM_STATE'].should eql('3')
|
||||
vm_hash['VM']['DEPLOY_ID'].should eql('dummy')
|
||||
vm_hash['VM']['TEMPLATE']['MEMORY'].should eql('512')
|
||||
vm_hash['VM']['TEMPLATE']['CONTEXT']['DNS'].should eql('192.169.1.4')
|
||||
vm_hash['VM']['TEMPLATE']['DISK'][0]['TARGET'].should eql('sda')
|
||||
vm_hash['VM']['HISTORY']['HOSTNAME'].should eql('dummyhost')
|
||||
vm_hash['VM']['HISTORY']['PSTIME'].should eql('1277375186')
|
||||
end
|
||||
end
|
||||
|
||||
describe "VirtualMachine using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = VirtualMachine.build_xml(6)
|
||||
|
||||
client = MockClient.new()
|
||||
@vm = VirtualMachine.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should allocate the new VM" do
|
||||
@vm.allocate(nil)
|
||||
|
||||
@vm.id.should eql(6)
|
||||
end
|
||||
|
||||
it "should update the VM info" do
|
||||
@vm.info()
|
||||
|
||||
@vm.id.should eql(6)
|
||||
@vm.name.should eql('vm-example')
|
||||
@vm.state.should eql(3)
|
||||
@vm.state_str.should eql('ACTIVE')
|
||||
@vm.lcm_state.should eql(3)
|
||||
@vm.lcm_state_str.should eql('RUNNING')
|
||||
@vm.status.should eql('runn')
|
||||
end
|
||||
|
||||
it "should deploy the VNET" do
|
||||
rc = @vm.deploy(nil)
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should migrate the VNET" do
|
||||
rc = @vm.migrate(nil)
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should live_migrate the VNET" do
|
||||
rc = @vm.live_migrate(nil)
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should shutdown the VNET" do
|
||||
rc = @vm.shutdown()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should cancel the VNET" do
|
||||
rc = @vm.cancel()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should hold the VNET" do
|
||||
rc = @vm.hold()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should release the VNET" do
|
||||
rc = @vm.release()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should stop the VNET" do
|
||||
rc = @vm.stop()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should suspend the VNET" do
|
||||
rc = @vm.suspend()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should resume the VNET" do
|
||||
rc = @vm.resume()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should finalize the VNET" do
|
||||
rc = @vm.finalize()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should restart the VNET" do
|
||||
rc = @vm.restart()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@vm['NAME'].should eql('vm-example')
|
||||
@vm['DEPLOY_ID'].should eql('dummy')
|
||||
@vm['TEMPLATE/MEMORY'].should eql('512')
|
||||
@vm['ID'].should eql('6')
|
||||
@vm['NAME'].should eql('vm-example')
|
||||
@vm['LCM_STATE'].should eql('3')
|
||||
@vm['DEPLOY_ID'].should eql('dummy')
|
||||
@vm['TEMPLATE/MEMORY'].should eql('512')
|
||||
@vm['TEMPLATE/CONTEXT/DNS'].should eql('192.169.1.4')
|
||||
@vm['TEMPLATE/DISK/SIZE'].should eql('1024')
|
||||
@vm['HISTORY/HOSTNAME'].should eql('dummyhost')
|
||||
@vm['HISTORY/PSTIME'].should eql('1277375186')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VM" do
|
||||
vm_hash = @vm.to_hash
|
||||
vm_hash['VM']['ID'].should eql('6')
|
||||
vm_hash['VM']['NAME'].should eql('vm-example')
|
||||
vm_hash['VM']['LCM_STATE'].should eql('3')
|
||||
vm_hash['VM']['DEPLOY_ID'].should eql('dummy')
|
||||
vm_hash['VM']['TEMPLATE']['MEMORY'].should eql('512')
|
||||
vm_hash['VM']['TEMPLATE']['CONTEXT']['DNS'].should eql('192.169.1.4')
|
||||
vm_hash['VM']['TEMPLATE']['DISK'][0]['TARGET'].should eql('sda')
|
||||
vm_hash['VM']['HISTORY']['HOSTNAME'].should eql('dummyhost')
|
||||
vm_hash['VM']['HISTORY']['PSTIME'].should eql('1277375186')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "VirtualMachine using NOKOGIRI without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = VirtualMachine.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@vm = VirtualMachine.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should deploy the VNET" do
|
||||
rc = @vm.deploy(nil)
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should migrate the VNET" do
|
||||
rc = @vm.migrate(nil)
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should live_migrate the VNET" do
|
||||
rc = @vm.live_migrate(nil)
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should shutdown the VNET" do
|
||||
rc = @vm.shutdown()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should cancel the VNET" do
|
||||
rc = @vm.cancel()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should hold the VNET" do
|
||||
rc = @vm.hold()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should release the VNET" do
|
||||
rc = @vm.release()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should stop the VNET" do
|
||||
rc = @vm.stop()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should suspend the VNET" do
|
||||
rc = @vm.suspend()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should resume the VNET" do
|
||||
rc = @vm.resume()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should finalize the VNET" do
|
||||
rc = @vm.finalize()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should restart the VNET" do
|
||||
rc = @vm.restart()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @vm.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
@vm.id.should eql(nil)
|
||||
@vm.name.should eql(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe "VirtualMachine using REXML without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = VirtualMachine.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@vm = VirtualMachine.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should deploy the VNET" do
|
||||
rc = @vm.deploy(nil)
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should migrate the VNET" do
|
||||
rc = @vm.migrate(nil)
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should live_migrate the VNET" do
|
||||
rc = @vm.live_migrate(nil)
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should shutdown the VNET" do
|
||||
rc = @vm.shutdown()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should cancel the VNET" do
|
||||
rc = @vm.cancel()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should hold the VNET" do
|
||||
rc = @vm.hold()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should release the VNET" do
|
||||
rc = @vm.release()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should stop the VNET" do
|
||||
rc = @vm.stop()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should suspend the VNET" do
|
||||
rc = @vm.suspend()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should resume the VNET" do
|
||||
rc = @vm.resume()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should finalize the VNET" do
|
||||
rc = @vm.finalize()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should restart the VNET" do
|
||||
rc = @vm.restart()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @vm.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
@vm.id.should eql(nil)
|
||||
@vm.name.should eql(nil)
|
||||
end
|
||||
end
|
||||
end
|
103
src/oca/ruby/test/VirtualNetworkPool_spec.rb
Normal file
103
src/oca/ruby/test/VirtualNetworkPool_spec.rb
Normal file
@ -0,0 +1,103 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "VirtualNetwork using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
client = MockClient.new()
|
||||
@vnet_pool = VirtualNetworkPool.new(client)
|
||||
end
|
||||
|
||||
#it "should get nil, trying to get a hash, if the info method was not called before" do
|
||||
# vnet_hash = @vnet_pool.to_hash
|
||||
# vnet_hash.nil?.should eql(true)
|
||||
#end
|
||||
|
||||
it "should update the VNET_POOL info" do
|
||||
rc = @vnet_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the VNET_POOL elements and get info from them" do
|
||||
rc = @vnet_pool.each{ |vn|
|
||||
vn.class.to_s.should eql("OpenNebula::VirtualNetwork")
|
||||
if vn.id == 4
|
||||
vn.name.should eql('Red LAN')
|
||||
elsif vn.id == 5
|
||||
vn.name.should eql('Public')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VNET_POOL" do
|
||||
vnet_hash = @vnet_pool.to_hash
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['ID'].should eql('4')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['UID'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['USERNAME'].should eql('oneadmin')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['NAME'].should eql('Red LAN')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['TYPE'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['TOTAL_LEASES'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['ID'].should eql('5')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['UID'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['USERNAME'].should eql('oneadmin')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['NAME'].should eql('Public')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['TYPE'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['TOTAL_LEASES'].should eql('1')
|
||||
end
|
||||
end
|
||||
|
||||
describe "VirtualNetwork using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
client = MockClient.new()
|
||||
@vnet_pool = VirtualNetworkPool.new(client)
|
||||
end
|
||||
|
||||
#it "should get nil, trying to get a hash, if the info method was not called before" do
|
||||
# vnet_hash = @vnet_pool.to_hash
|
||||
# vnet_hash.nil?.should eql(true)
|
||||
#end
|
||||
|
||||
it "should update the VNET_POOL info" do
|
||||
rc = @vnet_pool.info()
|
||||
rc.nil?.should eql(true)
|
||||
end
|
||||
|
||||
it "should iterate the VNET_POOL elements and get info from them" do
|
||||
rc = @vnet_pool.each{ |vn|
|
||||
vn.class.to_s.should eql("OpenNebula::VirtualNetwork")
|
||||
if vn.id == 4
|
||||
vn.name.should eql('Red LAN')
|
||||
elsif vn.id == 5
|
||||
vn.name.should eql('Public')
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VNET_POOL" do
|
||||
vnet_hash = @vnet_pool.to_hash
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['ID'].should eql('4')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['UID'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['USERNAME'].should eql('oneadmin')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['NAME'].should eql('Red LAN')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['TYPE'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET_POOL']['VNET'][0]['TOTAL_LEASES'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['ID'].should eql('5')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['UID'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['USERNAME'].should eql('oneadmin')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['NAME'].should eql('Public')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['TYPE'].should eql('0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET_POOL']['VNET'][1]['TOTAL_LEASES'].should eql('1')
|
||||
end
|
||||
end
|
||||
end
|
183
src/oca/ruby/test/VirtualNetwork_spec.rb
Normal file
183
src/oca/ruby/test/VirtualNetwork_spec.rb
Normal file
@ -0,0 +1,183 @@
|
||||
$: << '../'
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'MockClient'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
describe "VirtualNetwork using NOKOGIRI" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = VirtualNetwork.build_xml(3)
|
||||
|
||||
client = MockClient.new()
|
||||
@vnet = VirtualNetwork.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should allocate the new VNET" do
|
||||
@vnet.allocate(nil)
|
||||
|
||||
@vnet.id.should eql(3)
|
||||
end
|
||||
|
||||
it "should update the VNET info" do
|
||||
@vnet.info()
|
||||
|
||||
@vnet.id.should eql(3)
|
||||
@vnet.name.should eql('Red LAN')
|
||||
end
|
||||
|
||||
it "should delete the VNET" do
|
||||
rc = @vnet.delete()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@vnet['ID'].should eql('3')
|
||||
@vnet['NAME'].should eql('Red LAN')
|
||||
@vnet['BRIDGE'].should eql('vbr0')
|
||||
@vnet['TEMPLATE/NETWORK_ADDRESS'].should eql('192.168.0.0')
|
||||
@vnet['TEMPLATE/TYPE'].should eql('RANGED')
|
||||
@vnet['LEASES/LEASE/IP'].should eql('192.168.0.1')
|
||||
@vnet['LEASES/LEASE/USED'].should eql('1')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VNET" do
|
||||
vnet_hash = @vnet.to_hash
|
||||
vnet_hash['VNET']['NAME'].should eql('Red LAN')
|
||||
vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
|
||||
vnet_hash['VNET']['ID'].should eql('3')
|
||||
vnet_hash['VNET']['NAME'].should eql('Red LAN')
|
||||
vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
|
||||
vnet_hash['VNET']['TEMPLATE']['TYPE'].should eql('RANGED')
|
||||
vnet_hash['VNET']['LEASES']['LEASE']['IP'].should eql('192.168.0.1')
|
||||
vnet_hash['VNET']['LEASES']['LEASE']['USED'].should eql('1')
|
||||
end
|
||||
end
|
||||
|
||||
describe "VirtualNetwork using REXML" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = VirtualNetwork.build_xml(3)
|
||||
|
||||
client = MockClient.new()
|
||||
@vnet = VirtualNetwork.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should allocate the new VNET" do
|
||||
@vnet.allocate(nil)
|
||||
|
||||
@vnet.id.should eql(3)
|
||||
end
|
||||
|
||||
it "should update the VNET info" do
|
||||
@vnet.info()
|
||||
|
||||
@vnet.id.should eql(3)
|
||||
@vnet.name.should eql('Red LAN')
|
||||
end
|
||||
|
||||
it "should delete the VNET" do
|
||||
rc = @vnet.delete()
|
||||
|
||||
rc.should eql(nil)
|
||||
end
|
||||
|
||||
it "should access an attribute using []" do
|
||||
@vnet['ID'].should eql('3')
|
||||
@vnet['NAME'].should eql('Red LAN')
|
||||
@vnet['BRIDGE'].should eql('vbr0')
|
||||
@vnet['TEMPLATE/NETWORK_ADDRESS'].should eql('192.168.0.0')
|
||||
@vnet['TEMPLATE/TYPE'].should eql('RANGED')
|
||||
@vnet['LEASES/LEASE/IP'].should eql('192.168.0.1')
|
||||
@vnet['LEASES/LEASE/USED'].should eql('1')
|
||||
end
|
||||
|
||||
it "should get a hash representation of the VNET" do
|
||||
vnet_hash = @vnet.to_hash
|
||||
vnet_hash['VNET']['NAME'].should eql('Red LAN')
|
||||
vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
|
||||
vnet_hash['VNET']['ID'].should eql('3')
|
||||
vnet_hash['VNET']['NAME'].should eql('Red LAN')
|
||||
vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
|
||||
vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
|
||||
vnet_hash['VNET']['TEMPLATE']['TYPE'].should eql('RANGED')
|
||||
vnet_hash['VNET']['LEASES']['LEASE']['IP'].should eql('192.168.0.1')
|
||||
vnet_hash['VNET']['LEASES']['LEASE']['USED'].should eql('1')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "VirtualNetwork using NOKOGIRI without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=true
|
||||
|
||||
@xml = VirtualNetwork.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@vnet = VirtualNetwork.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a Nokogiri Node" do
|
||||
@xml.class.to_s.should eql('Nokogiri::XML::NodeSet')
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @vnet.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
@vnet.id.should eql(nil)
|
||||
@vnet.name.should eql(nil)
|
||||
end
|
||||
|
||||
it "should get Error deleting the VNET" do
|
||||
rc = @vnet.delete()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "VirtualNetwork using REXML without id" do
|
||||
before(:all) do
|
||||
NOKOGIRI=false
|
||||
|
||||
@xml = VirtualNetwork.build_xml()
|
||||
|
||||
client = MockClient.new()
|
||||
@vnet = VirtualNetwork.new(@xml,client)
|
||||
end
|
||||
|
||||
it "should create a REXML Element" do
|
||||
@xml.class.to_s.should eql('REXML::Element')
|
||||
end
|
||||
|
||||
it "should get Error getting info" do
|
||||
rc = @vnet.info()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
@vnet.id.should eql(nil)
|
||||
@vnet.name.should eql(nil)
|
||||
end
|
||||
|
||||
it "should get Error deleting the VNET" do
|
||||
rc = @vnet.delete()
|
||||
|
||||
OpenNebula.is_error?(rc).should eql(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
38
src/oca/ruby/test/xml_test/host.xml
Normal file
38
src/oca/ruby/test/xml_test/host.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<HOST>
|
||||
<ID>7</ID>
|
||||
<NAME>dummyhost</NAME>
|
||||
<STATE>2</STATE>
|
||||
<IM_MAD>im_dummy</IM_MAD>
|
||||
<VM_MAD>vmm_dummy</VM_MAD>
|
||||
<TM_MAD>tm_dummy</TM_MAD>
|
||||
<LAST_MON_TIME>1277733596</LAST_MON_TIME>
|
||||
<HOST_SHARE>
|
||||
<HID>0</HID>
|
||||
<DISK_USAGE>0</DISK_USAGE>
|
||||
<MEM_USAGE>1572864</MEM_USAGE>
|
||||
<CPU_USAGE>300</CPU_USAGE>
|
||||
<MAX_DISK>0</MAX_DISK>
|
||||
<MAX_MEM>16777216</MAX_MEM>
|
||||
<MAX_CPU>800</MAX_CPU>
|
||||
<FREE_DISK>0</FREE_DISK>
|
||||
<FREE_MEM>16777216</FREE_MEM>
|
||||
<FREE_CPU>800</FREE_CPU>
|
||||
<USED_DISK>0</USED_DISK>
|
||||
<USED_MEM>0</USED_MEM>
|
||||
<USED_CPU>0</USED_CPU>
|
||||
<RUNNING_VMS>3</RUNNING_VMS>
|
||||
</HOST_SHARE>
|
||||
<TEMPLATE>
|
||||
<CPUSPEED>2.2GHz</CPUSPEED>
|
||||
<FREECPU>800</FREECPU>
|
||||
<FREEMEMORY>16777216</FREEMEMORY>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HYPERVISOR>dummy</HYPERVISOR>
|
||||
<MAC>50:20:20:20:20:21</MAC>
|
||||
<NAME>dummyhost</NAME>
|
||||
<TOTALCPU>800</TOTALCPU>
|
||||
<TOTALMEMORY>16777216</TOTALMEMORY>
|
||||
<USEDCPU>0</USEDCPU>
|
||||
<USEDMEMORY>0</USEDMEMORY>
|
||||
</TEMPLATE>
|
||||
</HOST>
|
52
src/oca/ruby/test/xml_test/hostpool.xml
Normal file
52
src/oca/ruby/test/xml_test/hostpool.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<HOST_POOL>
|
||||
<HOST>
|
||||
<ID>0</ID>
|
||||
<NAME>dummyhost</NAME>
|
||||
<STATE>2</STATE>
|
||||
<IM_MAD>im_dummy</IM_MAD>
|
||||
<VM_MAD>vmm_dummy</VM_MAD>
|
||||
<TM_MAD>tm_dummy</TM_MAD>
|
||||
<LAST_MON_TIME>1277912461</LAST_MON_TIME>
|
||||
<HOST_SHARE>
|
||||
<HID>0</HID>
|
||||
<DISK_USAGE>0</DISK_USAGE>
|
||||
<MEM_USAGE>1572864</MEM_USAGE>
|
||||
<CPU_USAGE>300</CPU_USAGE>
|
||||
<MAX_DISK>0</MAX_DISK>
|
||||
<MAX_MEM>16777216</MAX_MEM>
|
||||
<MAX_CPU>800</MAX_CPU>
|
||||
<FREE_DISK>0</FREE_DISK>
|
||||
<FREE_MEM>16777216</FREE_MEM>
|
||||
<FREE_CPU>800</FREE_CPU>
|
||||
<USED_DISK>0</USED_DISK>
|
||||
<USED_MEM>0</USED_MEM>
|
||||
<USED_CPU>0</USED_CPU>
|
||||
<RUNNING_VMS>3</RUNNING_VMS>
|
||||
</HOST_SHARE>
|
||||
</HOST>
|
||||
<HOST>
|
||||
<ID>1</ID>
|
||||
<NAME>thost</NAME>
|
||||
<STATE>2</STATE>
|
||||
<IM_MAD>im_dummy</IM_MAD>
|
||||
<VM_MAD>vmm_dummy</VM_MAD>
|
||||
<TM_MAD>tm_dummy</TM_MAD>
|
||||
<LAST_MON_TIME>1277912461</LAST_MON_TIME>
|
||||
<HOST_SHARE>
|
||||
<HID>1</HID>
|
||||
<DISK_USAGE>0</DISK_USAGE>
|
||||
<MEM_USAGE>0</MEM_USAGE>
|
||||
<CPU_USAGE>0</CPU_USAGE>
|
||||
<MAX_DISK>0</MAX_DISK>
|
||||
<MAX_MEM>16777216</MAX_MEM>
|
||||
<MAX_CPU>800</MAX_CPU>
|
||||
<FREE_DISK>0</FREE_DISK>
|
||||
<FREE_MEM>16777216</FREE_MEM>
|
||||
<FREE_CPU>800</FREE_CPU>
|
||||
<USED_DISK>0</USED_DISK>
|
||||
<USED_MEM>0</USED_MEM>
|
||||
<USED_CPU>0</USED_CPU>
|
||||
<RUNNING_VMS>0</RUNNING_VMS>
|
||||
</HOST_SHARE>
|
||||
</HOST>
|
||||
</HOST_POOL>
|
6
src/oca/ruby/test/xml_test/user.xml
Normal file
6
src/oca/ruby/test/xml_test/user.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<USER>
|
||||
<ID>3</ID>
|
||||
<NAME>dan</NAME>
|
||||
<PASSWORD>d22a12348334v33f71ba846572d25250d40701e72</PASSWORD>
|
||||
<ENABLED>False</ENABLED>
|
||||
</USER>
|
14
src/oca/ruby/test/xml_test/userpool.xml
Normal file
14
src/oca/ruby/test/xml_test/userpool.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<USER_POOL>
|
||||
<USER>
|
||||
<ID>0</ID>
|
||||
<NAME>oneadmin</NAME>
|
||||
<PASSWORD>f13a1234833436f71ab846572d251c0d40391e72</PASSWORD>
|
||||
<ENABLED>True</ENABLED>
|
||||
</USER>
|
||||
<USER>
|
||||
<ID>1</ID>
|
||||
<NAME>dan</NAME>
|
||||
<PASSWORD>d22a12348334v33f71ba846572d25250d40701e72</PASSWORD>
|
||||
<ENABLED>False</ENABLED>
|
||||
</USER>
|
||||
</USER_POOL>
|
59
src/oca/ruby/test/xml_test/vm.xml
Normal file
59
src/oca/ruby/test/xml_test/vm.xml
Normal file
@ -0,0 +1,59 @@
|
||||
<VM>
|
||||
<ID>6</ID>
|
||||
<UID>0</UID>
|
||||
<NAME>vm-example</NAME>
|
||||
<LAST_POLL>1277729095</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<STIME>1277375180</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>512</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<TEMPLATE>
|
||||
<CONTEXT>
|
||||
<DNS>192.169.1.4</DNS>
|
||||
<TYPE/>
|
||||
</CONTEXT>
|
||||
<CPU>1</CPU>
|
||||
<DISK>
|
||||
<READONLY>no</READONLY>
|
||||
<SOURCE>/srv/cloud/images/ttylinux/ttylinux.img</SOURCE>
|
||||
<TARGET>sda</TARGET>
|
||||
</DISK>
|
||||
<DISK>
|
||||
<READONLY>no</READONLY>
|
||||
<SIZE>1024</SIZE>
|
||||
<TARGET>sdb</TARGET>
|
||||
<TYPE>swap</TYPE>
|
||||
</DISK>
|
||||
<MEMORY>512</MEMORY>
|
||||
<NAME>vm-example</NAME>
|
||||
<NIC>
|
||||
<MAC>50:20:20:20:20:20</MAC>
|
||||
</NIC>
|
||||
<OS>
|
||||
<INITRD>/initrd.img</INITRD>
|
||||
<KERNEL>/vmlinuz</KERNEL>
|
||||
<ROOT>sda</ROOT>
|
||||
</OS>
|
||||
<REQUIREMENTS>MAC="50:20:20:20:20:20"</REQUIREMENTS>
|
||||
<VMID>6</VMID>
|
||||
</TEMPLATE>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277375186</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277375186</PSTIME>
|
||||
<PETIME>1277375186</PETIME>
|
||||
<RSTIME>1277375186</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</VM>
|
92
src/oca/ruby/test/xml_test/vmpool.xml
Normal file
92
src/oca/ruby/test/xml_test/vmpool.xml
Normal file
@ -0,0 +1,92 @@
|
||||
<VM_POOL>
|
||||
<VM>
|
||||
<ID>6</ID>
|
||||
<UID>0</UID>
|
||||
<USERNAME>oneadmin</USERNAME>
|
||||
<NAME>vm-example</NAME>
|
||||
<LAST_POLL>1277910006</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<STIME>1277375180</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>512</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277375186</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277375186</PSTIME>
|
||||
<PETIME>1277375186</PETIME>
|
||||
<RSTIME>1277375186</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</VM>
|
||||
<VM>
|
||||
<ID>7</ID>
|
||||
<UID>0</UID>
|
||||
<USERNAME>oneadmin</USERNAME>
|
||||
<NAME>vm-in</NAME>
|
||||
<LAST_POLL>1277910006</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<STIME>1277377464</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>1024</MEMORY>
|
||||
<CPU>2</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>thost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277377466</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277377466</PSTIME>
|
||||
<PETIME>1277377466</PETIME>
|
||||
<RSTIME>1277377466</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</VM>
|
||||
<VM>
|
||||
<ID>8</ID>
|
||||
<UID>0</UID>
|
||||
<USERNAME>oneadmin</USERNAME>
|
||||
<NAME>vmext</NAME>
|
||||
<LAST_POLL>1277910006</LAST_POLL>
|
||||
<STATE>4</STATE>
|
||||
<LCM_STATE>5</LCM_STATE>
|
||||
<STIME>1277377533</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>thost</DEPLOY_ID>
|
||||
<MEMORY>256</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>thost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277377556</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277377556</PSTIME>
|
||||
<PETIME>1277377556</PETIME>
|
||||
<RSTIME>1277377556</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</VM>
|
||||
</VM_POOL>
|
23
src/oca/ruby/test/xml_test/vnet.xml
Normal file
23
src/oca/ruby/test/xml_test/vnet.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<VNET>
|
||||
<ID>3</ID>
|
||||
<UID>0</UID>
|
||||
<NAME>Red LAN</NAME>
|
||||
<TYPE>0</TYPE>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<TEMPLATE>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<DNS>192.169.1.4</DNS>
|
||||
<NAME>Red LAN</NAME>
|
||||
<NETWORK_ADDRESS>192.168.0.0</NETWORK_ADDRESS>
|
||||
<NETWORK_SIZE>C</NETWORK_SIZE>
|
||||
<TYPE>RANGED</TYPE>
|
||||
</TEMPLATE>
|
||||
<LEASES>
|
||||
<LEASE>
|
||||
<IP>192.168.0.1</IP>
|
||||
<MAC>00:03:c0:a8:00:01</MAC>
|
||||
<USED>1</USED>
|
||||
<VID>18</VID>
|
||||
</LEASE>
|
||||
</LEASES>
|
||||
</VNET>
|
20
src/oca/ruby/test/xml_test/vnetpool.xml
Normal file
20
src/oca/ruby/test/xml_test/vnetpool.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<VNET_POOL>
|
||||
<VNET>
|
||||
<ID>4</ID>
|
||||
<UID>0</UID>
|
||||
<USERNAME>oneadmin</USERNAME>
|
||||
<NAME>Red LAN</NAME>
|
||||
<TYPE>0</TYPE>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<TOTAL_LEASES>0</TOTAL_LEASES>
|
||||
</VNET>
|
||||
<VNET>
|
||||
<ID>5</ID>
|
||||
<UID>0</UID>
|
||||
<USERNAME>oneadmin</USERNAME>
|
||||
<NAME>Public</NAME>
|
||||
<TYPE>0</TYPE>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<TOTAL_LEASES>1</TOTAL_LEASES>
|
||||
</VNET>
|
||||
</VNET_POOL>
|
Loading…
x
Reference in New Issue
Block a user