From 15f596b4aa04fc246b4ef8c887ed22324425dd71 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 16 May 2014 12:24:40 +0200 Subject: [PATCH 1/5] bug #2923: Clean VM monitor when VM_INDIVIDUAL_MONITOR is set to "no" (default) (cherry picked from commit fbedfdc2a6e8a5d6d2ea329710feb7568276e336) --- include/VirtualMachineManager.h | 6 ++++++ src/nebula/Nebula.cc | 6 ++---- src/vmm/VirtualMachineManager.cc | 16 +++++----------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/VirtualMachineManager.h b/include/VirtualMachineManager.h index 5d6048a442..9b9723b94e 100644 --- a/include/VirtualMachineManager.h +++ b/include/VirtualMachineManager.h @@ -37,6 +37,7 @@ public: HostPool * _hpool, time_t _timer_period, time_t _poll_period, + bool _do_vm_poll, int _vm_limit, vector& _mads); @@ -131,6 +132,11 @@ private: */ time_t poll_period; + /** + * Perform pro-active VM monitoring + */ + bool do_vm_poll; + /** * Virtual Machine polling limit */ diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index b8d052f581..a225aa0ed5 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -563,16 +563,14 @@ void Nebula::start(bool bootstrap_only) nebula_configuration->get("VM_INDIVIDUAL_MONITORING", do_poll); - if (do_poll) - { - poll_period = monitor_period * 2.5; - } + poll_period = monitor_period * 2.5; vmm = new VirtualMachineManager( vmpool, hpool, timer_period, poll_period, + do_poll, vm_limit, vmm_mads); } diff --git a/src/vmm/VirtualMachineManager.cc b/src/vmm/VirtualMachineManager.cc index 2946e80349..a415a1983a 100644 --- a/src/vmm/VirtualMachineManager.cc +++ b/src/vmm/VirtualMachineManager.cc @@ -34,6 +34,7 @@ VirtualMachineManager::VirtualMachineManager( HostPool * _hpool, time_t _timer_period, time_t _poll_period, + bool _do_vm_poll, int _vm_limit, vector& _mads): MadManager(_mads), @@ -41,6 +42,7 @@ VirtualMachineManager::VirtualMachineManager( hpool(_hpool), timer_period(_timer_period), poll_period(_poll_period), + do_vm_poll(_do_vm_poll), vm_limit(_vm_limit) { am.addListener(this); @@ -63,15 +65,7 @@ extern "C" void * vmm_action_loop(void *arg) NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager started."); - if ( vmm->poll_period == 0 ) - { - vmm->am.loop(0,0); - } - else - { - NebulaLog::log("VMM",Log::INFO,"VM monitoring is enabled."); - vmm->am.loop(vmm->timer_period,0); - } + vmm->am.loop(vmm->timer_period, 0); NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager stopped."); @@ -1507,8 +1501,8 @@ void VirtualMachineManager::timer_action() vmpool->clean_expired_monitoring(); // Skip monitoring the first poll_period to allow the Host monitoring to - // gather the VM info - if ( timer_start + poll_period > thetime ) + // gather the VM info (or if it is disabled) + if ( timer_start + poll_period > thetime || !do_vm_poll) { return; } From c7d000fd986d8d13381a7c02ccdb1e31a3289663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 May 2014 12:47:44 +0200 Subject: [PATCH 2/5] Bug #2924: fix template id argument for oneflow-template --- src/cli/oneflow-template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli/oneflow-template b/src/cli/oneflow-template index ddfbb51bdc..94b00e7799 100755 --- a/src/cli/oneflow-template +++ b/src/cli/oneflow-template @@ -165,7 +165,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do OpenNebulaHelper.rname_to_id(arg, "USER") end - set :format, :template_id, Service.rname_to_id_desc("SERVICE TEMPLATE") do |arg| + set :format, :templateid, Service.rname_to_id_desc("SERVICE TEMPLATE") do |arg| Service.rname_to_id(arg, "SERVICE TEMPLATE") end @@ -266,7 +266,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do Show detailed information of a given Service Template EOT - command :show, show_desc, :template_id, :options => Service::JSON_FORMAT do + command :show, show_desc, :templateid, :options => Service::JSON_FORMAT do client = Service::Client.new( :username => options[:username], :password => options[:password], @@ -304,7 +304,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do Instantiate a Service Template EOT - command :instantiate, instantiate_desc, :template_id, [:file, nil], + command :instantiate, instantiate_desc, :templateid, [:file, nil], :options => [Service::JSON_FORMAT, Service::TOP] do client = Service::Client.new( :username => options[:username], From a4500673c311b16419bdd575312219a3ef44479b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 May 2014 14:56:52 +0200 Subject: [PATCH 3/5] Feature #2898: fix bug --- src/flow/lib/models/service_template.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flow/lib/models/service_template.rb b/src/flow/lib/models/service_template.rb index 92368ff2d2..d459d801d7 100644 --- a/src/flow/lib/models/service_template.rb +++ b/src/flow/lib/models/service_template.rb @@ -171,7 +171,7 @@ module OpenNebula def allocate(template_json) template = JSON.parse(template_json) - validate(template) + ServiceTemplate.validate(template) super(template.to_json, template['name']) end @@ -186,7 +186,7 @@ module OpenNebula def update(template_json) template = JSON.parse(template_json) - validator(template) + ServiceTemplate.validate(template) super(template.to_json) end From 604a4e120d8628669b2b9ad3bead8fe13178ebc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 May 2014 15:23:03 +0200 Subject: [PATCH 4/5] Feature #2898: fix bug. params is now optional --- src/flow/oneflow-server.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/flow/oneflow-server.rb b/src/flow/oneflow-server.rb index eb5d5c924c..74e7b9532c 100644 --- a/src/flow/oneflow-server.rb +++ b/src/flow/oneflow-server.rb @@ -408,6 +408,7 @@ post '/service_template/:id/action' do action = JSON.parse(request.body.read)['action'] opts = action['params'] + opts = {} if opts.nil? rc = case action['perform'] when 'instantiate' From c568444b1c179798c69286a73a406d37f7786011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 16 May 2014 15:24:49 +0200 Subject: [PATCH 5/5] Feature #2898: New role attribute, vm_template_contents, to add arbitrary data to the role VM template --- src/flow/lib/models/role.rb | 11 ++++++++--- src/flow/lib/models/service_template.rb | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/flow/lib/models/role.rb b/src/flow/lib/models/role.rb index f1fa515caa..2ceb21510d 100644 --- a/src/flow/lib/models/role.rb +++ b/src/flow/lib/models/role.rb @@ -238,6 +238,14 @@ module OpenNebula @body['last_vmname'] ||= 0 + extra_template = @body['vm_template_contents'] + + extra_template = "" if extra_template.nil? + + extra_template << + "\nSERVICE_ID = #{@service.id()}" << + "\nROLE_NAME = \"#{@body['name']}\"" + n_nodes.times { |i| vm_name = @@vm_name_template. gsub("$SERVICE_ID", @service.id().to_s). @@ -254,9 +262,6 @@ module OpenNebula template = OpenNebula::Template.new_with_id(template_id, @service.client) - extra_template = "SERVICE_ID = #{@service.id()}\n"\ - "ROLE_NAME = \"#{@body['name']}\"" - vm_id = template.instantiate(vm_name, false, extra_template) if OpenNebula.is_error?(vm_id) diff --git a/src/flow/lib/models/service_template.rb b/src/flow/lib/models/service_template.rb index d459d801d7..fced252c41 100644 --- a/src/flow/lib/models/service_template.rb +++ b/src/flow/lib/models/service_template.rb @@ -35,6 +35,10 @@ module OpenNebula :type => :integer, :required => true }, + 'vm_template_contents' => { + :type => :string, + :required => false + }, 'parents' => { :type => :array, :items => {