From 67e524f2b0dcc28a3689c8aeea500c37a8cfc8c4 Mon Sep 17 00:00:00 2001 From: david karapetyan Date: Tue, 12 May 2015 14:10:23 -0700 Subject: [PATCH 01/28] rstrip! the endpoint as well I kept getting bad URI error when loading the endpoint from a file because there was a trailing newline. This fixes that problem. --- src/oca/ruby/opennebula/client.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/oca/ruby/opennebula/client.rb b/src/oca/ruby/opennebula/client.rb index d649f36e8f..3f730d0bab 100644 --- a/src/oca/ruby/opennebula/client.rb +++ b/src/oca/ruby/opennebula/client.rb @@ -143,6 +143,8 @@ module OpenNebula else @one_endpoint = "http://localhost:2633/RPC2" end + + @one_endpoint.rstrip! @async = !options[:sync] From f7a5f90c3065e91bf5553deb79c6cdd2bf334715 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Thu, 14 May 2015 17:21:50 +0200 Subject: [PATCH 02/28] Feature #3645: Resize columns in LEASES table in onevnet show --- src/cli/one_helper/onevnet_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli/one_helper/onevnet_helper.rb b/src/cli/one_helper/onevnet_helper.rb index 958876b7d6..33f89a40a7 100644 --- a/src/cli/one_helper/onevnet_helper.rb +++ b/src/cli/one_helper/onevnet_helper.rb @@ -303,11 +303,11 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper d['AR_ID'] end - column :OWNER, "", :left, :size=>10 do |d| + column :OWNER, "", :left, :size=>15 do |d| if d['VM'] - "VM : #{d['VM']}" + "V:#{d['VM']}" elsif d['VNET'] - "NET: #{d['VNET']}" + "N:#{d['VNET']}" end end @@ -319,7 +319,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper d["IP"]||"-" end - column :IP6_GLOBAL, "", :donottruncate, :size=>31 do |d| + column :IP6_GLOBAL, "", :donottruncate, :size=>26 do |d| d["IP6_GLOBAL"]||"-" end end.show(leases, {}) From 61f3d21827c683e35ba31acd72e5743eff785bd2 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 14 May 2015 18:52:46 +0200 Subject: [PATCH 03/28] Update NOTICE file --- NOTICE | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/NOTICE b/NOTICE index 35da7197f9..dff13a505a 100644 --- a/NOTICE +++ b/NOTICE @@ -1,6 +1,6 @@ OpenNebula Open Source Project -------------------------------------------------------------------------------- -Copyright 2002-2014, OpenNebula Project, OpenNebula Systems (formerly C12G Labs) +Copyright 2002-2015, OpenNebula Project, OpenNebula Systems (formerly C12G Labs) -------------------------------------------------------------------------------- You can find more information about the project, release notes and @@ -21,11 +21,6 @@ The following people have contributed to the development of the technology - Daniel Molina Aranda (dmolina@opennebula.org) - Hector Sanjuan Redondo (hsanjuan@opennebula.org) -The new features for service elasticity (oneFlow) introduced in OpenNebula 4.2 -were funded by BlackBerry in the context of the Fund a Feature Program. - -OpenNebula Project also acknowledges the contributions of C12G Labs developers. - LICENSE OpenNebula is licensed under the Apache License, Version 2.0 (the From 945c0b5bef8e07cbd858ee231be460af5ac4dd01 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 14 May 2015 19:36:52 +0200 Subject: [PATCH 04/28] Feature #3723: Add support for keymap in vCenter --- .../public/js/plugins/templates-tab.js | 2 +- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 37 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 6b9a0cb99b..d49806a618 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -503,7 +503,7 @@ if (Config.isTemplateCreationTabEnabled('input_output')){ ''+ ''+ ''+ - '
'+ + '
'+ ''+ diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index aaba592cb3..6c4b4c8359 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -538,7 +538,8 @@ class VCenterHost < ::OpenNebula::Host ############################################################################ # Generate an OpenNebula monitor string for this host. Reference: - # https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.ComputeResource.Summary.html + # https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/Reference + # Guide/vim.ComputeResource.Summary.html # - effectiveCpu: Effective CPU resources (in MHz) available to run # VMs. This is the aggregated from all running hosts excluding hosts in # maintenance mode or unresponsive are not counted. @@ -1058,6 +1059,8 @@ class VCenterVm # ######################################################################## def vm_to_one + host_name = @vm.runtime.host.parent.name + str = "NAME = \"#{@vm.name}\"\n"\ "CPU = \"#{@vm.config.hardware.numCPU}\"\n"\ "vCPU = \"#{@vm.config.hardware.numCPU}\"\n"\ @@ -1068,21 +1071,25 @@ class VCenterVm " VM_TEMPLATE =\"#{@vm.config.uuid}\"\n"\ "]\n"\ "IMPORT_VM_ID = \"#{@vm.config.uuid}\"\n"\ - "SCHED_REQUIREMENTS=\"NAME=\\\"#{@vm.runtime.host.parent.name}\\\"\"\n" + "SCHED_REQUIREMENTS=\"NAME=\\\"#{host_name}\\\"\"\n" - vp=@vm.config.extraConfig.select{|v| v[:key]=="remotedisplay.vnc.port"} + vp = @vm.config.extraConfig.select{|v| + v[:key]=="remotedisplay.vnc.port"} + keymap = @vm.config.extraConfig.select{|v| + v[:key]=="remotedisplay.vnc.keymap"} if vp.size > 0 str << "GRAPHICS = [\n"\ " TYPE =\"vnc\",\n"\ " LISTEN =\"0.0.0.0\",\n"\ - " PORT =\"#{vp[0][:value]}\"\n"\ - "]\n" + " PORT =\"#{vp[0][:value]}\"\n" + str << " KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap[0] + str << "]\n" end if @vm.config.annotation.nil? || @vm.config.annotation.empty? - str << "DESCRIPTION = \"vCenter Virtual Machine imported by OpenNebula"\ - " from Cluster #{@vm.runtime.host.parent.name}\"\n" + str << "DESCRIPTION = \"vCenter Virtual Machine imported by"\ + " OpenNebula from Cluster #{@vm.runtime.host.parent.name}\"\n" else notes = @vm.config.annotation.gsub("\\", "\\\\").gsub("\"", "\\\"") str << "DESCRIPTION = \"#{notes}\"\n" @@ -1257,8 +1264,11 @@ private vm_uuid = vm.config.uuid + # VNC Section + vnc_port = xml.root.elements["/VM/TEMPLATE/GRAPHICS/PORT"] vnc_listen = xml.root.elements["/VM/TEMPLATE/GRAPHICS/LISTEN"] + vnc_keymap = xml.root.elements["/VM/TEMPLATE/GRAPHICS/KEYMAP"] if !vnc_listen vnc_listen = "0.0.0.0" @@ -1271,11 +1281,16 @@ private if vnc_port config_array += - [{:key=>"remotedisplay.vnc.enabled", :value=>"TRUE"}, - {:key=>"remotedisplay.vnc.port", :value=>vnc_port.text}, - {:key=>"remotedisplay.vnc.ip", :value=>vnc_listen}] + [{:key=>"remotedisplay.vnc.enabled",:value=>"TRUE"}, + {:key=>"remotedisplay.vnc.port", :value=>vnc_port.text}, + {:key=>"remotedisplay.vnc.ip", :value=>vnc_listen}] end + config_array += [{:key=>"remotedisplay.vnc.keymap", + :value=>vnc_keymap.text}] if vnc_keymap + + # Context section + if context # Remove (9) and \n (11) context_text = "# Context variables generated by OpenNebula\n" @@ -1293,7 +1308,7 @@ private context_vnc_spec = {:extraConfig =>config_array} end - # Take care of the NIC section, build the reconfig hash + # NIC section, build the reconfig hash nics = xml.root.get_elements("//TEMPLATE/NIC") nic_spec = {} From 33e6f7339a6db9c4a417e4d37ead5b734f33e716 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 14 May 2015 19:38:46 +0200 Subject: [PATCH 05/28] Feature #3723: Add missing comma --- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index 6c4b4c8359..c65ae733da 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -1083,7 +1083,7 @@ class VCenterVm " TYPE =\"vnc\",\n"\ " LISTEN =\"0.0.0.0\",\n"\ " PORT =\"#{vp[0][:value]}\"\n" - str << " KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap[0] + str << " ,KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap[0] str << "]\n" end From 86c86610b9164b400ec450ab54919247201fccd5 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 18 May 2015 19:25:07 +0200 Subject: [PATCH 06/28] Feature #3802: iDeprecate onevcenter vms with the new onehost import functionality --- src/cli/onevcenter | 78 ++-------------------------------- src/sunstone/routes/vcenter.rb | 20 --------- 2 files changed, 4 insertions(+), 94 deletions(-) diff --git a/src/cli/onevcenter b/src/cli/onevcenter index 87f11bc617..00bbc98944 100755 --- a/src/cli/onevcenter +++ b/src/cli/onevcenter @@ -216,84 +216,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do end vms_desc = <<-EOT.unindent - Import vCenter running Virtual Machines into OpenNebula + Deprecated action in onevcenter, please use onehost importvm instead EOT command :vms, vms_desc, :options=>[ VCENTER, USER, PASS ] do - if options[:vuser].nil? || - options[:vpass].nil? || - options[:vcenter].nil? - STDERR.puts "vCenter connection parameters are mandatory to import"\ - " VM templates:\n"\ - "\t --vcenter vCenter hostname\n"\ - "\t --vuser username to login in vcenter\n"\ - "\t --vpass password for the user" - exit -1 - end + STDERR.puts "Deprecated action in onevcenter, please use onehost "\ + "importvm instead" - begin - STDOUT.print "\nConnecting to vCenter: #{options[:vcenter]}..." - - vc = VCenterDriver::VIClient.new_connection( - :user => options[:vuser], - :password => options[:vpass], - :host => options[:vcenter]) - - STDOUT.print "done!\n\n" - - STDOUT.print "Looking for running Virtual Machines..." - - rs = vc.running_vms - - STDOUT.print "done!\n" - - rs.each {|dc, tmps| - STDOUT.print "\nDo you want to process datacenter #{dc} [y/n]? " - - next if STDIN.gets.strip.downcase != 'y' - - if tmps.empty? - STDOUT.print " No new running Virtual Machines found in"\ - " #{dc}...\n\n" - next - end - - tmps.each{ |v| - STDOUT.print "\n * Running Virtual Machine found:\n"\ - " - Name : #{v[:name]}\n"\ - " - UUID : #{v[:uuid]}\n"\ - " - Cluster: #{v[:host]}\n"\ - " Import this Virtual Machine [y/n]? " - - next if STDIN.gets.strip.downcase != 'y' - - one_v = ::OpenNebula::VirtualMachine.new( - ::OpenNebula::VirtualMachine.build_xml, vc.one) - - rc = one_v.allocate(v[:one]) - - if ::OpenNebula.is_error?(rc) - STDOUT.puts " Error creating Virtual Machine: "\ - "#{rc.message}\n" - end - - rc = one_v.deploy v[:host_id] - - if ::OpenNebula.is_error?(rc) - STDOUT.puts " Error creating Virtual Machine: "\ - "#{rc.message}\n" - else - STDOUT.puts " OpenNebula VM #{one_v.id} "\ - "created!\n" - end - } - } - rescue Exception => e - STDOUT.puts "error: #{e.message}" - exit -1 - end - - exit 0 + exit -1 end network_desc = <<-EOT.unindent diff --git a/src/sunstone/routes/vcenter.rb b/src/sunstone/routes/vcenter.rb index 74d09b03bb..ac7c125e18 100644 --- a/src/sunstone/routes/vcenter.rb +++ b/src/sunstone/routes/vcenter.rb @@ -87,26 +87,6 @@ get '/vcenter/templates' do end end - -get '/vcenter/vms' do - begin - vms = vcenter_client.running_vms( - $cloud_auth.client(session[:user], session[:active_zone_endpoint])) - if vms.nil? - msg = "No datacenter found" - logger.error("[vCenter] " + msg) - error = Error.new(msg) - error 404, error.to_json - end - - [200, vms.to_json] - rescue Exception => e - logger.error("[vCenter] " + e.message) - error = Error.new(e.message) - error 403, error.to_json - end -end - get '/vcenter/networks' do begin networks = vcenter_client.vcenter_networks( From aaf77b9dd1d96865ab0f6e01ea32df30951b89e8 Mon Sep 17 00:00:00 2001 From: Cherdancev Evgeni Date: Tue, 19 May 2015 14:02:21 +0600 Subject: [PATCH 07/28] add enp2 interface AND refactor mem&cpu for using /proc --- src/im_mad/remotes/kvm-probes.d/kvm.rb | 43 ++++++++++++-------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/im_mad/remotes/kvm-probes.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb index 7209dd67b5..c8b84cd34f 100755 --- a/src/im_mad/remotes/kvm-probes.d/kvm.rb +++ b/src/im_mad/remotes/kvm-probes.d/kvm.rb @@ -26,7 +26,7 @@ end # TODO : use virsh freecell when available ###### -nodeinfo_text = `virsh -c qemu:///system nodeinfo` +nodeinfo_text = `LANG=C virsh -c qemu:///system nodeinfo` exit(-1) if $?.exitstatus != 0 nodeinfo_text.split(/\n/).each{|line| @@ -43,33 +43,30 @@ nodeinfo_text.split(/\n/).each{|line| # for everything else, top & proc ##### -NETINTERFACE = "eth|bond|em|p[0-9]+p[0-9]+" +NETINTERFACE = "eth|bond|em|enp2|p[0-9]+p[0-9]+" -top_text=`top -bin2` -exit(-1) if $?.exitstatus != 0 +stat = `cat /proc/stat` -top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output +stat.each_line do |line| + if /\Acpu (.*)\Z/.match(line) + stat_cpu = Regexp.last_match[1].to_s.split + stat_total_cpu = stat_cpu.inject(0) {|s,sum| sum.to_i+s.to_i}.to_i + $free_cpu = $total_cpu * stat_cpu[3].to_f / stat_total_cpu + $used_cpu = $total_cpu - $free_cpu + end +end -top_text.split(/\n/).each{|line| - if line.match('^%?Cpu') - line[7..-1].split(",").each{|elemento| - temp = elemento.strip.split(/[% ]/) - if temp[1]=="id" - idle = temp[0] - $free_cpu = idle.to_f * $total_cpu.to_f / 100 - $used_cpu = $total_cpu.to_f - $free_cpu - break - end +memory = `cat /proc/meminfo` +meminfo = Hash.new() +memory.each_line do |line| + key, value = line.split(':') + meminfo[key] = /\d+/.match(value)[0].to_i +end - } - end -} +$total_memory = meminfo['MemTotal'] -$total_memory = `free -k|grep "Mem:" | awk '{print $2}'` -tmp=`free -k|grep "buffers\/cache"|awk '{print $3 " " $4}'`.split - -$used_memory=tmp[0] -$free_memory=tmp[1] +$used_memory = meminfo['MemTotal'] - meminfo['MemFree'] - meminfo['Buffers'] - meminfo['Cached'] +$free_memory = $total_memory - $used_memory net_text=`cat /proc/net/dev` exit(-1) if $?.exitstatus != 0 From 0728ea0bacd1da8918a59c9ac937fe65e5c06e71 Mon Sep 17 00:00:00 2001 From: Cherdancev Evgeni Date: Tue, 19 May 2015 14:10:23 +0600 Subject: [PATCH 08/28] change enp2 to enp interfaces --- src/im_mad/remotes/kvm-probes.d/kvm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/im_mad/remotes/kvm-probes.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb index c8b84cd34f..946934827c 100755 --- a/src/im_mad/remotes/kvm-probes.d/kvm.rb +++ b/src/im_mad/remotes/kvm-probes.d/kvm.rb @@ -43,7 +43,7 @@ nodeinfo_text.split(/\n/).each{|line| # for everything else, top & proc ##### -NETINTERFACE = "eth|bond|em|enp2|p[0-9]+p[0-9]+" +NETINTERFACE = "eth|bond|em|enp|p[0-9]+p[0-9]+" stat = `cat /proc/stat` From bc3b4a53880de6aeaf71ca5db43cc0ad5e7a116b Mon Sep 17 00:00:00 2001 From: Cherdancev Evgeni Date: Tue, 19 May 2015 14:28:55 +0600 Subject: [PATCH 09/28] inject swap arguments --- src/im_mad/remotes/kvm-probes.d/kvm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/im_mad/remotes/kvm-probes.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb index 946934827c..9dad514323 100755 --- a/src/im_mad/remotes/kvm-probes.d/kvm.rb +++ b/src/im_mad/remotes/kvm-probes.d/kvm.rb @@ -50,7 +50,7 @@ stat = `cat /proc/stat` stat.each_line do |line| if /\Acpu (.*)\Z/.match(line) stat_cpu = Regexp.last_match[1].to_s.split - stat_total_cpu = stat_cpu.inject(0) {|s,sum| sum.to_i+s.to_i}.to_i + stat_total_cpu = stat_cpu.inject(0) {|sum,s| sum.to_i+s.to_i}.to_i $free_cpu = $total_cpu * stat_cpu[3].to_f / stat_total_cpu $used_cpu = $total_cpu - $free_cpu end From df4cbea89be201332535679ded256916984a13de Mon Sep 17 00:00:00 2001 From: Cherdancev Evgeni Date: Tue, 19 May 2015 17:42:23 +0600 Subject: [PATCH 10/28] use vmstat instead of /proc/stat for cpu --- src/im_mad/remotes/kvm-probes.d/kvm.rb | 28 ++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/im_mad/remotes/kvm-probes.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb index 9dad514323..77b4dbac54 100755 --- a/src/im_mad/remotes/kvm-probes.d/kvm.rb +++ b/src/im_mad/remotes/kvm-probes.d/kvm.rb @@ -40,22 +40,15 @@ nodeinfo_text.split(/\n/).each{|line| } ###### -# for everything else, top & proc -##### - -NETINTERFACE = "eth|bond|em|enp|p[0-9]+p[0-9]+" - -stat = `cat /proc/stat` - -stat.each_line do |line| - if /\Acpu (.*)\Z/.match(line) - stat_cpu = Regexp.last_match[1].to_s.split - stat_total_cpu = stat_cpu.inject(0) {|sum,s| sum.to_i+s.to_i}.to_i - $free_cpu = $total_cpu * stat_cpu[3].to_f / stat_total_cpu - $used_cpu = $total_cpu - $free_cpu - end -end +# CPU +###### +vmstat = `vmstat 1 2` +$free_cpu = $total_cpu * ((vmstat.split("\n").to_a.last.split)[14].to_i)/100 +$used_cpu = $total_cpu - $free_cpu +###### +# MEMORY +###### memory = `cat /proc/meminfo` meminfo = Hash.new() memory.each_line do |line| @@ -68,6 +61,11 @@ $total_memory = meminfo['MemTotal'] $used_memory = meminfo['MemTotal'] - meminfo['MemFree'] - meminfo['Buffers'] - meminfo['Cached'] $free_memory = $total_memory - $used_memory +###### +# INTERFACE +###### +NETINTERFACE = "eth|bond|em|enp|p[0-9]+p[0-9]+" + net_text=`cat /proc/net/dev` exit(-1) if $?.exitstatus != 0 From d880cc6c6b644465967771ec322ffada62c26bec Mon Sep 17 00:00:00 2001 From: Cherdancev Evgeni Date: Tue, 19 May 2015 20:32:09 +0600 Subject: [PATCH 11/28] fix LANG=C --- src/im_mad/remotes/kvm-probes.d/kvm.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/im_mad/remotes/kvm-probes.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb index 77b4dbac54..32db20488f 100755 --- a/src/im_mad/remotes/kvm-probes.d/kvm.rb +++ b/src/im_mad/remotes/kvm-probes.d/kvm.rb @@ -26,7 +26,9 @@ end # TODO : use virsh freecell when available ###### -nodeinfo_text = `LANG=C virsh -c qemu:///system nodeinfo` +ENV['LANG'] = 'C' + +nodeinfo_text = `virsh -c qemu:///system nodeinfo` exit(-1) if $?.exitstatus != 0 nodeinfo_text.split(/\n/).each{|line| From b27d12e48de81e0f869356d8f188c0b42d12a1b3 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 26 May 2015 12:02:43 +0200 Subject: [PATCH 12/28] Feature #3021: disallow root to run onehost sync --- src/cli/one_helper/onehost_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index a9ed75ea51..44f262daa4 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -167,6 +167,11 @@ class OneHostHelper < OpenNebulaHelper::OneHelper NUM_THREADS = 15 def sync(host_ids, options) + if `id -u`.to_i == 0 || `id -G`.split.collect{|e| e.to_i}.include?(0) + STDERR.puts("Cannot run 'onehost sync' as root") + exit -1 + end + begin current_version = File.read(REMOTES_LOCATION+'/VERSION').strip rescue From aa4347023370a042178f63ec8da3ac2fc1b56496 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 26 May 2015 15:11:49 +0200 Subject: [PATCH 13/28] Feature #3650: Specify the default auth driver in oned.conf --- include/UserPool.h | 5 ----- share/etc/oned.conf | 9 +++++++++ src/um/UserPool.cc | 13 ++++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/UserPool.h b/include/UserPool.h index b94682c336..484f030b3d 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -187,11 +187,6 @@ public: */ static const char * PUBLIC_AUTH; - /** - * Name for the default auth driver to be used for not registered users - */ - static const char * DEFAULT_AUTH; - /** * Name for the default Sunstone server user */ diff --git a/share/etc/oned.conf b/share/etc/oned.conf index d32b5578a8..05b8647cac 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -703,6 +703,13 @@ HM_MAD = [ # defined all the modules available will be enabled # authz : list of authentication modules separated by commas # +# DEFAULT_AUTH: The default authentication driver to use when OpenNebula +# does not know the user and needs to authenticate it externally. The default +# value is "default", however as no "default" auth driver exists, there should +# be a symbolic link pointig to the actual authentication driver, example: +# 'default -> ldap', or simply use DEFAULT_AUTH = "ldap" and no symlink is +# required. +# # SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as # valid. During this time, the driver is not used. Use 0 to disable session # caching @@ -721,6 +728,8 @@ AUTH_MAD = [ authn = "ssh,x509,ldap,server_cipher,server_x509" ] +#DEFAULT_AUTH = "default" + SESSION_EXPIRATION_TIME = 900 #ENABLE_OTHER_PERMISSIONS = "YES" diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index fc50c7dee1..1400b66690 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -36,7 +36,6 @@ const char * UserPool::CORE_AUTH = "core"; const char * UserPool::SERVER_AUTH = "server*"; const char * UserPool::PUBLIC_AUTH = "public"; -const char * UserPool::DEFAULT_AUTH = "default"; const char * UserPool::SERVER_NAME = "serveradmin"; @@ -248,7 +247,7 @@ error_no_open: erro_exists: oss << "Password file " << filenames[i] << " already exists " - << "but OpenNebula is boostraping the database. Check your " + << "but OpenNebula is boostraping the database. Check your " << "database configuration in oned.conf."; goto error_common; @@ -713,6 +712,7 @@ bool UserPool::authenticate_external(const string& username, string mad_pass; string error_str; string tmp_str; + string default_auth; Nebula& nd = Nebula::instance(); AuthManager * authm = nd.get_authm(); @@ -734,7 +734,14 @@ bool UserPool::authenticate_external(const string& username, } //Initialize authentication request and call the driver - ar.add_authenticate(UserPool::DEFAULT_AUTH, username,"-",token); + nd.get_configuration_attribute("DEFAULT_AUTH",default_auth); + + if (default_auth.empty()) + { + default_auth = "default"; + } + + ar.add_authenticate(default_auth, username,"-",token); authm->trigger(AuthManager::AUTHENTICATE, &ar); ar.wait(); From d89ba1692aba4329773ec437f642b19480532c59 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 26 May 2015 15:25:51 +0200 Subject: [PATCH 14/28] Feature #3650: Use NebulaTemplate to set the default value of DEFAULT_AUTH --- src/nebula/NebulaTemplate.cc | 7 +++++++ src/um/UserPool.cc | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 1741404ae2..876310daf0 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -356,11 +356,18 @@ void OpenNebulaTemplate::set_conf_default() #******************************************************************************* # Auth Manager Configuration #******************************************************************************* +# DEFAULT_AUTH # SESSION_EXPIRATION_TIME # ENABLE_OTHER_PERMISSIONS # DEFAULT_UMASK #******************************************************************************* */ + // DEFAULT_AUTH + value = "default"; + + attribute = new SingleAttribute("DEFAULT_AUTH",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + // SESSION_EXPIRATION_TIME value = "0"; diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 1400b66690..808d8c829b 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -736,11 +736,6 @@ bool UserPool::authenticate_external(const string& username, //Initialize authentication request and call the driver nd.get_configuration_attribute("DEFAULT_AUTH",default_auth); - if (default_auth.empty()) - { - default_auth = "default"; - } - ar.add_authenticate(default_auth, username,"-",token); authm->trigger(AuthManager::AUTHENTICATE, &ar); From 4eb305b72166127d5cba95e61d87dbd10a41bf7a Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 26 May 2015 15:52:24 +0200 Subject: [PATCH 15/28] Feature #3650: Clarify documenation in oned.conf for DEFAULT_AUTH --- share/etc/oned.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 05b8647cac..b942dc390d 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -703,12 +703,12 @@ HM_MAD = [ # defined all the modules available will be enabled # authz : list of authentication modules separated by commas # -# DEFAULT_AUTH: The default authentication driver to use when OpenNebula -# does not know the user and needs to authenticate it externally. The default -# value is "default", however as no "default" auth driver exists, there should -# be a symbolic link pointig to the actual authentication driver, example: -# 'default -> ldap', or simply use DEFAULT_AUTH = "ldap" and no symlink is -# required. +# DEFAULT_AUTH: The default authentication driver to use when OpenNebula does +# not know the user and needs to authenticate it externally. If you want to +# use "default" (not recommended, but supported for backwards compatibility +# reasons) make sure you create a symlink pointing to the actual authentication +# driver in /var/lib/one/remotes/auth, and add "default" to the 'auth' +# parameter in the 'AUTH_MAD' section. # # SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as # valid. During this time, the driver is not used. Use 0 to disable session From d3feae9b03d5c0e493a7ea4bf96787ccdc3d5084 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 26 May 2015 17:15:20 +0200 Subject: [PATCH 16/28] Bug #3818: Fix wrong polling in shutdown --- src/vmm_mad/remotes/vmware/shutdown | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vmm_mad/remotes/vmware/shutdown b/src/vmm_mad/remotes/vmware/shutdown index fbaac03238..50041948de 100755 --- a/src/vmm_mad/remotes/vmware/shutdown +++ b/src/vmm_mad/remotes/vmware/shutdown @@ -28,6 +28,7 @@ $: << RUBY_LIB_LOCATION $: << File.dirname(__FILE__) require 'vmware_driver' +require 'vi_driver' #------------------------------------------------------------------------------ # Wait the VM to shutdown TIMEOUT (xPOLL_INTERVAL) seconds. @@ -39,12 +40,14 @@ TIMEOUT=300 deploy_id = ARGV[0] host = ARGV[1] +VIDriver::initialize(host) + vmware_drv = VMwareDriver.new(host) vmware_drv.shutdown(deploy_id) count=0 -while (vmware_drv.poll(deploy_id).match(/STATE=(.*)/)[1] != "d") do +while (VIDriver::poll_vm(deploy_id).match(/STATE=(.*)/)[1] != "d") do sleep POLL_INTERVAL if count > TIMEOUT then OpenNebula.log_debug("Timeout reached and VM #{deploy_id} is still alive.") From dc318dd06467f41f478d1cd027cdb0b4279fc48b Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 26 May 2015 19:01:08 +0200 Subject: [PATCH 17/28] Bug #3807: Remove only rules for ATTACH=YES nics when doing a detach (deactivate method) --- src/vnm_mad/remotes/ebtables/Ebtables.rb | 7 +++++++ src/vnm_mad/remotes/lib/fw_driver.rb | 13 ++++++++++--- src/vnm_mad/remotes/lib/sg_driver.rb | 12 +++++++++--- src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb | 6 ++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/vnm_mad/remotes/ebtables/Ebtables.rb b/src/vnm_mad/remotes/ebtables/Ebtables.rb index 931bd23308..cf1f29b788 100644 --- a/src/vnm_mad/remotes/ebtables/Ebtables.rb +++ b/src/vnm_mad/remotes/ebtables/Ebtables.rb @@ -62,8 +62,15 @@ class EbtablesVLAN < VNMMAD::VNMDriver def deactivate lock + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + mac = nic[:mac] + # remove 0-padding mac = mac.split(":").collect{|e| e.hex.to_s(16)}.join(":") diff --git a/src/vnm_mad/remotes/lib/fw_driver.rb b/src/vnm_mad/remotes/lib/fw_driver.rb index 513f7980ed..592b3f7f44 100644 --- a/src/vnm_mad/remotes/lib/fw_driver.rb +++ b/src/vnm_mad/remotes/lib/fw_driver.rb @@ -40,7 +40,7 @@ module VNMMAD lock vm_id = @vm['ID'] - + process do |nic| #:white_ports_tcp => iptables_range #:white_ports_udp => iptables_range @@ -93,8 +93,15 @@ module VNMMAD def deactivate lock - vm_id = @vm['ID'] + vm_id = @vm['ID'] + + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + chain = "one-#{vm_id}-#{nic[:network_id]}" iptables_out = `#{command(:iptables)} -n -v --line-numbers -L FORWARD` if m = iptables_out.match(/.*#{chain}.*/) @@ -196,4 +203,4 @@ module VNMMAD "#{command(:iptables)} #{rule}" end end -end \ No newline at end of file +end diff --git a/src/vnm_mad/remotes/lib/sg_driver.rb b/src/vnm_mad/remotes/lib/sg_driver.rb index bf2efea5f4..9a87b0ccbb 100644 --- a/src/vnm_mad/remotes/lib/sg_driver.rb +++ b/src/vnm_mad/remotes/lib/sg_driver.rb @@ -23,7 +23,7 @@ module VNMMAD DRIVER = "sg" XPATH_FILTER = "TEMPLATE/NIC" - + # Creates a new SG driver and scans SG Rules def initialize(vm, deploy_id = nil, hypervisor = nil) super(vm, XPATH_FILTER, deploy_id, hypervisor) @@ -48,7 +48,7 @@ module VNMMAD @security_group_rules = rules end - # Activate the rules, bootstrap iptables chains and set filter rules for + # Activate the rules, bootstrap iptables chains and set filter rules for # each VM NIC def activate deactivate @@ -68,7 +68,7 @@ module VNMMAD sg_ids.each do |sg_id| rules = @security_group_rules[sg_id] - sg = SGIPTables::SecurityGroupIPTables.new(@vm, nic, sg_id, + sg = SGIPTables::SecurityGroupIPTables.new(@vm, nic, sg_id, rules) begin @@ -92,7 +92,13 @@ module VNMMAD lock begin + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + @vm.nics.each do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + SGIPTables.nic_deactivate(@vm, nic) end rescue Exception => e diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index 8a1bd5e848..adb9e74a44 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -72,7 +72,13 @@ class OpenvSwitchVLAN < VNMMAD::VNMDriver def deactivate lock + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + @nic = nic # Remove flows From f503bcbffee6865a05283cda85fa6f65262bc669 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 28 May 2015 16:09:00 +0200 Subject: [PATCH 18/28] bug #3743: add Debian8 directory and fix ipset path in Debian 7 --- share/pkgs/{Debian => Debian7}/opennebula | 0 .../pkgs/{Debian => Debian7}/opennebula-econe | 0 .../pkgs/{Debian => Debian7}/opennebula-flow | 0 .../pkgs/{Debian => Debian7}/opennebula-gate | 0 .../pkgs/{Debian => Debian7}/opennebula-novnc | 0 .../{Debian => Debian7}/opennebula-sunstone | 0 share/pkgs/Debian7/opennebula.sudoers | 11 ++ share/pkgs/Debian8/opennebula | 128 ++++++++++++++++++ share/pkgs/Debian8/opennebula-econe | 106 +++++++++++++++ share/pkgs/Debian8/opennebula-flow | 94 +++++++++++++ share/pkgs/Debian8/opennebula-gate | 94 +++++++++++++ share/pkgs/Debian8/opennebula-novnc | 105 ++++++++++++++ share/pkgs/Debian8/opennebula-sunstone | 108 +++++++++++++++ .../{Debian => Debian8}/opennebula.sudoers | 0 14 files changed, 646 insertions(+) rename share/pkgs/{Debian => Debian7}/opennebula (100%) rename share/pkgs/{Debian => Debian7}/opennebula-econe (100%) rename share/pkgs/{Debian => Debian7}/opennebula-flow (100%) rename share/pkgs/{Debian => Debian7}/opennebula-gate (100%) rename share/pkgs/{Debian => Debian7}/opennebula-novnc (100%) rename share/pkgs/{Debian => Debian7}/opennebula-sunstone (100%) create mode 100644 share/pkgs/Debian7/opennebula.sudoers create mode 100755 share/pkgs/Debian8/opennebula create mode 100755 share/pkgs/Debian8/opennebula-econe create mode 100755 share/pkgs/Debian8/opennebula-flow create mode 100755 share/pkgs/Debian8/opennebula-gate create mode 100755 share/pkgs/Debian8/opennebula-novnc create mode 100755 share/pkgs/Debian8/opennebula-sunstone rename share/pkgs/{Debian => Debian8}/opennebula.sudoers (100%) diff --git a/share/pkgs/Debian/opennebula b/share/pkgs/Debian7/opennebula similarity index 100% rename from share/pkgs/Debian/opennebula rename to share/pkgs/Debian7/opennebula diff --git a/share/pkgs/Debian/opennebula-econe b/share/pkgs/Debian7/opennebula-econe similarity index 100% rename from share/pkgs/Debian/opennebula-econe rename to share/pkgs/Debian7/opennebula-econe diff --git a/share/pkgs/Debian/opennebula-flow b/share/pkgs/Debian7/opennebula-flow similarity index 100% rename from share/pkgs/Debian/opennebula-flow rename to share/pkgs/Debian7/opennebula-flow diff --git a/share/pkgs/Debian/opennebula-gate b/share/pkgs/Debian7/opennebula-gate similarity index 100% rename from share/pkgs/Debian/opennebula-gate rename to share/pkgs/Debian7/opennebula-gate diff --git a/share/pkgs/Debian/opennebula-novnc b/share/pkgs/Debian7/opennebula-novnc similarity index 100% rename from share/pkgs/Debian/opennebula-novnc rename to share/pkgs/Debian7/opennebula-novnc diff --git a/share/pkgs/Debian/opennebula-sunstone b/share/pkgs/Debian7/opennebula-sunstone similarity index 100% rename from share/pkgs/Debian/opennebula-sunstone rename to share/pkgs/Debian7/opennebula-sunstone diff --git a/share/pkgs/Debian7/opennebula.sudoers b/share/pkgs/Debian7/opennebula.sudoers new file mode 100644 index 0000000000..4f75c3eec7 --- /dev/null +++ b/share/pkgs/Debian7/opennebula.sudoers @@ -0,0 +1,11 @@ +Defaults:oneadmin !requiretty +Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin + +Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync +Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /usr/sbin/ipset +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm +Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl +Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm + +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN diff --git a/share/pkgs/Debian8/opennebula b/share/pkgs/Debian8/opennebula new file mode 100755 index 0000000000..9d923565b4 --- /dev/null +++ b/share/pkgs/Debian8/opennebula @@ -0,0 +1,128 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Should-Start: mysql +# Should-Stop: mysql +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OpenNebula init script +# Description: OpenNebula cloud initialisation script +### END INIT INFO + +# Author: Soren Hansen + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OpenNebula cloud" +NAME=one +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one + chown oneadmin /var/run/one /var/lock/one + su oneadmin -s /bin/sh -c 'one start' +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c 'one stop' +} + +do_start_sched() +{ + su oneadmin -s /bin/sh -c 'one start-sched' +} + +do_stop_sched() +{ + su oneadmin -s /bin/sh -c 'one stop-sched' +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "oned" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + restart-sched) + log_daemon_msg "Restarting scheduler" + do_stop_sched + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-econe b/share/pkgs/Debian8/opennebula-econe new file mode 100755 index 0000000000..31003b2b0d --- /dev/null +++ b/share/pkgs/Debian8/opennebula-econe @@ -0,0 +1,106 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-econe +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: ECONE Server init script +# Description: OpenNebula ECONE service initialisation script +### END INIT INFO + +# Author: Tino Vázquez + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="ECONE Service" +NAME=econe-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/$NAME +PID_FILE=/var/run/one/econe-server.pid + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + ECONE_PID=`cat $PID_FILE` + kill -0 $ECONE_PID > /dev/null 2>&1 + if [ "$?" -eq "0" ]; then + log_daemon_msg "$NAME is running" + log_end_msg 0 + else + log_daemon_msg "$NAME is not running" + log_end_msg 1 + fi + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-flow b/share/pkgs/Debian8/opennebula-flow new file mode 100755 index 0000000000..6467dd9476 --- /dev/null +++ b/share/pkgs/Debian8/opennebula-flow @@ -0,0 +1,94 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-flow +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OneFlow init script +# Description: OpenNebula OneFlow service initialisation script +### END INIT INFO + +# Author: Tino Vázquez + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OneFlow Service" +NAME=oneflow-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-gate b/share/pkgs/Debian8/opennebula-gate new file mode 100755 index 0000000000..613f2614ef --- /dev/null +++ b/share/pkgs/Debian8/opennebula-gate @@ -0,0 +1,94 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-gate +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OneGate init script +# Description: OpenNebula OneGate service initialisation script +### END INIT INFO + +# Author: Tino Vázquez + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OneGate Service" +NAME=onegate-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-novnc b/share/pkgs/Debian8/opennebula-novnc new file mode 100755 index 0000000000..f583a5fe1c --- /dev/null +++ b/share/pkgs/Debian8/opennebula-novnc @@ -0,0 +1,105 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-novnc +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: novnc init script +# Description: OpenNebula novnc server +### END INIT INFO + +# Author: Arnold Bechtoldt + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OpenNebula novnc server" +NAME=novnc-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/opennebula-novnc + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/lock/one /var/log/one + chown oneadmin /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that retrives the status of the daemon/service +# +do_status() +{ + su oneadmin -s /bin/sh -c "$DAEMON status" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + do_status && exit 0 || exit $? + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-sunstone b/share/pkgs/Debian8/opennebula-sunstone new file mode 100755 index 0000000000..34e9e1fbfb --- /dev/null +++ b/share/pkgs/Debian8/opennebula-sunstone @@ -0,0 +1,108 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-sunstone +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Sunstone init script +# Description: OpenNebula Sunstone web interface cloud initialisation script +### END INIT INFO + +# Author: Jaime Melis + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Sunstone Web interface" +NAME=sunstone-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/opennebula-sunstone +PID_FILE=/var/run/one/sunstone.pid + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + service opennebula-novnc start + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start-sunstone" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop-sunstone" + service opennebula-novnc stop +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + SUNSTONE_PID=`cat $PID_FILE` + kill -0 $SUNSTONE_PID > /dev/null 2>&1 + if [ "$?" -eq "0" ]; then + log_daemon_msg "$NAME is running" + log_end_msg 0 + else + log_daemon_msg "$NAME is not running" + log_end_msg 1 + fi + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian/opennebula.sudoers b/share/pkgs/Debian8/opennebula.sudoers similarity index 100% rename from share/pkgs/Debian/opennebula.sudoers rename to share/pkgs/Debian8/opennebula.sudoers From b96c2e635ef4ac6e9918d8fc7744d4eb69f0d646 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Fri, 29 May 2015 14:59:03 +0200 Subject: [PATCH 19/28] Bug #3732: The FILES datastores should use NO_DECOMPRESS = yes --- src/datastore_mad/remotes/fs/cp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/datastore_mad/remotes/fs/cp b/src/datastore_mad/remotes/fs/cp index e65991a68e..cfd9560d8c 100755 --- a/src/datastore_mad/remotes/fs/cp +++ b/src/datastore_mad/remotes/fs/cp @@ -52,6 +52,7 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/STAGING_DIR \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TYPE \ /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ @@ -65,6 +66,7 @@ RESTRICTED_DIRS="${XPATH_ELEMENTS[i++]}" SAFE_DIRS="${XPATH_ELEMENTS[i++]}" BRIDGE_LIST="${XPATH_ELEMENTS[i++]}" STAGING_DIR="${XPATH_ELEMENTS[i++]:-/var/tmp}" +TYPE="${XPATH_ELEMENTS[i++]}" SRC="${XPATH_ELEMENTS[i++]}" MD5="${XPATH_ELEMENTS[i++]}" SHA1="${XPATH_ELEMENTS[i++]}" @@ -76,6 +78,11 @@ IMAGE_HASH=`basename $DST` set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" +# Disable auto-decompress for the 'files' datastores (type 2) +if [ "$TYPE" = "2" ]; then + NO_DECOMPRESS="${NO_DECOMPRESS:-yes}" +fi + if [ -n "$BRIDGE_LIST" ]; then DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -` else From 0c3bee9ec36141cf1bac720894a19978373d7a0f Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 29 May 2015 18:51:02 +0200 Subject: [PATCH 20/28] Feature #3767: Add support for resource pool confinment in vCenter drivers --- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index c65ae733da..9d7366db11 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -146,7 +146,50 @@ class VIClient # The associated resource pool for this connection ######################################################################## def resource_pool - return @cluster.resourcePool + rp_name = @one_host["TEMPLATE/VCENTER_RESOURCE_POOL"] + + if rp_name.nil? + @cluster.resourcePool + else + find_resource_pool(rp_name) + end + end + + ######################################################################## + # Searches the desired ResourcePool of the DataCenter for the current + # connection. Returns a RbVmomi::VIM::ResourcePool or the default pool + # if not found + # @param rpool [String] the ResourcePool name + ######################################################################## + def find_resource_pool(poolName) + baseEntity = @cluster + entityArray = poolName.split('/') + entityArray.each do |entityArrItem| + if entityArrItem != '' + if baseEntity.is_a? RbVmomi::VIM::Folder + baseEntity = baseEntity.childEntity.find { |f| + f.name == entityArrItem + } or return @cluster.resourcePool + elsif baseEntity.is_a? RbVmomi::VIM::ClusterComputeResource + baseEntity = baseEntity.resourcePool.resourcePool.find { |f| + f.name == entityArrItem + } or return @cluster.resourcePool + elsif baseEntity.is_a? RbVmomi::VIM::ResourcePool + baseEntity = baseEntity.resourcePool.find { |f| + f.name == entityArrItem + } or return @cluster.resourcePool + else + return @cluster.resourcePool + end + end + end + + if !baseEntity.is_a?(RbVmomi::VIM::ResourcePool) and + baseEntity.respond_to?(:resourcePool) + baseEntity = baseEntity.resourcePool + end + + baseEntity end ######################################################################## @@ -1083,7 +1126,7 @@ class VCenterVm " TYPE =\"vnc\",\n"\ " LISTEN =\"0.0.0.0\",\n"\ " PORT =\"#{vp[0][:value]}\"\n" - str << " ,KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap[0] + str << " KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap str << "]\n" end From 14557d9cd2ea579beb2d83ea5d857b66c951a81c Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Sat, 30 May 2015 00:40:16 +0200 Subject: [PATCH 21/28] Fix lamely introduced bug --- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index 9d7366db11..6559f26cbf 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -1125,7 +1125,7 @@ class VCenterVm str << "GRAPHICS = [\n"\ " TYPE =\"vnc\",\n"\ " LISTEN =\"0.0.0.0\",\n"\ - " PORT =\"#{vp[0][:value]}\"\n" + " PORT =\"#{vp[0][:value]},\"\n" str << " KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap str << "]\n" end From 71d4bdd0ec790b2a4980b2f64c85cf0e411318f6 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 2 Jun 2015 11:55:14 +0200 Subject: [PATCH 22/28] Fix wrongly generated GRAPHICS section --- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index 6559f26cbf..f16fb7bf54 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -1125,8 +1125,8 @@ class VCenterVm str << "GRAPHICS = [\n"\ " TYPE =\"vnc\",\n"\ " LISTEN =\"0.0.0.0\",\n"\ - " PORT =\"#{vp[0][:value]},\"\n" - str << " KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap + " PORT =\"#{vp[0][:value]}\"\n" + str << " ,KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap str << "]\n" end From bdd231bf517bd61d0ca656ec59c011ef37fc2b13 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Wed, 3 Jun 2015 18:17:52 -0400 Subject: [PATCH 23/28] bug #3768: add tm/failmigrate call on error --- src/vmm_mad/exec/one_vmm_exec.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index 4e4ffaa7b2..3f45fb4560 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -478,9 +478,11 @@ class ExecDriver < VirtualMachineDriver action = VmmAction.new(self, id, :migrate, drv_message) pre = "PRE" post = "POST" + failed = "FAIL" pre << action.data[:tm_command] << " " << action.data[:vm] post << action.data[:tm_command] << " " << action.data[:vm] + failed << action.data[:tm_command] << " " << action.data[:vm] steps=[ # Execute a pre-migrate TM setup @@ -499,7 +501,15 @@ class ExecDriver < VirtualMachineDriver { :driver => :vmm, :action => :migrate, - :parameters => [:deploy_id, :dest_host, :host] + :parameters => [:deploy_id, :dest_host, :host], + :fail_actions => [ + { + :driver => :tm, + :action => :tm_failmigrate, + :parameters => failed.split, + :no_fail => true + } + ] }, # Execute networking clean up operations # NOTE: VM is now in the new host. If we fail from now on, oned will From 94105537f4674591a531dec9b5b1538879fa51f5 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 4 Jun 2015 18:46:33 +0200 Subject: [PATCH 24/28] Add capacity resizing and honoring capacity changes in VM templates in the VM drivers (cherry picked from commit d2f7e7bb28468451f1b73ab1eb0c30a1b692a8f9) --- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index f16fb7bf54..5c52d9b232 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -734,6 +734,19 @@ class VCenterVm hid = VIClient::translate_hostname(hostname) connection = VIClient.new(hid) vm = connection.find_vm_template(deploy_id) + + # Find out if we need to reconfigure capacity + expected_cpu, expected_memory = get_cpu_and_memory(xml_text) + current_cpu = vm.config.hardware.numCPU + current_memory = vm.config.hardware.memoryMB + + if current_cpu != expected_cpu or current_memory != expected_memory + capacity_hash = {:numCPUs => expected_cpu.to_i, + :memoryMB => expected_memory } + spec = RbVmomi::VIM.VirtualMachineConfigSpec(capacity_hash) + vm.ReconfigVM_Task(:spec => spec).wait_for_completion + end + vm.PowerOnVM_Task.wait_for_completion return vm.config.uuid end @@ -1237,13 +1250,21 @@ private } end + def self.get_cpu_and_memory(xml_text) + xml = REXML::Document.new xml_text + + cpu = xml.root.elements["//TEMPLATE/CPU"].text + memory = xml.root.elements["//TEMPLATE/MEMORY"].text + + return cpu, memory + end + ######################################################################## # Clone a vCenter VM Template and leaves it powered on ######################################################################## def self.clone_vm(xml_text) xml = REXML::Document.new xml_text - pcs = xml.root.get_elements("//USER_TEMPLATE/PUBLIC_CLOUD") raise "Cannot find VCenter element in VM template." if pcs.nil? @@ -1260,33 +1281,29 @@ private raise "Cannot find VM_TEMPLATE in VCenter element." if uuid.nil? uuid = uuid.text - vmid = xml.root.elements["/VM/ID"].text - hid = xml.root.elements["//HISTORY_RECORDS/HISTORY/HID"] raise "Cannot find host id in deployment file history." if hid.nil? context = xml.root.elements["//TEMPLATE/CONTEXT"] - connection = VIClient.new(hid) - vc_template = connection.find_vm_template(uuid) relocate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec( - :diskMoveType => :moveChildMostDiskBacking, - :pool => connection.resource_pool) + :diskMoveType => :moveChildMostDiskBacking, + :pool => connection.resource_pool) clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec( - :location => relocate_spec, - :powerOn => false, - :template => false) + :location => relocate_spec, + :powerOn => false, + :template => false) begin vm = vc_template.CloneVM_Task( - :folder => vc_template.parent, - :name => "one-#{vmid}", - :spec => clone_spec).wait_for_completion + :folder => vc_template.parent, + :name => "one-#{vmid}", + :spec => clone_spec).wait_for_completion rescue Exception => e if !e.message.start_with?('DuplicateName') @@ -1297,8 +1314,7 @@ private raise "Cannot clone VM Template" if vm.nil? - vm.Destroy_Task.wait_for_completion - + vm.Destroy_Task.wait_for_completion vm = vc_template.CloneVM_Task( :folder => vc_template.parent, :name => "one-#{vmid}", @@ -1352,6 +1368,7 @@ private end # NIC section, build the reconfig hash + nics = xml.root.get_elements("//TEMPLATE/NIC") nic_spec = {} @@ -1367,12 +1384,19 @@ private nic_spec = {:deviceChange => nic_array} end - if !context_vnc_spec.empty? or !nic_spec.empty? - spec_hash = context_vnc_spec.merge(nic_spec) - spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash) - vm.ReconfigVM_Task(:spec => spec).wait_for_completion - end + # Capacity section + cpu = xml.root.elements["//TEMPLATE/CPU"].text + memory = xml.root.elements["//TEMPLATE/MEMORY"].text + capacity_spec = {:numCPUs => cpu.to_i, + :memoryMB => memory } + + # Perform the VM reconfiguration + spec_hash = context_vnc_spec.merge(nic_spec).merge(capacity_spec) + spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash) + vm.ReconfigVM_Task(:spec => spec).wait_for_completion + + # Power on the VM vm.PowerOnVM_Task.wait_for_completion return vm_uuid From adc3e0e4e711149ff86bbfd273a74c0df520c625 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 4 Jun 2015 15:43:32 -0400 Subject: [PATCH 25/28] bug #3768: add placeholder failmigrate script --- install.sh | 9 +++++++++ src/tm_mad/ceph/failmigrate | 1 + src/tm_mad/common/failmigrate | 29 +++++++++++++++++++++++++++++ src/tm_mad/dev/failmigrate | 1 + src/tm_mad/dummy/failmigrate | 1 + src/tm_mad/fs_lvm/failmigrate | 1 + src/tm_mad/lvm/failmigrate | 1 + src/tm_mad/qcow2/failmigrate | 1 + src/tm_mad/shared/failmigrate | 1 + src/tm_mad/ssh/failmigrate | 1 + src/tm_mad/vmfs/failmigrate | 1 + 11 files changed, 47 insertions(+) create mode 120000 src/tm_mad/ceph/failmigrate create mode 100755 src/tm_mad/common/failmigrate create mode 120000 src/tm_mad/dev/failmigrate create mode 120000 src/tm_mad/dummy/failmigrate create mode 120000 src/tm_mad/fs_lvm/failmigrate create mode 120000 src/tm_mad/lvm/failmigrate create mode 120000 src/tm_mad/qcow2/failmigrate create mode 120000 src/tm_mad/shared/failmigrate create mode 120000 src/tm_mad/ssh/failmigrate create mode 120000 src/tm_mad/vmfs/failmigrate diff --git a/install.sh b/install.sh index d29e734f5f..075d381737 100755 --- a/install.sh +++ b/install.sh @@ -1018,6 +1018,7 @@ TM_SHARED_FILES="src/tm_mad/shared/clone \ src/tm_mad/shared/context \ src/tm_mad/shared/premigrate \ src/tm_mad/shared/postmigrate \ + src/tm_mad/shared/failmigrate \ src/tm_mad/shared/mvds \ src/tm_mad/shared/cpds" @@ -1028,6 +1029,7 @@ TM_FS_LVM_FILES="src/tm_mad/fs_lvm/clone \ src/tm_mad/fs_lvm/cpds \ src/tm_mad/fs_lvm/premigrate \ src/tm_mad/fs_lvm/postmigrate \ + src/tm_mad/fs_lvm/failmigrate \ src/tm_mad/fs_lvm/delete" TM_QCOW2_FILES="src/tm_mad/qcow2/clone \ @@ -1039,6 +1041,7 @@ TM_QCOW2_FILES="src/tm_mad/qcow2/clone \ src/tm_mad/qcow2/context \ src/tm_mad/qcow2/premigrate \ src/tm_mad/qcow2/postmigrate \ + src/tm_mad/qcow2/failmigrate \ src/tm_mad/qcow2/mvds \ src/tm_mad/qcow2/cpds" @@ -1051,6 +1054,7 @@ TM_SSH_FILES="src/tm_mad/ssh/clone \ src/tm_mad/ssh/context \ src/tm_mad/ssh/premigrate \ src/tm_mad/ssh/postmigrate \ + src/tm_mad/ssh/failmigrate \ src/tm_mad/ssh/mvds \ src/tm_mad/ssh/cpds" @@ -1063,6 +1067,7 @@ TM_DUMMY_FILES="src/tm_mad/dummy/clone \ src/tm_mad/dummy/context \ src/tm_mad/dummy/premigrate \ src/tm_mad/dummy/postmigrate \ + src/tm_mad/dummy/failmigrate \ src/tm_mad/dummy/mvds \ src/tm_mad/dummy/cpds" @@ -1076,6 +1081,7 @@ TM_VMFS_FILES="src/tm_mad/vmfs/clone \ src/tm_mad/vmfs/mvds \ src/tm_mad/vmfs/cpds \ src/tm_mad/vmfs/postmigrate \ + src/tm_mad/vmfs/failmigrate \ src/tm_mad/vmfs/premigrate" TM_LVM_FILES="src/tm_mad/lvm/clone \ @@ -1085,6 +1091,7 @@ TM_LVM_FILES="src/tm_mad/lvm/clone \ src/tm_mad/lvm/cpds \ src/tm_mad/lvm/premigrate \ src/tm_mad/lvm/postmigrate \ + src/tm_mad/lvm/failmigrate \ src/tm_mad/lvm/delete" TM_CEPH_FILES="src/tm_mad/ceph/clone \ @@ -1094,6 +1101,7 @@ TM_CEPH_FILES="src/tm_mad/ceph/clone \ src/tm_mad/ceph/cpds \ src/tm_mad/ceph/premigrate \ src/tm_mad/ceph/postmigrate \ + src/tm_mad/ceph/failmigrate \ src/tm_mad/ceph/delete" TM_DEV_FILES="src/tm_mad/dev/clone \ @@ -1103,6 +1111,7 @@ TM_DEV_FILES="src/tm_mad/dev/clone \ src/tm_mad/dev/cpds \ src/tm_mad/dev/premigrate \ src/tm_mad/dev/postmigrate \ + src/tm_mad/dev/failmigrate \ src/tm_mad/dev/delete" #------------------------------------------------------------------------------- diff --git a/src/tm_mad/ceph/failmigrate b/src/tm_mad/ceph/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/ceph/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/common/failmigrate b/src/tm_mad/common/failmigrate new file mode 100755 index 0000000000..49ab4a881d --- /dev/null +++ b/src/tm_mad/common/failmigrate @@ -0,0 +1,29 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # +# FAILMIGRATE SOURCE DST remote_system_dir vmid dsid template +# - SOURCE is the host where the VM is running +# - DST is the host where the VM failed to be migrated +# - remote_system_dir is the path for the VM home in the system datastore +# - vmid is the id of the VM +# - dsid is the target datastore +# - template is the template of the VM in XML and base64 encoded + +# To access the vm_template you can use the xpath.rb utility. Check the +# datastore drivers for an example. + +exit 0 diff --git a/src/tm_mad/dev/failmigrate b/src/tm_mad/dev/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/dev/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/dummy/failmigrate b/src/tm_mad/dummy/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/dummy/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/fs_lvm/failmigrate b/src/tm_mad/fs_lvm/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/fs_lvm/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/lvm/failmigrate b/src/tm_mad/lvm/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/lvm/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/qcow2/failmigrate b/src/tm_mad/qcow2/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/qcow2/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/shared/failmigrate b/src/tm_mad/shared/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/shared/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/ssh/failmigrate b/src/tm_mad/ssh/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/ssh/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/vmfs/failmigrate b/src/tm_mad/vmfs/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/vmfs/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file From ce6f465b9546dfc3ec0faaa0ea606257790e54d6 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 5 Jun 2015 11:06:11 -0400 Subject: [PATCH 26/28] Only create predefined set of filesystems --- src/mad/sh/scripts_common.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 343e869186..43317bce2f 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -320,7 +320,7 @@ function mkfs_command { OPTS="-F" ;; - "reiserfs") + "reiserfs"|"xfs") OPTS="-f -q" ;; @@ -355,7 +355,9 @@ function mkfs_command { return 0 ;; *) - OPTS="" + echo "" + echo "Filesystem '$FSTYPE' not valid." 1>&2 + return 1 ;; esac From ced1a29bfb3f3d1991ea88e658ea9462071fe4b8 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 5 Jun 2015 11:31:30 -0400 Subject: [PATCH 27/28] Copy ONE_AUTH and ONE_XMLRPC before stripping The strings that come from the environment are frozen and cannot be modified. --- src/oca/ruby/opennebula/client.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/oca/ruby/opennebula/client.rb b/src/oca/ruby/opennebula/client.rb index 3f730d0bab..a733dd5269 100644 --- a/src/oca/ruby/opennebula/client.rb +++ b/src/oca/ruby/opennebula/client.rb @@ -130,7 +130,7 @@ module OpenNebula raise "ONE_AUTH file not present" end - @one_auth.rstrip! + @one_auth = @one_auth.rstrip if endpoint @one_endpoint = endpoint @@ -143,8 +143,8 @@ module OpenNebula else @one_endpoint = "http://localhost:2633/RPC2" end - - @one_endpoint.rstrip! + + @one_endpoint= @one_endpoint.rstrip @async = !options[:sync] From 56af55f57fc566f0e6bb99c52ba8034c79e68131 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 8 Jun 2015 12:42:42 +0200 Subject: [PATCH 28/28] Small refactor to have a self-contained deploy action in vCenter --- src/vmm_mad/remotes/vcenter/vcenter_driver.rb | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index 5c52d9b232..e86d9cde30 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -736,9 +736,12 @@ class VCenterVm vm = connection.find_vm_template(deploy_id) # Find out if we need to reconfigure capacity - expected_cpu, expected_memory = get_cpu_and_memory(xml_text) - current_cpu = vm.config.hardware.numCPU - current_memory = vm.config.hardware.memoryMB + xml = REXML::Document.new xml_text + + expected_cpu = xml.root.elements["//TEMPLATE/CPU"].text + expected_memory = xml.root.elements["//TEMPLATE/MEMORY"].text + current_cpu = vm.config.hardware.numCPU + current_memory = vm.config.hardware.memoryMB if current_cpu != expected_cpu or current_memory != expected_memory capacity_hash = {:numCPUs => expected_cpu.to_i, @@ -1250,15 +1253,6 @@ private } end - def self.get_cpu_and_memory(xml_text) - xml = REXML::Document.new xml_text - - cpu = xml.root.elements["//TEMPLATE/CPU"].text - memory = xml.root.elements["//TEMPLATE/MEMORY"].text - - return cpu, memory - end - ######################################################################## # Clone a vCenter VM Template and leaves it powered on ########################################################################