From 1a864ef3f13397e4a7938e34bc3c0ce520c1f5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 14 Sep 2011 12:27:08 +0200 Subject: [PATCH 01/24] Fix oca incompatibility with ruby 1.8.5 --- src/oca/ruby/OpenNebula/Group.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/oca/ruby/OpenNebula/Group.rb b/src/oca/ruby/OpenNebula/Group.rb index 5ec9c2f1e7..98c359ed3a 100644 --- a/src/oca/ruby/OpenNebula/Group.rb +++ b/src/oca/ruby/OpenNebula/Group.rb @@ -127,7 +127,11 @@ module OpenNebula # Returns whether or not the user with id 'uid' is part of this group def contains(uid) - return self["USERS/ID[.=#{uid}]"] != nil + # This doesn't work in ruby 1.8.5 +# return self["USERS/ID[.=#{uid}]"] != nil + + id_array = retrieve_elements('USERS/ID') + return id_array != nil && id_array.include?(uid.to_s) end # Returns an array with the numeric user ids From d37f19638e6cc1dd3262868d8b30f4ffb7da8b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 14 Sep 2011 17:05:27 +0200 Subject: [PATCH 02/24] Add new Image unit test, and fix segfault problems --- src/image/test/ImagePoolTest.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 002736709a..6ec2480186 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -146,10 +146,7 @@ class ImagePoolTest : public PoolTest CPPUNIT_TEST ( bus_source_assignment ); CPPUNIT_TEST ( public_attribute ); CPPUNIT_TEST ( persistence ); - -// Requires ImageManger, and NebulaTest -// CPPUNIT_TEST ( imagepool_disk_attribute ); - + CPPUNIT_TEST ( imagepool_disk_attribute ); CPPUNIT_TEST ( dump ); CPPUNIT_TEST ( dump_where ); @@ -159,6 +156,7 @@ protected: NebulaTestImage * tester; ImagePool * ipool; + ImageManager * imagem; void bootstrap(SqlDB* db) { @@ -217,12 +215,23 @@ public: neb.start(); ipool = neb.get_ipool(); + imagem = neb.get_imagem(); pool = ipool; }; void tearDown() { + // ----------------------------------------------------------- + // Stop the managers & free resources + // ----------------------------------------------------------- + + imagem->finalize(); + pthread_join(imagem->get_thread_id(),0); + + //XML Library + xmlCleanupParser(); + delete_db(); delete tester; @@ -614,7 +623,7 @@ public: // Disk using image 0 disk = new VectorAttribute("DISK"); - disk->replace("IMAGE", "Image 0"); + disk->replace("IMAGE_ID", "0"); ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); @@ -622,9 +631,6 @@ public: value = disk->vector_value("TARGET"); CPPUNIT_ASSERT( value == "hda" ); - value = ""; - value = disk->vector_value("IMAGE_ID"); - CPPUNIT_ASSERT( value == "0" ); delete disk; From de0d8cba732a9e024fd654271defa908dd219bc8 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 17:10:49 +0200 Subject: [PATCH 03/24] bug #716: Fix monitoring information when no resources are present --- src/acct/accounting.rb | 2 +- src/acct/monitoring.rb | 12 ++++- src/acct/watch_client.rb | 46 ++++++++-------- src/acct/watch_helper.rb | 113 +++++++++++++++++++++++++-------------- 4 files changed, 110 insertions(+), 63 deletions(-) diff --git a/src/acct/accounting.rb b/src/acct/accounting.rb index de872c4d60..9f07eb1274 100644 --- a/src/acct/accounting.rb +++ b/src/acct/accounting.rb @@ -72,7 +72,7 @@ module OneWatch # Upate the active VMs @active_vms = new_active_vms.sort - WatchHelper::Vm.flush(@timestamp) + WatchHelper::Vm.flush end private diff --git a/src/acct/monitoring.rb b/src/acct/monitoring.rb index c01e66f83c..4ff76c7dcc 100644 --- a/src/acct/monitoring.rb +++ b/src/acct/monitoring.rb @@ -28,7 +28,7 @@ module OneWatch } end - sql_elem.flush(timestamp) + sql_elem.flush end private @@ -50,6 +50,11 @@ module OneWatch WatchHelper::Vm end end + + def generate_timestamp + ts = super + WatchHelper::VmTimestamp.find_or_create(:id=>ts) + end end class HostMonitoring < Monitoring @@ -64,5 +69,10 @@ module OneWatch WatchHelper::Host end end + + def generate_timestamp + ts = super + WatchHelper::HostTimestamp.find_or_create(:id=>ts) + end end end diff --git a/src/acct/watch_client.rb b/src/acct/watch_client.rb index 1b1feb6a5c..36efadb078 100644 --- a/src/acct/watch_client.rb +++ b/src/acct/watch_client.rb @@ -97,25 +97,21 @@ module OneWatchClient # Get the MAX for each VM and last_poll value max_per_vm = rsql. - group(:id, :last_poll). - select{[:last_poll, max(mr.to_sym).as(:max_mr)]} + group(:vm_id, :timestamp). + select{[:timestamp, max(mr.to_sym).as(:max_mr)]} # SUM the monitoring resource for each last_poll value last_poll_and_sum = max_per_vm. from_self. - group(:last_poll). - select{[:last_poll, sum(:max_mr).as(:sum_mr)]} + group(:timestamp). + select{[:timestamp, sum(:max_mr).as(:sum_mr)]} - # Retrieve the information in an Array - a = Array.new - last_poll_and_sum.each do |row| - if row[:last_poll] && row[:last_poll] != 0 - a << [row[:last_poll], row[:sum_mr].to_i] - end - end - - a + # Add all the existing timestamps + with_ts = timestamps.left_join(last_poll_and_sum, :timestamp=>:id) + with_ts.collect do |row| + [row[:id], row[:sum_mr].to_i] + end end def count_monitoring(rsql, opt) @@ -126,13 +122,13 @@ module OneWatchClient else return nil end - a = Array.new + count = resources.group_and_count(:timestamp) - resources.group_and_count(:timestamp).all.each { |row| - a << [row[:timestamp], row[:count].to_i] - } - - a + # Add all the existing timestamps + with_ts = timestamps.left_join(count, :timestamp=>:id) + with_ts.collect do |row| + [row[:id], row[:count].to_i] + end end end @@ -157,6 +153,10 @@ module OneWatchClient pool.filter(:state=>3) end + def timestamps + WatchHelper::HostTimestamp + end + def filter_pool(filter) if filter[:uid] filter[:uid]==0 ? (hosts = pool) : (return nil) @@ -166,7 +166,7 @@ module OneWatchClient hosts = pool end - hosts.join(WatchHelper::HostSample, :host_id=>:id) + WatchHelper::HostSample.join(vms.select(:id.as(:host_id)), [:host_id]) end def filter_resource(id, filter) @@ -204,6 +204,10 @@ module OneWatchClient pool.filter(:state=>7) end + def timestamps + WatchHelper::VmTimestamp + end + def filter_pool(filter) if filter[:uid] vms = pool.filter(:uid=>filter[:uid]) @@ -213,7 +217,7 @@ module OneWatchClient vms = pool end - vms.join(WatchHelper::VmSample, :vm_id=>:id) + WatchHelper::VmSample.join(vms.select(:id.as(:vm_id)), [:vm_id]) end def filter_resource(id, filter) diff --git a/src/acct/watch_helper.rb b/src/acct/watch_helper.rb index edb7456d90..439606dd6c 100644 --- a/src/acct/watch_helper.rb +++ b/src/acct/watch_helper.rb @@ -140,7 +140,7 @@ module WatchHelper Integer :uid Integer :gid Integer :mem - Integer :cpu + Float :cpu Integer :vcpu Integer :stime Integer :etime @@ -154,12 +154,16 @@ module WatchHelper String :tm_mad end + DB.create_table? :vm_timestamps do + Integer :id, :primary_key=>true + end + DB.create_table? :vm_samples do foreign_key :vm_id, :vms, :key=>:id + foreign_key :timestamp, :vm_timestamps, :key=>:id Integer :state Integer :lcm_state Integer :last_poll - Integer :timestamp VM_SAMPLE.each { |key,value| column key, value[:type] @@ -168,10 +172,14 @@ module WatchHelper primary_key [:vm_id, :timestamp] end + DB.create_table? :host_timestamps do + Integer :id, :primary_key=>true + end + DB.create_table? :host_samples do foreign_key :host_id, :hosts, :key=>:id + foreign_key :timestamp, :host_timestamps, :key=>:id Integer :last_poll - Integer :timestamp Integer :state HOST_SAMPLE.each { |key,value| @@ -216,12 +224,62 @@ module WatchHelper unrestrict_primary_key many_to_one :vm + many_to_one :timestamp, + :class=>"WatchHelper::VmTimestamp", + :key=>:id + end + + class VmTimestamp < Sequel::Model + unrestrict_primary_key + + one_to_many :samples, + :order=>:timestamp, + :class=>"WatchHelper::VmSample", + :key=>:timestamp + + @@window_size = WatchHelper::get_config( + :VM_MONITORING, + :WINDOW_SIZE + ) + + def self.fix_size + if self.count > @@window_size + last_timestamp = self.all.first + last_timestamp.samples_dataset.destroy + last_timestamp.destroy + end + end end class HostSample < Sequel::Model unrestrict_primary_key many_to_one :host + many_to_one :timestamp, + :class=>"WatchHelper::HostTimestamp", + :key=>:id + end + + class HostTimestamp < Sequel::Model + unrestrict_primary_key + + one_to_many :samples, + :order=>:timestamp, + :class=>"WatchHelper::HostSample", + :key=>:timestamp + + @@window_size = WatchHelper::get_config( + :HOST_MONITORING, + :WINDOW_SIZE + ) + + def self.fix_size + if self.count > @@window_size + last_timestamp = self.all.first + last_timestamp.remove_all_samples + last_timestamp.destroy + end + end end class Register < Sequel::Model @@ -256,26 +314,21 @@ module WatchHelper # Accounting one_to_many :registers, :order=>:seq - one_to_many :deltas, :order=>:timestamp, :class=>VmDelta + one_to_many :deltas, :order=>:timestamp, :class=>"WatchHelper::VmDelta" # Monitoring - one_to_many :samples, :order=>:timestamp, :class=>VmSample + one_to_many :samples, :order=>:timestamp, :class=>"WatchHelper::VmSample" @@samples_cache = [] @@deltas_cache = [] - @@vm_window_size = WatchHelper::get_config( - :VM_MONITORING, - :WINDOW_SIZE - ) - def self.info(vm) Vm.find_or_create(:id=>vm['ID']) { |v| v.name = vm['NAME'] v.uid = vm['UID'].to_i v.gid = vm['GID'].to_i v.mem = vm['TEMPLATE/MEMORY'].to_i - v.cpu = vm['TEMPLATE/CPU'].to_i + v.cpu = vm['TEMPLATE/CPU'].to_f v.vcpu = vm['TEMPLATE/VCPU'].to_i v.stime = vm['STIME'].to_i v.etime = vm['ETIME'].to_i @@ -300,7 +353,7 @@ module WatchHelper def add_sample_from_resource(vm, timestamp) hash = { :vm_id => vm['ID'], - :timestamp => timestamp, + :timestamp => timestamp.id, :last_poll => vm['LAST_POLL'], :state => vm['STATE'], :lcm_state => vm['LCM_STATE'] @@ -343,21 +396,14 @@ module WatchHelper @@deltas_cache << hash end - def self.flush(timestamp) + def self.flush DB.transaction do VmDelta.multi_insert(@@deltas_cache) VmSample.multi_insert(@@samples_cache) + + VmTimestamp.fix_size end - step = WatchHelper::get_config(:STEP) - ws = WatchHelper::get_config(:VM_MONITORING,:WINDOW_SIZE) - vm_s = WatchHelper::get_config(:VM_MONITORING,:STEPS) - - t = step*ws*vm_s - tl = timestamp - t - - VmSample.filter('timestamp < ?', tl).destroy - @@samples_cache = [] @@deltas_cache = [] end @@ -367,16 +413,10 @@ module WatchHelper unrestrict_primary_key # Monitoring - one_to_many :samples, :order=>:timestamp, :class=>HostSample + one_to_many :samples, :order=>:timestamp, :class=>:HostSample @@samples_cache = [] - @@host_window_size = WatchHelper::get_config( - :HOST_MONITORING, - :WINDOW_SIZE - ) - - def self.info(host) Host.find_or_create(:id=>host['ID']) { |h| h.name = host['NAME'] @@ -389,7 +429,7 @@ module WatchHelper def add_sample_from_resource(host, timestamp) hash = { :host_id => host['ID'], - :timestamp => timestamp, + :timestamp => timestamp.id, :last_poll => host['LAST_MON_TIME'], :state => host['STATE'], } @@ -402,20 +442,13 @@ module WatchHelper @@samples_cache << hash end - def self.flush(timestamp) + def self.flush DB.transaction do HostSample.multi_insert(@@samples_cache) + + HostTimestamp.fix_size end - step = WatchHelper::get_config(:STEP) - ws = WatchHelper::get_config(:HOST_MONITORING,:WINDOW_SIZE) - vm_s = WatchHelper::get_config(:HOST_MONITORING,:STEPS) - - t = step*ws*vm_s - tl = timestamp - t - - HostSample.filter('timestamp < ?', tl).destroy - @@samples_cache = [] end end From aab42cee603ad28899232346593987f173216a80 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 17:12:08 +0200 Subject: [PATCH 04/24] bug #716: Add monitoring tests --- src/acct/test/1Vm1His.rb | 2 + src/acct/test/1VmXHis.rb | 2 + src/acct/test/XVm1His.rb | 2 + src/acct/test/cmonitoring_spec.rb | 273 ++++++++++++++++--------- src/acct/test/helper/test_helper.rb | 3 +- src/acct/test/monitoring_spec.rb | 102 ---------- src/acct/test/vm_monitoring_spec.rb | 299 ++++++++++++++++++++++++++++ 7 files changed, 485 insertions(+), 198 deletions(-) delete mode 100644 src/acct/test/monitoring_spec.rb create mode 100644 src/acct/test/vm_monitoring_spec.rb diff --git a/src/acct/test/1Vm1His.rb b/src/acct/test/1Vm1His.rb index 0dad640a1c..babf836dc9 100644 --- a/src/acct/test/1Vm1His.rb +++ b/src/acct/test/1Vm1His.rb @@ -1,3 +1,5 @@ +$: << '.' + require 'helper/test_helper.rb' describe "1 Vm 1 History" do diff --git a/src/acct/test/1VmXHis.rb b/src/acct/test/1VmXHis.rb index d0a94a0840..0d92ebb369 100644 --- a/src/acct/test/1VmXHis.rb +++ b/src/acct/test/1VmXHis.rb @@ -1,3 +1,5 @@ +$: << '.' + require 'helper/test_helper.rb' describe "1 Vm X History" do diff --git a/src/acct/test/XVm1His.rb b/src/acct/test/XVm1His.rb index 1aa11c2d7c..c0640feb48 100644 --- a/src/acct/test/XVm1His.rb +++ b/src/acct/test/XVm1His.rb @@ -1,3 +1,5 @@ +$: << '.' + require 'helper/test_helper.rb' describe "X Vm 1 History" do diff --git a/src/acct/test/cmonitoring_spec.rb b/src/acct/test/cmonitoring_spec.rb index 814ce9a7f4..dd79ed8719 100644 --- a/src/acct/test/cmonitoring_spec.rb +++ b/src/acct/test/cmonitoring_spec.rb @@ -1,4 +1,7 @@ +$: << '.' + require 'helper/test_helper.rb' +require 'watch_client' describe "VmWatchClient tests" do before(:all) do @@ -13,7 +16,7 @@ describe "VmWatchClient tests" do @db[:vms].count.should eql(0) end - it "1 VM, 1 timestamp. Check totals, sums and resource info" do + it "Create a VM: uid=2 gid=4, timestamp=100" do @monitoring.set_mock_timestamp(100) @monitoring.insert(create_vmpool_hash) @@ -24,7 +27,7 @@ describe "VmWatchClient tests" do :memory => 128, :net_tx => 200, :net_rx => 400, - :last_poll => 90, + :last_poll => 100, :uid => 2, :gid => 4, :history => [ @@ -55,16 +58,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check all the monitoring resources are shown by default and filtered" do @@ -78,16 +81,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check no info for non exisiting user" do @@ -104,7 +107,7 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(1) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) end it "should check only two monitoring resources are shown if specified" do @@ -115,10 +118,10 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(2) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) end it "should check all the total monitoring resources are shown by default" do @@ -134,19 +137,20 @@ describe "VmWatchClient tests" do monitoring[:active].size.should eql(1) monitoring[:active].first.should eql([100,1]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(1) + monitoring[:error].first.should eql([100,0]) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check only one total monitoring resources is shown if specified" do @@ -172,7 +176,7 @@ describe "VmWatchClient tests" do mon.should eql(nil) end - it "add a second VM" do + it "Create a second VM: uid=2 gid=4, timestamp=200" do @monitoring.set_mock_timestamp(200) values = { @@ -180,7 +184,7 @@ describe "VmWatchClient tests" do :memory => 128, :net_tx => 200, :net_rx => 400, - :last_poll => 90, + :last_poll => 100, :uid => 2, :gid => 4, :history => [ @@ -211,16 +215,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(2) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(2) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(2) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(2) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) mon = @watch_client.resource_monitoring(2) @@ -232,16 +236,16 @@ describe "VmWatchClient tests" do monitoring.keys.size.should eql(4) monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].first.should eql([100,1]) monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].first.should eql([100,128]) monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].first.should eql([100,200]) monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].first.should eql([100,400]) end it "should check all the total monitoring resources are shown by default" do @@ -259,22 +263,28 @@ describe "VmWatchClient tests" do monitoring[:active].first.should eql([100,1]) monitoring[:active][1].should eql([200,2]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(2) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1*2]) + monitoring[:cpu_usage].size.should eql(2) + monitoring[:cpu_usage].first.should eql([100,1]) + monitoring[:cpu_usage][1].should eql([200,1*2]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128*2]) + monitoring[:mem_usage].size.should eql(2) + monitoring[:mem_usage].first.should eql([100,128]) + monitoring[:mem_usage][1].should eql([200,128*2]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200*2]) + monitoring[:net_tx].size.should eql(2) + monitoring[:net_tx].first.should eql([100,200]) + monitoring[:net_tx][1].should eql([200,200*2]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400*2]) + monitoring[:net_rx].size.should eql(2) + monitoring[:net_rx].first.should eql([100,400]) + monitoring[:net_rx][1].should eql([200,400*2]) end - it "add a third VM" do + it "Create a third VM: uid=3 gid=5, timestamp=300" do @monitoring.set_mock_timestamp(300) values = { @@ -282,7 +292,7 @@ describe "VmWatchClient tests" do :memory => 128, :net_tx => 200, :net_rx => 400, - :last_poll => 90, + :last_poll => 270, :uid => 3, :gid => 5, :history => [ @@ -302,63 +312,93 @@ describe "VmWatchClient tests" do @db[:vms].count.should eql(3) end - it "should check the total monitoring resources are filtered by user" do + it "should check the total monitoring resources are filtered by uid(3)" do mon = @watch_client.total_monitoring(nil, :uid=>3) mon[:resource].should eql("VM_POOL") monitoring = mon[:monitoring] - monitoring[:total].size.should eql(1) - monitoring[:total].first.should eql([300,1]) + monitoring[:total].size.should eql(3) + monitoring[:total].first.should eql([100,0]) + monitoring[:total][1].should eql([200,0]) + monitoring[:total][2].should eql([300,1]) - monitoring[:active].size.should eql(1) - monitoring[:active].first.should eql([300,1]) + monitoring[:active].size.should eql(3) + monitoring[:active].first.should eql([100,0]) + monitoring[:active][1].should eql([200,0]) + monitoring[:active][2].should eql([300,1]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,0]) + monitoring[:cpu_usage][1].should eql([200,0]) + monitoring[:cpu_usage][2].should eql([300,1]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,0]) + monitoring[:mem_usage][1].should eql([200,0]) + monitoring[:mem_usage][2].should eql([300,128]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,0]) + monitoring[:net_tx][1].should eql([200,0]) + monitoring[:net_tx][2].should eql([300,200]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,0]) + monitoring[:net_rx][1].should eql([200,0]) + monitoring[:net_rx][2].should eql([300,400]) end - it "should check the total monitoring resources are filtered by group" do + it "should check the total monitoring resources are filtered by gid(5)" do mon = @watch_client.total_monitoring(nil, :gid=>5) mon[:resource].should eql("VM_POOL") monitoring = mon[:monitoring] - monitoring[:total].size.should eql(1) - monitoring[:total].first.should eql([300,1]) + monitoring[:total].size.should eql(3) + monitoring[:total].first.should eql([100,0]) + monitoring[:total][1].should eql([200,0]) + monitoring[:total][2].should eql([300,1]) - monitoring[:active].size.should eql(1) - monitoring[:active].first.should eql([300,1]) + monitoring[:active].size.should eql(3) + monitoring[:active].first.should eql([100,0]) + monitoring[:active][1].should eql([200,0]) + monitoring[:active][2].should eql([300,1]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,0]) + monitoring[:cpu_usage][1].should eql([200,0]) + monitoring[:cpu_usage][2].should eql([300,1]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,0]) + monitoring[:mem_usage][1].should eql([200,0]) + monitoring[:mem_usage][2].should eql([300,128]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,0]) + monitoring[:net_tx][1].should eql([200,0]) + monitoring[:net_tx][2].should eql([300,200]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,0]) + monitoring[:net_rx][1].should eql([200,0]) + monitoring[:net_rx][2].should eql([300,400]) end - it "should check the total monitoring resources are filtered by user" do + it "should check the total monitoring resources are filtered by uid(2)" do mon = @watch_client.total_monitoring(nil, :uid=>2) mon[:resource].should eql("VM_POOL") @@ -375,22 +415,33 @@ describe "VmWatchClient tests" do monitoring[:active][1].should eql([200,2]) monitoring[:active].last.should eql([300,2]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1*2]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,1]) + monitoring[:cpu_usage][1].should eql([200,2]) + monitoring[:cpu_usage][2].should eql([300,2]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128*2]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,128]) + monitoring[:mem_usage][1].should eql([200,256]) + monitoring[:mem_usage][2].should eql([300,256]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200*2]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,200]) + monitoring[:net_tx][1].should eql([200,400]) + monitoring[:net_tx][2].should eql([300,400]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400*2]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,400]) + monitoring[:net_rx][1].should eql([200,800]) + monitoring[:net_rx][2].should eql([300,800]) end - it "should check the total monitoring resources are filtered by group" do + it "should check the total monitoring resources are filtered by gid(4)" do mon = @watch_client.total_monitoring(nil, :gid=>4) mon[:resource].should eql("VM_POOL") @@ -400,26 +451,37 @@ describe "VmWatchClient tests" do monitoring[:total].size.should eql(3) monitoring[:total].first.should eql([100,1]) monitoring[:total][1].should eql([200,2]) - monitoring[:active].last.should eql([300,2]) + monitoring[:total].last.should eql([300,2]) monitoring[:active].size.should eql(3) monitoring[:active].first.should eql([100,1]) monitoring[:active][1].should eql([200,2]) monitoring[:active].last.should eql([300,2]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(1) - monitoring[:cpu_usage].first.should eql([90,1*2]) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,1]) + monitoring[:cpu_usage][1].should eql([200,2]) + monitoring[:cpu_usage][2].should eql([300,2]) - monitoring[:mem_usage].size.should eql(1) - monitoring[:mem_usage].first.should eql([90,128*2]) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,128]) + monitoring[:mem_usage][1].should eql([200,256]) + monitoring[:mem_usage][2].should eql([300,256]) - monitoring[:net_tx].size.should eql(1) - monitoring[:net_tx].first.should eql([90,200*2]) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,200]) + monitoring[:net_tx][1].should eql([200,400]) + monitoring[:net_tx][2].should eql([300,400]) - monitoring[:net_rx].size.should eql(1) - monitoring[:net_rx].first.should eql([90,400*2]) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,400]) + monitoring[:net_rx][1].should eql([200,800]) + monitoring[:net_rx][2].should eql([300,800]) end it "should check no total info for non existing user" do @@ -429,18 +491,39 @@ describe "VmWatchClient tests" do monitoring = mon[:monitoring] - monitoring[:total].size.should eql(0) + monitoring[:total].size.should eql(3) + monitoring[:total].first.should eql([100,0]) + monitoring[:total][1].should eql([200,0]) + monitoring[:total].last.should eql([300,0]) - monitoring[:active].size.should eql(0) + monitoring[:active].size.should eql(3) + monitoring[:active].first.should eql([100,0]) + monitoring[:active][1].should eql([200,0]) + monitoring[:active].last.should eql([300,0]) - monitoring[:error].size.should eql(0) + monitoring[:error].size.should eql(3) + monitoring[:error].first.should eql([100,0]) + monitoring[:error][1].should eql([200,0]) + monitoring[:error][2].should eql([300,0]) - monitoring[:cpu_usage].size.should eql(0) + monitoring[:cpu_usage].size.should eql(3) + monitoring[:cpu_usage].first.should eql([100,0]) + monitoring[:cpu_usage][1].should eql([200,0]) + monitoring[:cpu_usage][2].should eql([300,0]) - monitoring[:mem_usage].size.should eql(0) + monitoring[:mem_usage].size.should eql(3) + monitoring[:mem_usage].first.should eql([100,0]) + monitoring[:mem_usage][1].should eql([200,0]) + monitoring[:mem_usage][2].should eql([300,0]) - monitoring[:net_tx].size.should eql(0) + monitoring[:net_tx].size.should eql(3) + monitoring[:net_tx].first.should eql([100,0]) + monitoring[:net_tx][1].should eql([200,0]) + monitoring[:net_tx][2].should eql([300,0]) - monitoring[:net_rx].size.should eql(0) + monitoring[:net_rx].size.should eql(3) + monitoring[:net_rx].first.should eql([100,0]) + monitoring[:net_rx][1].should eql([200,0]) + monitoring[:net_rx][2].should eql([300,0]) end end \ No newline at end of file diff --git a/src/acct/test/helper/test_helper.rb b/src/acct/test/helper/test_helper.rb index eab69fbf94..ef4b0948dd 100644 --- a/src/acct/test/helper/test_helper.rb +++ b/src/acct/test/helper/test_helper.rb @@ -18,7 +18,6 @@ $: << '..' require 'examples/acct_client' -require 'watch_client' require 'mock_client' require 'accounting' @@ -58,6 +57,8 @@ def clean_db WatchHelper::VmDelta.destroy WatchHelper::VmSample.destroy WatchHelper::HostSample.destroy + WatchHelper::VmTimestamp.destroy + WatchHelper::HostTimestamp.destroy WatchHelper::Vm.destroy WatchHelper::Host.destroy rescue Exception => e diff --git a/src/acct/test/monitoring_spec.rb b/src/acct/test/monitoring_spec.rb deleted file mode 100644 index f3f7272a17..0000000000 --- a/src/acct/test/monitoring_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -require 'helper/test_helper.rb' - -describe "1 Vm 1 10 steps" do - before(:each) do - clean_db - - @mock_client = MockClient.new - @monitoring = OneWatch::VmMonitoring.new - - @watch_client = OneWatchClient::WatchClient.new - - @db = WatchHelper::DB - @db[:vms].count.should eql(0) - end - - it "CPU testing" do - ts1 = 100 - @monitoring.set_mock_timestamp(ts1) - - @monitoring.insert(create_vmpool_hash) - @db[:vms].count.should eql(0) - - 10.times { |i| - ts2 = 200+100*i - @monitoring.set_mock_timestamp(ts2) - - values = { - :cpu => 80+i, - :memory => 122+i, - :net_tx => 200+i, - :net_rx => 134+i, - :last_poll => 1309275256+i, - :uid => 2, - :gid => 4, - :history => [ - :hid => 7, - :pstime => 150, - :petime => 0, - :rstime => 0, - :retime => 0, - :estime => 0, - :eetime => 0, - :reason => 0 - ] - } - - @mock_client.add_vm(1, values) - - @monitoring.insert(create_vmpool_hash) - @db[:vms].count.should eql(1) - @db[:vm_samples].count.should eql(1+i > 5 ? 5 : 1+i) - - @watch_client.vm_monitoring(1, ['cpu', 'net_tx']) - - @watch_client.vm_total - } - end - - it "Total testing" do - ts1 = 100 - @monitoring.set_mock_timestamp(ts1) - - @monitoring.insert(create_vmpool_hash) - @db[:vms].count.should eql(0) - - 10.times { |i| - ts2 = 200+100*i - @monitoring.set_mock_timestamp(ts2) - - values = { - :cpu => 80+i, - :memory => 122+i, - :net_tx => 200+i, - :net_rx => 134+i, - :state => 7, - :last_poll => 1309275256+i, - :uid => 2, - :gid => 4, - :history => [ - :hid => 7, - :pstime => 150, - :petime => 0, - :rstime => 0, - :retime => 0, - :estime => 0, - :eetime => 0, - :reason => 0 - ] - } - - values[:state] = 7 - @mock_client.add_vm(i+100, values) - values[:state] = 3 - @mock_client.add_vm(i+10, values) - - @monitoring.insert(create_vmpool_hash) - - @db[:vm_samples].count - total = @watch_client.vm_total([:total, :error, :active]) - } - end -end \ No newline at end of file diff --git a/src/acct/test/vm_monitoring_spec.rb b/src/acct/test/vm_monitoring_spec.rb new file mode 100644 index 0000000000..5465a238a8 --- /dev/null +++ b/src/acct/test/vm_monitoring_spec.rb @@ -0,0 +1,299 @@ +$: << '.' + +require 'helper/test_helper.rb' + +describe "VM Monitoring tests" do + before(:all) do + clean_db + + @mock_client = MockClient.new + @monitoring = OneWatch::VmMonitoring.new + + #@watch_client = OneWatchClient::WatchClient.new + + @db = WatchHelper::DB + @db[:vms].count.should eql(0) + @db[:vm_samples].count.should eql(0) + @db[:vm_timestamps].count.should eql(0) + end + + it "after monitoring an empty pool: 0 VMs, 0 Samples, 1 Timestamp" do + ts1 = 100 + @monitoring.set_mock_timestamp(ts1) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(0) + @db[:vm_samples].count.should eql(0) + @db[:vm_timestamps].count.should eql(1) + end + + it "after monitoring a pool of 1 VM: 1 VMs, 1 Samples, 2 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(0, values) + + ts2 = 200 + @monitoring.set_mock_timestamp(ts2) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(1) + @db[:vm_samples].count.should eql(1) + @db[:vm_timestamps].count.should eql(2) + end + + it "after monitoring a pool of 1 VM: 1 VMs, 2 Samples, 3 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(0, values) + + ts = 300 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(1) + @db[:vm_samples].count.should eql(2) + @db[:vm_timestamps].count.should eql(3) + end + + it "after monitoring a pool of 2 VM: 2 VMs, 4 Samples, 4 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(1, values) + + ts = 400 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(2) + @db[:vm_samples].count.should eql(4) + @db[:vm_timestamps].count.should eql(4) + end + + it "after monitoring a pool of 2 VM: 2 VMs, 6 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(1, values) + + ts = 500 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(2) + @db[:vm_samples].count.should eql(6) + @db[:vm_timestamps].count.should eql(5) + end + + it "after monitoring a pool of 3 VM: 3 VMs, 9 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(2, values) + + ts = 600 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(3) + @db[:vm_samples].count.should eql(9) + @db[:vm_timestamps].count.should eql(5) + end + + it "after monitoring a pool of 3 VM: 3 VMs, 11 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(2, values) + + ts = 700 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(3) + @db[:vm_samples].count.should eql(11) + @db[:vm_timestamps].count.should eql(5) + end + + + it "after monitoring a pool of 3 VM: 3 VMs, 13 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(2, values) + + ts = 800 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(3) + @db[:vm_samples].count.should eql(13) + @db[:vm_timestamps].count.should eql(5) + end + + it "after monitoring a pool of 4 VM: 4 VMs, 16 Samples, 5 Timestamp" do + values = { + :cpu => 80, + :memory => 122, + :net_tx => 200, + :net_rx => 134, + :last_poll => 1309275256, + :uid => 2, + :gid => 4, + :history => [ + :hid => 7, + :pstime => 150, + :petime => 0, + :rstime => 0, + :retime => 0, + :estime => 0, + :eetime => 0, + :reason => 0 + ] + } + + @mock_client.add_vm(3, values) + + ts = 900 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + @db[:vms].count.should eql(4) + @db[:vm_samples].count.should eql(15) + @db[:vm_timestamps].count.should eql(5) + end + + it "after (10)monitoring a pool of 4 VM: 4 VMs, 20 Samples, 5 Timestamp" do + 10.times { |i| + ts = 1000+i*100 + @monitoring.set_mock_timestamp(ts) + + @monitoring.insert(create_vmpool_hash) + } + + @db[:vms].count.should eql(4) + @db[:vm_samples].count.should eql(20) + @db[:vm_timestamps].count.should eql(5) + end +end \ No newline at end of file From e1d6264ea88a0b64c8cb13704cb9a418bc1e0718 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 18:06:03 +0200 Subject: [PATCH 05/24] bug #716: Fix bug in host monitoring client(cherry picked from commit 16424e9a52632b734af6de789c8b168caf78319c) --- src/acct/watch_client.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/acct/watch_client.rb b/src/acct/watch_client.rb index 36efadb078..0ff9c4f7c0 100644 --- a/src/acct/watch_client.rb +++ b/src/acct/watch_client.rb @@ -97,18 +97,11 @@ module OneWatchClient # Get the MAX for each VM and last_poll value max_per_vm = rsql. - group(:vm_id, :timestamp). - select{[:timestamp, max(mr.to_sym).as(:max_mr)]} - - # SUM the monitoring resource for each last_poll value - last_poll_and_sum = - max_per_vm. - from_self. group(:timestamp). - select{[:timestamp, sum(:max_mr).as(:sum_mr)]} + select{[:timestamp, sum(mr.to_sym).as(:sum_mr)]} # Add all the existing timestamps - with_ts = timestamps.left_join(last_poll_and_sum, :timestamp=>:id) + with_ts = timestamps.left_join(max_per_vm, :timestamp=>:id) with_ts.collect do |row| [row[:id], row[:sum_mr].to_i] end @@ -166,7 +159,7 @@ module OneWatchClient hosts = pool end - WatchHelper::HostSample.join(vms.select(:id.as(:host_id)), [:host_id]) + WatchHelper::HostSample.join(hosts.select(:id.as(:host_id)), [:host_id]) end def filter_resource(id, filter) From 96a539d481767365d0e13beca2ee5d727e535196 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 18:25:06 +0200 Subject: [PATCH 06/24] bug #716: Fix constant name(cherry picked from commit 6cc9a076a881b725ac1222d0a5ea9550e537005f) --- src/acct/watch_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/acct/watch_helper.rb b/src/acct/watch_helper.rb index 439606dd6c..8a87182d39 100644 --- a/src/acct/watch_helper.rb +++ b/src/acct/watch_helper.rb @@ -413,7 +413,7 @@ module WatchHelper unrestrict_primary_key # Monitoring - one_to_many :samples, :order=>:timestamp, :class=>:HostSample + one_to_many :samples, :order=>:timestamp, :class=>"WatchHelper::HostSample" @@samples_cache = [] From 459b41fb425c9f343b11e0b98b66d78c96e2e28f Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 15 Sep 2011 12:54:29 +0200 Subject: [PATCH 07/24] Bug #811: Image delete does not use the old image repo anymore (cherry picked from commit c8c82f03783c5f297fa8db4bc3fad54a335d6738) --- src/cloud/occi/lib/OCCIServer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index f86f90dda5..9ba674a869 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -563,7 +563,7 @@ class OCCIServer < CloudServer return rc, 404 if OpenNebula::is_error?(rc) # --- Delete the Image --- - rc = @img_repo.delete(image) + rc = image.delete return rc, 500 if OpenNebula::is_error?(rc) return "", 204 From 954715074aecf27e0ff0c0a196c0872d37dd5611 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 14:07:22 +0200 Subject: [PATCH 08/24] Bug #805: Saveas images are now left in lock state (cherry picked from commit 4ff07776d812cc86cd900f6c38ddf5862ec7618a) --- src/image/ImageManagerActions.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc index 9d88e98ea1..1d3cdd8dec 100644 --- a/src/image/ImageManagerActions.cc +++ b/src/image/ImageManagerActions.cc @@ -382,11 +382,16 @@ int ImageManager::register_image(int iid) } else { - img->set_state(Image::READY); - ipool->update(img); + string source = img->get_source(); - oss << "Using source " << img->get_source() - << " from template for image " << img->get_name(); + if (source != "-") //SAVE_AS IMAGE DO NOT ENABLE THE IMAGE + { + img->set_state(Image::READY); + ipool->update(img); + + oss << "Using source " << img->get_source() + << " from template for image " << img->get_name(); + } } } else //PATH -> COPY TO REPOSITORY AS SOURCE From 1abd55d030c07daa498118b9d6f0b28a93919da3 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 12 Jul 2011 18:08:07 +0200 Subject: [PATCH 09/24] feature #715: changed tm_nfs name to tm_shared (cherry picked from commit 67d278990b282e98f2968b204cc44b2e3e324f8d) --- install.sh | 30 +++++++++---------- share/etc/oned.conf | 6 ++-- src/mad/ruby/test/fixtures/var/config | 2 +- src/oca/java/test/oned.conf | 6 ++-- src/onedb/test/oned.conf | 6 ++-- src/scheduler/src/pool/test/HostXMLTest.cc | 10 +++---- .../src/pool/test/VirtualMachineXMLTest.cc | 10 +++---- src/sunstone/public/js/plugins/hosts-tab.js | 2 +- src/tm_mad/{nfs => shared}/tm_clone.sh | 0 src/tm_mad/{nfs => shared}/tm_context.sh | 0 src/tm_mad/{nfs => shared}/tm_delete.sh | 0 src/tm_mad/{nfs => shared}/tm_ln.sh | 0 src/tm_mad/{nfs => shared}/tm_mkimage.sh | 0 src/tm_mad/{nfs => shared}/tm_mkswap.sh | 0 src/tm_mad/{nfs => shared}/tm_mv.sh | 0 .../tm_nfs.conf => shared/tm_shared.conf} | 14 ++++----- .../{nfs/tm_nfsrc => shared/tm_sharedrc} | 0 src/vnm_mad/test/output/onevm_show | 2 +- src/xml/test/ObjectXMLTest.cc | 2 +- 19 files changed, 45 insertions(+), 45 deletions(-) rename src/tm_mad/{nfs => shared}/tm_clone.sh (100%) rename src/tm_mad/{nfs => shared}/tm_context.sh (100%) rename src/tm_mad/{nfs => shared}/tm_delete.sh (100%) rename src/tm_mad/{nfs => shared}/tm_ln.sh (100%) rename src/tm_mad/{nfs => shared}/tm_mkimage.sh (100%) rename src/tm_mad/{nfs => shared}/tm_mkswap.sh (100%) rename src/tm_mad/{nfs => shared}/tm_mv.sh (100%) rename src/tm_mad/{nfs/tm_nfs.conf => shared/tm_shared.conf} (85%) rename src/tm_mad/{nfs/tm_nfsrc => shared/tm_sharedrc} (100%) diff --git a/install.sh b/install.sh index 8a28e0d9cd..4628a9a348 100755 --- a/install.sh +++ b/install.sh @@ -185,7 +185,7 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/im_ec2 \ $ETC_LOCATION/vmm_ec2 \ $ETC_LOCATION/vmm_exec \ - $ETC_LOCATION/tm_nfs \ + $ETC_LOCATION/tm_shared \ $ETC_LOCATION/tm_ssh \ $ETC_LOCATION/tm_dummy \ $ETC_LOCATION/tm_lvm \ @@ -204,7 +204,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/cloud/occi \ $LIB_LOCATION/ruby/onedb \ $LIB_LOCATION/tm_commands \ - $LIB_LOCATION/tm_commands/nfs \ + $LIB_LOCATION/tm_commands/shared \ $LIB_LOCATION/tm_commands/ssh \ $LIB_LOCATION/tm_commands/dummy \ $LIB_LOCATION/tm_commands/lvm \ @@ -336,7 +336,7 @@ INSTALL_FILES=( VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/xen/poll VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll_local VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/xen/poll_local - NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs + SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm @@ -445,7 +445,7 @@ INSTALL_ETC_FILES=( VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2 - TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs + TM_SHARED_ETC_FILES:$ETC_LOCATION/tm_shared TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm @@ -609,19 +609,19 @@ AUTH_QUOTA_FILES="src/authm_mad/remotes/quota/authorize" #------------------------------------------------------------------------------- # Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands -# - NFS TM, $LIB_LOCATION/tm_commands/nfs +# - SHARED TM, $LIB_LOCATION/tm_commands/shared # - SSH TM, $LIB_LOCATION/tm_commands/ssh # - dummy TM, $LIB_LOCATION/tm_commands/dummy # - LVM TM, $LIB_LOCATION/tm_commands/lvm #------------------------------------------------------------------------------- -NFS_TM_COMMANDS_LIB_FILES="src/tm_mad/nfs/tm_clone.sh \ - src/tm_mad/nfs/tm_delete.sh \ - src/tm_mad/nfs/tm_ln.sh \ - src/tm_mad/nfs/tm_mkswap.sh \ - src/tm_mad/nfs/tm_mkimage.sh \ - src/tm_mad/nfs/tm_mv.sh \ - src/tm_mad/nfs/tm_context.sh" +SHARED_TM_COMMANDS_LIB_FILES="src/tm_mad/shared/tm_clone.sh \ + src/tm_mad/shared/tm_delete.sh \ + src/tm_mad/shared/tm_ln.sh \ + src/tm_mad/shared/tm_mkswap.sh \ + src/tm_mad/shared/tm_mkimage.sh \ + src/tm_mad/shared/tm_mv.sh \ + src/tm_mad/shared/tm_context.sh" SSH_TM_COMMANDS_LIB_FILES="src/tm_mad/ssh/tm_clone.sh \ src/tm_mad/ssh/tm_delete.sh \ @@ -691,14 +691,14 @@ IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \ #------------------------------------------------------------------------------- # Storage drivers config. files, to be installed under $ETC_LOCATION -# - nfs, $ETC_LOCATION/tm_nfs +# - shared, $ETC_LOCATION/tm_shared # - ssh, $ETC_LOCATION/tm_ssh # - dummy, $ETC_LOCATION/tm_dummy # - lvm, $ETC_LOCATION/tm_lvm #------------------------------------------------------------------------------- -TM_NFS_ETC_FILES="src/tm_mad/nfs/tm_nfs.conf \ - src/tm_mad/nfs/tm_nfsrc" +TM_SHARED_ETC_FILES="src/tm_mad/shared/tm_shared.conf \ + src/tm_mad/shared/tm_sharedrc" TM_SSH_ETC_FILES="src/tm_mad/ssh/tm_ssh.conf \ src/tm_mad/ssh/tm_sshrc" diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 1f110b3b6d..762465c9df 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -254,12 +254,12 @@ VM_MAD = [ #******************************************************************************* #------------------------------------------------------------------------------- -# NFS Transfer Manager Driver Configuration +# SHARED Transfer Manager Driver Configuration #------------------------------------------------------------------------------- TM_MAD = [ - name = "tm_nfs", + name = "tm_shared", executable = "one_tm", - arguments = "tm_nfs/tm_nfs.conf" ] + arguments = "tm_shared/tm_shared.conf" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/mad/ruby/test/fixtures/var/config b/src/mad/ruby/test/fixtures/var/config index bc785fa891..58ddb96adf 100644 --- a/src/mad/ruby/test/fixtures/var/config +++ b/src/mad/ruby/test/fixtures/var/config @@ -12,7 +12,7 @@ MANAGER_TIMER=15 NETWORK_SIZE=254 PORT=2633 SCRIPTS_REMOTE_DIR=/var/tmp/one -TM_MAD=ARGUMENTS=tm_nfs/tm_nfs.conf,EXECUTABLE=one_tm,NAME=tm_nfs +TM_MAD=ARGUMENTS=tm_shared/tm_shared.conf,EXECUTABLE=one_tm,NAME=tm_shared VM_DIR=/Users/jfontan/tmp/borrar/git/one/install/var/ VM_MAD=ARGUMENTS=-t 15 -r 0 kvm,DEFAULT=vmm_ssh/vmm_ssh_kvm.conf,EXECUTABLE=one_vmm_ssh,NAME=vmm_kvm,TYPE=kvm VM_POLLING_INTERVAL=600 diff --git a/src/oca/java/test/oned.conf b/src/oca/java/test/oned.conf index cc7eb53924..4a82a75f18 100644 --- a/src/oca/java/test/oned.conf +++ b/src/oca/java/test/oned.conf @@ -250,12 +250,12 @@ VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] #******************************************************************************* #------------------------------------------------------------------------------- -# NFS Transfer Manager Driver Configuration +# SHARED Transfer Manager Driver Configuration #------------------------------------------------------------------------------- TM_MAD = [ - name = "tm_nfs", + name = "tm_shared", executable = "one_tm", - arguments = "tm_nfs/tm_nfs.conf" ] + arguments = "tm_shared/tm_shared.conf" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/onedb/test/oned.conf b/src/onedb/test/oned.conf index 1394fcdd2a..e8a6aca4f9 100644 --- a/src/onedb/test/oned.conf +++ b/src/onedb/test/oned.conf @@ -245,12 +245,12 @@ VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] #******************************************************************************* #------------------------------------------------------------------------------- -# NFS Transfer Manager Driver Configuration +# SHARED Transfer Manager Driver Configuration #------------------------------------------------------------------------------- #TM_MAD = [ -# name = "tm_nfs", +# name = "tm_shared", # executable = "one_tm", -# arguments = "tm_nfs/tm_nfs.conf" ] +# arguments = "tm_shared/tm_shared.conf" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/scheduler/src/pool/test/HostXMLTest.cc b/src/scheduler/src/pool/test/HostXMLTest.cc index 2d47c9e5e4..b928f52679 100644 --- a/src/scheduler/src/pool/test/HostXMLTest.cc +++ b/src/scheduler/src/pool/test/HostXMLTest.cc @@ -266,7 +266,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107238\ \ 1\ @@ -307,7 +307,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107299\ \ 2\ @@ -350,7 +350,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107328\ \ 4\ @@ -391,7 +391,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107300\ \ 5\ @@ -428,6 +428,6 @@ const string FriendHostPool::xmls[] = }; const string FriendHostPool::host_dump = -" 1 ursa12 2 im_kvm vmm_kvm tm_nfs 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_nfs 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_nfs 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_nfs 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_nfs 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_nfs 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; +" 1 ursa12 2 im_kvm vmm_kvm tm_shared 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_shared 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_shared 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_shared 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_shared 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_shared 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; diff --git a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc index d28823a547..5780793a7c 100644 --- a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc +++ b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc @@ -333,7 +333,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107238\ \ 1\ @@ -374,7 +374,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107299\ \ 2\ @@ -417,7 +417,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107328\ \ 4\ @@ -458,7 +458,7 @@ const string FriendHostPool::xmls[] = 2\ im_kvm\ vmm_kvm\ - tm_nfs\ + tm_shared\ 1274107300\ \ 5\ @@ -495,6 +495,6 @@ const string FriendHostPool::xmls[] = }; const string FriendHostPool::host_dump = -" 1 ursa12 2 im_kvm vmm_kvm tm_nfs 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_nfs 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_nfs 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_nfs 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_nfs 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_nfs 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; +" 1 ursa12 2 im_kvm vmm_kvm tm_shared 1274107145 1 0 0 0 0 8194368 800 0 7955180 800 0 535848 0 0 2 ursa 2 im_kvm vmm_kvm tm_shared 1274107206 2 0 4280320 700 0 16468252 800 0 9109156 628 0 13891232 172 7 4 ursa11 2 im_kvm vmm_kvm tm_shared 1274107145 4 0 0 0 0 8194368 800 0 7958684 800 0 621616 0 0 5 ursa10 2 im_kvm vmm_kvm tm_shared 1274107207 5 0 0 0 0 8194368 800 0 7870776 796 0 2192424 4 0 6 ursa08 3 im_kvm vmm_kvm tm_shared 1274107176 6 0 0 0 0 0 0 0 6585200 0 0 1132608 0 0 7 ursa09 3 im_kvm vmm_kvm tm_shared 1274107146 7 0 524288 100 0 8194368 800 0 7286128 798 0 8011908 1 1 "; diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 497e585f61..d3a09a0be7 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -83,7 +83,7 @@ var create_host_tmpl =
\ \ \ diff --git a/src/tm_mad/nfs/tm_clone.sh b/src/tm_mad/shared/tm_clone.sh similarity index 100% rename from src/tm_mad/nfs/tm_clone.sh rename to src/tm_mad/shared/tm_clone.sh diff --git a/src/tm_mad/nfs/tm_context.sh b/src/tm_mad/shared/tm_context.sh similarity index 100% rename from src/tm_mad/nfs/tm_context.sh rename to src/tm_mad/shared/tm_context.sh diff --git a/src/tm_mad/nfs/tm_delete.sh b/src/tm_mad/shared/tm_delete.sh similarity index 100% rename from src/tm_mad/nfs/tm_delete.sh rename to src/tm_mad/shared/tm_delete.sh diff --git a/src/tm_mad/nfs/tm_ln.sh b/src/tm_mad/shared/tm_ln.sh similarity index 100% rename from src/tm_mad/nfs/tm_ln.sh rename to src/tm_mad/shared/tm_ln.sh diff --git a/src/tm_mad/nfs/tm_mkimage.sh b/src/tm_mad/shared/tm_mkimage.sh similarity index 100% rename from src/tm_mad/nfs/tm_mkimage.sh rename to src/tm_mad/shared/tm_mkimage.sh diff --git a/src/tm_mad/nfs/tm_mkswap.sh b/src/tm_mad/shared/tm_mkswap.sh similarity index 100% rename from src/tm_mad/nfs/tm_mkswap.sh rename to src/tm_mad/shared/tm_mkswap.sh diff --git a/src/tm_mad/nfs/tm_mv.sh b/src/tm_mad/shared/tm_mv.sh similarity index 100% rename from src/tm_mad/nfs/tm_mv.sh rename to src/tm_mad/shared/tm_mv.sh diff --git a/src/tm_mad/nfs/tm_nfs.conf b/src/tm_mad/shared/tm_shared.conf similarity index 85% rename from src/tm_mad/nfs/tm_nfs.conf rename to src/tm_mad/shared/tm_shared.conf index bb980d7e48..1e09c41cff 100644 --- a/src/tm_mad/nfs/tm_nfs.conf +++ b/src/tm_mad/shared/tm_shared.conf @@ -14,10 +14,10 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -CLONE = nfs/tm_clone.sh -LN = nfs/tm_ln.sh -MKSWAP = nfs/tm_mkswap.sh -MKIMAGE = nfs/tm_mkimage.sh -DELETE = nfs/tm_delete.sh -MV = nfs/tm_mv.sh -CONTEXT = nfs/tm_context.sh +CLONE = shared/tm_clone.sh +LN = shared/tm_ln.sh +MKSWAP = shared/tm_mkswap.sh +MKIMAGE = shared/tm_mkimage.sh +DELETE = shared/tm_delete.sh +MV = shared/tm_mv.sh +CONTEXT = shared/tm_context.sh diff --git a/src/tm_mad/nfs/tm_nfsrc b/src/tm_mad/shared/tm_sharedrc similarity index 100% rename from src/tm_mad/nfs/tm_nfsrc rename to src/tm_mad/shared/tm_sharedrc diff --git a/src/vnm_mad/test/output/onevm_show b/src/vnm_mad/test/output/onevm_show index a64d22fa1b..ec56cbf225 100644 --- a/src/vnm_mad/test/output/onevm_show +++ b/src/vnm_mad/test/output/onevm_show @@ -62,7 +62,7 @@ 1304502543 0 vmm_kvm - tm_nfs + tm_shared 1304502543 1304502544 1304502544 diff --git a/src/xml/test/ObjectXMLTest.cc b/src/xml/test/ObjectXMLTest.cc index fd538203d3..977189c35b 100644 --- a/src/xml/test/ObjectXMLTest.cc +++ b/src/xml/test/ObjectXMLTest.cc @@ -434,7 +434,7 @@ const string ObjectXMLTest::host = "2" "im_kvm" "vmm_kvm" - "tm_nfs" + "tm_shared" "1273799044" "cluster A" "" From 7f88793fa9aadaf084043baa341024ce825c21bb Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 15 Sep 2011 17:43:13 +0200 Subject: [PATCH 10/24] bug #616: files copied in multiple dirs are now links --- install.sh | 15 ++++----------- src/vmm_mad/remotes/kvm/poll | 1 + src/vmm_mad/remotes/kvm/poll_local | 1 + src/vmm_mad/remotes/xen/poll | 1 + src/vmm_mad/remotes/xen/poll_local | 1 + 5 files changed, 8 insertions(+), 11 deletions(-) create mode 120000 src/vmm_mad/remotes/kvm/poll create mode 120000 src/vmm_mad/remotes/kvm/poll_local create mode 120000 src/vmm_mad/remotes/xen/poll create mode 120000 src/vmm_mad/remotes/xen/poll_local diff --git a/install.sh b/install.sh index 4628a9a348..d6bc746d5b 100755 --- a/install.sh +++ b/install.sh @@ -332,10 +332,6 @@ INSTALL_FILES=( AUTH_QUOTA_FILES:$VAR_LOCATION/remotes/auth/quota VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm VMM_EXEC_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen - VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll - VMM_EXEC_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/xen/poll - VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll_local - VMM_EXEC_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/xen/poll_local SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy @@ -552,6 +548,8 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \ src/vmm_mad/remotes/kvm/migrate_local \ src/vmm_mad/remotes/kvm/restore \ src/vmm_mad/remotes/kvm/save \ + src/vmm_mad/remotes/kvm/poll \ + src/vmm_mad/remotes/kvm/poll_local \ src/vmm_mad/remotes/kvm/shutdown" #------------------------------------------------------------------------------- @@ -564,15 +562,10 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ src/vmm_mad/remotes/xen/migrate \ src/vmm_mad/remotes/xen/restore \ src/vmm_mad/remotes/xen/save \ + src/vmm_mad/remotes/xen/poll \ + src/vmm_mad/remotes/xen/poll_local \ src/vmm_mad/remotes/xen/shutdown" -#----------------------------------------------------------------------------- -# VMM SH Driver xen/kvm scripts, to be installed under $REMOTES_LOCATION/vmm/* -#----------------------------------------------------------------------------- - -VMM_EXEC_XEN_KVM_POLL="src/vmm_mad/remotes/poll_xen_kvm.rb" -VMM_EXEC_GANGLIA_POLL="src/vmm_mad/remotes/poll_ganglia.rb" - #------------------------------------------------------------------------------- # Information Manager Probes, to be installed under $REMOTES_LOCATION/im #------------------------------------------------------------------------------- diff --git a/src/vmm_mad/remotes/kvm/poll b/src/vmm_mad/remotes/kvm/poll new file mode 120000 index 0000000000..fb5e9b8f73 --- /dev/null +++ b/src/vmm_mad/remotes/kvm/poll @@ -0,0 +1 @@ +../poll_xen_kvm.rb \ No newline at end of file diff --git a/src/vmm_mad/remotes/kvm/poll_local b/src/vmm_mad/remotes/kvm/poll_local new file mode 120000 index 0000000000..ca1f0231c9 --- /dev/null +++ b/src/vmm_mad/remotes/kvm/poll_local @@ -0,0 +1 @@ +../poll_ganglia.rb \ No newline at end of file diff --git a/src/vmm_mad/remotes/xen/poll b/src/vmm_mad/remotes/xen/poll new file mode 120000 index 0000000000..fb5e9b8f73 --- /dev/null +++ b/src/vmm_mad/remotes/xen/poll @@ -0,0 +1 @@ +../poll_xen_kvm.rb \ No newline at end of file diff --git a/src/vmm_mad/remotes/xen/poll_local b/src/vmm_mad/remotes/xen/poll_local new file mode 120000 index 0000000000..ca1f0231c9 --- /dev/null +++ b/src/vmm_mad/remotes/xen/poll_local @@ -0,0 +1 @@ +../poll_ganglia.rb \ No newline at end of file From 5a39c6b5bd395758c68d6b6181110b9d39b52bcb Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 15 Sep 2011 17:50:49 +0200 Subject: [PATCH 11/24] poll_local is now called poll_ganglia --- src/vmm_mad/remotes/kvm/{poll_local => poll_ganglia} | 0 src/vmm_mad/remotes/xen/{poll_local => poll_ganglia} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/vmm_mad/remotes/kvm/{poll_local => poll_ganglia} (100%) rename src/vmm_mad/remotes/xen/{poll_local => poll_ganglia} (100%) diff --git a/src/vmm_mad/remotes/kvm/poll_local b/src/vmm_mad/remotes/kvm/poll_ganglia similarity index 100% rename from src/vmm_mad/remotes/kvm/poll_local rename to src/vmm_mad/remotes/kvm/poll_ganglia diff --git a/src/vmm_mad/remotes/xen/poll_local b/src/vmm_mad/remotes/xen/poll_ganglia similarity index 100% rename from src/vmm_mad/remotes/xen/poll_local rename to src/vmm_mad/remotes/xen/poll_ganglia From 91d554b3aa9d78008ecc4399c673325fa58a2309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 15 Sep 2011 19:06:16 +0200 Subject: [PATCH 12/24] Bug #804: Better image release rollback when a VM can't be created --- include/ImageManager.h | 21 ++++++++++++ include/ImagePool.h | 4 ++- src/image/ImageManagerActions.cc | 10 ++---- src/image/ImagePool.cc | 4 +-- src/vm/VirtualMachine.cc | 55 ++++++++++++++++++++++---------- 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/include/ImageManager.h b/include/ImageManager.h index 4e7daca0dd..de14c32455 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -96,6 +96,27 @@ public: void release_image(const string& iid, const string& disk_path, int disk_num, + const string& saveid) + { + int image_id; + istringstream iss; + + iss.str(iid); + iss >> image_id; + + return release_image(image_id, disk_path, disk_num, saveid); + }; + + /** + * Releases an image and triggers any needed operations in the repo + * @param iid image id of the image to be released + * @param disk_path base path for disk location + * @param disk number for this image in the VM + * @param saveid id of image to save the current image + */ + void release_image(int iid, + const string& disk_path, + int disk_num, const string& saveid); /** diff --git a/include/ImagePool.h b/include/ImagePool.h index d69a2f3a60..78052d7349 100644 --- a/include/ImagePool.h +++ b/include/ImagePool.h @@ -130,6 +130,7 @@ public: * automatically increased. * @param img_type will be set to the used image's type * @param uid of VM owner (to look for the image id within its images) + * @param image_id on success returns the acquired image id * @return 0 on success, * -1 error, * -2 not using the pool, @@ -139,7 +140,8 @@ public: int disk_id, int * index, Image::ImageType * img_type, - int uid); + int uid, + int& image_id); /** * Generates an Authorization token for the DISK attribute * @param disk the disk to be authorized diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc index 1d3cdd8dec..769c8dffbf 100644 --- a/src/image/ImageManagerActions.cc +++ b/src/image/ImageManagerActions.cc @@ -141,14 +141,13 @@ void ImageManager::disk_to_image(const string& disk_path, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void ImageManager::release_image(const string& image_id, +void ImageManager::release_image(int iid, const string& disk_path, int disk_num, const string& save_id) { int rvms; - int iid; int sid = -1; istringstream iss; @@ -156,13 +155,8 @@ void ImageManager::release_image(const string& image_id, ostringstream disk_file; - iss.str(image_id); - - iss >> iid; - if ( save_id.empty() == false ) { - iss.clear(); iss.str(save_id); iss >> sid; @@ -180,7 +174,7 @@ void ImageManager::release_image(const string& image_id, case Image::USED: rvms = img->dec_running(); - if ( img->isPersistent() ) + if ( img->isPersistent() && !disk_path.empty() ) { disk_file << disk_path << "/disk." << disk_num; diff --git a/src/image/ImagePool.cc b/src/image/ImagePool.cc index 69931e6798..f64a0bb386 100644 --- a/src/image/ImagePool.cc +++ b/src/image/ImagePool.cc @@ -131,7 +131,8 @@ int ImagePool::disk_attribute(VectorAttribute * disk, int disk_id, int * index, Image::ImageType * img_type, - int uid) + int uid, + int& image_id) { string source; Image * img = 0; @@ -143,7 +144,6 @@ int ImagePool::disk_attribute(VectorAttribute * disk, ImageManager * imagem = nd.get_imagem(); istringstream is; - int image_id; source = disk->vector_value("IMAGE"); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 99a082ca9c..b7dbc1b66a 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -220,7 +220,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) if ( rc != 0 ) { - goto error_leases; + goto error_leases_rollback; } // ------------------------------------------------------------------------ @@ -231,7 +231,9 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) if ( rc != 0 ) { - goto error_images; + // The get_disk_images method has an internal rollback for + // the acquired images, release_disk_images() would release all disks + goto error_leases_rollback; } // ------------------------------------------------------------------------- @@ -269,26 +271,24 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) error_update: error_str = "Can not insert VM in the database."; - goto error_common; - -error_leases: - NebulaLog::log("ONE",Log::ERROR, error_str); - release_network_leases(); - return -1; - -error_images: - goto error_common; + goto error_rollback; error_context: - goto error_common; + goto error_rollback; error_requirements: - goto error_common; + goto error_rollback; + +error_rollback: + release_disk_images(); + +error_leases_rollback: + release_network_leases(); + goto error_common; // just to avoid compilation warnings error_common: NebulaLog::log("ONE",Log::ERROR, error_str); - release_network_leases(); - release_disk_images(); + return -1; } @@ -663,11 +663,13 @@ int VirtualMachine::get_disk_images(string& error_str) vector disks; ImagePool * ipool; VectorAttribute * disk; + vector acquired_images; int n_os = 0; // Number of OS images int n_cd = 0; // Number of CDROMS int n_db = 0; // Number of DATABLOCKS string type; + int image_id; ostringstream oss; Image::ImageType img_type; @@ -686,10 +688,12 @@ int VirtualMachine::get_disk_images(string& error_str) continue; } - rc = ipool->disk_attribute(disk, i, &index, &img_type, uid); + rc = ipool->disk_attribute(disk, i, &index, &img_type, uid, image_id); if (rc == 0 ) { + acquired_images.push_back(image_id); + switch(img_type) { case Image::OS: @@ -728,6 +732,10 @@ int VirtualMachine::get_disk_images(string& error_str) { goto error_name; } + else if ( rc != -2 ) // The only known code left + { + goto error_unknown; + } } return 0; @@ -750,8 +758,23 @@ error_image: error_name: error_str = "IMAGE is not supported for DISK. Use IMAGE_ID instead."; + goto error_common; + +error_unknown: + error_str = "Unknown error code."; error_common: + ImageManager * imagem = nd.get_imagem(); + + vector::iterator it; + + for ( it=acquired_images.begin() ; it < acquired_images.end(); it++ ) + { + // Set disk_path and save_id to empty string, this way the image manager + // won't try to move any files + imagem->release_image(*it,"",-1,""); + } + return -1; } From 84a8d9e2821d45593b3a592be0aa2dc677f4c5a0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 23:15:13 +0200 Subject: [PATCH 13/24] Bug #804:removed unneeded return (cherry picked from commit 2fc3d7fbb4a49d89c088125435789d6cb962252f) --- include/ImageManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ImageManager.h b/include/ImageManager.h index de14c32455..509a25f7d2 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -104,7 +104,7 @@ public: iss.str(iid); iss >> image_id; - return release_image(image_id, disk_path, disk_num, saveid); + release_image(image_id, disk_path, disk_num, saveid); }; /** From b4bb68be2e8442c65aaa6c1e125f34b83ccf1644 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 23:15:54 +0200 Subject: [PATCH 14/24] Added execution permissions to driver file (cherry picked from commit 1ebae15af962f7dfe267724a6cd2d5b80f622fac) --- src/vmm_mad/remotes/kvm/migrate_local | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/vmm_mad/remotes/kvm/migrate_local diff --git a/src/vmm_mad/remotes/kvm/migrate_local b/src/vmm_mad/remotes/kvm/migrate_local old mode 100644 new mode 100755 From 6aa268d52fb6263db4d78864fbf4ccc365f59fcd Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 15 Sep 2011 23:16:13 +0200 Subject: [PATCH 15/24] Installs poll_ganglia instead of non-existent poll_local (cherry picked from commit 9a419d498cb7b6edd19995451dd110e478ac88d7) --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index d6bc746d5b..a0706fea87 100755 --- a/install.sh +++ b/install.sh @@ -549,7 +549,7 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \ src/vmm_mad/remotes/kvm/restore \ src/vmm_mad/remotes/kvm/save \ src/vmm_mad/remotes/kvm/poll \ - src/vmm_mad/remotes/kvm/poll_local \ + src/vmm_mad/remotes/kvm/poll_ganglia \ src/vmm_mad/remotes/kvm/shutdown" #------------------------------------------------------------------------------- @@ -563,7 +563,7 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ src/vmm_mad/remotes/xen/restore \ src/vmm_mad/remotes/xen/save \ src/vmm_mad/remotes/xen/poll \ - src/vmm_mad/remotes/xen/poll_local \ + src/vmm_mad/remotes/xen/poll_ganglia \ src/vmm_mad/remotes/xen/shutdown" #------------------------------------------------------------------------------- From c6a8c1fbdcc1d11df23f8ead30a1fd0df3d2630e Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 11:52:55 +0200 Subject: [PATCH 16/24] bug #265: Failure actions will *NOT* remove VM files in the host. Host files will be removed from the remote host upon VM resubmition or deletion. This will let sysadmins to easily debug any failure or perform forensic analysis. --- src/dm/DispatchManagerActions.cc | 6 ++++-- src/lcm/LifeCycleActions.cc | 12 +++++++----- src/lcm/LifeCycleStates.cc | 5 +---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 93d95a4ab1..37189b4a81 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -565,6 +565,7 @@ int DispatchManager::finalize( switch (state) { case VirtualMachine::SUSPENDED: + case VirtualMachine::FAILED: tm->trigger(TransferManager::EPILOG_DELETE,vid); case VirtualMachine::INIT: @@ -573,7 +574,6 @@ int DispatchManager::finalize( case VirtualMachine::STOPPED: vm->set_exit_time(time(0)); - case VirtualMachine::FAILED: vm->set_state(VirtualMachine::LCM_INIT); vm->set_state(VirtualMachine::DONE); vmpool->update(vm); @@ -608,6 +608,7 @@ int DispatchManager::resubmit(int vid) Nebula& nd = Nebula::instance(); LifeCycleManager * lcm = nd.get_lcm(); + TransferManager * tm = nd.get_tm(); vm = vmpool->get(vid,true); @@ -628,9 +629,10 @@ int DispatchManager::resubmit(int vid) case VirtualMachine::PENDING: break; + case VirtualMachine::FAILED: //Cleanup VM host files + tm->trigger(TransferManager::EPILOG_DELETE,vid); case VirtualMachine::HOLD: // Move the VM to PENDING in any of these case VirtualMachine::STOPPED: - case VirtualMachine::FAILED: vm->set_state(VirtualMachine::LCM_INIT); vm->set_state(VirtualMachine::PENDING); vmpool->update(vm); diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 03683a2473..c415692bed 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -500,8 +500,7 @@ void LifeCycleManager::delete_action(int vid) VirtualMachine::LcmState state = vm->get_lcm_state(); if ((state == VirtualMachine::LCM_INIT) || - (state == VirtualMachine::CLEANUP) || - (state == VirtualMachine::FAILURE)) + (state == VirtualMachine::CLEANUP)) { vm->unlock(); return; @@ -535,8 +534,7 @@ void LifeCycleManager::clean_action(int vid) VirtualMachine::LcmState state = vm->get_lcm_state(); if ((state == VirtualMachine::LCM_INIT) || - (state == VirtualMachine::CLEANUP) || - (state == VirtualMachine::FAILURE)) + (state == VirtualMachine::CLEANUP)) { vm->unlock(); return; @@ -664,7 +662,11 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) tm->trigger(TransferManager::EPILOG_DELETE,vid); break; - default: //FAILURE,LCM_INIT,CLEANUP + case VirtualMachine::FAILURE: + tm->trigger(TransferManager::EPILOG_DELETE,vid); + break; + + default: //LCM_INIT,CLEANUP break; } diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index ac01274093..5d9eb8dc61 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -778,7 +778,6 @@ void LifeCycleManager::monitor_done_action(int vid) void LifeCycleManager::failure_action(VirtualMachine * vm) { Nebula& nd = Nebula::instance(); - TransferManager * tm = nd.get_tm(); DispatchManager * dm = nd.get_dm(); time_t the_time = time(0); @@ -802,11 +801,9 @@ void LifeCycleManager::failure_action(VirtualMachine * vm) hpool->del_capacity(vm->get_hid(),cpu,mem,disk); - //------------- Clean up remote files ---------------- + //--- VM to FAILED. Remote host cleanup upon VM deletion --- dm->trigger(DispatchManager::FAILED,vm->get_oid()); - - tm->trigger(TransferManager::EPILOG_DELETE,vm->get_oid()); } /* -------------------------------------------------------------------------- */ From d582636e47688be98c78ff82243fd1338f59973a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 12:09:37 +0200 Subject: [PATCH 17/24] bug: wrong access to exitstatus (cherry picked from commit 1aad41ffe6990fad4f7a57d2291cb92d888216fb) --- src/mad/ruby/scripts_common.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mad/ruby/scripts_common.rb b/src/mad/ruby/scripts_common.rb index c5a7119b79..ba24205e20 100644 --- a/src/mad/ruby/scripts_common.rb +++ b/src/mad/ruby/scripts_common.rb @@ -53,7 +53,8 @@ module OpenNebula # the command fails def self.exec_and_log(command, message=nil) output=`#{command} 2>&1 1>/dev/null` - code=$? + code=$?.exitstatus + if code!=0 log_error "Command \"#{command}\" failed." log_error output From 770728fb2148b4dc9c26ca9a2a3a5e3c5dc4a30b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 12:23:22 +0200 Subject: [PATCH 18/24] bug #810: Gets device prefix from defaults if DEV_PREFIX attribute is removed from image template --- src/image/Image.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/image/Image.cc b/src/image/Image.cc index a66af4935c..ace9db96ba 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -433,6 +433,11 @@ int Image::disk_attribute( VectorAttribute * disk, get_template_attribute("DEV_PREFIX", prefix); + if (prefix.empty())//Removed from image template, get it again from defaults + { + prefix = ImagePool::default_dev_prefix(); + } + //--------------------------------------------------------------------------- // BASE DISK ATTRIBUTES //--------------------------------------------------------------------------- From da07254da7520c5ba386e3767001d217514c79af Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 13:39:52 +0200 Subject: [PATCH 19/24] bug: fixes exitstatus access in Ruby scripts (cherry picked from commit db74e8532a219c2283019621062bbf812714b82c) --- src/cli/one_helper.rb | 3 ++- src/im_mad/remotes/kvm.d/kvm.rb | 6 +++--- src/im_mad/remotes/xen.d/xen.rb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index f1ce493baa..8bd8d69115 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -398,7 +398,8 @@ EOT editor_path = ENV["EDITOR"] ? ENV["EDITOR"] : EDITOR_PATH system("#{editor_path} #{path}") - unless $?==0 + + unless $?.exitstatus == 0 puts "Editor not defined" exit -1 end diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb index ec857ccfd2..9fd51c7eb6 100755 --- a/src/im_mad/remotes/kvm.d/kvm.rb +++ b/src/im_mad/remotes/kvm.d/kvm.rb @@ -27,7 +27,7 @@ end ###### nodeinfo_text = `virsh -c qemu:///system nodeinfo` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 nodeinfo_text.split(/\n/).each{|line| if line.match('^CPU\(s\)') @@ -46,7 +46,7 @@ nodeinfo_text.split(/\n/).each{|line| NETINTERFACE = "eth1" top_text=`top -bin2` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output @@ -72,7 +72,7 @@ $used_memory=tmp[0] $free_memory=tmp[1] net_text=`cat /proc/net/dev` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 net_text.split(/\n/).each{|line| if line.match("^ *#{NETINTERFACE}") diff --git a/src/im_mad/remotes/xen.d/xen.rb b/src/im_mad/remotes/xen.d/xen.rb index 0fe19b7673..c979907522 100755 --- a/src/im_mad/remotes/xen.d/xen.rb +++ b/src/im_mad/remotes/xen.d/xen.rb @@ -27,10 +27,10 @@ def print_info(name, value) end xentop_text=`sudo #{XENTOP_PATH} -bi2` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 xm_text=`sudo #{XM_PATH} info` -exit(-1) if $?!=0 +exit(-1) if $?.exitstatus != 0 #xentop_text.gsub!(/^xentop.*^xentop.*?$/m, "") # Strip first top output xentop_text.gsub!("no limit", "no_limit") From 32421690f3acefb5a8e0e758a5b8460dbbd9a3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 15:51:28 +0200 Subject: [PATCH 20/24] Bug #804: Fix core unit tests --- src/image/test/ImagePoolTest.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 6ec2480186..1b61ff193a 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -589,7 +589,7 @@ public: Image * img; VectorAttribute * disk; - int oid_0, oid_1, index; + int oid_0, oid_1, index, img_id; string value; Image::ImageType img_type; @@ -625,7 +625,7 @@ public: disk = new VectorAttribute("DISK"); disk->replace("IMAGE_ID", "0"); - ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); + ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0, img_id); value = ""; value = disk->vector_value("TARGET"); @@ -639,7 +639,7 @@ public: disk = new VectorAttribute("DISK"); disk->replace("IMAGE_ID", "1"); - ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0); + ((ImagePool*)imp)->disk_attribute(disk, 0, &index, &img_type,0, img_id); value = ""; value = disk->vector_value("TARGET"); From 5cf24e23fc5734d682f08afe556931705ec19bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 18:09:34 +0200 Subject: [PATCH 21/24] New tests for onedb with mysql backend --- src/onedb/test/2.2/mysqldb.sql | 314 +++++++++++++ src/onedb/test/oned_mysql.conf | 433 ++++++++++++++++++ .../test/{oned.conf => oned_sqlite.conf} | 0 src/onedb/test/test_mysql.sh | 173 +++++++ src/onedb/test/{test.sh => test_sqlite.sh} | 2 +- 5 files changed, 921 insertions(+), 1 deletion(-) create mode 100644 src/onedb/test/2.2/mysqldb.sql create mode 100644 src/onedb/test/oned_mysql.conf rename src/onedb/test/{oned.conf => oned_sqlite.conf} (100%) create mode 100755 src/onedb/test/test_mysql.sh rename src/onedb/test/{test.sh => test_sqlite.sh} (99%) diff --git a/src/onedb/test/2.2/mysqldb.sql b/src/onedb/test/2.2/mysqldb.sql new file mode 100644 index 0000000000..16fb92e86c --- /dev/null +++ b/src/onedb/test/2.2/mysqldb.sql @@ -0,0 +1,314 @@ +-- MySQL dump 10.13 Distrib 5.1.41, for debian-linux-gnu (i486) +-- +-- Host: localhost Database: onedb_test +-- ------------------------------------------------------ +-- Server version 5.1.41-3ubuntu12.10 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `cluster_pool` +-- + +DROP TABLE IF EXISTS `cluster_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `cluster_pool` ( + `oid` int(11) NOT NULL, + `cluster_name` varchar(128) DEFAULT NULL, + PRIMARY KEY (`oid`), + UNIQUE KEY `cluster_name` (`cluster_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `cluster_pool` +-- + +LOCK TABLES `cluster_pool` WRITE; +/*!40000 ALTER TABLE `cluster_pool` DISABLE KEYS */; +INSERT INTO `cluster_pool` VALUES (0,'default'); +/*!40000 ALTER TABLE `cluster_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `history` +-- + +DROP TABLE IF EXISTS `history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `history` ( + `vid` int(11) NOT NULL DEFAULT '0', + `seq` int(11) NOT NULL DEFAULT '0', + `host_name` text, + `vm_dir` text, + `hid` int(11) DEFAULT NULL, + `vm_mad` text, + `tm_mad` text, + `stime` int(11) DEFAULT NULL, + `etime` int(11) DEFAULT NULL, + `pstime` int(11) DEFAULT NULL, + `petime` int(11) DEFAULT NULL, + `rstime` int(11) DEFAULT NULL, + `retime` int(11) DEFAULT NULL, + `estime` int(11) DEFAULT NULL, + `eetime` int(11) DEFAULT NULL, + `reason` int(11) DEFAULT NULL, + PRIMARY KEY (`vid`,`seq`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `history` +-- + +LOCK TABLES `history` WRITE; +/*!40000 ALTER TABLE `history` DISABLE KEYS */; +INSERT INTO `history` VALUES (0,0,'host_0','/home/cmartin/trabajo/opennebula/install/var/',0,'vmm_dummy','tm_dummy',1316187929,1316187934,1316187929,1316187929,1316187929,1316187934,0,0,3),(1,0,'host_1','/home/cmartin/trabajo/opennebula/install/var/',1,'vmm_dummy','tm_dummy',1316187929,1316187935,1316187929,1316187929,1316187929,1316187935,0,0,3),(2,0,'host_2','/home/cmartin/trabajo/opennebula/install/var/',2,'vmm_dummy','tm_dummy',1316187930,1316187940,1316187930,1316187930,1316187930,1316187940,1316187940,1316187940,0),(3,0,'host_3','/home/cmartin/trabajo/opennebula/install/var/',3,'vmm_dummy','tm_dummy',1316187930,1316187941,1316187930,1316187930,1316187930,1316187941,0,0,3),(0,1,'host_1','/home/cmartin/trabajo/opennebula/install/var/',1,'vmm_dummy','tm_dummy',1316187934,0,1316187934,1316187934,1316187934,0,0,0,0),(1,1,'host_2','/home/cmartin/trabajo/opennebula/install/var/',2,'vmm_dummy','tm_dummy',1316187935,1316187936,0,0,1316187935,1316187936,1316187936,1316187936,2),(1,2,'host_0','/home/cmartin/trabajo/opennebula/install/var/',0,'vmm_dummy','tm_dummy',1316187937,1316187938,1316187937,1316187937,1316187937,1316187938,0,0,3),(1,3,'host_3','/home/cmartin/trabajo/opennebula/install/var/',3,'vmm_dummy','tm_dummy',1316187938,1316187939,1316187938,1316187938,1316187938,1316187939,1316187939,1316187939,0); +/*!40000 ALTER TABLE `history` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_pool` +-- + +DROP TABLE IF EXISTS `host_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `host_pool` ( + `oid` int(11) NOT NULL, + `host_name` varchar(256) DEFAULT NULL, + `state` int(11) DEFAULT NULL, + `im_mad` varchar(128) DEFAULT NULL, + `vm_mad` varchar(128) DEFAULT NULL, + `tm_mad` varchar(128) DEFAULT NULL, + `last_mon_time` int(11) DEFAULT NULL, + `cluster` varchar(128) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `host_name` (`host_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_pool` +-- + +LOCK TABLES `host_pool` WRITE; +/*!40000 ALTER TABLE `host_pool` DISABLE KEYS */; +INSERT INTO `host_pool` VALUES (1,'host_1',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(3,'host_3',4,'im_dummy','vmm_dummy','tm_dummy',1316187931,'default',''),(4,'host_4',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(0,'host_0',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''),(2,'host_2',2,'im_dummy','vmm_dummy','tm_dummy',1316187946,'default',''); +/*!40000 ALTER TABLE `host_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `host_shares` +-- + +DROP TABLE IF EXISTS `host_shares`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `host_shares` ( + `hid` int(11) NOT NULL, + `disk_usage` int(11) DEFAULT NULL, + `mem_usage` int(11) DEFAULT NULL, + `cpu_usage` int(11) DEFAULT NULL, + `max_disk` int(11) DEFAULT NULL, + `max_mem` int(11) DEFAULT NULL, + `max_cpu` int(11) DEFAULT NULL, + `free_disk` int(11) DEFAULT NULL, + `free_mem` int(11) DEFAULT NULL, + `free_cpu` int(11) DEFAULT NULL, + `used_disk` int(11) DEFAULT NULL, + `used_mem` int(11) DEFAULT NULL, + `used_cpu` int(11) DEFAULT NULL, + `running_vms` int(11) DEFAULT NULL, + PRIMARY KEY (`hid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `host_shares` +-- + +LOCK TABLES `host_shares` WRITE; +/*!40000 ALTER TABLE `host_shares` DISABLE KEYS */; +INSERT INTO `host_shares` VALUES (0,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(1,0,524288,0,0,16777216,800,0,16777216,800,0,0,0,1),(2,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(3,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0),(4,0,0,0,0,16777216,800,0,16777216,800,0,0,0,0); +/*!40000 ALTER TABLE `host_shares` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `image_pool` +-- + +DROP TABLE IF EXISTS `image_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `image_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` varchar(128) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `public` int(11) DEFAULT NULL, + `persistent` int(11) DEFAULT NULL, + `regtime` int(11) DEFAULT NULL, + `source` text, + `state` int(11) DEFAULT NULL, + `running_vms` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `image_pool` +-- + +LOCK TABLES `image_pool` WRITE; +/*!40000 ALTER TABLE `image_pool` DISABLE KEYS */; +INSERT INTO `image_pool` VALUES (0,1,'image_0',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/f4f08f2ad6fcb19432db9da3161d144aa2d5e730',2,1,''),(3,4,'image_3',2,0,1,1316187926,'/home/cmartin/trabajo/opennebula/install/var//images/01a1e990037cabc5419076c78e21f96b8c889dbf',1,0,''),(4,5,'image_4',2,0,0,1316187926,'/home/cmartin/trabajo/opennebula/install/var//images/df76114f6749fb9ef6674649c809f28054c0d125',2,1,''),(1,2,'image_1',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/1dbcefd204efa3c32280d2c56a2d499f89790bae',1,0,''),(2,3,'image_2',2,0,0,1316187925,'/home/cmartin/trabajo/opennebula/install/var//images/a42e387dcd957218a4f5c86f1b586631ab769c17',1,0,''); +/*!40000 ALTER TABLE `image_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `leases` +-- + +DROP TABLE IF EXISTS `leases`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `leases` ( + `oid` int(11) NOT NULL DEFAULT '0', + `ip` bigint(20) NOT NULL DEFAULT '0', + `mac_prefix` bigint(20) DEFAULT NULL, + `mac_suffix` bigint(20) DEFAULT NULL, + `vid` int(11) DEFAULT NULL, + `used` int(11) DEFAULT NULL, + PRIMARY KEY (`oid`,`ip`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `leases` +-- + +LOCK TABLES `leases` WRITE; +/*!40000 ALTER TABLE `leases` DISABLE KEYS */; +INSERT INTO `leases` VALUES (0,3232235521,512,3232235521,0,1),(0,3232235522,512,3232235522,-1,0),(0,3232235523,512,3232235523,-1,0),(0,3232235524,512,3232235524,-1,0),(0,3232235525,512,3232235525,-1,0),(1,3232235777,512,3232235777,-1,0),(1,3232235778,512,3232235778,-1,0),(1,3232235779,512,3232235779,-1,0),(1,3232235780,512,3232235780,-1,0),(1,3232235781,512,3232235781,-1,0),(2,3232236033,512,3232236033,-1,0),(2,3232236034,512,3232236034,-1,0),(2,3232236035,512,3232236035,-1,0),(2,3232236036,512,3232236036,-1,0),(2,3232236037,512,3232236037,-1,0),(4,3232236545,512,3232236545,4,1); +/*!40000 ALTER TABLE `leases` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `network_pool` +-- + +DROP TABLE IF EXISTS `network_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `network_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` varchar(256) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `bridge` text, + `public` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`), + UNIQUE KEY `name` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `network_pool` +-- + +LOCK TABLES `network_pool` WRITE; +/*!40000 ALTER TABLE `network_pool` DISABLE KEYS */; +INSERT INTO `network_pool` VALUES (0,1,'vnet_fixed_0',1,'vbr1',0,''),(1,2,'vnet_fixed_1',1,'vbr1',0,''),(2,3,'vnet_fixed_2',1,'vbr1',1,''),(3,4,'vnet_ranged_3',0,'vbr0',0,''),(4,5,'vnet_ranged_4',0,'vbr0',1,''); +/*!40000 ALTER TABLE `network_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_pool` +-- + +DROP TABLE IF EXISTS `user_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_pool` ( + `oid` int(11) NOT NULL, + `user_name` varchar(256) DEFAULT NULL, + `password` text, + `enabled` int(11) DEFAULT NULL, + PRIMARY KEY (`oid`), + UNIQUE KEY `user_name` (`user_name`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_pool` +-- + +LOCK TABLES `user_pool` WRITE; +/*!40000 ALTER TABLE `user_pool` DISABLE KEYS */; +INSERT INTO `user_pool` VALUES (0,'oneadmin','7bc8559a8fe509e680562b85c337f170956fcb06',1),(1,'user_0','90e3707afc67a2038d1088761fea5cd50bbd08bb',1),(2,'user_1','681aae69de00c2df72381c3e5f9d77e70e7e384c',1),(3,'user_2','a195b95bf777854dfe566d1ffef1b76a34dc15a1',1),(4,'user_3','05bf903dc5ff0f2f69f630d9a59bc0b6df8c1cff',1),(5,'user_4','1a6f9b4e378ab45beee6cde9396df5c6ea9863b8',1); +/*!40000 ALTER TABLE `user_pool` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `vm_pool` +-- + +DROP TABLE IF EXISTS `vm_pool`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `vm_pool` ( + `oid` int(11) NOT NULL, + `uid` int(11) DEFAULT NULL, + `name` text, + `last_poll` int(11) DEFAULT NULL, + `state` int(11) DEFAULT NULL, + `lcm_state` int(11) DEFAULT NULL, + `stime` int(11) DEFAULT NULL, + `etime` int(11) DEFAULT NULL, + `deploy_id` text, + `memory` int(11) DEFAULT NULL, + `cpu` int(11) DEFAULT NULL, + `net_tx` int(11) DEFAULT NULL, + `net_rx` int(11) DEFAULT NULL, + `last_seq` int(11) DEFAULT NULL, + `template` text, + PRIMARY KEY (`oid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `vm_pool` +-- + +LOCK TABLES `vm_pool` WRITE; +/*!40000 ALTER TABLE `vm_pool` DISABLE KEYS */; +INSERT INTO `vm_pool` VALUES (0,1,'one-0',1316187945,3,3,1316187927,0,'dummy',0,0,12345,0,1,''),(1,2,'one-1',1316187930,6,0,1316187927,1316187939,'dummy',0,0,0,0,3,''),(2,3,'one-2',1316187930,6,0,1316187928,1316187940,'dummy',0,0,0,0,0,''),(3,4,'one-3',1316187930,6,0,1316187928,1316187941,'dummy',0,0,0,0,0,''),(4,5,'one-4',0,1,0,1316187928,0,'',0,0,0,0,-1,''); +/*!40000 ALTER TABLE `vm_pool` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2011-09-16 8:45:58 diff --git a/src/onedb/test/oned_mysql.conf b/src/onedb/test/oned_mysql.conf new file mode 100644 index 0000000000..052cb81c03 --- /dev/null +++ b/src/onedb/test/oned_mysql.conf @@ -0,0 +1,433 @@ +#******************************************************************************* +# OpenNebula Configuration file +#******************************************************************************* + +#******************************************************************************* +# Daemon configuration attributes +#------------------------------------------------------------------------------- +# MANAGER_TIMER: Time in seconds the core uses to evaluate periodical functions. +# HOST_MONITORING_INTERVAL and VM_POLLING_INTERVAL can not have smaller values +# than MANAGER_TIMER. +# +# HOST_MONITORING_INTERVAL: Time in seconds between host monitorization. +# +# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization. +# (use 0 to disable VM monitoring). +# +# VM_DIR: Remote path to store the VM images, it should be shared between all +# the cluster nodes to perform live migrations. This variable is the default +# for all the hosts in the cluster. VM_DIR IS ONLY FOR THE NODES AND *NOT* THE +# FRONT-END +# +# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management +# scripts. +# +# PORT: Port where oned will listen for xmlrpc calls. +# +# DB: Configuration attributes for the database backend +# backend : can be sqlite or mysql (default is sqlite) +# server : (mysql) host name or an IP address for the MySQL server +# port : (mysql) port for the connection to the server. +# If set to 0, the default port is used. +# user : (mysql) user's MySQL login ID +# passwd : (mysql) the password for user +# db_name : (mysql) the database name +# +# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT + +# VMID +# +# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG +#******************************************************************************* + +#MANAGER_TIMER=30 + +HOST_MONITORING_INTERVAL = 1 + +VM_POLLING_INTERVAL = 1 + +#VM_DIR=/srv/cloud/one/var + +SCRIPTS_REMOTE_DIR=/var/tmp/one + +PORT=2888 + +#DB = [ backend = "sqlite" ] + +# Sample configuration for MySQL +DB = [ backend = "mysql", + server = "localhost", + port = 0, + user = "oneadmin", + passwd = "oneadmin", + db_name = "onedb_test" ] + +VNC_BASE_PORT = 5900 + +DEBUG_LEVEL=3 + +#******************************************************************************* +# Physical Networks configuration +#******************************************************************************* +# NETWORK_SIZE: Here you can define the default size for the virtual networks +# +# MAC_PREFIX: Default MAC prefix to be used to create the auto-generated MAC +# addresses is defined here (this can be overrided by the Virtual Network +# template) +#******************************************************************************* + +NETWORK_SIZE = 254 + +MAC_PREFIX = "02:00" + +#******************************************************************************* +# Image Repository Configuration +#******************************************************************************* +# DEFAULT_IMAGE_TYPE: This can take values +# OS Image file holding an operating system +# CDROM Image file holding a CDROM +# DATABLOCK Image file holding a datablock, +# always created as an empty block +# DEFAULT_DEVICE_PREFIX: This can be set to +# hd IDE prefix +# sd SCSI +# xvd XEN Virtual Disk +# vd KVM virtual disk +#******************************************************************************* +DEFAULT_IMAGE_TYPE = "OS" +DEFAULT_DEVICE_PREFIX = "hd" + +#******************************************************************************* +# Information Driver Configuration +#******************************************************************************* +# You can add more information managers with different configurations but make +# sure it has different names. +# +# name : name for this information manager +# +# executable: path of the information driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, usually a probe configuration file, +# can be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +#******************************************************************************* + +#------------------------------------------------------------------------------- +# KVM Information Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_kvm", +# executable = "one_im_ssh", +# arguments = "-r 0 -t 15 kvm" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# XEN Information Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_xen", +# executable = "one_im_ssh", +# arguments = "xen" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# EC2 Information Driver Manager Configuration +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_ec2", +# executable = "one_im_ec2", +# arguments = "im_ec2/im_ec2.conf" ] +#------------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Ganglia Information Driver Manager Configuration +#----------------------------------------------------------------------------- +#IM_MAD = [ +# name = "im_ganglia", +# executable = "one_im_sh", +# arguments = "ganglia" ] +#----------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Information Driver Manager Configuration +#------------------------------------------------------------------------------- +IM_MAD = [ name="im_dummy", executable="one_im_dummy"] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Virtualization Driver Configuration +#******************************************************************************* +# You can add more virtualization managers with different configurations but +# make sure it has different names. +# +# name : name of the virtual machine manager driver +# +# executable: path of the virtualization driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable +# +# default : default values and configuration parameters for the driver, can +# be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +# +# type : driver type, supported drivers: xen, kvm, xml +#******************************************************************************* + +#------------------------------------------------------------------------------- +# KVM Virtualization Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +# -p name of the poll probe (executed locally) +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_kvm", +# executable = "one_vmm_ssh", +# arguments = "-t 15 -r 0 kvm", +# default = "vmm_ssh/vmm_ssh_kvm.conf", +# type = "kvm" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# XEN Virtualization Driver Manager Configuration +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of hosts monitored at the same time +# -l do not perform the VM polling in the node +# -p name of the poll probe (executed locally) +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_xen", +# executable = "one_vmm_ssh", +# arguments = "xen", +# default = "vmm_ssh/vmm_ssh_xen.conf", +# type = "xen" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# EC2 Virtualization Driver Manager Configuration +# arguments: default values for the EC2 driver, can be an absolute path or +# relative to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was +# installed in /). +#------------------------------------------------------------------------------- +#VM_MAD = [ +# name = "vmm_ec2", +# executable = "one_vmm_ec2", +# arguments = "vmm_ec2/vmm_ec2.conf", +# type = "xml" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Virtualization Driver Configuration +#------------------------------------------------------------------------------- +VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Transfer Manager Driver Configuration +#******************************************************************************* +# You can add more transfer managers with different configurations but make +# sure it has different names. +# name : name for this transfer driver +# +# executable: path of the transfer driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, usually a commands configuration file +# , can be an absolute path or relative to $ONE_LOCATION/etc (or +# /etc/one/ if OpenNebula was installed in /) +#******************************************************************************* + +#------------------------------------------------------------------------------- +# SHARED Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_shared", +# executable = "one_tm", +# arguments = "tm_shared/tm_shared.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# SSH Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_ssh", +# executable = "one_tm", +# arguments = "tm_ssh/tm_ssh.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Dummy Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +TM_MAD = [ + name = "tm_dummy", + executable = "one_tm", + arguments = "tm_dummy/tm_dummy.conf" ] +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# LVM Transfer Manager Driver Configuration +#------------------------------------------------------------------------------- +#TM_MAD = [ +# name = "tm_lvm", +# executable = "one_tm", +# arguments = "tm_lvm/tm_lvm.conf" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Image Manager Driver Configuration +#******************************************************************************* +# Drivers to manage the image repository, specialized for the storage backend +# executable: path of the transfer driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable +#******************************************************************************* +#------------------------------------------------------------------------------- +# FS based Image Manager Driver Configuration +# -t number of threads, i.e. number of repo operations at the same time +#------------------------------------------------------------------------------- +IMAGE_MAD = [ + executable = "one_image", + arguments = "fs -t 15" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Hook Manager Configuration +#******************************************************************************* +# The Driver (HM_MAD), used to execute the Hooks +# executable: path of the hook driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, can be an absolute path or relative +# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed +# in /) +# +# Virtual Machine Hooks (VM_HOOK) defined by: +# name : for the hook, useful to track the hook (OPTIONAL) +# on : when the hook should be executed, +# - CREATE, when the VM is created (onevm create) +# - RUNNING, after the VM is successfully booted +# - SHUTDOWN, after the VM is shutdown +# - STOP, after the VM is stopped (including VM image transfers) +# - DONE, after the VM is deleted or shutdown +# - FAILED, when the VM enters the failed state +# command : path can be absolute or relative to $ONE_LOCATION/share/hooks +# case of self-contained installation or relative to +# /usr/share/one/hooks in case of system-wide installation +# arguments : for the hook. You can access to VM information with $ +# - $VMID, the ID of the virtual machine +# - $TEMPLATE, the VM template in xml and base64 encoded +# remote : values, +# - YES, The hook is executed in the host where the VM was +# allocated +# - NO, The hook is executed in the OpenNebula server (default) +# +# +# Host Hooks (HOST_HOOK) defined by: +# name : for the hook, useful to track the hook (OPTIONAL) +# on : when the hook should be executed, +# - CREATE, when the Host is created (onehost create) +# - ERROR, when the Host enters the error state +# - DISABLE, when the Host is disabled +# command : path can be absolute or relative to $ONE_LOCATION/share/hooks +# case of self-contained installation or relative to +# /usr/share/one/hooks in case of system-wide installation +# arguments : for the hook. You can use the following Host information: +# - $HID, the ID of the host +# - $TEMPLATE, the Host template in xml and base64 encoded +# remote : values, +# - YES, The hook is executed in the host +# - NO, The hook is executed in the OpenNebula server (default) +#------------------------------------------------------------------------------- + +HM_MAD = [ + executable = "one_hm" ] + +#------------------------------------------------------------------------------- + +#------------------------------ Fault Tolerance Hooks -------------------------- +# This hook is used to perform recovery actions when a host fails. The VMs +# running in the host can be deleted (use -d option) or resubmitted (-r) in +# other host +# Last argument (force) can be "y", so suspended VMs in the host will be +# resubmitted/deleted, or "n", so suspended VMs in the host will be ignored +# +#HOST_HOOK = [ +# name = "error", +# on = "ERROR", +# command = "host_error.rb", +# arguments = "$HID -r n", +# remote = "no" ] +#------------------------------------------------------------------------------- +# This two hooks can be used to automatically delete or resubmit VMs that reach +# the "failed" state. This way, the administrator doesn't have to interact +# manually to release its resources or retry the deployment. +# +# Only one of them should be uncommented. +#------------------------------------------------------------------------------- +# +#VM_HOOK = [ +# name = "on_failure_delete", +# on = "FAILED", +# command = "/usr/bin/env onevm delete", +# arguments = "$VMID" ] +# +#VM_HOOK = [ +# name = "on_failure_resubmit", +# on = "FAILED", +# command = "/usr/bin/env onevm resubmit", +# arguments = "$VMID" ] +#------------------------------------------------------------------------------- + +#-------------------------------- ebtables Hook--------------------------------- +# You can use these two hooks to isolate networks at the ethernet level so the +# traffic generated in different virtual networks can not be seen in others. +# +# All the network configuration will be done in the cluster nodes, these are the +# additional requisites: +# - ebtables package installed +# - sudoers configured so oneadmin can execute ebtables without password +# +# NOTE: Change the first command for ebtables-xen if you are using Xen +# +#VM_HOOK = [ +# name = "ebtables-start", +# on = "running", +# command = "ebtables-kvm", # or ebtables-xen +# arguments = "one-$VMID", +# remote = "yes" ] +# +#VM_HOOK = [ +# name = "ebtables-flush", +# on = "done", +# command = "ebtables-flush", +# arguments = "", +# remote = "yes" ] +#------------------------------------------------------------------------------- + +#******************************************************************************* +# Auth Manager Configuration +#******************************************************************************* +# The Driver (AUTHM_MAD) that will be used to authenticate and authorize +# OpenNebula requests. If not defined OpenNebula will use the built-in auth +# policies +# executable: path of the auth driver executable, can be an +# absolute path or relative to $ONE_LOCATION/lib/mads (or +# /usr/lib/one/mads/ if OpenNebula was installed in /) +# +# arguments : for the driver executable, can be an absolute path or relative +# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed +# in /) +#------------------------------------------------------------------------------- + +#AUTH_MAD = [ +# executable = "one_auth_mad" ] diff --git a/src/onedb/test/oned.conf b/src/onedb/test/oned_sqlite.conf similarity index 100% rename from src/onedb/test/oned.conf rename to src/onedb/test/oned_sqlite.conf diff --git a/src/onedb/test/test_mysql.sh b/src/onedb/test/test_mysql.sh new file mode 100755 index 0000000000..4cac73d2eb --- /dev/null +++ b/src/onedb/test/test_mysql.sh @@ -0,0 +1,173 @@ +#!/bin/bash + +################################################################################ +# Initialization +################################################################################ + +if [ -z $ONE_LOCATION ]; then + echo "ONE_LOCATION not defined." + exit -1 +fi + +ONEDCONF_LOCATION="$ONE_LOCATION/etc/oned.conf" + +if [ -f $ONEDCONF_LOCATION ]; then + echo "$ONEDCONF_LOCATION has to be overwritten, move it to a safe place." + exit -1 +fi + +VAR_LOCATION="$ONE_LOCATION/var" + + +# Clean DB +mysql -u oneadmin -poneadmin -h localhost -P 0 -e "DROP DATABASE IF EXISTS onedb_test;" + +cp oned_mysql.conf $ONEDCONF_LOCATION + + +echo "oneadmin:oneadmin" > oneadmin_auth +export ONE_XMLRPC=http://localhost:2888/RPC2 +export PATH=$ONE_LOCATION/bin:$PATH +export ONE_AUTH="`pwd`/oneadmin_auth" + + +PID=$$ + +mkdir results + +################################################################################ +# Start OpenNebula and populate a DB +################################################################################ + +echo "Starting oned, some resources will be created" + +oned -f & +sleep 2s; + +./create.sh + +pkill -P $PID oned +sleep 2s; +pkill -9 -P $PID oned + +################################################################################ +# Upgrade the 2.2 sample DB, and compare schemas +################################################################################ + +echo "All resources created, now 2.2 DB will be upgraded." + +# dump current DB and schema +onedb backup results/mysqldb.3.0 +mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.3.0.tmpschema + +# restore 2.2 +onedb restore -f 2.2/mysqldb.sql +# upgrade +onedb upgrade -v --backup results/mysqldb.backup +# dump upgraded DB schema +mysqldump -u oneadmin -poneadmin -h localhost -P 0 --no-data onedb_test > results/mysqldb.upgraded.tmpschema + +echo "Done. Upgraded DB and the one just created will be compared." + +# Sort the files contents, to avoid false diff errors +sort results/mysqldb.upgraded.tmpschema > results/mysqldb.upgraded.schema +sort results/mysqldb.3.0.tmpschema > results/mysqldb.3.0.schema + +rm results/mysqldb.upgraded.tmpschema +rm results/mysqldb.3.0.tmpschema + + + +# Perform a diff +FILE=results/schema.diff +diff <(grep -v -e "Dump completed on" results/mysqldb.upgraded.schema) <(grep -v -e "Dump completed on" results/mysqldb.3.0.schema) > $FILE + + +if [[ -s $FILE ]] ; then + echo "Error: Schemas do not match. Check file $FILE" + exit -1 +fi + + +################################################################################ +# Start oned using the upgraded DB and compare objects XMLs +################################################################################ + +echo "Schemas match. OpenNebula 3.0 will be started with the upgraded 2.2 DB." + +oned -f & +sleep 2s; + +for obj in host vnet image vm user; do + for i in 0 1 2 3 4; do + one$obj show -x $i > results/xml_files/$obj-$i-upgraded.xml + done +done + +for obj in host vnet image vm acl group user; do + one$obj list a -x > results/xml_files/$obj-pool-upgraded.xml +done + + +pkill -P $PID oned +sleep 2s; +pkill -9 -P $PID oned + +echo "XML output collected. A diff will be performed." + +mkdir results/diff_files + +diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-pool-upgraded.xml) > results/diff_files/host-pool.diff + +# TODO: fix +# The image-pool.xml files are the same, but for some reason the Images are +# returned in different order. +#diff <(grep -v -e "" -e "" -e "" results/xml_files/image-pool.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-pool-upgraded.xml) > results/diff_files/image-pool.diff + +diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" results/xml_files/vm-pool-upgraded.xml) > results/diff_files/vm-pool.diff + +for obj in vnet acl group user; do + diff <(cat results/xml_files/$obj-pool.xml) <(cat results/xml_files/$obj-pool-upgraded.xml) > results/diff_files/$obj-pool.diff +done + +for i in 0 1 2 3 4; do + diff <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-$i.xml) <(grep -v -e "" -e "" -e "NAME>" results/xml_files/host-$i-upgraded.xml) > results/diff_files/host-$i.diff + + diff <(cat results/xml_files/vnet-$i.xml) <(cat results/xml_files/vnet-$i-upgraded.xml) > results/diff_files/vnet-$i.diff + + diff <(grep -v -e "" -e "" -e "" results/xml_files/image-$i.xml) <(grep -v -e "" -e "" -e "" results/xml_files/image-$i-upgraded.xml) > results/diff_files/image-$i.diff + + diff <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i.xml) <(grep -v -e "" -e "TIME>" -e "" -e "" -e "" -e "" results/xml_files/vm-$i-upgraded.xml) > results/diff_files/vm-$i.diff + + diff <(cat results/xml_files/user-$i.xml) <(cat results/xml_files/user-$i-upgraded.xml) > results/diff_files/user-$i.diff +done + + +CODE=0 + +for obj in host vnet image vm user; do + for i in 0 1 2 3 4; do + FILE=results/diff_files/$obj-$i.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi + done +done + +for obj in host vnet image vm acl group user; do + FILE=results/diff_files/$obj-pool.diff + if [[ -s $FILE ]] ; then + echo "Error: diff file $FILE is not empty." + CODE=-1 + fi +done + + +if [ $CODE -eq 0 ]; then + echo "Done, all tests passed." +fi + +rm oneadmin_auth + +exit $CODE diff --git a/src/onedb/test/test.sh b/src/onedb/test/test_sqlite.sh similarity index 99% rename from src/onedb/test/test.sh rename to src/onedb/test/test_sqlite.sh index 5253b93cee..c0ff4d0d0a 100755 --- a/src/onedb/test/test.sh +++ b/src/onedb/test/test_sqlite.sh @@ -24,7 +24,7 @@ if [ -f $VAR_LOCATION/one.db ]; then fi -cp oned.conf $ONEDCONF_LOCATION +cp oned_sqlite.conf $ONEDCONF_LOCATION echo "oneadmin:oneadmin" > oneadmin_auth From 3e8bc8046d763bc53f568d672240050a1be0824b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 18:11:15 +0200 Subject: [PATCH 22/24] Bug #812: Fix onedb sql syntax to work with mysql --- src/onedb/2.0_to_2.9.80.rb | 4 ++-- src/onedb/onedb_backend.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index 20d47aeb62..a3e9afe400 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -257,8 +257,8 @@ module Migrator public = row[:public] total_leases = 0 - @db.fetch("SELECT COUNT (ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| - total_leases = r[:"COUNT (ip)"] + @db.fetch("SELECT COUNT(ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| + total_leases = r[:"COUNT(ip)"] end diff --git a/src/onedb/onedb_backend.rb b/src/onedb/onedb_backend.rb index cfe079052d..71cbda3324 100644 --- a/src/onedb/onedb_backend.rb +++ b/src/onedb/onedb_backend.rb @@ -177,7 +177,7 @@ class BackEndMySQL < OneDBBacKEnd end create_cmd = mysql_cmd+"-e 'CREATE DATABASE IF NOT EXISTS #{@db_name};'" - rc = system(create_cnd) + rc = system(create_cmd) if !rc raise "Error creating MySQL DB #{@db_name} at #{@server}." end From cbbe638d5b7a0a76ccfa5d92a34d3caccf7ba126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 Sep 2011 18:27:56 +0200 Subject: [PATCH 23/24] onedb tests: Set a different port for mysql tests, otherwise there are collisions when hudson launches both onedb tests --- src/onedb/test/oned_mysql.conf | 2 +- src/onedb/test/test_mysql.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onedb/test/oned_mysql.conf b/src/onedb/test/oned_mysql.conf index 052cb81c03..164abeaf5d 100644 --- a/src/onedb/test/oned_mysql.conf +++ b/src/onedb/test/oned_mysql.conf @@ -49,7 +49,7 @@ VM_POLLING_INTERVAL = 1 SCRIPTS_REMOTE_DIR=/var/tmp/one -PORT=2888 +PORT=2889 #DB = [ backend = "sqlite" ] diff --git a/src/onedb/test/test_mysql.sh b/src/onedb/test/test_mysql.sh index 4cac73d2eb..ac973b72ac 100755 --- a/src/onedb/test/test_mysql.sh +++ b/src/onedb/test/test_mysql.sh @@ -26,7 +26,7 @@ cp oned_mysql.conf $ONEDCONF_LOCATION echo "oneadmin:oneadmin" > oneadmin_auth -export ONE_XMLRPC=http://localhost:2888/RPC2 +export ONE_XMLRPC=http://localhost:2889/RPC2 export PATH=$ONE_LOCATION/bin:$PATH export ONE_AUTH="`pwd`/oneadmin_auth" From f9a4eaf55a211d6f057d71ee1424f77c7a57ca39 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 Sep 2011 18:48:46 +0200 Subject: [PATCH 24/24] bug #695: False timeouts are now checked within the Authmanager --- src/authm/AuthManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index 8ed3a16b9b..384e6d4272 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -358,7 +358,7 @@ void AuthManager::timer_action() while ( it !=auth_requests.end()) { - if (the_time > it->second->time_out) + if ((it->second->time_out != 0) && (the_time > it->second->time_out)) { AuthRequest * ar = it->second; auth_requests.erase(it++);