From 93ffea79f997c3c41cd7e7b5087ca944e8a2cc68 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 2 Sep 2013 16:01:44 +0200 Subject: [PATCH 01/44] feature #2289: monitor all VMs in EC2 IM Get information from all EC2 instances in IM driver and provide this information to OpenNebula so a VM poll is not executed per VM. The monitoring will be much faster as VM is very expensive and the time it takes to get info about one VM is very similar to getting information about all VMs. To keep track of the OpenNebula ID in EC2 machines a new tag is added to EC2 instances (ONE_ID). This is used when monitoring VMs. VMs without this tag wont be correctly reported to OpenNebula and will be monitored with the old method (VM poll). This version is kind of a PoC. The driver should be refactored so it is similar to other drivers, that is, one script per action. The library that holds the functionality will be held in a library file in VMM driver as VMware drivers. Special care should be taken read EC2 parameters as now is needed by both VMM and IM. --- src/im_mad/ec2/one_im_ec2.rb | 13 ++++++++ src/vmm_mad/ec2/one_vmm_ec2.rb | 60 +++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/im_mad/ec2/one_im_ec2.rb b/src/im_mad/ec2/one_im_ec2.rb index cbe5b54025..d77dee0142 100755 --- a/src/im_mad/ec2/one_im_ec2.rb +++ b/src/im_mad/ec2/one_im_ec2.rb @@ -20,8 +20,10 @@ ONE_LOCATION=ENV["ONE_LOCATION"] if !ONE_LOCATION RUBY_LIB_LOCATION="/usr/lib/one/ruby" + MAD_LOCATION="/usr/lib/one/mads" else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" + MAD_LOCATION=ONE_LOCATION+"/lib/mads" end $: << RUBY_LIB_LOCATION @@ -66,9 +68,20 @@ class EC2InformationManagerDriver < OpenNebulaDriver # The monitor action, just print the capacity info and hostname def action_monitor(num, host, not_used) info = "HOSTNAME=\"#{host}\"\n#{@info}" + info << get_vm_info info64 = Base64::encode64(info).strip.delete("\n") send_message("MONITOR", RESULT[:success], num, info64) end + + def get_vm_info + exe=LocalCommand.run(MAD_LOCATION+'/one_vmm_ec2 --poll') + + if exe.code==0 + exe.stdout + else + '' + end + end end # The EC2 Information Driver main program diff --git a/src/vmm_mad/ec2/one_vmm_ec2.rb b/src/vmm_mad/ec2/one_vmm_ec2.rb index 0399177b42..24383136d2 100755 --- a/src/vmm_mad/ec2/one_vmm_ec2.rb +++ b/src/vmm_mad/ec2/one_vmm_ec2.rb @@ -212,6 +212,10 @@ class EC2Driver < VirtualMachineDriver exec_and_log_ec2(:authorize, ec2_info, 'default', id) end + LocalCommand.run( + "#{EC2_LOCATION}/bin/ec2-create-tags #{deploy_id} -t ONE_ID=#{id}", + log_method(id)) + if ec2_value(ec2_info, 'TAGS') exec_and_log_ec2(:tags, ec2_info, deploy_id, id) end @@ -254,19 +258,24 @@ class EC2Driver < VirtualMachineDriver deploy_id = msg.elements["DEPLOY_ID"].text - info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ - "#{POLL_ATTRIBUTE[:nettx]}=0 " \ - "#{POLL_ATTRIBUTE[:netrx]}=0" - - exe = exec_and_log_ec2(:describe, nil, deploy_id, id) if exe.code != 0 send_message(ACTION[:poll], RESULT[:failure], id, exe.stderr) return end - exe.stdout.match(Regexp.new("INSTANCE\\s+#{deploy_id}\\s+(.+)")) + info = EC2Driver.parse_poll(exe.stdout, deploy_id) + + send_message(ACTION[:poll], RESULT[:success], id, info) + end + + def self.parse_poll(text, deploy_id) + text.match(Regexp.new("INSTANCE\\s+#{deploy_id}\\s+(.+)")) + + info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ + "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ + "#{POLL_ATTRIBUTE[:nettx]}=0 " \ + "#{POLL_ATTRIBUTE[:netrx]}=0" if !$1 info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}" @@ -284,7 +293,7 @@ class EC2Driver < VirtualMachineDriver end end - send_message(ACTION[:poll], RESULT[:success], id, info) + info end private @@ -396,8 +405,43 @@ private end end +def monitor_all_vms + exe = LocalCommand.run( + "#{EC2_LOCATION}/bin/ec2-describe-instances", + lambda { |str| STDERR.puts str }) + + if exe.code != 0 + exit -1 + end + + puts "VM_POLL=YES" + + exe.stdout.split(/^RESERVATION\s.*?$/).each do |vm| + m=vm.match(/^INSTANCE\s+(\S+)/) + next if !m + + deploy_id = m[1] + + one_id='-1' + + vm.scan(/^TAG.*ONE_ID\s+(\d+)/) {|i| one_id = i.first } + + poll_data=EC2Driver.parse_poll(vm, deploy_id) + + puts "VM=[" + puts " ID=#{one_id}," + puts " DEPLOY_ID=#{deploy_id}," + puts " POLL=\"#{poll_data}\" ]" + end +end + # EC2Driver Main program +if ARGV[0]=='--poll' + monitor_all_vms + exit(0) +end + ec2_conf = ARGV.last if ec2_conf From b4c05bd62be54d14d6eeb9859dbde15c9d94dc71 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 3 Sep 2013 18:40:41 +0200 Subject: [PATCH 02/44] feature #2289: refactor ec2 drivers to standard form --- install.sh | 54 +-- src/im_mad/ec2/im_ec2.conf | 7 - src/im_mad/ec2/one_im_ec2.rb | 89 ----- src/im_mad/remotes/ec2.d/monitor | 63 ++++ .../{ec2/im_ec2rc => remotes/ec2.d/poll} | 15 +- .../{ec2/vmm_ec2.conf => remotes/ec2/cancel} | 38 +- src/vmm_mad/remotes/ec2/deploy | 34 ++ .../ec2/ec2_driver.rb} | 326 ++++++++---------- .../{ec2/vmm_ec2rc => remotes/ec2/ec2rc} | 26 +- .../one_im_ec2 => vmm_mad/remotes/ec2/poll} | 33 +- .../{ec2/one_vmm_ec2 => remotes/ec2/reboot} | 37 +- src/vmm_mad/remotes/ec2/restore | 32 ++ src/vmm_mad/remotes/ec2/save | 37 ++ src/vmm_mad/remotes/ec2/shutdown | 29 ++ 14 files changed, 438 insertions(+), 382 deletions(-) delete mode 100644 src/im_mad/ec2/im_ec2.conf delete mode 100755 src/im_mad/ec2/one_im_ec2.rb create mode 100755 src/im_mad/remotes/ec2.d/monitor rename src/im_mad/{ec2/im_ec2rc => remotes/ec2.d/poll} (77%) mode change 100644 => 100755 rename src/vmm_mad/{ec2/vmm_ec2.conf => remotes/ec2/cancel} (61%) mode change 100644 => 100755 create mode 100755 src/vmm_mad/remotes/ec2/deploy rename src/vmm_mad/{ec2/one_vmm_ec2.rb => remotes/ec2/ec2_driver.rb} (69%) rename src/vmm_mad/{ec2/vmm_ec2rc => remotes/ec2/ec2rc} (74%) rename src/{im_mad/ec2/one_im_ec2 => vmm_mad/remotes/ec2/poll} (57%) rename src/vmm_mad/{ec2/one_vmm_ec2 => remotes/ec2/reboot} (56%) create mode 100755 src/vmm_mad/remotes/ec2/restore create mode 100755 src/vmm_mad/remotes/ec2/save create mode 100755 src/vmm_mad/remotes/ec2/shutdown diff --git a/install.sh b/install.sh index 141abc4113..87d8467fb3 100755 --- a/install.sh +++ b/install.sh @@ -227,9 +227,7 @@ SHARE_DIRS="$SHARE_LOCATION/examples \ $SHARE_LOCATION/tgt \ $SHARE_LOCATION/websockify" -ETC_DIRS="$ETC_LOCATION/im_ec2 \ - $ETC_LOCATION/vmm_ec2 \ - $ETC_LOCATION/vmm_exec \ +ETC_DIRS="$ETC_LOCATION/vmm_exec \ $ETC_LOCATION/hm \ $ETC_LOCATION/auth \ $ETC_LOCATION/auth/certificates \ @@ -266,11 +264,13 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im/xen4.d \ $VAR_LOCATION/remotes/im/vmware.d \ $VAR_LOCATION/remotes/im/ganglia.d \ + $VAR_LOCATION/remotes/im/ec2.d \ $VAR_LOCATION/remotes/vmm \ $VAR_LOCATION/remotes/vmm/kvm \ $VAR_LOCATION/remotes/vmm/xen3 \ $VAR_LOCATION/remotes/vmm/xen4 \ $VAR_LOCATION/remotes/vmm/vmware \ + $VAR_LOCATION/remotes/vmm/ec2 \ $VAR_LOCATION/remotes/vnm \ $VAR_LOCATION/remotes/vnm/802.1Q \ $VAR_LOCATION/remotes/vnm/dummy \ @@ -451,6 +451,7 @@ INSTALL_FILES=( IM_PROBES_XEN4_FILES:$VAR_LOCATION/remotes/im/xen4.d IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.d IM_PROBES_GANGLIA_FILES:$VAR_LOCATION/remotes/im/ganglia.d + IM_PROBES_EC2_FILES:$VAR_LOCATION/remotes/im/ec2.d AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509 AUTH_LDAP_FILES:$VAR_LOCATION/remotes/auth/ldap @@ -462,6 +463,7 @@ INSTALL_FILES=( VMM_EXEC_XEN3_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen3 VMM_EXEC_XEN4_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen4 VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware + VMM_EXEC_EC2_SCRIPTS:$VAR_LOCATION/remotes/vmm/ec2 TM_FILES:$VAR_LOCATION/remotes/tm TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared TM_QCOW2_FILES:$VAR_LOCATION/remotes/tm/qcow2 @@ -656,9 +658,8 @@ INSTALL_ONEFLOW_ETC_FILES=( INSTALL_ETC_FILES=( ETC_FILES:$ETC_LOCATION VMWARE_ETC_FILES:$ETC_LOCATION - VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 + EC2_ETC_FILES:$ETC_LOCATION VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec - IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2 HM_ETC_FILES:$ETC_LOCATION/hm AUTH_ETC_FILES:$ETC_LOCATION/auth ECO_ETC_FILES:$ETC_LOCATION @@ -744,16 +745,12 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/vmm_mad/exec/one_vmm_exec \ src/vmm_mad/exec/one_vmm_sh \ src/vmm_mad/exec/one_vmm_ssh \ - src/vmm_mad/ec2/one_vmm_ec2.rb \ - src/vmm_mad/ec2/one_vmm_ec2 \ src/vmm_mad/dummy/one_vmm_dummy.rb \ src/vmm_mad/dummy/one_vmm_dummy \ src/im_mad/im_exec/one_im_exec.rb \ src/im_mad/im_exec/one_im_exec \ src/im_mad/im_exec/one_im_ssh \ src/im_mad/im_exec/one_im_sh \ - src/im_mad/ec2/one_im_ec2.rb \ - src/im_mad/ec2/one_im_ec2 \ src/im_mad/dummy/one_im_dummy.rb \ src/im_mad/dummy/one_im_dummy \ src/tm_mad/one_tm \ @@ -855,6 +852,30 @@ VMM_EXEC_VMWARE_SCRIPTS="src/vmm_mad/remotes/vmware/cancel \ src/vmm_mad/remotes/vmware/vmware_driver.rb \ src/vmm_mad/remotes/vmware/vi_driver.rb" +#------------------------------------------------------------------------------ +# VMM Driver EC2 scripts, to be installed under $REMOTES_LOCATION/vmm/ec2 +#------------------------------------------------------------------------------ + +VMM_EXEC_EC2_SCRIPTS="src/vmm_mad/remotes/ec2/cancel \ + src/vmm_mad/remotes/ec2/attach_disk \ + src/vmm_mad/remotes/ec2/detach_disk \ + src/vmm_mad/remotes/ec2/attach_nic \ + src/vmm_mad/remotes/ec2/detach_nic \ + src/vmm_mad/remotes/ec2/snapshot_create \ + src/vmm_mad/remotes/ec2/snapshot_revert \ + src/vmm_mad/remotes/ec2/snapshot_delete \ + src/vmm_mad/remotes/ec2/scripts_common_sh.sh \ + src/vmm_mad/remotes/ec2/deploy \ + src/vmm_mad/remotes/ec2/migrate \ + src/vmm_mad/remotes/ec2/restore \ + src/vmm_mad/remotes/ec2/reboot \ + src/vmm_mad/remotes/ec2/reset \ + src/vmm_mad/remotes/ec2/save \ + src/vmm_mad/remotes/ec2/poll \ + src/vmm_mad/remotes/ec2/checkpoint \ + src/vmm_mad/remotes/ec2/shutdown \ + src/vmm_mad/remotes/ec2/ec2_driver.rb" + #------------------------------------------------------------------------------- # Information Manager Probes, to be installed under $REMOTES_LOCATION/im #------------------------------------------------------------------------------- @@ -883,6 +904,9 @@ IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb" IM_PROBES_GANGLIA_FILES="src/im_mad/remotes/ganglia.d/ganglia_probe" +IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/monitor \ + src/im_mad/remotes/ec2.d/poll" + #------------------------------------------------------------------------------- # Auth Manager drivers to be installed under $REMOTES_LOCATION/auth #------------------------------------------------------------------------------- @@ -1146,15 +1170,13 @@ ETC_FILES="share/etc/oned.conf \ src/cli/etc/group.default" VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc" +EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2rc" #------------------------------------------------------------------------------- # Virtualization drivers config. files, to be installed under $ETC_LOCATION -# - ec2, $ETC_LOCATION/vmm_ec2 # - ssh, $ETC_LOCATION/vmm_exec #------------------------------------------------------------------------------- -VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \ - src/vmm_mad/ec2/vmm_ec2.conf" VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \ src/vmm_mad/exec/vmm_exec_kvm.conf \ @@ -1162,14 +1184,6 @@ VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \ src/vmm_mad/exec/vmm_exec_xen4.conf \ src/vmm_mad/exec/vmm_exec_vmware.conf" -#------------------------------------------------------------------------------- -# Information drivers config. files, to be installed under $ETC_LOCATION -# - ec2, $ETC_LOCATION/im_ec2 -#------------------------------------------------------------------------------- - -IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \ - src/im_mad/ec2/im_ec2.conf" - #------------------------------------------------------------------------------- # Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm #------------------------------------------------------------------------------- diff --git a/src/im_mad/ec2/im_ec2.conf b/src/im_mad/ec2/im_ec2.conf deleted file mode 100644 index 4feb01b512..0000000000 --- a/src/im_mad/ec2/im_ec2.conf +++ /dev/null @@ -1,7 +0,0 @@ -#------------------------------------------------------------------------------- -# Max number of instances that can be launched into EC2 -#------------------------------------------------------------------------------- - -SMALL_INSTANCES=5 -LARGE_INSTANCES= -EXTRALARGE_INSTANCES= diff --git a/src/im_mad/ec2/one_im_ec2.rb b/src/im_mad/ec2/one_im_ec2.rb deleted file mode 100755 index d77dee0142..0000000000 --- a/src/im_mad/ec2/one_im_ec2.rb +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, 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. # -#--------------------------------------------------------------------------- # - -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" - MAD_LOCATION="/usr/lib/one/mads" -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - MAD_LOCATION=ONE_LOCATION+"/lib/mads" -end - -$: << RUBY_LIB_LOCATION - -require 'pp' -require 'OpenNebulaDriver' -require 'base64' - -# The EC2 Information Manager Driver -class EC2InformationManagerDriver < OpenNebulaDriver - # Init the driver, and compute the predefined maximum capacity for this - # EC2 cloud - def initialize() - super('', - :concurrency => 1, - :threaded => false - ) - - register_action(:MONITOR, method("action_monitor")) - - sinst = ENV["SMALL_INSTANCES"].to_i - linst = ENV["LARGE_INSTANCES"].to_i - xlinst = ENV["EXTRALARGE_INSTANCES"].to_i - - smem = 1048576 * 1.7 * sinst - scpu = 100 * sinst - - lmem = 1048576 * 7.5 * linst - lcpu = 400 * linst - - xlmem = 1048576 * 15 * xlinst - xlcpu = 800 * xlinst - - totalmemory = smem + lmem + xlmem - totalcpu = scpu + lcpu + xlcpu - - @info="HYPERVISOR=ec2\nTOTALMEMORY=#{totalmemory}\n"<< - "TOTALCPU=#{totalcpu}\nCPUSPEED=1000\nFREEMEMORY=#{totalmemory}"<< - "\nFREECPU=#{totalcpu}\n" - end - - # The monitor action, just print the capacity info and hostname - def action_monitor(num, host, not_used) - info = "HOSTNAME=\"#{host}\"\n#{@info}" - info << get_vm_info - info64 = Base64::encode64(info).strip.delete("\n") - send_message("MONITOR", RESULT[:success], num, info64) - end - - def get_vm_info - exe=LocalCommand.run(MAD_LOCATION+'/one_vmm_ec2 --poll') - - if exe.code==0 - exe.stdout - else - '' - end - end -end - -# The EC2 Information Driver main program -im = EC2InformationManagerDriver.new -im.start_driver diff --git a/src/im_mad/remotes/ec2.d/monitor b/src/im_mad/remotes/ec2.d/monitor new file mode 100755 index 0000000000..c8d5506688 --- /dev/null +++ b/src/im_mad/remotes/ec2.d/monitor @@ -0,0 +1,63 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +ONE_LOCATION=ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" + MAD_LOCATION="/usr/lib/one/mads" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" + MAD_LOCATION=ONE_LOCATION+"/lib/mads" +end + +$: << RUBY_LIB_LOCATION +$: << File.join(File.dirname(__FILE__), '../../vmm/ec2') + +require 'pp' +require 'OpenNebulaDriver' +require 'ec2_driver' + +host = ARGV[2] + +def monitor(host) + sinst = ENV["SMALL_INSTANCES"].to_i + linst = ENV["LARGE_INSTANCES"].to_i + xlinst = ENV["EXTRALARGE_INSTANCES"].to_i + + smem = 1048576 * 1.7 * sinst + scpu = 100 * sinst + + lmem = 1048576 * 7.5 * linst + lcpu = 400 * linst + + xlmem = 1048576 * 15 * xlinst + xlcpu = 800 * xlinst + + totalmemory = smem + lmem + xlmem + totalcpu = scpu + lcpu + xlcpu + + info="HYPERVISOR=ec2\nTOTALMEMORY=#{totalmemory}\n"<< + "TOTALCPU=#{totalcpu}\nCPUSPEED=1000\nFREEMEMORY=#{totalmemory}"<< + "\nFREECPU=#{totalcpu}\n" + info << "HOSTNAME=\"#{host}\"\n" + + puts info +end + +monitor(host) diff --git a/src/im_mad/ec2/im_ec2rc b/src/im_mad/remotes/ec2.d/poll old mode 100644 new mode 100755 similarity index 77% rename from src/im_mad/ec2/im_ec2rc rename to src/im_mad/remotes/ec2.d/poll index 90c559ab5d..9ca90fd7a7 --- a/src/im_mad/ec2/im_ec2rc +++ b/src/im_mad/remotes/ec2.d/poll @@ -1,5 +1,7 @@ +#!/usr/bin/env ruby + # -------------------------------------------------------------------------- # -# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -12,4 +14,13 @@ # 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. # -#--------------------------------------------------------------------------- # +# -------------------------------------------------------------------------- # + +$: << File.join(File.dirname(__FILE__), '../../vmm/ec2') + +require 'ec2_driver' + +ec2_drv = EC2Driver.new + +ec2_drv.monitor_all_vms + diff --git a/src/vmm_mad/ec2/vmm_ec2.conf b/src/vmm_mad/remotes/ec2/cancel old mode 100644 new mode 100755 similarity index 61% rename from src/vmm_mad/ec2/vmm_ec2.conf rename to src/vmm_mad/remotes/ec2/cancel index e80cd87b98..d6b31bed9e --- a/src/vmm_mad/ec2/vmm_ec2.conf +++ b/src/vmm_mad/remotes/ec2/cancel @@ -1,6 +1,7 @@ - +# -------------------------------------------------------------------------- # - +$: << File.dirname(__FILE__) + +require 'ec2_driver' + +deploy_id = ARGV[0] +host = ARGV[1] + +ec2_drv = EC2Driver.new + +ec2_drv.cancel(deploy_id) - diff --git a/src/vmm_mad/remotes/ec2/deploy b/src/vmm_mad/remotes/ec2/deploy new file mode 100755 index 0000000000..1372e04315 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/deploy @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +# ---------------------------------------------------------------------------- # +# Copyright 2010-2013, C12G Labs S.L # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +$: << File.dirname(__FILE__) + +require 'ec2_driver' + +dfile = ARGV[0] +host = ARGV[1] +id = ARGV[2] + +ec2_drv = EC2Driver.new(host) + +text=File.read(dfile) + +puts ec2_drv.deploy(id, host, text) + +exit 0 + diff --git a/src/vmm_mad/ec2/one_vmm_ec2.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb similarity index 69% rename from src/vmm_mad/ec2/one_vmm_ec2.rb rename to src/vmm_mad/remotes/ec2/ec2_driver.rb index 24383136d2..6e824f7217 100755 --- a/src/vmm_mad/ec2/one_vmm_ec2.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -1,30 +1,19 @@ #!/usr/bin/env ruby -# ---------------------------------------------------------------------------- # +# -------------------------------------------------------------------------- # # Copyright 2002-2013, 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. # -# ---------------------------------------------------------------------------- # - -# Set up the environment for the driver - -EC2_LOCATION = ENV["EC2_HOME"] - -if !EC2_LOCATION - puts "EC2_HOME not set" - exit(-1) -end - -EC2_JVM_CONCURRENCY = ENV["EC2_JVM_CONCURRENCY"] +# # +# 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. # +# -------------------------------------------------------------------------- # ONE_LOCATION = ENV["ONE_LOCATION"] @@ -36,15 +25,37 @@ else ETC_LOCATION = ONE_LOCATION + "/etc/" end +# Load EC2 credentials and environment +require 'yaml' + +ec2_env = "#{ETC_LOCATION}/ec2rc" +if File.exist?(ec2_env) + env = YAML::load(File.read(ec2_env)) + env.each do |key, value| + ENV[key] = value.to_s + end +end + +# Set up the environment for the driver +EC2_LOCATION = ENV["EC2_HOME"] + +if !EC2_LOCATION + STDERR.puts "EC2_HOME not set" + exit(-1) +end + $: << RUBY_LIB_LOCATION -require "VirtualMachineDriver" -require "CommandManager" +require 'CommandManager' require 'scripts_common' -require "rexml/document" +require 'rexml/document' +require 'VirtualMachineDriver' # The main class for the EC2 driver -class EC2Driver < VirtualMachineDriver +class EC2Driver + ACTION = VirtualMachineDriver::ACTION + POLL_ATTRIBUTE = VirtualMachineDriver::POLL_ATTRIBUTE + VM_STATE = VirtualMachineDriver::VM_STATE # EC2 commands constants EC2 = { @@ -151,16 +162,12 @@ class EC2Driver < VirtualMachineDriver # EC2 constructor, loads defaults for the EC2Driver def initialize(ec2_conf = nil) - if !EC2_JVM_CONCURRENCY - concurrency = 5 - else - concurrency = EC2_JVM_CONCURRENCY.to_i - end - - super('', :concurrency => concurrency, :threaded => true) - @defaults = Hash.new + if !ec2_conf && ENV['EC2_CONF'] + ec2_conf = ENV['EC2_CONF'] + end + if ec2_conf && File.exists?(ec2_conf) fd = File.new(ec2_conf) xml = REXML::Document.new fd @@ -183,93 +190,153 @@ class EC2Driver < VirtualMachineDriver end # DEPLOY action, also sets ports and ip if needed - def deploy(id, drv_message) - ec2_info = get_deployment_info(drv_message) + def deploy(id, host, xml_text) + ec2_info = get_deployment_info(host, xml_text) return unless ec2_info if !ec2_value(ec2_info, 'AMI') msg = "Cannot find AMI in deployment file" - send_message(ACTION[:deploy], RESULT[:failure], id, msg) - return + STDERR.puts(msg) + exit(-1) end - deploy_exe = exec_and_log_ec2(:run, ec2_info, "", id) + deploy_exe = exec_and_log_ec2(:run, ec2_info, "") if deploy_exe.code != 0 msg = deploy_exe.stderr - send_message(ACTION[:deploy], RESULT[:failure], id, msg) - return + STDERR.puts(msg) + exit(-1) end if !deploy_exe.stdout.match(/^INSTANCE\s*(.+?)\s/) msg = "Could not find instance id. Check ec2-describe-instances" - send_message(ACTION[:deploy], RESULT[:failure], id, msg) - return + STDERR.puts(msg) + exit(-1) end deploy_id = $1 if ec2_value(ec2_info, 'AUTHORIZEDPORTS') - exec_and_log_ec2(:authorize, ec2_info, 'default', id) + exec_and_log_ec2(:authorize, ec2_info, 'default') end LocalCommand.run( "#{EC2_LOCATION}/bin/ec2-create-tags #{deploy_id} -t ONE_ID=#{id}", - log_method(id)) + lambda {|str| STDERR.puts(str) }) if ec2_value(ec2_info, 'TAGS') - exec_and_log_ec2(:tags, ec2_info, deploy_id, id) + exec_and_log_ec2(:tags, ec2_info, deploy_id) end if ec2_value(ec2_info, 'ELASTICIP') - exec_and_log_ec2(:associate, ec2_info, "-i #{deploy_id}", id) + exec_and_log_ec2(:associate, ec2_info, "-i #{deploy_id}") end - send_message(ACTION[:deploy], RESULT[:success], id, deploy_id) + puts(deploy_id) end # Shutdown a EC2 instance - def shutdown(id, drv_message) - ec2_action(drv_message, :terminate, ACTION[:shutdown], id) + def shutdown(deploy_id) + ec2_action(deploy_id, :terminate, ACTION[:shutdown]) end # Reboot a EC2 instance - def reboot(id, drv_message) - ec2_action(drv_message, :reboot, ACTION[:reboot], id) + def reboot(deploy_id) + ec2_action(deploy_id, :reboot, ACTION[:reboot]) end # Cancel a EC2 instance - def cancel(id, drv_message) - ec2_action(drv_message, :terminate, ACTION[:cancel], id) + def cancel(deploy_id) + ec2_action(deploy_id, :terminate, ACTION[:cancel]) end # Stop a EC2 instance - def save(id, drv_message) - ec2_action(drv_message, :stop, ACTION[:save], id) + def save(deploy_id) + ec2_action(deploy_id, :stop, ACTION[:save]) end # Cancel a EC2 instance - def restore(id, drv_message) - ec2_action(drv_message, :start, ACTION[:restor], id) + def restore(deploy_id) + ec2_action(deploy_id, :start, ACTION[:restore]) end # Get info (IP, and state) for a EC2 instance - def poll(id, drv_message) - msg = decode(drv_message) - - deploy_id = msg.elements["DEPLOY_ID"].text - - exe = exec_and_log_ec2(:describe, nil, deploy_id, id) + def poll(id, deploy_id) + exe = exec_and_log_ec2(:describe, nil, deploy_id) if exe.code != 0 - send_message(ACTION[:poll], RESULT[:failure], id, exe.stderr) - return + STDERR.puts(exe.stderr) + exit(-1) end - info = EC2Driver.parse_poll(exe.stdout, deploy_id) - - send_message(ACTION[:poll], RESULT[:success], id, info) + info = parse_poll(exe.stdout, deploy_id) + puts info end - def self.parse_poll(text, deploy_id) + def monitor_all_vms + exe = LocalCommand.run( + "#{EC2_LOCATION}/bin/ec2-describe-instances", + lambda { |str| STDERR.puts str }) + + if exe.code != 0 + exit(-1) + end + + puts "VM_POLL=YES" + + exe.stdout.split(/^RESERVATION\s.*?$/).each do |vm| + m=vm.match(/^INSTANCE\s+(\S+)/) + next if !m + + deploy_id = m[1] + + one_id='-1' + + vm.scan(/^TAG.*ONE_ID\s+(\d+)/) {|i| one_id = i.first } + + poll_data=parse_poll(vm, deploy_id) + + puts "VM=[" + puts " ID=#{one_id}," + puts " DEPLOY_ID=#{deploy_id}," + puts " POLL=\"#{poll_data}\" ]" + end + end + +private + + def get_deployment_info(host, xml_text) + xml = REXML::Document.new xml_text + + ec2 = nil + + all_ec2_elements = xml.root.get_elements("//USER_TEMPLATE/EC2") + + # First, let's see if we have an EC2 site that matches + # our desired host name + all_ec2_elements.each { |element| + cloud=element.elements["CLOUD"] + if cloud and cloud.text.upcase == host.upcase + ec2 = element + end + } + + if !ec2 + # If we don't find the EC2 site, and ONE just + # knows about one EC2 site, let's use that + if all_ec2_elements.size == 1 + ec2 = all_ec2_elements[0] + else + STDERR.puts( + "Cannot find EC2 element in deployment file "<< + "#{local_dfile} or couldn't find any EC2 site matching "<< + "one of the template.") + exit(-1) + end + end + + ec2 + end + + def parse_poll(text, deploy_id) text.match(Regexp.new("INSTANCE\\s+#{deploy_id}\\s+(.+)")) info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ @@ -296,69 +363,15 @@ class EC2Driver < VirtualMachineDriver info end -private - - def get_deployment_info(drv_message) - msg = decode(drv_message) - - host = msg.elements["HOST"].text - local_dfile = msg.elements["LOCAL_DEPLOYMENT_FILE"].text - - if !local_dfile - send_message(ACTION[:deploy],RESULT[:failure],id, - "Cannot open deployment file #{local_dfile}") - return - end - - tmp = File.new(local_dfile) - xml = REXML::Document.new tmp - tmp.close() - - ec2 = nil - - all_ec2_elements = xml.root.get_elements("USER_TEMPLATE/EC2") - - # First, let's see if we have an EC2 site that matches - # our desired host name - all_ec2_elements.each { |element| - cloud=element.elements["CLOUD"] - if cloud and cloud.text.upcase == host.upcase - ec2 = element - end - } - - if !ec2 - # If we don't find the EC2 site, and ONE just - # knows about one EC2 site, let's use that - if all_ec2_elements.size == 1 - ec2 = all_ec2_elements[0] - else - send_message(ACTION[:deploy],RESULT[:failure],id, - "Cannot find EC2 element in deployment file "<< - "#{local_dfile} or couldn't find any EC2 site matching "<< - "one of the template.") - return - end - end - - ec2 - end - # Execute an EC2 command and send the SUCCESS or FAILURE signal - # +drv_message+: String, base64 encoded info sent by ONE + # +deploy_id+: String, VM id in EC2 # +ec2_action+: Symbol, one of the keys of the EC2 hash constant (i.e :run) # +one_action+: String, OpenNebula action - # +id+: String, action id - def ec2_action(drv_message, ec2_action, one_action, id) - msg = decode(drv_message) - - deploy_id = msg.elements["DEPLOY_ID"].text - - exe = exec_and_log_ec2(ec2_action, nil, deploy_id, id) + def ec2_action(deploy_id, ec2_action, one_action) + exe = exec_and_log_ec2(ec2_action, nil, deploy_id) if exe.code != 0 - send_message(one_action, RESULT[:failure], id, exe.stderr) - else - send_message(one_action, RESULT[:success], id) + STDERR.puts(exe.stderr) + exit(-1) end end @@ -369,7 +382,7 @@ private # +action+: Symbol, one of the keys of the EC2 hash constant (i.e :run) # +xml+: REXML Document, containing EC2 information # +extra_params+: String, extra information to be added to the command - def exec_and_log_ec2(action, xml, extra_params, id) + def exec_and_log_ec2(action, xml, extra_params) cmd = EC2[action][:cmd].clone cmd << ' ' << extra_params << ' ' if extra_params @@ -380,7 +393,7 @@ private }.join(' ') end - LocalCommand.run(cmd, log_method(id)) + LocalCommand.run(cmd, lambda {|str| STDERR.puts(str) }) end # Returns the value of the xml specified by the name or the default @@ -405,48 +418,3 @@ private end end -def monitor_all_vms - exe = LocalCommand.run( - "#{EC2_LOCATION}/bin/ec2-describe-instances", - lambda { |str| STDERR.puts str }) - - if exe.code != 0 - exit -1 - end - - puts "VM_POLL=YES" - - exe.stdout.split(/^RESERVATION\s.*?$/).each do |vm| - m=vm.match(/^INSTANCE\s+(\S+)/) - next if !m - - deploy_id = m[1] - - one_id='-1' - - vm.scan(/^TAG.*ONE_ID\s+(\d+)/) {|i| one_id = i.first } - - poll_data=EC2Driver.parse_poll(vm, deploy_id) - - puts "VM=[" - puts " ID=#{one_id}," - puts " DEPLOY_ID=#{deploy_id}," - puts " POLL=\"#{poll_data}\" ]" - end -end - -# EC2Driver Main program - -if ARGV[0]=='--poll' - monitor_all_vms - exit(0) -end - -ec2_conf = ARGV.last - -if ec2_conf - ec2_conf = ETC_LOCATION + ec2_conf if ec2_conf[0] != ?/ -end - -ec2_driver = EC2Driver.new(ec2_conf) -ec2_driver.start_driver diff --git a/src/vmm_mad/ec2/vmm_ec2rc b/src/vmm_mad/remotes/ec2/ec2rc similarity index 74% rename from src/vmm_mad/ec2/vmm_ec2rc rename to src/vmm_mad/remotes/ec2/ec2rc index 69435d5ff1..0d1e5841db 100644 --- a/src/vmm_mad/ec2/vmm_ec2rc +++ b/src/vmm_mad/remotes/ec2/ec2rc @@ -14,22 +14,28 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -#May be needed in some setups -#CLASSPATH="" +# May be needed in some setups +#CLASSPATH: "" +#JAVA_HOME: "" #---------------------------------------------------------------------------- # EC2 API TOOLS Configuration. #---------------------------------------------------------------------------- -#EC2_HOME="" -#EC2_PRIVATE_KEY="" -#EC2_CERT="" +#EC2_HOME: "" +#EC2_PRIVATE_KEY: "" +#EC2_CERT: "" -# #---------------------------------------------------------------------------- -# Driver configuration +# Driver configuration #---------------------------------------------------------------------------- # Arguments for the JAVA Virtual Machine -EC2_JVM_ARGS="-Xms16m -Xmx64m" +EC2_JVM_ARGS: "-Xms16m -Xmx64m" + +#---------------------------------------------------------------------------- +# Max number of instances that can be launched into EC2 +#---------------------------------------------------------------------------- + +SMALL_INSTANCES: 5 +LARGE_INSTANCES: 0 +EXTRALARGE_INSTANCES: 0 -# Number of concurrent EC2 operations (not instances) -EC2_JVM_CONCURRENCY=10 diff --git a/src/im_mad/ec2/one_im_ec2 b/src/vmm_mad/remotes/ec2/poll similarity index 57% rename from src/im_mad/ec2/one_im_ec2 rename to src/vmm_mad/remotes/ec2/poll index 7f8b1345f9..20fb27c4d7 100755 --- a/src/im_mad/ec2/one_im_ec2 +++ b/src/vmm_mad/remotes/ec2/poll @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -14,30 +14,17 @@ # 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. # -#--------------------------------------------------------------------------- # +# -------------------------------------------------------------------------- # -if [ -z "${ONE_LOCATION}" ]; then - EC2RC=/etc/one/im_ec2/im_ec2rc - EC2CONF=/etc/one/im_ec2/im_ec2.conf - MADCOMMON=/usr/lib/one/mads/madcommon.sh - VAR_LOCATION=/var/lib/one -else - EC2RC=$ONE_LOCATION/etc/im_ec2/im_ec2rc - EC2CONF=$ONE_LOCATION/etc/im_ec2/im_ec2.conf - MADCOMMON=$ONE_LOCATION/lib/mads/madcommon.sh - VAR_LOCATION=$ONE_LOCATION/var -fi +$: << File.dirname(__FILE__) -. $MADCOMMON +require 'ec2_driver' -# Export the vmm_mad specific rc -export_rc_vars $EC2RC +deploy_id = ARGV[0] +host = ARGV[1] +id = ARGV[2] -# Export max instance type usages -export_rc_vars $EC2CONF +ec2_drv = EC2Driver.new -# Go to var directory ONE_LOCATION/var or /var/lib/one -cd $VAR_LOCATION +ec2_drv.poll(id, deploy_id) -# Execute the actual MAD -execute_mad $* diff --git a/src/vmm_mad/ec2/one_vmm_ec2 b/src/vmm_mad/remotes/ec2/reboot similarity index 56% rename from src/vmm_mad/ec2/one_vmm_ec2 rename to src/vmm_mad/remotes/ec2/reboot index ae1c9896ab..9fdc51f450 100755 --- a/src/vmm_mad/ec2/one_vmm_ec2 +++ b/src/vmm_mad/remotes/ec2/reboot @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # +# Copyright 2010-2013, C12G Labs S.L # # # # 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 # @@ -14,35 +14,16 @@ # 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. # -#--------------------------------------------------------------------------- # +# -------------------------------------------------------------------------- # -if [ -z "${ONE_LOCATION}" ]; then - DRIVERRC=/etc/one/vmm_ec2/vmm_ec2rc - MADCOMMON=/usr/lib/one/mads/madcommon.sh - VAR_LOCATION=/var/lib/one -else - DRIVERRC=$ONE_LOCATION/etc/vmm_ec2/vmm_ec2rc - MADCOMMON=$ONE_LOCATION/lib/mads/madcommon.sh - VAR_LOCATION=$ONE_LOCATION/var -fi +$: << File.dirname(__FILE__) -. $MADCOMMON +require 'ec2_driver' -# Export the vmm_mad specific rc -export_rc_vars $DRIVERRC +deploy_id = ARGV[0] +host = ARGV[1] -# Go to ONE_LOCATION -cd $VAR_LOCATION +ec2_drv = EC2Driver.new -while getopts u:h:k:c: option $@ -do - case $option in - u) export EC2_URL="$OPTARG";; - h) export EC2_HOME="$OPTARG";; - k) export EC2_PRIVATE_KEY="$OPTARG";; - c) export EC2_CERT="$OPTARG";; - esac -done +ec2_drv.reboot(deploy_id) -# Execute the actual MAD -execute_mad $* diff --git a/src/vmm_mad/remotes/ec2/restore b/src/vmm_mad/remotes/ec2/restore new file mode 100755 index 0000000000..39530e23b7 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/restore @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2010-2013, C12G Labs S.L # +# # +# 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. # +# -------------------------------------------------------------------------- # + +$: << File.dirname(__FILE__) + +require 'ec2_driver' + +checkpoint_file = ARGV[0] +host = ARGV[1] + +deploy_id=File.read(checkpoint_file).strip + +ec2_drv = EC2Driver.new + +ec2_drv.restore(deploy_id) + +#File.rm(checkpoint_file) diff --git a/src/vmm_mad/remotes/ec2/save b/src/vmm_mad/remotes/ec2/save new file mode 100755 index 0000000000..e9d5144eb8 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/save @@ -0,0 +1,37 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2010-2013, C12G Labs S.L # +# # +# 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. # +# -------------------------------------------------------------------------- # + +$: << File.dirname(__FILE__) + +require 'ec2_driver' + +deploy_id = ARGV[0] +file = ARGV[1] +host = ARGV[2] + +ec2_drv = EC2Driver.new + +dir=File.dirname(file) +Dir.mkdir(dir) if !Dir.exist?(dir) + +f=open(file, "w") +f.write(deploy_id) +f.close + +ec2_drv.save(deploy_id) + diff --git a/src/vmm_mad/remotes/ec2/shutdown b/src/vmm_mad/remotes/ec2/shutdown new file mode 100755 index 0000000000..161d0f657b --- /dev/null +++ b/src/vmm_mad/remotes/ec2/shutdown @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2010-2013, C12G Labs S.L # +# # +# 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. # +# -------------------------------------------------------------------------- # + +$: << File.dirname(__FILE__) + +require 'ec2_driver' + +deploy_id = ARGV[0] +host = ARGV[1] + +ec2_drv = EC2Driver.new + +ec2_drv.shutdown(deploy_id) + From 6b16ffabbf81d6f0ad425eb8c48dbec19dc5038e Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 3 Sep 2013 18:52:33 +0200 Subject: [PATCH 03/44] feature #2289: change oned.conf to use the new ec2 drivers --- share/etc/oned.conf | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index dd85ebad8a..6ee5f80643 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -218,8 +218,8 @@ IM_MAD = [ #------------------------------------------------------------------------------- #IM_MAD = [ # name = "ec2", -# executable = "one_im_ec2", -# arguments = "im_ec2/im_ec2.conf" ] +# executable = "one_im_sh", +# arguments = "-c -t 1 -r 0 ec2" ] #------------------------------------------------------------------------------- #----------------------------------------------------------------------------- @@ -321,14 +321,13 @@ VM_MAD = [ #------------------------------------------------------------------------------- # 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 /). +# -r number of retries when monitoring a host +# -t number of threads, i.e. number of actions performed at the same time #------------------------------------------------------------------------------- #VM_MAD = [ # name = "ec2", -# executable = "one_vmm_ec2", -# arguments = "vmm_ec2/vmm_ec2.conf", +# executable = "one_vmm_sh", +# arguments = "-t 15 -r 0 ec2", # type = "xml" ] #------------------------------------------------------------------------------- From df9862ad302b169e7c587782ab5a7a300e0894d7 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 5 Sep 2013 12:27:15 +0200 Subject: [PATCH 04/44] feature #2289: add default parameters to ec2 drivers --- install.sh | 4 +++- src/vmm_mad/remotes/ec2/deploy | 2 +- src/vmm_mad/remotes/ec2/ec2.conf | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/vmm_mad/remotes/ec2/ec2.conf diff --git a/install.sh b/install.sh index 87d8467fb3..4debea1e61 100755 --- a/install.sh +++ b/install.sh @@ -1170,7 +1170,9 @@ ETC_FILES="share/etc/oned.conf \ src/cli/etc/group.default" VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc" -EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2rc" + +EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2rc \ + src/vmm_mad/remotes/ec2/ec2.conf" #------------------------------------------------------------------------------- # Virtualization drivers config. files, to be installed under $ETC_LOCATION diff --git a/src/vmm_mad/remotes/ec2/deploy b/src/vmm_mad/remotes/ec2/deploy index 1372e04315..ce0d2e94cd 100755 --- a/src/vmm_mad/remotes/ec2/deploy +++ b/src/vmm_mad/remotes/ec2/deploy @@ -24,7 +24,7 @@ dfile = ARGV[0] host = ARGV[1] id = ARGV[2] -ec2_drv = EC2Driver.new(host) +ec2_drv = EC2Driver.new(ETC_LOCATION+'/ec2.conf') text=File.read(dfile) diff --git a/src/vmm_mad/remotes/ec2/ec2.conf b/src/vmm_mad/remotes/ec2/ec2.conf new file mode 100644 index 0000000000..a8272d6237 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/ec2.conf @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + + + From 577a721873beaf24f3d4c1f93e1bc709af17cef1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sun, 29 Sep 2013 23:08:08 +0200 Subject: [PATCH 05/44] im-collectd: Collect driver that listens UDP async connections from hosts. Collectd, collects the hosts monitoring data and periodically flushes to OpenNebula core. Needs configuration, error checking and logs --- SConstruct | 3 +- install.sh | 1 + src/im_mad/collectd/ListenerThread.cc | 137 ++++++++++++++++++ src/im_mad/collectd/ListenerThread.h | 133 +++++++++++++++++ src/im_mad/collectd/OpenNebulaDriver.cc | 184 ++++++++++++++++++++++++ src/im_mad/collectd/OpenNebulaDriver.h | 108 ++++++++++++++ src/im_mad/collectd/SConstruct | 42 ++++++ src/im_mad/collectd/collectd.cc | 25 ++++ 8 files changed, 632 insertions(+), 1 deletion(-) create mode 100644 src/im_mad/collectd/ListenerThread.cc create mode 100644 src/im_mad/collectd/ListenerThread.h create mode 100644 src/im_mad/collectd/OpenNebulaDriver.cc create mode 100644 src/im_mad/collectd/OpenNebulaDriver.h create mode 100644 src/im_mad/collectd/SConstruct create mode 100644 src/im_mad/collectd/collectd.cc diff --git a/SConstruct b/SConstruct index 4180d1ae10..5d92c9106b 100644 --- a/SConstruct +++ b/SConstruct @@ -246,7 +246,8 @@ build_scripts=[ 'share/man/SConstruct', 'src/sunstone/locale/languages/SConstruct', 'share/scripts/context-packages/SConstruct', - 'share/rubygems/SConstruct' + 'share/rubygems/SConstruct', + 'src/im_mad/collectd/SConstruct' ] # Testing diff --git a/install.sh b/install.sh index 31878aee22..05303abb67 100755 --- a/install.sh +++ b/install.sh @@ -755,6 +755,7 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/im_mad/ec2/one_im_ec2 \ src/im_mad/dummy/one_im_dummy.rb \ src/im_mad/dummy/one_im_dummy \ + src/im_mad/collectd/collectd \ src/tm_mad/one_tm \ src/tm_mad/one_tm.rb \ src/hm_mad/one_hm.rb \ diff --git a/src/im_mad/collectd/ListenerThread.cc b/src/im_mad/collectd/ListenerThread.cc new file mode 100644 index 0000000000..c5bb30ef31 --- /dev/null +++ b/src/im_mad/collectd/ListenerThread.cc @@ -0,0 +1,137 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, 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. */ +/* -------------------------------------------------------------------------- */ + +#include "ListenerThread.h" + +#include +#include + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +const size_t ListenerThread::MESSAGE_SIZE = 100000; +const size_t ListenerThread::BUFFER_SIZE = 100; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void ListenerThread::flush_buffer(int fd) +{ + lock(); + + std::vector::iterator it; + + for(it = monitor_data.begin() ; it != monitor_data.end(); ++it) + { + size_t size = (*it).size(); + const char * message = (*it).c_str(); + + write(fd, message, size); + } + + monitor_data.clear(); + + unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void ListenerThread::monitor_loop() +{ + char buffer[MESSAGE_SIZE]; + size_t rc; + + struct sockaddr addr; + socklen_t addr_size = sizeof(struct sockaddr); + + while(true) + { + rc = recvfrom(socket, buffer, MESSAGE_SIZE, 0, &addr, &addr_size); + + if (rc > 0 && rc < MESSAGE_SIZE) + { + std::string message(buffer, rc); + + lock(); + + monitor_data.push_back(message); + + unlock(); + } + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +extern "C" void * listener_main(void *arg) +{ + ListenerThread * listener = static_cast(arg); + + listener->monitor_loop(); + + return 0; +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +ListenerPool::~ListenerPool() +{ + std::vector::iterator it; + + for(it = listeners.begin() ; it != listeners.end(); ++it) + { + pthread_cancel((*it).thread_id()); + } +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void ListenerPool::start_pool() +{ + pthread_attr_t attr; + pthread_t id; + + std::vector::iterator it; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + for(it = listeners.begin() ; it != listeners.end(); ++it) + { + pthread_create(&id, &attr, listener_main, (void *)&(*it)); + + (*it).thread_id(id); + } + + pthread_attr_destroy(&attr); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void ListenerPool::flush_pool() +{ + std::vector::iterator it; + + for(it = listeners.begin() ; it != listeners.end(); ++it) + { + (*it).flush_buffer(out_fd); + } +} diff --git a/src/im_mad/collectd/ListenerThread.h b/src/im_mad/collectd/ListenerThread.h new file mode 100644 index 0000000000..f3abdedf95 --- /dev/null +++ b/src/im_mad/collectd/ListenerThread.h @@ -0,0 +1,133 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, 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. */ +/* -------------------------------------------------------------------------- */ + +#include +#include + +#include + +/** + * This class implements a listener thread for the IM collector. It receives + * messages from a UDP port and stores it in a BUFFER. The class is controlled + * by two parameters + * - BUFFER_SIZE the number of pre-allocated capacity to store monitor + * messages. It should be roughly equal to the number of hosts per thread + * - MESSAGE_SIZE the size of each monitor message (100K by default). Each VM + * needs ~100bytes so ~1000VMs per host + */ +class ListenerThread +{ +public: + /** + * @param _socket descriptor to listen for messages + */ + ListenerThread(int _socket):socket(_socket) + { + pthread_mutex_init(&mutex,0); + + monitor_data.reserve(BUFFER_SIZE); + }; + + ~ListenerThread() + { + pthread_mutex_destroy(&mutex); + }; + + /** + * Write the contents of the message buffer to a descriptor. Buffer is + * cleared + * @param fd file descriptor to send monitor data. + */ + void flush_buffer(int fd); + + /** + * Waits for UDP messages in a loop and store them in a buffer + */ + void monitor_loop(); + + /** + * Set the thread ID for the listener + */ + void thread_id(pthread_t id) + { + _thread_id = id; + } + + /** + * Get the thread ID of the listener + */ + pthread_t thread_id() + { + return _thread_id; + } + +private: + static const size_t MESSAGE_SIZE; /**< Monitor message size */ + static const size_t BUFFER_SIZE; /**< Pre-allocated capacoty */ + + pthread_mutex_t mutex; + pthread_t _thread_id; + + std::vector monitor_data; + + int socket; + + void lock() + { + pthread_mutex_lock(&mutex); + } + + void unlock() + { + pthread_mutex_unlock(&mutex); + } +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +/** + * Main function for each listener, starts the monitor loop + */ +extern "C" void * listener_main(void *arg); + +/** + * Represents a pool of listener threads, it should be periodically flushed to + * a file descriptor + */ +class ListenerPool +{ +public: + /** + * @param fd descriptor to flush the data + * @param sock socket for the UDP connections + * @param num number of threads in the pool + */ + ListenerPool(int fd, int sock, size_t num) + :listeners(num, ListenerThread(sock)), out_fd(fd), socket(sock){}; + + ~ListenerPool(); + + void start_pool(); + + void flush_pool(); + +private: + std::vector listeners; + + int out_fd; + int socket; +}; diff --git a/src/im_mad/collectd/OpenNebulaDriver.cc b/src/im_mad/collectd/OpenNebulaDriver.cc new file mode 100644 index 0000000000..d629c73a7f --- /dev/null +++ b/src/im_mad/collectd/OpenNebulaDriver.cc @@ -0,0 +1,184 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, 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. */ +/* -------------------------------------------------------------------------- */ + +#include + +#include +#include +#include +#include +#include + +#include "OpenNebulaDriver.h" +#include "ListenerThread.h" + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int OpenNebulaDriver::read_one(std::string& message) +{ + fd_set in_pipes; + std::ostringstream oss; + + char c; + int rc; + + FD_ZERO(&in_pipes); + FD_SET (0,&in_pipes); + + rc = select(1, &in_pipes, NULL, NULL, NULL); + + if (rc == -1) + { + return -1; + } + + do + { + rc = read(0, (void *) &c, sizeof(char)); + oss << c; + } + while ( rc > 0 && c != '\n' ); + + if (rc < 0) + { + return -1; + } + + message = oss.str(); + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void OpenNebulaDriver::driver_loop() +{ + while (true) + { + std::string message; + + if (read_one(message) == 0) + { + std::istringstream is(message); + std::string action; + + if ( is.good() ) + { + is >> action >> std::ws; + } + else + { + continue; + } + + if (action == "INIT") + { + write2one("INIT SUCCESS\n",13); + } + else if (action == "FINALIZE") + { + break; + } + else + { + driver_action(action, is); + } + } + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int IMCollectorDriver::init_collector() +{ + struct sockaddr_in im_server; + int rc; + + int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + + if ( sock < 0 ) + { + return -1; + } + + im_server.sin_family = AF_INET; + im_server.sin_port = htons(_port); + + if ( inet_pton(AF_INET, _address.c_str(), &im_server.sin_addr.s_addr) < 0 ) + { + return -1; + } + + rc = bind(sock, (struct sockaddr *) &im_server, sizeof(struct sockaddr_in)); + + if ( rc < 0 ) + { + return -1; + } + + pool = new ListenerPool(1, sock, _threads); + + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void IMCollectorDriver::start_collector() +{ + pthread_attr_t attr; + pthread_t id; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + pthread_create(&id, &attr, flush_thread, (void *)this); + + pool->start_pool(); + + start(); + + pthread_attr_destroy(&attr); + + pthread_cancel(id); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +extern "C" void * flush_thread(void *arg) +{ + IMCollectorDriver * collectd = static_cast(arg); + + collectd->flush_loop(); + + return 0; +} + +/* -------------------------------------------------------------------------- */ + +void IMCollectorDriver::flush_loop() +{ + while(true) + { + sleep(_flush_period); + + pool->flush_pool(); + } +}; diff --git a/src/im_mad/collectd/OpenNebulaDriver.h b/src/im_mad/collectd/OpenNebulaDriver.h new file mode 100644 index 0000000000..e512150451 --- /dev/null +++ b/src/im_mad/collectd/OpenNebulaDriver.h @@ -0,0 +1,108 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, 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. */ +/* -------------------------------------------------------------------------- */ + +#ifndef _OPENNEBULA_DRIVER_H +#define _OPENNEBULA_DRIVER_H + +#include +#include + +class OpenNebulaDriver +{ +public: + + OpenNebulaDriver(){}; + + virtual ~OpenNebulaDriver(){}; + + void start() + { + driver_loop(); + }; + +protected: + + void write2one(const char * buf, size_t bsize) const + { + write(1, buf, bsize); + }; + + + void write2one(const std::string& buf) const + { + write2one(buf.c_str(), buf.size()); + } + +private: + + /** + * Main driver loop. reads actions from OpenNebula core and deals with them + */ + void driver_loop(); + + /** + * Read OpenNebula message + * @param message from OpenNebula + * @retuen 0 on success + */ + int read_one(std::string& message); + + /** + * Generic Driver Action + */ + virtual void driver_action(const std::string& action, + std::istringstream &is) = 0; +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +extern "C" void * flush_thread(void *arg); + +class ListenerPool; + +class IMCollectorDriver: public OpenNebulaDriver +{ +public: + + IMCollectorDriver(std::string address, int port, int threads, + int flush_period) + :OpenNebulaDriver(),_address(address),_port(port),_threads(threads), + _flush_period(flush_period){}; + + virtual ~IMCollectorDriver(){}; + + int init_collector(); + + void flush_loop(); + + void start_collector(); + +private: + void driver_action(const std::string& action, std::istringstream &is){}; + + std::string _address; + + int _port; + + int _threads; + + int _flush_period; + + ListenerPool *pool; +}; + +#endif diff --git a/src/im_mad/collectd/SConstruct b/src/im_mad/collectd/SConstruct new file mode 100644 index 0000000000..fda4483f0a --- /dev/null +++ b/src/im_mad/collectd/SConstruct @@ -0,0 +1,42 @@ +# ---------------------------------------------------------------------------- # +# Copyright 2010-2013, C12G Labs S.L # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +import os +Import('env') + +cwd=os.getcwd() + +env.Append(LIBPATH=[ + cwd +]) + +lib_name='im_collectd' + +source_files=[ + 'OpenNebulaDriver.cc', + 'ListenerThread.cc' + ] + +# Build library +env.StaticLibrary(lib_name, source_files) + +# Build daemon +env.Prepend(LIBS=[ + 'im_collectd', + 'util' +]) + +env.Program('collectd.cc') diff --git a/src/im_mad/collectd/collectd.cc b/src/im_mad/collectd/collectd.cc new file mode 100644 index 0000000000..2c939f2bbb --- /dev/null +++ b/src/im_mad/collectd/collectd.cc @@ -0,0 +1,25 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2013, 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. */ +/* -------------------------------------------------------------------------- */ + +#include "OpenNebulaDriver.h" + +int main() +{ + IMCollectorDriver collectd("127.0.0.1", 9876, 1, 1); + + collectd.init_collector(); + collectd.start_collector(); +} From 3b269146bc6396e673410d77abd6db23a0bc3bba Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 4 Oct 2013 19:05:55 +0200 Subject: [PATCH 06/44] feature #2092: Added hybrid mode, not triggering PROLOG Still need to figure out EPILOG --- include/Host.h | 15 +++++++++++++++ include/VirtualMachineTemplate.h | 15 +++++++++++++++ src/host/Host.cc | 30 ++++++++++++++++++++++++++++++ src/lcm/LifeCycleActions.cc | 12 ++++++++++++ src/vm/VirtualMachine.cc | 21 ++++++++++++++++++++- src/vm/VirtualMachineTemplate.cc | 26 ++++++++++++++++++++++++++ src/vm_template/VMTemplate.cc | 4 +++- 7 files changed, 121 insertions(+), 2 deletions(-) diff --git a/include/Host.h b/include/Host.h index 1a479db757..29e7d40e6c 100644 --- a/include/Host.h +++ b/include/Host.h @@ -23,6 +23,7 @@ #include "Clusterable.h" #include "ObjectCollection.h" #include "NebulaLog.h" +#include "NebulaUtil.h" using namespace std; @@ -85,6 +86,12 @@ public: (state == MONITORING_DISABLED)); } + /** + * Check if host is hybrid + * @return true if the host is enabled + */ + bool isHybrid() const; + /** * Disables the current host, it will not be monitored nor used by the * scheduler @@ -459,6 +466,7 @@ private: */ ObjectCollection vm_collection; + // ************************************************************************* // Constructor // ************************************************************************* @@ -489,6 +497,13 @@ private: static const char * monit_table; + /** + * Array containing the hybrid hypervisors, and counter + */ + static const char * HYBRID_HYPERVISORS[]; + + static const int NUM_HYBRID_HYPERVISORS; + /** * Execute an INSERT or REPLACE Sql query. * @param db The SQL DB diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h index c637f48168..1d14ccc7e1 100644 --- a/include/VirtualMachineTemplate.h +++ b/include/VirtualMachineTemplate.h @@ -67,12 +67,27 @@ public: */ void remove_all_except_restricted(); + /** + * Returns a copy of the VirtualMachineTemplate + * @param hypervisor the resulting hypervisor string + * @return true if any hybrid hypervisor found, false otherwise + */ + bool get_hybrid_hypervisor(string& hypervisor) const; + private: friend class VirtualMachinePool; static vector restricted_attributes; + + /** + * Array containing the hybrid attributes, and counter + */ + static const char * HYBRID_ATTRIBUTES[]; + + static const int NUM_HYBRID_ATTRIBUTES; + /** * Stores the attributes as restricted, these attributes will be used in * VirtualMachineTemplate::check diff --git a/src/host/Host.cc b/src/host/Host.cc index ad03f7209f..25e480e403 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -23,6 +23,13 @@ #include "Host.h" #include "Nebula.h" +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +const char * Host::HYBRID_HYPERVISORS[] = {"EC2"}; + +const int Host::NUM_HYBRID_HYPERVISORS = 1; + /* ************************************************************************ */ /* Host :: Constructor/Destructor */ /* ************************************************************************ */ @@ -426,6 +433,29 @@ error_common: return -1; } +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + +bool Host::isHybrid() const +{ + string hypervisor; + bool is_hybrid = false; + + get_template_attribute("HYPERVISOR", hypervisor); + one_util::toupper(hypervisor); + + for(int i=0; i < NUM_HYBRID_HYPERVISORS; i++) + { + if(hypervisor==HYBRID_HYPERVISORS[i]) + { + is_hybrid = true; + break; + } + } + + return is_hybrid; +} + /* ************************************************************************ */ /* Host :: Misc */ /* ************************************************************************ */ diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 88703058aa..22d3d6f254 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -21,6 +21,8 @@ void LifeCycleManager::deploy_action(int vid) { VirtualMachine * vm; ostringstream os; + Host * host; + bool host_is_hybrid; vm = vmpool->get(vid,true); @@ -29,6 +31,16 @@ void LifeCycleManager::deploy_action(int vid) return; } + host = hpool->get(vm->get_hid(),true); + host_is_hybrid=host->isHybrid(); + host->unlock(); + + if (host_is_hybrid) + { + trigger(PROLOG_SUCCESS,vid); + return; + } + if ( vm->get_state() == VirtualMachine::ACTIVE ) { Nebula& nd = Nebula::instance(); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 9619d59a9d..0bdd56b35f 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -252,6 +252,8 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) int ivalue; float fvalue; + bool ec2_present; + ostringstream oss; // ------------------------------------------------------------------------ @@ -1067,6 +1069,7 @@ int VirtualMachine::automatic_requirements(string& error_str) ostringstream oss; string requirements; string cluster_id = ""; + string hypervisor; int incomp_id; int rc; @@ -1143,11 +1146,27 @@ int VirtualMachine::automatic_requirements(string& error_str) } } + static_cast(obj_template)->get_hybrid_hypervisor( + hypervisor); + oss.str(""); + if ( !cluster_id.empty() ) { - oss.str(""); oss << "CLUSTER_ID = " << cluster_id; + } + if ( !hypervisor.empty() ) + { + if ( !cluster_id.empty() ) + { + oss << " || "; + } + + oss << "HYPERVISOR = " << hypervisor; + } + + if ( !cluster_id.empty() || !hypervisor.empty() ) + { obj_template->add("AUTOMATIC_REQUIREMENTS", oss.str()); } diff --git a/src/vm/VirtualMachineTemplate.cc b/src/vm/VirtualMachineTemplate.cc index fd7ae6af9e..b18d177800 100644 --- a/src/vm/VirtualMachineTemplate.cc +++ b/src/vm/VirtualMachineTemplate.cc @@ -21,6 +21,14 @@ vector VirtualMachineTemplate::restricted_attributes; +/* ************************************************************************ */ +/* Hybrid Attributes */ +/* ************************************************************************ */ + +const char * VirtualMachineTemplate::HYBRID_ATTRIBUTES[] = {"EC2"}; + +const int VirtualMachineTemplate::NUM_HYBRID_ATTRIBUTES = 1; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -136,3 +144,21 @@ void VirtualMachineTemplate::remove_all_except_restricted() } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ + +bool VirtualMachineTemplate::get_hybrid_hypervisor(string& hypervisor) const +{ + vector attrs; + bool found_it = false; + + for(int i=0; i < NUM_HYBRID_ATTRIBUTES; i++) + { + if(get(HYBRID_ATTRIBUTES[i],attrs)) + { + hypervisor = HYBRID_ATTRIBUTES[i]; + found_it = true; + break; + } + } + + return found_it; +} diff --git a/src/vm_template/VMTemplate.cc b/src/vm_template/VMTemplate.cc index 63415969ec..28683784ff 100644 --- a/src/vm_template/VMTemplate.cc +++ b/src/vm_template/VMTemplate.cc @@ -18,7 +18,6 @@ #define TO_UPPER(S) transform(S.begin(),S.end(),S.begin(),(int(*)(int))toupper) - /* ************************************************************************ */ /* VMTemplate :: Constructor/Destructor */ /* ************************************************************************ */ @@ -241,3 +240,6 @@ int VMTemplate::from_xml(const string& xml) return 0; } + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ From e0f2a3b393a1ac327683f434470713a19bc8d651 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 4 Oct 2013 20:24:31 +0200 Subject: [PATCH 07/44] feature #1612: Functions to check if a disk is volatile and to compute the total size of volatile disks of a template --- include/VirtualMachine.h | 10 ++++++++ src/vm/VirtualMachine.cc | 50 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 645dc0b377..9ea3e36d1c 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1068,6 +1068,16 @@ public: */ void release_disk_images(); + /** + * Check if the given disk is volatile + */ + static bool isVolatile(const VectorAttribute * disk); + + /** + * Return the total SIZE of volatile disks + */ + static float get_volatile_disk_size(Template * tmpl); + // ------------------------------------------------------------------------ // Context related functions // ------------------------------------------------------------------------ diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 33395a6831..35b0ea322c 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2005,6 +2005,56 @@ VectorAttribute * VirtualMachine::delete_attach_disk() return 0; } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +bool VirtualMachine::isVolatile(const VectorAttribute * disk) +{ + string type = disk->vector_value("TYPE"); + + one_util::toupper(type); + + return ( type == "SWAP" || type == "FS"); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +float VirtualMachine::get_volatile_disk_size(Template * tmpl) +{ + float size = 0; + + vector disks; + int num_disks = tmpl->get("DISKS", disks); + + if (num_disks == 0) + { + return size; + } + + for (int i = 0 ; i < num_disks ; i++) + { + float disk_size; + const VectorAttribute * disk = dynamic_cast(disks[i]); + + if (disk == 0) + { + continue; + } + + if (!VirtualMachine::isVolatile(disk)) + { + continue; + } + + if (disk->vector_value("SIZE", disk_size) == 0) + { + size += disk_size; + } + } + + return size; +} /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ From 205483630193f7a0654b2eaa2b9f72ee3fe4bc7e Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Sat, 5 Oct 2013 15:34:55 -0400 Subject: [PATCH 08/44] Feature #1683: create a way to initialize without service start + This allows a mode to just initialize the database + Changes the decision making about DB bootstrapping such that a missing DB no longer produces misleading messages in the log file + Allows the DB to be initialized/bootstrapped during an automated install process without having to wait for some arbitrary time to kill the daemon - return the SQL error code from the DB::exec method + This allows to make decisions about DB bootstrapping earlier and avoids misleading messages in the log file --- include/Nebula.h | 5 ++ share/pkgs/openSUSE/systemd/onedsetup | 7 +- src/nebula/Nebula.cc | 122 ++++++++++++++++---------- src/nebula/oned.cc | 29 +++++- src/sql/MySqlDB.cc | 4 +- 5 files changed, 112 insertions(+), 55 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index 3c54369f03..58c60d61ac 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -343,6 +343,11 @@ public: */ void start(); + /** + * Initialize the database + */ + void init(); + // ----------------------------------------------------------------------- // Configuration attributes (read from oned.conf) // ----------------------------------------------------------------------- diff --git a/share/pkgs/openSUSE/systemd/onedsetup b/share/pkgs/openSUSE/systemd/onedsetup index ec82ef2811..65e0f9fb3e 100644 --- a/share/pkgs/openSUSE/systemd/onedsetup +++ b/share/pkgs/openSUSE/systemd/onedsetup @@ -79,7 +79,7 @@ if [ ! -d /var/lock/one ]; then fi # Start the one daemon -$ONED -f 2>&1 & +$ONED -i 2>&1 & STARTED=$? CURPID=$! @@ -89,9 +89,10 @@ if [ $STARTED -ne 0 ]; then fi # Give oned a chance to do it's thing... -sleep 2 +sleep 5 # OK we're all done here +# Just in case the process gets stuck, kill it kill -TERM $CURPID > /dev/null 2>&1 counter=0 @@ -105,4 +106,4 @@ while ps $CURPID > /dev/null 2>&1; do done # If the lock file is left over remove it -rm -f /var/lol/one/one +rm -f /var/lock/one/one diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 45c64c373f..33b80833eb 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -23,7 +23,8 @@ #include #include #include - + +#include #include #include #include @@ -116,7 +117,6 @@ int SystemDB::select_cb(void *_loaded_db_version, int num, char **values, int SystemDB::check_db_version() { - int rc; ostringstream oss; string loaded_db_version = ""; @@ -133,21 +133,6 @@ int SystemDB::check_db_version() oss.str(""); unset_callback(); - if( loaded_db_version == "" ) - { - // Table user_pool is present for all OpenNebula versions, and it - // always contains at least the oneadmin user. - oss << "SELECT MAX(oid) FROM user_pool"; - rc = db->exec(oss); - - oss.str(""); - - if( rc != 0 ) // Database needs bootstrap - { - return -2; - } - } - if( Nebula::db_version() != loaded_db_version ) { oss << "Database version mismatch. " @@ -268,21 +253,10 @@ int SystemDB::select_sys_attribute(const string& attr_name, string& attr_xml) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void Nebula::start() +void Nebula::init() { - int rc; - int fd; - sigset_t mask; - int signal; - char hn[80]; - string scripts_remote_dir; - - if ( gethostname(hn,79) != 0 ) - { - throw runtime_error("Error getting hostname"); - } - - hostname = hn; + int rc; + string scripts_remote_dir; // ----------------------------------------------------------- // Configuration @@ -384,6 +358,7 @@ void Nebula::start() int rc; bool db_is_sqlite = true; + bool bootstrap_db = false; string server = "localhost"; string port_str; @@ -445,8 +420,19 @@ void Nebula::start() if ( db_is_sqlite ) { - string db_name = var_location + "one.db"; - + db_name = var_location + "one.db"; + rc = access(db_name.c_str(), R_OK|W_OK|F_OK); + if (rc == -1) + { + if (errno == ENOENT) + { + bootstrap_db = true; + } + else + { + throw runtime_error("Could not acces one.db file"); + } + } db = new SqliteDB(db_name); } else @@ -454,28 +440,41 @@ void Nebula::start() ostringstream oss; db = new MySqlDB(server,port,user,passwd,db_name); + + oss << "USE " << db_name; + rc = db->exec(oss); + + if ( rc == 1044 ) + { + oss.str(""); + oss << "CREATE DATABASE " << db_name; + rc = db->exec(oss); + + if ( rc == 0 ) + { + bootstrap_db = true; + } + else if ( rc == 1044 ) + { + throw runtime_error("Could not create database."); + } + } + else if ( rc != 0 ) + { + throw runtime_error("Could not open database."); + } } // --------------------------------------------------------------------- // Prepare the SystemDB and check versions // --------------------------------------------------------------------- - NebulaLog::log("ONE",Log::INFO,"Checking database version."); - system_db = new SystemDB(db); - rc = system_db->check_db_version(); - - if( rc == -1 ) - { - throw runtime_error("Database version mismatch."); - } - - if( rc == -2 ) - { + if (bootstrap_db) { rc = 0; - - NebulaLog::log("ONE",Log::INFO,"Bootstrapping OpenNebula database."); + NebulaLog::log("ONE",Log::INFO, + "Bootstrapping OpenNebula database."); rc += VirtualMachinePool::bootstrap(db); rc += HostPool::bootstrap(db); @@ -502,13 +501,42 @@ void Nebula::start() if ( rc != 0 ) { throw runtime_error("Error bootstrapping database."); - } + } + } + + NebulaLog::log("ONE",Log::INFO,"Checking database version."); + rc = system_db->check_db_version(); + + if( rc == -1 ) + { + throw runtime_error("Database version mismatch."); } } catch (exception&) { throw; } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void Nebula::start() +{ + int rc; + int fd; + sigset_t mask; + int signal; + char hn[80]; + + if ( gethostname(hn,79) != 0 ) + { + throw runtime_error("Error getting hostname"); + } + + hostname = hn; + + Nebula::init(); try { diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index 81e45adec3..457ab7b71c 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -32,9 +32,10 @@ static const char * usage = "SYNOPSIS\n" " Starts the OpenNebula daemon\n\n" "OPTIONS\n" -"\t-h\tprints this help.\n" "\t-v\tprints OpenNebula version and license\n" -"\t-f\tforeground, do not fork the oned daemon\n"; +"\t-h\tprints this help.\n" +"\t-f\tforeground, do not fork the oned daemon\n" +"\t-i\tinitialize the dabase and exit.\n"; static const char * susage = "usage: oned [-h] [-v] [-f]\n"; @@ -50,6 +51,24 @@ static void print_license() << "(http://www.apache.org/licenses/LICENSE-2.0).\n"; } +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +static void oned_init() +{ + try + { + Nebula& nd = Nebula::instance(); + nd.init(); + } + catch (exception &e) + { + cerr << e.what() << endl; + + return; + } +} + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -81,7 +100,7 @@ int main(int argc, char **argv) string wd; int rc; - while((opt = getopt(argc,argv,"vhf")) != -1) + while((opt = getopt(argc,argv,"vhif")) != -1) switch(opt) { case 'v': @@ -92,6 +111,10 @@ int main(int argc, char **argv) cout << usage; exit(0); break; + case 'i': + oned_init(); + exit(0); + break; case 'f': foreground = true; break; diff --git a/src/sql/MySqlDB.cc b/src/sql/MySqlDB.cc index 652b799af8..5b2c4ad1c4 100644 --- a/src/sql/MySqlDB.cc +++ b/src/sql/MySqlDB.cc @@ -180,7 +180,7 @@ int MySqlDB::exec(ostringstream& cmd, Callbackable* obj) free_db_connection(db); - return -1; + return err_num; } @@ -208,7 +208,7 @@ int MySqlDB::exec(ostringstream& cmd, Callbackable* obj) free_db_connection(db); - return -1; + return err_num; } // Fetch the names of the fields From a9bccd442333f6decfba75026ec5975144a8f3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 8 Oct 2013 15:09:30 +0200 Subject: [PATCH 09/44] Feature #1683: Simplify bootstrap methods --- include/MySqlDB.h | 4 +- include/Nebula.h | 2 +- include/SqlDB.h | 4 +- include/SqliteDB.h | 4 +- src/nebula/Nebula.cc | 137 ++++++++++++++++++++----------------------- src/sql/MySqlDB.cc | 12 ++-- src/sql/SqliteDB.cc | 6 +- 7 files changed, 83 insertions(+), 86 deletions(-) diff --git a/include/MySqlDB.h b/include/MySqlDB.h index d9059190c3..df3beea811 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -58,7 +58,7 @@ public: * @param obj Callbackable obj to call if the query succeeds * @return 0 on success */ - int exec(ostringstream& cmd, Callbackable* obj=0); + int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false); /** * This function returns a legal SQL string that can be used in an SQL @@ -143,7 +143,7 @@ public: ~MySqlDB(){}; - int exec(ostringstream& cmd, Callbackable* obj=0){return -1;}; + int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false){return -1;}; char * escape_str(const string& str){return 0;}; diff --git a/include/Nebula.h b/include/Nebula.h index 58c60d61ac..2db19d6725 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -341,7 +341,7 @@ public: /** * Starts all the modules and services for OpenNebula */ - void start(); + void start(bool bootstrap_only=false); /** * Initialize the database diff --git a/include/SqlDB.h b/include/SqlDB.h index 4daafeb8c0..b0e9552d0e 100644 --- a/include/SqlDB.h +++ b/include/SqlDB.h @@ -37,10 +37,10 @@ public: * Performs a DB transaction * @param sql_cmd the SQL command * @param callbak function to execute on each data returned - * @param arg to pass to the callback function + * @param quiet True to log errors with DDEBUG level instead of ERROR * @return 0 on success */ - virtual int exec(ostringstream& cmd, Callbackable* obj=0) = 0; + virtual int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false) = 0; /** * This function returns a legal SQL string that can be used in an SQL diff --git a/include/SqliteDB.h b/include/SqliteDB.h index 197712782a..43c7476310 100644 --- a/include/SqliteDB.h +++ b/include/SqliteDB.h @@ -57,7 +57,7 @@ public: * @param arg to pass to the callback function * @return 0 on success */ - int exec(ostringstream& cmd, Callbackable* obj=0); + int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false); /** * This function returns a legal SQL string that can be used in an SQL @@ -113,7 +113,7 @@ public: ~SqliteDB(){}; - int exec(ostringstream& cmd, Callbackable* obj=0){return -1;}; + int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false){return -1;}; char * escape_str(const string& str){return 0;}; diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 33b80833eb..065a383565 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -23,8 +23,7 @@ #include #include #include - -#include + #include #include #include @@ -117,6 +116,7 @@ int SystemDB::select_cb(void *_loaded_db_version, int num, char **values, int SystemDB::check_db_version() { + int rc; ostringstream oss; string loaded_db_version = ""; @@ -133,6 +133,21 @@ int SystemDB::check_db_version() oss.str(""); unset_callback(); + if( loaded_db_version == "" ) + { + // Table user_pool is present for all OpenNebula versions, and it + // always contains at least the oneadmin user. + oss << "SELECT MAX(oid) FROM user_pool"; + rc = db->exec(oss); + + oss.str(""); + + if( rc != 0 ) // Database needs bootstrap + { + return -2; + } + } + if( Nebula::db_version() != loaded_db_version ) { oss << "Database version mismatch. " @@ -255,8 +270,27 @@ int SystemDB::select_sys_attribute(const string& attr_name, string& attr_xml) void Nebula::init() { - int rc; - string scripts_remote_dir; + start(true); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void Nebula::start(bool bootstrap_only) +{ + int rc; + int fd; + sigset_t mask; + int signal; + char hn[80]; + string scripts_remote_dir; + + if ( gethostname(hn,79) != 0 ) + { + throw runtime_error("Error getting hostname"); + } + + hostname = hn; // ----------------------------------------------------------- // Configuration @@ -350,7 +384,7 @@ void Nebula::init() xmlInitParser(); // ----------------------------------------------------------- - // Pools + // Database // ----------------------------------------------------------- try { @@ -358,7 +392,6 @@ void Nebula::init() int rc; bool db_is_sqlite = true; - bool bootstrap_db = false; string server = "localhost"; string port_str; @@ -420,19 +453,8 @@ void Nebula::init() if ( db_is_sqlite ) { - db_name = var_location + "one.db"; - rc = access(db_name.c_str(), R_OK|W_OK|F_OK); - if (rc == -1) - { - if (errno == ENOENT) - { - bootstrap_db = true; - } - else - { - throw runtime_error("Could not acces one.db file"); - } - } + string db_name = var_location + "one.db"; + db = new SqliteDB(db_name); } else @@ -440,41 +462,28 @@ void Nebula::init() ostringstream oss; db = new MySqlDB(server,port,user,passwd,db_name); - - oss << "USE " << db_name; - rc = db->exec(oss); - - if ( rc == 1044 ) - { - oss.str(""); - oss << "CREATE DATABASE " << db_name; - rc = db->exec(oss); - - if ( rc == 0 ) - { - bootstrap_db = true; - } - else if ( rc == 1044 ) - { - throw runtime_error("Could not create database."); - } - } - else if ( rc != 0 ) - { - throw runtime_error("Could not open database."); - } } // --------------------------------------------------------------------- // Prepare the SystemDB and check versions // --------------------------------------------------------------------- + NebulaLog::log("ONE",Log::INFO,"Checking database version."); + system_db = new SystemDB(db); - if (bootstrap_db) { + rc = system_db->check_db_version(); + + if( rc == -1 ) + { + throw runtime_error("Database version mismatch."); + } + + if( rc == -2 ) + { rc = 0; - NebulaLog::log("ONE",Log::INFO, - "Bootstrapping OpenNebula database."); + + NebulaLog::log("ONE",Log::INFO,"Bootstrapping OpenNebula database."); rc += VirtualMachinePool::bootstrap(db); rc += HostPool::bootstrap(db); @@ -501,43 +510,27 @@ void Nebula::init() if ( rc != 0 ) { throw runtime_error("Error bootstrapping database."); - } - } - - NebulaLog::log("ONE",Log::INFO,"Checking database version."); - rc = system_db->check_db_version(); - - if( rc == -1 ) - { - throw runtime_error("Database version mismatch."); + } } } catch (exception&) { throw; } -} -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void Nebula::start() -{ - int rc; - int fd; - sigset_t mask; - int signal; - char hn[80]; - - if ( gethostname(hn,79) != 0 ) + if (bootstrap_only) { - throw runtime_error("Error getting hostname"); + //XML Library + xmlCleanupParser(); + + NebulaLog::log("ONE", Log::INFO, "Database bootstrap finalized, exiting.\n"); + + return; } - hostname = hn; - - Nebula::init(); - + // ----------------------------------------------------------- + // Pools + // ----------------------------------------------------------- try { int size; diff --git a/src/sql/MySqlDB.cc b/src/sql/MySqlDB.cc index 5b2c4ad1c4..90cccd1d3e 100644 --- a/src/sql/MySqlDB.cc +++ b/src/sql/MySqlDB.cc @@ -132,7 +132,7 @@ MySqlDB::~MySqlDB() /* -------------------------------------------------------------------------- */ -int MySqlDB::exec(ostringstream& cmd, Callbackable* obj) +int MySqlDB::exec(ostringstream& cmd, Callbackable* obj, bool quiet) { int rc; @@ -142,6 +142,8 @@ int MySqlDB::exec(ostringstream& cmd, Callbackable* obj) str = cmd.str(); c_str = str.c_str(); + Log::MessageType error_level = quiet ? Log::DDEBUG : Log::ERROR; + MYSQL *db; db = get_db_connection(); @@ -176,11 +178,11 @@ int MySqlDB::exec(ostringstream& cmd, Callbackable* obj) oss << ", error " << err_num << " : " << err_msg; } - NebulaLog::log("ONE",Log::ERROR,oss); + NebulaLog::log("ONE",error_level,oss); free_db_connection(db); - return err_num; + return -1; } @@ -204,11 +206,11 @@ int MySqlDB::exec(ostringstream& cmd, Callbackable* obj) oss << "SQL command was: " << c_str; oss << ", error " << err_num << " : " << err_msg; - NebulaLog::log("ONE",Log::ERROR,oss); + NebulaLog::log("ONE",error_level,oss); free_db_connection(db); - return err_num; + return -1; } // Fetch the names of the fields diff --git a/src/sql/SqliteDB.cc b/src/sql/SqliteDB.cc index 11b2f7d7bd..e629addf0d 100644 --- a/src/sql/SqliteDB.cc +++ b/src/sql/SqliteDB.cc @@ -66,7 +66,7 @@ SqliteDB::~SqliteDB() /* -------------------------------------------------------------------------- */ -int SqliteDB::exec(ostringstream& cmd, Callbackable* obj) +int SqliteDB::exec(ostringstream& cmd, Callbackable* obj, bool quiet) { int rc; @@ -119,10 +119,12 @@ int SqliteDB::exec(ostringstream& cmd, Callbackable* obj) { if (err_msg != 0) { + Log::MessageType error_level = quiet ? Log::DDEBUG : Log::ERROR; + ostringstream oss; oss << "SQL command was: " << c_str << ", error: " << err_msg; - NebulaLog::log("ONE",Log::ERROR,oss); + NebulaLog::log("ONE",error_level,oss); sqlite3_free(err_msg); } From 4cc34621ecdd0e6622f4b6a875da3a9800cc89fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 8 Oct 2013 15:20:09 +0200 Subject: [PATCH 10/44] Feature #1683: Make initial sql queries quiet, so errors do not show in log --- src/nebula/Nebula.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 065a383565..7f78165fb7 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -128,7 +128,7 @@ int SystemDB::check_db_version() oss << "SELECT version FROM " << ver_table << " WHERE oid=(SELECT MAX(oid) FROM " << ver_table << ")"; - db->exec(oss, this); + db->exec(oss, this, true); oss.str(""); unset_callback(); @@ -138,7 +138,7 @@ int SystemDB::check_db_version() // Table user_pool is present for all OpenNebula versions, and it // always contains at least the oneadmin user. oss << "SELECT MAX(oid) FROM user_pool"; - rc = db->exec(oss); + rc = db->exec(oss, 0, true); oss.str(""); From ab85640c56c995ac75d7c2ec4460c215211c49d3 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 8 Oct 2013 19:40:39 +0200 Subject: [PATCH 11/44] feature #2092: Changed PROLOG and EPILOG bypass to TransferManager.cc --- src/lcm/LifeCycleActions.cc | 12 ------------ src/tm/TransferManager.cc | 28 +++++++++++++++++++++++++++- src/vm/VirtualMachine.cc | 4 +--- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 22d3d6f254..88703058aa 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -21,8 +21,6 @@ void LifeCycleManager::deploy_action(int vid) { VirtualMachine * vm; ostringstream os; - Host * host; - bool host_is_hybrid; vm = vmpool->get(vid,true); @@ -31,16 +29,6 @@ void LifeCycleManager::deploy_action(int vid) return; } - host = hpool->get(vm->get_hid(),true); - host_is_hybrid=host->isHybrid(); - host->unlock(); - - if (host_is_hybrid) - { - trigger(PROLOG_SUCCESS,vid); - return; - } - if ( vm->get_state() == VirtualMachine::ACTIVE ) { Nebula& nd = Nebula::instance(); diff --git a/src/tm/TransferManager.cc b/src/tm/TransferManager.cc index 20c627d1ab..1ace1db10b 100644 --- a/src/tm/TransferManager.cc +++ b/src/tm/TransferManager.cc @@ -436,6 +436,8 @@ void TransferManager::prolog_action(int vid) string error_str; VirtualMachine * vm; + Host * host; + bool host_is_hybrid; Nebula& nd = Nebula::instance(); const TransferManagerDriver * tm_md; @@ -460,9 +462,19 @@ void TransferManager::prolog_action(int vid) } int uid = vm->get_uid(); - vm->unlock(); + host = hpool->get(vm->get_hid(),true); + host_is_hybrid=host->isHybrid(); + host->unlock(); + + if (host_is_hybrid) + { + vm->unlock(); + (nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid); + return; + } + User * user = Nebula::instance().get_upool()->get(uid, true); if (user != 0) @@ -1041,6 +1053,9 @@ void TransferManager::epilog_action(int vid) VirtualMachine * vm; Nebula& nd = Nebula::instance(); + Host * host; + bool host_is_hybrid; + const TransferManagerDriver * tm_md; vector attrs; @@ -1061,6 +1076,17 @@ void TransferManager::epilog_action(int vid) goto error_history; } + host = hpool->get(vm->get_hid(),true); + host_is_hybrid=host->isHybrid(); + host->unlock(); + + if (host_is_hybrid) + { + vm->unlock(); + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + return; + } + vm_tm_mad = vm->get_tm_mad(); vm_ds_id = vm->get_ds_id(); tm_md = get(); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 0bdd56b35f..833bf953d3 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -251,9 +251,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) string value; int ivalue; float fvalue; - - bool ec2_present; - + ostringstream oss; // ------------------------------------------------------------------------ From 4020d536cb3194b16f8baaef7f6e767401009d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 9 Oct 2013 12:13:23 +0200 Subject: [PATCH 12/44] Feature #1612: Add VOLATILE_SIZE to VM quotas --- include/QuotaVirtualMachine.h | 14 ++++++++------ src/tm/TransferManager.cc | 23 +++++------------------ src/um/QuotaVirtualMachine.cc | 23 ++++++++++++++++++----- src/vm/VirtualMachine.cc | 2 +- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/include/QuotaVirtualMachine.h b/include/QuotaVirtualMachine.h index e46c47c0c3..ab3bc24ad9 100644 --- a/include/QuotaVirtualMachine.h +++ b/include/QuotaVirtualMachine.h @@ -22,12 +22,14 @@ /** * VM Quotas, defined as: * VM = [ - * VMS = - * MEMORY = - * CPU = - * VMS_USED = Current number of VMs - * MEMORY_USED = Overall Memory requested - * CPU_USED = Overall CPU requested + * VMS = + * MEMORY = + * CPU = + * VOLATILE_SIZE = + * VMS_USED = Current number of VMs + * MEMORY_USED = Overall Memory requested + * CPU_USED = Overall CPU requested + * VOLATILE_SIZE_USED = * ] * * 0 = unlimited, default if missing diff --git a/src/tm/TransferManager.cc b/src/tm/TransferManager.cc index 20c627d1ab..0c3bc93a85 100644 --- a/src/tm/TransferManager.cc +++ b/src/tm/TransferManager.cc @@ -653,19 +653,6 @@ error_common: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -static bool isVolatile(const VectorAttribute * disk) -{ - string type; - - type = disk->vector_value("TYPE"); - transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper); - - return ( type == "SWAP" || type == "FS"); -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - void TransferManager::prolog_migr_action(int vid) { ofstream xfr; @@ -736,7 +723,7 @@ void TransferManager::prolog_migr_action(int vid) disk->vector_value_str("DISK_ID", disk_id); - if ( isVolatile(disk) == true ) + if ( VirtualMachine::isVolatile(disk) == true ) { tm_mad = vm_tm_mad; ds_id = vm_ds_id; @@ -875,7 +862,7 @@ void TransferManager::prolog_resume_action(int vid) disk->vector_value_str("DISK_ID", disk_id); - if ( isVolatile(disk) == true ) + if ( VirtualMachine::isVolatile(disk) == true ) { tm_mad = vm_tm_mad; ds_id = vm_ds_id; @@ -999,7 +986,7 @@ void TransferManager::epilog_transfer_command( } else //No saving disk { - if ( isVolatile(disk) == true ) + if ( VirtualMachine::isVolatile(disk) == true ) { tm_mad = vm->get_tm_mad(); ds_id = vm->get_ds_id(); @@ -1205,7 +1192,7 @@ void TransferManager::epilog_stop_action(int vid) disk->vector_value_str("DISK_ID", disk_id); - if ( isVolatile(disk) == true ) + if ( VirtualMachine::isVolatile(disk) == true ) { tm_mad = vm_tm_mad; ds_id = vm_ds_id; @@ -1357,7 +1344,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm, disk->vector_value_str("DISK_ID", disk_id); - if ( isVolatile(disk) == true ) + if ( VirtualMachine::isVolatile(disk) == true ) { tm_mad = vm_tm_mad; ds_id = vm_ds_id; diff --git a/src/um/QuotaVirtualMachine.cc b/src/um/QuotaVirtualMachine.cc index a7cf49c240..55eea64d81 100644 --- a/src/um/QuotaVirtualMachine.cc +++ b/src/um/QuotaVirtualMachine.cc @@ -16,13 +16,15 @@ #include "QuotaVirtualMachine.h" #include "Quotas.h" +#include "VirtualMachine.h" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -const char * QuotaVirtualMachine::VM_METRICS[] = {"VMS", "CPU", "MEMORY"}; +const char * QuotaVirtualMachine::VM_METRICS[] = + {"VMS", "CPU", "MEMORY", "VOLATILE_SIZE"}; -const int QuotaVirtualMachine::NUM_VM_METRICS = 3; +const int QuotaVirtualMachine::NUM_VM_METRICS = 4; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -56,7 +58,7 @@ bool QuotaVirtualMachine::check(Template * tmpl, map vm_request; int memory; - float cpu; + float cpu, size; if ( tmpl->get("MEMORY", memory) == false || memory <= 0 ) { @@ -70,9 +72,12 @@ bool QuotaVirtualMachine::check(Template * tmpl, return false; } + size = VirtualMachine::get_volatile_disk_size(tmpl); + vm_request.insert(make_pair("VMS",1)); vm_request.insert(make_pair("MEMORY", memory)); vm_request.insert(make_pair("CPU", cpu)); + vm_request.insert(make_pair("VOLATILE_SIZE", size)); return check_quota("", vm_request, default_quotas, error); } @@ -85,7 +90,7 @@ void QuotaVirtualMachine::del(Template * tmpl) map vm_request; int memory, vms; - float cpu; + float cpu, size; if ( tmpl->get("MEMORY", memory) == false ) { @@ -102,9 +107,12 @@ void QuotaVirtualMachine::del(Template * tmpl) vms = 1; } + size = VirtualMachine::get_volatile_disk_size(tmpl); + vm_request.insert(make_pair("VMS", vms)); vm_request.insert(make_pair("MEMORY", memory)); vm_request.insert(make_pair("CPU", cpu)); + vm_request.insert(make_pair("VOLATILE_SIZE", size)); del_quota("", vm_request); } @@ -130,7 +138,7 @@ bool QuotaVirtualMachine::update(Template * tmpl, map vm_request; int delta_memory; - float delta_cpu; + float delta_cpu, delta_size; if ( tmpl->get("MEMORY", delta_memory) == true ) { @@ -142,5 +150,10 @@ bool QuotaVirtualMachine::update(Template * tmpl, vm_request.insert(make_pair("CPU", delta_cpu)); } + if ( tmpl->get("VOLATILE_SIZE", delta_size) == true ) + { + vm_request.insert(make_pair("VOLATILE_SIZE", delta_size)); + } + return check_quota("", vm_request, default_quotas, error); } diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 35b0ea322c..c03b7e4c7d 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2025,7 +2025,7 @@ float VirtualMachine::get_volatile_disk_size(Template * tmpl) float size = 0; vector disks; - int num_disks = tmpl->get("DISKS", disks); + int num_disks = tmpl->get("DISK", disks); if (num_disks == 0) { From b048c2973bc578f4b45b1188b1fbbb2ddf6913db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 9 Oct 2013 12:34:51 +0200 Subject: [PATCH 13/44] Feature #1612: Add VOLATILE_SIZE quota to CLI --- src/cli/one_helper/onequota_helper.rb | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/cli/one_helper/onequota_helper.rb b/src/cli/one_helper/onequota_helper.rb index 3290d76306..947b959f3c 100644 --- a/src/cli/one_helper/onequota_helper.rb +++ b/src/cli/one_helper/onequota_helper.rb @@ -31,9 +31,10 @@ class OneQuotaHelper # ] # # VM = [ - # VMS = - # MEMORY = - # CPU = + # VMS = + # MEMORY = + # CPU = + # VOLATILE_SIZE = # ] # # NETWORK = [ @@ -180,14 +181,14 @@ class OneQuotaHelper if !vm_quotas[0].nil? CLIHelper::ShowTable.new(nil, self) do - column :"NUMBER OF VMS", "", :right, :size=>20 do |d| + column :"NUMBER OF VMS", "", :right, :size=>17 do |d| if !d.nil? elem = 'VMS' limit = d[elem] limit = helper.get_default_limit( limit, "VM_QUOTA/VM/#{elem}") - "%8d / %8d" % [d["VMS_USED"], limit] + "%7d / %7d" % [d["VMS_USED"], limit] end end @@ -215,6 +216,20 @@ class OneQuotaHelper "%8.2f / %8.2f" % [d["CPU_USED"], limit] end end + + column :"VOLATILE_SIZE", "", :right, :size=>20 do |d| + if !d.nil? + elem = 'VOLATILE_SIZE' + limit = d[elem] + limit = helper.get_default_limit( + limit, "VM_QUOTA/VM/#{elem}") + + "%8s / %8s" % [ + OpenNebulaHelper.unit_to_str(d["VOLATILE_SIZE_USED"].to_i,{},"M"), + OpenNebulaHelper.unit_to_str(limit.to_i,{},"M") + ] + end + end end.show(vm_quotas, {}) puts From 7e2507e86f6a8f81feca06725e648adcb48f7a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 9 Oct 2013 13:27:23 +0200 Subject: [PATCH 14/44] Feature #1612: Add VOLATILE_SIZE quota to Sunstone --- src/sunstone/public/js/plugins/config-tab.js | 2 ++ src/sunstone/public/js/plugins/groups-tab.js | 30 ++++++++++++++------ src/sunstone/public/js/plugins/users-tab.js | 30 ++++++++++++++------ src/sunstone/public/js/sunstone-util.js | 26 ++++++++++++++--- 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/sunstone/public/js/plugins/config-tab.js b/src/sunstone/public/js/plugins/config-tab.js index 23ec93b022..8c68f1e907 100644 --- a/src/sunstone/public/js/plugins/config-tab.js +++ b/src/sunstone/public/js/plugins/config-tab.js @@ -360,6 +360,7 @@ function updateUserConfigInfo(request,user_json) { var quotas_tab_html = Quotas.vms(info, default_user_quotas); quotas_tab_html += Quotas.cpu(info, default_user_quotas); quotas_tab_html += Quotas.memory(info, default_user_quotas); + quotas_tab_html += Quotas.volatile_size(info, default_user_quotas); quotas_tab_html += Quotas.image(info, default_user_quotas); quotas_tab_html += Quotas.network(info, default_user_quotas); quotas_tab_html += Quotas.datastore(info, default_user_quotas); @@ -456,6 +457,7 @@ function fillGroupQuotas(group_id){ var quotas_tab_html = Quotas.vms(info, default_group_quotas); quotas_tab_html += Quotas.cpu(info, default_group_quotas); quotas_tab_html += Quotas.memory(info, default_group_quotas); + quotas_tab_html += Quotas.volatile_size(info, default_group_quotas); quotas_tab_html += Quotas.image(info, default_group_quotas); quotas_tab_html += Quotas.network(info, default_group_quotas); quotas_tab_html += Quotas.datastore(info, default_group_quotas); diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index bf59d3caae..bac5cd7650 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -133,10 +133,10 @@ var group_quotas_tmpl = '
\
\
\
\ -
\ +
\ \
\ -
\ +
\ \
\
\ @@ -144,10 +144,10 @@ var group_quotas_tmpl = '
\
\
\
\ -
\ +
\ \
\ -
\ +
\ \
\
\ @@ -155,16 +155,27 @@ var group_quotas_tmpl = '
\
\
\
\ -
\ +
\ \
\ -
\ +
\ \
\
\
\
\
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\
\
\
\ @@ -528,9 +539,10 @@ function updateGroupInfo(request,group){ var info = group.GROUP; var default_group_quotas = Quotas.default_quotas(info.DEFAULT_GROUP_QUOTAS); - var quotas_tab_html = '
' + Quotas.vms(info, default_group_quotas) + '
'; - quotas_tab_html += '
' + Quotas.cpu(info, default_group_quotas) + '
'; - quotas_tab_html += '
' + Quotas.memory(info, default_group_quotas) + '
'; + var quotas_tab_html = '
' + Quotas.vms(info, default_group_quotas) + '
'; + quotas_tab_html += '
' + Quotas.cpu(info, default_group_quotas) + '
'; + quotas_tab_html += '
' + Quotas.memory(info, default_group_quotas) + '
'; + quotas_tab_html += '
' + Quotas.volatile_size(info, default_group_quotas) + '
'; quotas_tab_html += '

'; quotas_tab_html += '
' + Quotas.image(info, default_group_quotas) + '
'; quotas_tab_html += '
' + Quotas.network(info, default_group_quotas) + '
'; diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index 2a1aa1d57a..2add849c63 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -219,10 +219,10 @@ var user_quotas_tmpl = '
\
\
\
\ -
\ +
\ \
\ -
\ +
\ \
\
\ @@ -230,10 +230,10 @@ var user_quotas_tmpl = '
\
\
\
\ -
\ +
\ \
\ -
\ +
\ \
\
\ @@ -241,16 +241,27 @@ var user_quotas_tmpl = '
\
\
\
\ -
\ +
\ \
\ -
\ +
\ \
\
\
\
\
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\
\
\
\ @@ -780,9 +791,10 @@ function updateUserInfo(request,user){ }; var default_user_quotas = Quotas.default_quotas(info.DEFAULT_USER_QUOTAS) - var quotas_tab_html = '
' + Quotas.vms(info, default_user_quotas) + '
'; - quotas_tab_html += '
' + Quotas.cpu(info, default_user_quotas) + '
'; - quotas_tab_html += '
' + Quotas.memory(info, default_user_quotas) + '
'; + var quotas_tab_html = '
' + Quotas.vms(info, default_user_quotas) + '
'; + quotas_tab_html += '
' + Quotas.cpu(info, default_user_quotas) + '
'; + quotas_tab_html += '
' + Quotas.memory(info, default_user_quotas) + '
'; + quotas_tab_html += '
' + Quotas.volatile_size(info, default_user_quotas) + '
'; quotas_tab_html += '

'; quotas_tab_html += '
' + Quotas.image(info, default_user_quotas) + '
'; quotas_tab_html += '
' + Quotas.network(info, default_user_quotas) + '
'; diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 24062c3a13..c2804934b9 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -1238,6 +1238,21 @@ var Quotas = { return ''; } }, + "volatile_size" : function(info, default_quotas){ + if (!$.isEmptyObject(info.VM_QUOTA)){ + var volatile_bar = quotaBarMB( + info.VM_QUOTA.VM.VOLATILE_SIZE_USED, + info.VM_QUOTA.VM.VOLATILE_SIZE, + default_quotas.VM_QUOTA.VM.VOLATILE_SIZE); + + var quotas_tab_html = + '
' + tr("Volatile disks") + '
'+volatile_bar+'

' + + return quotas_tab_html; + } else { + return ''; + } + }, "datastore" : function(info, default_quotas) { if (!$.isEmptyObject(info.DATASTORE_QUOTA)){ var quotas_tab_html = @@ -1410,9 +1425,10 @@ var Quotas = { if ($.isEmptyObject(default_quotas.VM_QUOTA)){ default_quotas.VM_QUOTA = { "VM" : { - "VMS" : "0", - "MEMORY" : "0", - "CPU" : "0" + "VMS" : "0", + "MEMORY" : "0", + "CPU" : "0", + "VOLATILE_SIZE" : "0" } } } @@ -1581,6 +1597,7 @@ function setupQuotaIcons(){ $('div#vm_quota input[name="VMS"]',dialog).val(quota.VMS); $('div#vm_quota input[name="MEMORY"]',dialog).val(quota.MEMORY); $('div#vm_quota input[name="CPU"]',dialog).val(quota.CPU); + $('div#vm_quota input[name="VOLATILE_SIZE"]',dialog).val(quota.VOLATILE_SIZE); break; case "DATASTORE": $('div#datastore_quota select[name="ID"]',dialog).val(quota.ID); @@ -1675,7 +1692,8 @@ function quotaListItem(quota_json){ case "VM": str += 'VMs: ' + quota_json.VMS + (quota_json.VMS_USED ? ' (' + quota_json.VMS_USED + '). ' : ". ") + '
' + 'Memory: ' + quota_json.MEMORY + (quota_json.MEMORY_USED ? ' MB (' + quota_json.MEMORY_USED + ' MB). ' : " MB. ") + '
' + - 'CPU: ' + quota_json.CPU + (quota_json.CPU_USED ? ' (' + quota_json.CPU_USED + '). ' : ". "); + 'CPU: ' + quota_json.CPU + (quota_json.CPU_USED ? ' (' + quota_json.CPU_USED + '). ' : ". ") + '
' + + 'Volatile disks: ' + quota_json.VOLATILE_SIZE + (quota_json.VOLATILE_SIZE_USED ? ' MB (' + quota_json.VOLATILE_SIZE_USED + ' MB). ' : " MB. "); break; case "DATASTORE": str += 'ID/Name: ' + getDatastoreName(quota_json.ID) + '. ' + '
' + From c783b963f46bfe84abece78634f14843e21cddd4 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Wed, 9 Oct 2013 15:41:16 +0200 Subject: [PATCH 15/44] Feature #2092: Put hybrid checks in do_action for better coding understanding --- src/tm/TransferManager.cc | 128 +++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 37 deletions(-) diff --git a/src/tm/TransferManager.cc b/src/tm/TransferManager.cc index 1ace1db10b..04e5710e42 100644 --- a/src/tm/TransferManager.cc +++ b/src/tm/TransferManager.cc @@ -148,7 +148,11 @@ void TransferManager::trigger(Actions action, int _vid) void TransferManager::do_action(const string &action, void * arg) { - int vid; + int vid; + VirtualMachine * vm; + Host * host; + bool host_is_hybrid; + Nebula& nd = Nebula::instance(); if (arg == 0) { @@ -159,41 +163,118 @@ void TransferManager::do_action(const string &action, void * arg) delete static_cast(arg); + vm = vmpool->get(vid,true); + + if (vm == 0) + { + return; + } + + host = hpool->get(vm->get_hid(),true); + host_is_hybrid=host->isHybrid(); + + vm->unlock(); + host->unlock(); + if (action == "PROLOG") { - prolog_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid); + } + else + { + prolog_action(vid); + } } else if (action == "PROLOG_MIGR") { - prolog_migr_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid); + } + else + { + prolog_migr_action(vid); + } } else if (action == "PROLOG_RESUME") { - prolog_resume_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid); + } + else + { + prolog_resume_action(vid); + } } else if (action == "EPILOG") { - epilog_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + } + else + { + epilog_action(vid); + } } else if (action == "EPILOG_STOP") { - epilog_stop_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + } + else + { + epilog_stop_action(vid); + } } else if (action == "EPILOG_DELETE") { - epilog_delete_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + } + else + { + epilog_delete_action(vid); + } } else if (action == "EPILOG_DELETE_STOP") { - epilog_delete_stop_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + } + else + { + epilog_delete_stop_action(vid); + } } else if (action == "EPILOG_DELETE_PREVIOUS") { - epilog_delete_previous_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + } + else + { + epilog_delete_previous_action(vid); + + } } else if (action == "EPILOG_DELETE_BOTH") { - epilog_delete_both_action(vid); + if (host_is_hybrid) + { + (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); + } + else + { + epilog_delete_both_action(vid); + } } else if (action == "CHECKPOINT") { @@ -436,8 +517,6 @@ void TransferManager::prolog_action(int vid) string error_str; VirtualMachine * vm; - Host * host; - bool host_is_hybrid; Nebula& nd = Nebula::instance(); const TransferManagerDriver * tm_md; @@ -464,17 +543,6 @@ void TransferManager::prolog_action(int vid) int uid = vm->get_uid(); vm->unlock(); - host = hpool->get(vm->get_hid(),true); - host_is_hybrid=host->isHybrid(); - host->unlock(); - - if (host_is_hybrid) - { - vm->unlock(); - (nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid); - return; - } - User * user = Nebula::instance().get_upool()->get(uid, true); if (user != 0) @@ -1053,9 +1121,6 @@ void TransferManager::epilog_action(int vid) VirtualMachine * vm; Nebula& nd = Nebula::instance(); - Host * host; - bool host_is_hybrid; - const TransferManagerDriver * tm_md; vector attrs; @@ -1076,17 +1141,6 @@ void TransferManager::epilog_action(int vid) goto error_history; } - host = hpool->get(vm->get_hid(),true); - host_is_hybrid=host->isHybrid(); - host->unlock(); - - if (host_is_hybrid) - { - vm->unlock(); - (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); - return; - } - vm_tm_mad = vm->get_tm_mad(); vm_ds_id = vm->get_ds_id(); tm_md = get(); From 2b92010fef5c7189b4a9f369574f4b10b4dff8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 9 Oct 2013 18:01:47 +0200 Subject: [PATCH 16/44] Feature #1612: Add VOLATILE_SIZE quota to onedb migrator and fsck --- src/onedb/4.2.0_to_4.3.80.rb | 122 ++++++++++++++++++++++++++++++++++- src/onedb/fsck.rb | 34 ++++++++++ 2 files changed, 155 insertions(+), 1 deletion(-) diff --git a/src/onedb/4.2.0_to_4.3.80.rb b/src/onedb/4.2.0_to_4.3.80.rb index e79db99b15..4c893b9b03 100644 --- a/src/onedb/4.2.0_to_4.3.80.rb +++ b/src/onedb/4.2.0_to_4.3.80.rb @@ -28,7 +28,7 @@ module Migrator def up ######################################################################## - # Feature #1742 + # Feature #1742 & #1612 ######################################################################## @db.run "ALTER TABLE user_pool RENAME TO old_user_pool;" @@ -39,6 +39,11 @@ module Migrator doc.root.add_element("GROUPS").add_element("ID").text = row[:gid].to_s + # oneadmin does not have quotas + if row[:oid] != 0 + redo_vm_quotas(doc, "uid=#{row[:oid]}") + end + @db[:user_pool].insert( :oid => row[:oid], :name => row[:name], @@ -52,6 +57,44 @@ module Migrator @db.run "DROP TABLE old_user_pool;" + ######################################################################## + # Feature #1612 + ######################################################################## + + @db.run "ALTER TABLE group_pool RENAME TO old_group_pool;" + @db.run "CREATE TABLE group_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name));" + + # oneadmin group does not have quotas + @db.fetch("SELECT * FROM old_group_pool WHERE oid=0") do |row| + @db[:group_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => row[:body], + :uid => row[:oid], + :gid => row[:gid], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u]) + end + + @db.fetch("SELECT * FROM old_group_pool WHERE oid>0") do |row| + doc = REXML::Document.new(row[:body]) + + redo_vm_quotas(doc, "gid=#{row[:oid]}") + + @db[:group_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :uid => row[:oid], + :gid => row[:gid], + :owner_u => row[:owner_u], + :group_u => row[:group_u], + :other_u => row[:other_u]) + end + + @db.run "DROP TABLE old_group_pool;" + ######################################################################## # Bug #2330 ######################################################################## @@ -82,4 +125,81 @@ module Migrator return true end + + def redo_vm_quotas(doc, where_filter) + cpu_limit = "-1" + mem_limit = "-1" + vms_limit = "-1" + vol_limit = "-1" + + doc.root.each_element("VM_QUOTA/VM/CPU") { |e| + cpu_limit = e.text + } + + doc.root.each_element("VM_QUOTA/VM/MEMORY") { |e| + mem_limit = e.text + } + + doc.root.each_element("VM_QUOTA/VM/VMS") { |e| + vms_limit = e.text + } + + doc.root.delete_element("VM_QUOTA") + vm_quota = doc.root.add_element("VM_QUOTA") + + # VM quotas + cpu_used = 0 + mem_used = 0 + vms_used = 0 + vol_used = 0 + + @db.fetch("SELECT body FROM vm_pool WHERE #{where_filter} AND state<>6") do |vm_row| + vmdoc = REXML::Document.new(vm_row[:body]) + + # VM quotas + vmdoc.root.each_element("TEMPLATE/CPU") { |e| + cpu_used += e.text.to_f + } + + vmdoc.root.each_element("TEMPLATE/MEMORY") { |e| + mem_used += e.text.to_i + } + + vmdoc.root.each_element("TEMPLATE/DISK") { |e| + type = "" + + e.each_element("TYPE") { |t_elem| + type = t_elem.text.upcase + } + + if ( type == "SWAP" || type == "FS") + e.each_element("SIZE") { |size_elem| + vol_used += size_elem.text.to_f + } + end + } + + vms_used += 1 + end + + if (vms_used != 0 || + cpu_limit != "-1" || mem_limit != "-1" || vms_limit != "-1" || vol_limit != "-1" ) + + # VM quotas + vm_elem = vm_quota.add_element("VM") + + vm_elem.add_element("CPU").text = cpu_limit + vm_elem.add_element("CPU_USED").text = sprintf('%.2f', cpu_used) + + vm_elem.add_element("MEMORY").text = mem_limit + vm_elem.add_element("MEMORY_USED").text = mem_used.to_s + + vm_elem.add_element("VMS").text = vms_limit + vm_elem.add_element("VMS_USED").text = vms_used.to_s + + vm_elem.add_element("VOLATILE_SIZE").text = vol_limit + vm_elem.add_element("VOLATILE_SIZE_USED").text = sprintf('%.2f', vol_used) + end + end + end diff --git a/src/onedb/fsck.rb b/src/onedb/fsck.rb index 1d29fd41fd..d01c217ef3 100644 --- a/src/onedb/fsck.rb +++ b/src/onedb/fsck.rb @@ -1286,6 +1286,7 @@ module OneDBFsck cpu_used = 0.0 mem_used = 0 vms_used = 0 + vol_used = 0.0 # VNet quotas vnet_usage = {} @@ -1301,12 +1302,28 @@ module OneDBFsck # truncate to 2 decimals cpu = (e.text.to_f * 100).to_i / 100.0 cpu_used += cpu + cpu_used = (cpu_used * 100).to_i / 100.0 } vmdoc.root.each_element("TEMPLATE/MEMORY") { |e| mem_used += e.text.to_i } + vmdoc.root.each_element("TEMPLATE/DISK") { |e| + type = "" + + e.each_element("TYPE") { |t_elem| + type = t_elem.text.upcase + } + + if ( type == "SWAP" || type == "FS") + e.each_element("SIZE") { |size_elem| + vol_used += size_elem.text.to_f + vol_used = (vol_used * 100).to_i / 100.0 + } + end + } + vms_used += 1 # VNet quotas @@ -1342,6 +1359,9 @@ module OneDBFsck vm_elem.add_element("VMS").text = "-1" vm_elem.add_element("VMS_USED").text = "0" + + vm_elem.add_element("VOLATILE_SIZE").text = "-1" + vm_elem.add_element("VOLATILE_SIZE_USED").text = "0" end @@ -1378,6 +1398,20 @@ module OneDBFsck end } + vm_elem.each_element("VOLATILE_SIZE_USED") { |e| + # Check if the float value or the string representation mismatch, + # but ignoring the precision + + different = ( e.text.to_f != vol_used || + ![sprintf('%.2f', vol_used), sprintf('%.1f', vol_used), sprintf('%.0f', vol_used)].include?(e.text) ) + + vol_used_str = sprintf('%.2f', vol_used) + + if different + log_error("#{resource} #{oid} quotas: VOLATILE_SIZE_USED has #{e.text} \tis\t#{vol_used_str}") + e.text = vol_used_str + end + } # VNet quotas From 1f3a60070a44d896d2318ea47f3a2a6e8251020b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 9 Oct 2013 18:02:12 +0200 Subject: [PATCH 17/44] Feature #1612: Add VOLATILE_SIZE quota to xsd doc files --- share/doc/xsd/group.xsd | 2 ++ share/doc/xsd/group_pool.xsd | 2 ++ share/doc/xsd/user.xsd | 2 ++ share/doc/xsd/user_pool.xsd | 2 ++ 4 files changed, 8 insertions(+) diff --git a/share/doc/xsd/group.xsd b/share/doc/xsd/group.xsd index 56c2438f7c..f34dee62fb 100644 --- a/share/doc/xsd/group.xsd +++ b/share/doc/xsd/group.xsd @@ -57,6 +57,8 @@ + + diff --git a/share/doc/xsd/group_pool.xsd b/share/doc/xsd/group_pool.xsd index a217be7b08..3ff318f090 100644 --- a/share/doc/xsd/group_pool.xsd +++ b/share/doc/xsd/group_pool.xsd @@ -60,6 +60,8 @@ + + diff --git a/share/doc/xsd/user.xsd b/share/doc/xsd/user.xsd index d2eae5fe4e..7716f54cb1 100644 --- a/share/doc/xsd/user.xsd +++ b/share/doc/xsd/user.xsd @@ -63,6 +63,8 @@ + + diff --git a/share/doc/xsd/user_pool.xsd b/share/doc/xsd/user_pool.xsd index c7d72c0594..af35614963 100644 --- a/share/doc/xsd/user_pool.xsd +++ b/share/doc/xsd/user_pool.xsd @@ -67,6 +67,8 @@ + + From 09fe471af6616c5cfa1293b9ef1b91025d2708c4 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 9 Oct 2013 18:39:18 +0200 Subject: [PATCH 18/44] feature #1683: Renamed Nebula::init() to Nebula::bootstrap_db() --- include/Nebula.h | 2 +- src/nebula/Nebula.cc | 2 +- src/nebula/oned.cc | 74 ++++++++++++++++++++++---------------------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index 2db19d6725..d62a55ed94 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -346,7 +346,7 @@ public: /** * Initialize the database */ - void init(); + void bootstrap_db(); // ----------------------------------------------------------------------- // Configuration attributes (read from oned.conf) diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 7f78165fb7..66a03d9494 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -268,7 +268,7 @@ int SystemDB::select_sys_attribute(const string& attr_name, string& attr_xml) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void Nebula::init() +void Nebula::bootstrap_db() { start(true); } diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index 457ab7b71c..5cfeda178f 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -59,12 +59,12 @@ static void oned_init() try { Nebula& nd = Nebula::instance(); - nd.init(); + nd.bootstrap_db(); } catch (exception &e) { cerr << e.what() << endl; - + return; } } @@ -77,19 +77,19 @@ static void oned_main() try { Nebula& nd = Nebula::instance(); - nd.start(); + nd.start(); } catch (exception &e) { cerr << e.what() << endl; - + return; } } - + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - + int main(int argc, char **argv) { int opt; @@ -99,7 +99,7 @@ int main(int argc, char **argv) pid_t pid,sid; string wd; int rc; - + while((opt = getopt(argc,argv,"vhif")) != -1) switch(opt) { @@ -117,7 +117,7 @@ int main(int argc, char **argv) break; case 'f': foreground = true; - break; + break; default: cerr << susage; exit(-1); @@ -125,24 +125,24 @@ int main(int argc, char **argv) } // --------------------------------- - // Check if other oned is running - // --------------------------------- - + // Check if other oned is running + // --------------------------------- + string lockfile; string var_location; - + nl = getenv("ONE_LOCATION"); if (nl == 0) // OpenNebula in root of FSH { - var_location = "/var/lib/one/"; + var_location = "/var/lib/one/"; lockfile = "/var/lock/one/one"; } else { var_location = nl; var_location += "/var/"; - + lockfile = var_location + ".lock"; } @@ -150,70 +150,70 @@ int main(int argc, char **argv) if( fd == -1) { - cerr<< "Error: Cannot start oned, opening lock file " << lockfile + cerr<< "Error: Cannot start oned, opening lock file " << lockfile << endl; - + exit(-1); } close(fd); - - // ---------------------------- - // Fork & exit main process - // ---------------------------- - + + // ---------------------------- + // Fork & exit main process + // ---------------------------- + if (foreground == true) { pid = 0; //Do not fork } else { - pid = fork(); + pid = fork(); } - + switch (pid){ case -1: // Error - cerr << "Error: Unable to fork.\n"; + cerr << "Error: Unable to fork.\n"; exit(-1); - + case 0: // Child process - + rc = chdir(var_location.c_str()); - + if (rc != 0) { goto error_chdir; } - + if (foreground == false) - { + { sid = setsid(); - + if (sid == -1) { goto error_sid; } } - + oned_main(); - - unlink(lockfile.c_str()); + + unlink(lockfile.c_str()); break; default: // Parent process - break; + break; } - + return 0; - + error_chdir: cerr << "Error: cannot change to dir " << wd << "\n"; unlink(lockfile.c_str()); exit(-1); -error_sid: +error_sid: cerr << "Error: creating new session\n"; unlink(lockfile.c_str()); exit(-1); From 38ad6cebebbbf2149be67ecfaa7eaec01ff9d27e Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 10 Oct 2013 13:07:33 +0200 Subject: [PATCH 19/44] feature #2092: Make use of hybrid hypervisor instead of attribute --- include/Host.h | 15 ++++++++++++++- include/VirtualMachineTemplate.h | 11 +++++++---- src/vm/VirtualMachine.cc | 8 ++------ src/vm/VirtualMachineTemplate.cc | 5 +++-- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/include/Host.h b/include/Host.h index 29e7d40e6c..2ca409d055 100644 --- a/include/Host.h +++ b/include/Host.h @@ -92,6 +92,15 @@ public: */ bool isHybrid() const; + /** + * Return an element of the hypervisor array. The calling function + * must check that the index is valid. + */ + static const char * get_hybrid_hypervisor_by_id(int i) + { + return HYBRID_HYPERVISORS[i]; + } + /** * Disables the current host, it will not be monitored nor used by the * scheduler @@ -498,7 +507,11 @@ private: static const char * monit_table; /** - * Array containing the hybrid hypervisors, and counter + * Array containing the hybrid hypervisors, and counter. There is a + * correspondence between Host::HYBRID_HYPERVISOR and + * VirtualMachine::HYBRID_ATTRIBUTES. Attributes in HYBRID_ATTRIBUTES[i] are + * meant to be used in hosts reporting a a hypervisor of type + * HYBRID_HYPERVISOR[i] */ static const char * HYBRID_HYPERVISORS[]; diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h index 1d14ccc7e1..a30132e78e 100644 --- a/include/VirtualMachineTemplate.h +++ b/include/VirtualMachineTemplate.h @@ -68,9 +68,9 @@ public: void remove_all_except_restricted(); /** - * Returns a copy of the VirtualMachineTemplate + * Returns the hypervisor name if the template is hybrid * @param hypervisor the resulting hypervisor string - * @return true if any hybrid hypervisor found, false otherwise + * @return true if any hybrid hypervisor attribute found, false otherwise */ bool get_hybrid_hypervisor(string& hypervisor) const; @@ -80,9 +80,12 @@ private: static vector restricted_attributes; - /** - * Array containing the hybrid attributes, and counter + * Array containing the hybrid attributes, and counter. There is a + * correspondence between Host::HYBRID_HYPERVISOR and + * VirtualMachine::HYBRID_ATTRIBUTES. Attributes in HYBRID_ATTRIBUTES[i] are + * meant to be used in hosts reporting a a hypervisor of type + * HYBRID_HYPERVISOR[i] */ static const char * HYBRID_ATTRIBUTES[]; diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 833bf953d3..f84011c1e8 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -251,7 +251,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) string value; int ivalue; float fvalue; - + ostringstream oss; // ------------------------------------------------------------------------ @@ -1144,16 +1144,12 @@ int VirtualMachine::automatic_requirements(string& error_str) } } - static_cast(obj_template)->get_hybrid_hypervisor( - hypervisor); - oss.str(""); - if ( !cluster_id.empty() ) { oss << "CLUSTER_ID = " << cluster_id; } - if ( !hypervisor.empty() ) + if (static_cast(obj_template)->get_hybrid_hypervisor(hypervisor)) { if ( !cluster_id.empty() ) { diff --git a/src/vm/VirtualMachineTemplate.cc b/src/vm/VirtualMachineTemplate.cc index b18d177800..6504727a17 100644 --- a/src/vm/VirtualMachineTemplate.cc +++ b/src/vm/VirtualMachineTemplate.cc @@ -15,6 +15,7 @@ /* -------------------------------------------------------------------------- */ #include "VirtualMachineTemplate.h" +#include "Host.h" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -151,10 +152,10 @@ bool VirtualMachineTemplate::get_hybrid_hypervisor(string& hypervisor) const bool found_it = false; for(int i=0; i < NUM_HYBRID_ATTRIBUTES; i++) - { + { if(get(HYBRID_ATTRIBUTES[i],attrs)) { - hypervisor = HYBRID_ATTRIBUTES[i]; + hypervisor = Host::get_hybrid_hypervisor_by_id(i); found_it = true; break; } From 18d67d02af80f4c0ff7470e06e56977bd715c4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 10 Oct 2013 18:09:13 +0200 Subject: [PATCH 20/44] Feature #1712: Fix scheduler resched migration --- src/scheduler/src/sched/Scheduler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 220fa426cf..c959eb6634 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -863,7 +863,7 @@ void Scheduler::dispatch() //------------------------------------------------------------------ // Dispatch and update host and DS capacity, and dispatch counters //------------------------------------------------------------------ - if (vmpool->dispatch(vm_it->first, hid, dsid, false) != 0) + if (vmpool->dispatch(vm_it->first, hid, dsid, vm->is_resched()) != 0) { continue; } From 37e065b7f7c1f9f6b47b6dad06d6f004f6c827f8 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Fri, 11 Oct 2013 16:37:35 +0200 Subject: [PATCH 21/44] Bump to version 4.3.80 --- include/Nebula.h | 4 ++-- share/man/econe-allocate-address.1 | 4 ++-- share/man/econe-associate-address.1 | 4 ++-- share/man/econe-attach-volume.1 | 4 ++-- share/man/econe-create-keypair.1 | 4 ++-- share/man/econe-create-volume.1 | 4 ++-- share/man/econe-delete-keypair.1 | 4 ++-- share/man/econe-delete-volume.1 | 4 ++-- share/man/econe-describe-addresses.1 | 4 ++-- share/man/econe-describe-images.1 | 4 ++-- share/man/econe-describe-instances.1 | 4 ++-- share/man/econe-describe-keypairs.1 | 4 ++-- share/man/econe-describe-volumes.1 | 4 ++-- share/man/econe-detach-volume.1 | 4 ++-- share/man/econe-disassociate-address.1 | 4 ++-- share/man/econe-reboot-instances.1 | 4 ++-- share/man/econe-register.1 | 4 ++-- share/man/econe-release-address.1 | 4 ++-- share/man/econe-run-instances.1 | 4 ++-- share/man/econe-start-instances.1 | 4 ++-- share/man/econe-stop-instances.1 | 4 ++-- share/man/econe-terminate-instances.1 | 4 ++-- share/man/econe-upload.1 | 4 ++-- share/man/occi-compute.1 | 2 +- share/man/occi-instance-type.1 | 2 +- share/man/occi-network.1 | 2 +- share/man/occi-storage.1 | 2 +- share/man/oneacct.1 | 4 ++-- share/man/oneacl.1 | 4 ++-- share/man/onecluster.1 | 7 ++++-- share/man/onedatastore.1 | 7 ++++-- share/man/onedb.1 | 2 +- share/man/oneflow-template.1 | 4 ++-- share/man/oneflow.1 | 4 ++-- share/man/onegroup.1 | 4 ++-- share/man/onehost.1 | 7 ++++-- share/man/oneimage.1 | 4 ++-- share/man/onetemplate.1 | 18 +++++++++++---- share/man/oneuser.1 | 12 +++++++--- share/man/onevdc.1 | 4 ++-- share/man/onevm.1 | 23 +++++++++++++++---- share/man/onevnet.1 | 4 ++-- share/man/onezone.1 | 4 ++-- share/rubygems/generate | 2 +- share/scripts/context-packages/generate.sh | 2 +- src/cloud/common/CloudClient.rb | 2 +- .../src/org/opennebula/client/OneSystem.java | 2 +- src/oca/ruby/opennebula.rb | 2 +- src/onedb/fsck.rb | 2 +- src/ozones/Server/templates/index.html | 2 +- src/ozones/Server/templates/login.html | 2 +- src/sunstone/views/index.erb | 2 +- src/sunstone/views/login.erb | 2 +- 53 files changed, 135 insertions(+), 97 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index d62a55ed94..ce98100187 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -330,12 +330,12 @@ public: */ static string version() { - return "OpenNebula 4.3.0"; + return "OpenNebula 4.3.80"; }; static string db_version() { - return "4.3.0"; + return "4.3.80"; } /** diff --git a/share/man/econe-allocate-address.1 b/share/man/econe-allocate-address.1 index 2dfc9c5ce5..9f88ec3a47 100644 --- a/share/man/econe-allocate-address.1 +++ b/share/man/econe-allocate-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-ALLOCATE\-ADDRESS" "1" "August 2013" "" "econe-allocate-address(1) -- Allocates a new elastic IP address for the user" +.TH "ECONE\-ALLOCATE\-ADDRESS" "1" "October 2013" "" "econe-allocate-address(1) -- Allocates a new elastic IP address for the user" . .SH "NAME" \fBecone\-allocate\-address\fR @@ -39,7 +39,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-associate-address.1 b/share/man/econe-associate-address.1 index 2b40789570..50ea57631d 100644 --- a/share/man/econe-associate-address.1 +++ b/share/man/econe-associate-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-ASSOCIATE\-ADDRESS" "1" "August 2013" "" "econe-associate-address(1) -- Associates a publicIP of the user with a given instance" +.TH "ECONE\-ASSOCIATE\-ADDRESS" "1" "October 2013" "" "econe-associate-address(1) -- Associates a publicIP of the user with a given instance" . .SH "NAME" \fBecone\-associate\-address\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-attach-volume.1 b/share/man/econe-attach-volume.1 index 1a89f0e5fa..0b80a1ddf9 100644 --- a/share/man/econe-attach-volume.1 +++ b/share/man/econe-attach-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-ATTACH\-VOLUME" "1" "August 2013" "" "econe-attach-volume(1) -- Attaches a DATABLOCK to an instance" +.TH "ECONE\-ATTACH\-VOLUME" "1" "October 2013" "" "econe-attach-volume(1) -- Attaches a DATABLOCK to an instance" . .SH "NAME" \fBecone\-attach\-volume\fR @@ -45,7 +45,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-create-keypair.1 b/share/man/econe-create-keypair.1 index 44fa3b778c..7bb79cd531 100644 --- a/share/man/econe-create-keypair.1 +++ b/share/man/econe-create-keypair.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-CREATE\-KEYPAIR" "1" "August 2013" "" "econe-create-keypair(1) -- Creates the named keypair" +.TH "ECONE\-CREATE\-KEYPAIR" "1" "October 2013" "" "econe-create-keypair(1) -- Creates the named keypair" . .SH "NAME" \fBecone\-create\-keypair\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-create-volume.1 b/share/man/econe-create-volume.1 index 578c3590af..edf5de1dd8 100644 --- a/share/man/econe-create-volume.1 +++ b/share/man/econe-create-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-CREATE\-VOLUME" "1" "August 2013" "" "econe-create-volume(1) -- Creates a new DATABLOCK in OpenNebula" +.TH "ECONE\-CREATE\-VOLUME" "1" "October 2013" "" "econe-create-volume(1) -- Creates a new DATABLOCK in OpenNebula" . .SH "NAME" \fBecone\-create\-volume\fR @@ -40,7 +40,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-delete-keypair.1 b/share/man/econe-delete-keypair.1 index a142a23d88..467603f7e4 100644 --- a/share/man/econe-delete-keypair.1 +++ b/share/man/econe-delete-keypair.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DELETE\-KEYPAIR" "1" "August 2013" "" "econe-delete-keypair(1) -- Deletes the named keypair, removes the associated keys" +.TH "ECONE\-DELETE\-KEYPAIR" "1" "October 2013" "" "econe-delete-keypair(1) -- Deletes the named keypair, removes the associated keys" . .SH "NAME" \fBecone\-delete\-keypair\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-delete-volume.1 b/share/man/econe-delete-volume.1 index eb47e26c9c..d34f4906b0 100644 --- a/share/man/econe-delete-volume.1 +++ b/share/man/econe-delete-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DELETE\-VOLUME" "1" "August 2013" "" "econe-delete-volume(1) -- Deletes an existing DATABLOCK" +.TH "ECONE\-DELETE\-VOLUME" "1" "October 2013" "" "econe-delete-volume(1) -- Deletes an existing DATABLOCK" . .SH "NAME" \fBecone\-delete\-volume\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-describe-addresses.1 b/share/man/econe-describe-addresses.1 index d2ff32e20b..5fa9b08800 100644 --- a/share/man/econe-describe-addresses.1 +++ b/share/man/econe-describe-addresses.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-ADDRESSES" "1" "August 2013" "" "econe-describe-addresses(1) -- Lists elastic IP addresses" +.TH "ECONE\-DESCRIBE\-ADDRESSES" "1" "October 2013" "" "econe-describe-addresses(1) -- Lists elastic IP addresses" . .SH "NAME" \fBecone\-describe\-addresses\fR @@ -39,7 +39,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-describe-images.1 b/share/man/econe-describe-images.1 index 12e507e5e3..294eca6ee1 100644 --- a/share/man/econe-describe-images.1 +++ b/share/man/econe-describe-images.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-IMAGES" "1" "August 2013" "" "econe-describe-images(1) -- Lists all registered images belonging to one particular user" +.TH "ECONE\-DESCRIBE\-IMAGES" "1" "October 2013" "" "econe-describe-images(1) -- Lists all registered images belonging to one particular user" . .SH "SYNOPSIS" econe\-describe\-images \fIOPTIONS\fR @@ -36,7 +36,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-describe-instances.1 b/share/man/econe-describe-instances.1 index bc43d2eef2..c4f446cbe5 100644 --- a/share/man/econe-describe-instances.1 +++ b/share/man/econe-describe-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-INSTANCES" "1" "August 2013" "" "econe-describe-instances(1) -- Outputs a list of launched images belonging to one particular user" +.TH "ECONE\-DESCRIBE\-INSTANCES" "1" "October 2013" "" "econe-describe-instances(1) -- Outputs a list of launched images belonging to one particular user" . .SH "NAME" \fBecone\-describe\-instances\fR @@ -39,7 +39,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-describe-keypairs.1 b/share/man/econe-describe-keypairs.1 index dd039a958d..eacb30b6fa 100644 --- a/share/man/econe-describe-keypairs.1 +++ b/share/man/econe-describe-keypairs.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-KEYPAIRS" "1" "August 2013" "" "econe-describe-keypairs(1) -- List and describe the key pairs available to the user" +.TH "ECONE\-DESCRIBE\-KEYPAIRS" "1" "October 2013" "" "econe-describe-keypairs(1) -- List and describe the key pairs available to the user" . .SH "NAME" \fBecone\-describe\-keypairs\fR @@ -39,7 +39,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-describe-volumes.1 b/share/man/econe-describe-volumes.1 index 22d61287f3..312a7fd3da 100644 --- a/share/man/econe-describe-volumes.1 +++ b/share/man/econe-describe-volumes.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DESCRIBE\-VOLUMES" "1" "August 2013" "" "econe-describe-volumes(1) -- Describe all available DATABLOCKs for this user" +.TH "ECONE\-DESCRIBE\-VOLUMES" "1" "October 2013" "" "econe-describe-volumes(1) -- Describe all available DATABLOCKs for this user" . .SH "NAME" \fBecone\-describe\-volumes\fR @@ -39,7 +39,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-detach-volume.1 b/share/man/econe-detach-volume.1 index 523b2f6e72..1b59d49571 100644 --- a/share/man/econe-detach-volume.1 +++ b/share/man/econe-detach-volume.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DETACH\-VOLUME" "1" "August 2013" "" "econe-detach-volume(1) -- Detaches a DATABLOCK from an instance" +.TH "ECONE\-DETACH\-VOLUME" "1" "October 2013" "" "econe-detach-volume(1) -- Detaches a DATABLOCK from an instance" . .SH "NAME" \fBecone\-detach\-volume\fR @@ -45,7 +45,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-disassociate-address.1 b/share/man/econe-disassociate-address.1 index 290c323c08..4dfe0a9a7a 100644 --- a/share/man/econe-disassociate-address.1 +++ b/share/man/econe-disassociate-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-DISASSOCIATE\-ADDRESS" "1" "August 2013" "" "econe-disassociate-address(1) -- Disasociate a publicIP of the user currently associated with an instance" +.TH "ECONE\-DISASSOCIATE\-ADDRESS" "1" "October 2013" "" "econe-disassociate-address(1) -- Disasociate a publicIP of the user currently associated with an instance" . .SH "NAME" \fBecone\-disassociate\-address\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-reboot-instances.1 b/share/man/econe-reboot-instances.1 index fdf2178c92..d9586d2de5 100644 --- a/share/man/econe-reboot-instances.1 +++ b/share/man/econe-reboot-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-REBOOT\-INSTANCES" "1" "August 2013" "" "econe-reboot-instances(1) -- Reboots a set of virtual machines" +.TH "ECONE\-REBOOT\-INSTANCES" "1" "October 2013" "" "econe-reboot-instances(1) -- Reboots a set of virtual machines" . .SH "NAME" \fBecone\-reboot\-instances\fR @@ -45,7 +45,7 @@ instance_id The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-register.1 b/share/man/econe-register.1 index 867b43ccc5..2a46cdb1eb 100644 --- a/share/man/econe-register.1 +++ b/share/man/econe-register.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-REGISTER" "1" "August 2013" "" "econe-register(1) -- Registers an image" +.TH "ECONE\-REGISTER" "1" "October 2013" "" "econe-register(1) -- Registers an image" . .SH "NAME" \fBecone\-register\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-release-address.1 b/share/man/econe-release-address.1 index a4966da799..fd3dc7de63 100644 --- a/share/man/econe-release-address.1 +++ b/share/man/econe-release-address.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-RELEASE\-ADDRESS" "1" "August 2013" "" "econe-release-address(1) -- Releases a publicIP of the user" +.TH "ECONE\-RELEASE\-ADDRESS" "1" "October 2013" "" "econe-release-address(1) -- Releases a publicIP of the user" . .SH "NAME" \fBecone\-release\-address\fR @@ -42,7 +42,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-run-instances.1 b/share/man/econe-run-instances.1 index 8987a8da12..64314bdfca 100644 --- a/share/man/econe-run-instances.1 +++ b/share/man/econe-run-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-RUN\-INSTANCES" "1" "August 2013" "" "econe-run-instances(1) -- Runs an instance of a particular image (that needs to be referenced)" +.TH "ECONE\-RUN\-INSTANCES" "1" "October 2013" "" "econe-run-instances(1) -- Runs an instance of a particular image (that needs to be referenced)" . .SH "NAME" \fBecone\-run\-instances\fR @@ -53,7 +53,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-start-instances.1 b/share/man/econe-start-instances.1 index 950fb5e5b1..5dc2b347c8 100644 --- a/share/man/econe-start-instances.1 +++ b/share/man/econe-start-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-START\-INSTANCES" "1" "August 2013" "" "econe-start-instances(1) -- Starts a set of virtual machines" +.TH "ECONE\-START\-INSTANCES" "1" "October 2013" "" "econe-start-instances(1) -- Starts a set of virtual machines" . .SH "NAME" \fBecone\-start\-instances\fR @@ -45,7 +45,7 @@ instance_id The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-stop-instances.1 b/share/man/econe-stop-instances.1 index 2561b1905f..3d919fca09 100644 --- a/share/man/econe-stop-instances.1 +++ b/share/man/econe-stop-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-STOP\-INSTANCES" "1" "August 2013" "" "econe-stop-instances(1) -- Stops a set of virtual machines" +.TH "ECONE\-STOP\-INSTANCES" "1" "October 2013" "" "econe-stop-instances(1) -- Stops a set of virtual machines" . .SH "NAME" \fBecone\-stop\-instances\fR @@ -45,7 +45,7 @@ instance_id The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-terminate-instances.1 b/share/man/econe-terminate-instances.1 index 441c666978..b806a4da45 100644 --- a/share/man/econe-terminate-instances.1 +++ b/share/man/econe-terminate-instances.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-TERMINATE\-INSTANCES" "1" "August 2013" "" "econe-terminate-instances(1) -- Shutdowns a set of virtual machines (or cancel, depending on its state)" +.TH "ECONE\-TERMINATE\-INSTANCES" "1" "October 2013" "" "econe-terminate-instances(1) -- Shutdowns a set of virtual machines (or cancel, depending on its state)" . .SH "NAME" \fBecone\-terminate\-instances\fR @@ -45,7 +45,7 @@ instance_id The IDs of instances, comma\-separated .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/econe-upload.1 b/share/man/econe-upload.1 index 9229db88b2..a3392659a3 100644 --- a/share/man/econe-upload.1 +++ b/share/man/econe-upload.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ECONE\-UPLOAD" "1" "August 2013" "" "econe-upload(1) -- Uploads an image to OpenNebula" +.TH "ECONE\-UPLOAD" "1" "October 2013" "" "econe-upload(1) -- Uploads an image to OpenNebula" . .SH "NAME" \fBecone\-upload\fR @@ -43,7 +43,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/occi-compute.1 b/share/man/occi-compute.1 index 58aa18db76..465972e6d0 100644 --- a/share/man/occi-compute.1 +++ b/share/man/occi-compute.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "August 2013" "OpenNebula 4.3.0" "User Commands" +.TH OPENNEBULA "1" "October 2013" "OpenNebula 4.3.80" "User Commands" .SH NAME OpenNebula \- OCCI Manage Compute .SH SYNOPSIS diff --git a/share/man/occi-instance-type.1 b/share/man/occi-instance-type.1 index ff6ad134f7..8244aeeeaa 100644 --- a/share/man/occi-instance-type.1 +++ b/share/man/occi-instance-type.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "August 2013" "OpenNebula 4.3.0" "User Commands" +.TH OPENNEBULA "1" "October 2013" "OpenNebula 4.3.80" "User Commands" .SH NAME OpenNebula \- OCCI Manage Instance .SH SYNOPSIS diff --git a/share/man/occi-network.1 b/share/man/occi-network.1 index a2e846b674..bbb14c6932 100644 --- a/share/man/occi-network.1 +++ b/share/man/occi-network.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "August 2013" "OpenNebula 4.3.0" "User Commands" +.TH OPENNEBULA "1" "October 2013" "OpenNebula 4.3.80" "User Commands" .SH NAME OpenNebula \- OCCI Manage Network .SH SYNOPSIS diff --git a/share/man/occi-storage.1 b/share/man/occi-storage.1 index 07fc876812..599378bb08 100644 --- a/share/man/occi-storage.1 +++ b/share/man/occi-storage.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "August 2013" "OpenNebula 4.3.0" "User Commands" +.TH OPENNEBULA "1" "October 2013" "OpenNebula 4.3.80" "User Commands" .SH NAME OpenNebula \- OCCI Manage Storage .SH SYNOPSIS diff --git a/share/man/oneacct.1 b/share/man/oneacct.1 index 0719873349..34f01e58b5 100644 --- a/share/man/oneacct.1 +++ b/share/man/oneacct.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEACCT" "1" "August 2013" "" "oneacct(1) -- OpenNebula Accounting Tool" +.TH "ONEACCT" "1" "October 2013" "" "oneacct(1) -- OpenNebula Accounting Tool" . .SH "NAME" \fBoneacct\fR @@ -46,7 +46,7 @@ text String .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/oneacl.1 b/share/man/oneacl.1 index 0e87b1c3f0..9f757e75cf 100644 --- a/share/man/oneacl.1 +++ b/share/man/oneacl.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEACL" "1" "August 2013" "" "oneacl(1) -- manages OpenNebula ACLs" +.TH "ONEACL" "1" "October 2013" "" "oneacl(1) -- manages OpenNebula ACLs" . .SH "NAME" \fBoneacl\fR @@ -54,7 +54,7 @@ aclid_list Comma\-separated list of OpenNebula ACL names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onecluster.1 b/share/man/onecluster.1 index 99687e4632..a71592a242 100644 --- a/share/man/onecluster.1 +++ b/share/man/onecluster.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONECLUSTER" "1" "August 2013" "" "onecluster(1) -- manages OpenNebula clusters" +.TH "ONECLUSTER" "1" "October 2013" "" "onecluster(1) -- manages OpenNebula clusters" . .SH "NAME" \fBonecluster\fR @@ -65,6 +65,9 @@ delvnet \fIclusterid\fR \fIvnetid\fR Deletes a Virtual Network from the given Cl .IP "\(bu" 4 update \fIclusterid\fR [\fIfile\fR] Update the template contents\. If a path is not provided the editor will be launched to modify the current content\. valid options: append . +.IP "\(bu" 4 +rename \fIclusterid\fR \fIname\fR Renames the Cluster +. .IP "" 0 . .SH "ARGUMENT FORMATS" @@ -96,7 +99,7 @@ datastoreid OpenNebula DATASTORE name or id .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onedatastore.1 b/share/man/onedatastore.1 index f7a0f4a4f4..3996cc7a46 100644 --- a/share/man/onedatastore.1 +++ b/share/man/onedatastore.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEDATASTORE" "1" "August 2013" "" "onedatastore(1) -- manages OpenNebula datastores" +.TH "ONEDATASTORE" "1" "October 2013" "" "onedatastore(1) -- manages OpenNebula datastores" . .SH "NAME" \fBonedatastore\fR @@ -57,6 +57,9 @@ show \fIdatastoreid\fR Shows information for the given Datastore valid options: .IP "\(bu" 4 update \fIdatastoreid\fR [\fIfile\fR] Update the template contents\. If a path is not provided the editor will be launched to modify the current content\. valid options: append . +.IP "\(bu" 4 +rename \fIdatastoreid\fR \fIname\fR Renames the Datastore +. .IP "" 0 . .SH "ARGUMENT FORMATS" @@ -88,7 +91,7 @@ userid OpenNebula USER name or id .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onedb.1 b/share/man/onedb.1 index 38ea32ac36..276ecd9914 100644 --- a/share/man/onedb.1 +++ b/share/man/onedb.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEDB" "1" "August 2013" "" "onedb(1) -- OpenNebula database migration tool" +.TH "ONEDB" "1" "October 2013" "" "onedb(1) -- OpenNebula database migration tool" . .SH "NAME" \fBonedb\fR diff --git a/share/man/oneflow-template.1 b/share/man/oneflow-template.1 index e70fbcf2f2..a90adc9f71 100644 --- a/share/man/oneflow-template.1 +++ b/share/man/oneflow-template.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEFLOW\-TEMPLATE" "1" "August 2013" "" "oneflow-template(1) -- Manage oneFlow Templates" +.TH "ONEFLOW\-TEMPLATE" "1" "October 2013" "" "oneflow-template(1) -- Manage oneFlow Templates" . .SH "NAME" \fBoneflow\-template\fR @@ -84,7 +84,7 @@ templateid_list Comma\-separated list of OpenNebula SERVICE TEMPLATE names or id .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/oneflow.1 b/share/man/oneflow.1 index 75fe05304f..b69e522256 100644 --- a/share/man/oneflow.1 +++ b/share/man/oneflow.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEFLOW" "1" "August 2013" "" "oneflow(1) -- Manage oneFlow Services" +.TH "ONEFLOW" "1" "October 2013" "" "oneflow(1) -- Manage oneFlow Services" . .SH "NAME" \fBoneflow\fR @@ -94,7 +94,7 @@ vm_action Actions supported: shutdown, shutdown\-hard, undeploy, undeploy\-hard, .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onegroup.1 b/share/man/onegroup.1 index 19d6f6b9b1..3317255ba7 100644 --- a/share/man/onegroup.1 +++ b/share/man/onegroup.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEGROUP" "1" "August 2013" "" "onegroup(1) -- manages OpenNebula groups" +.TH "ONEGROUP" "1" "October 2013" "" "onegroup(1) -- manages OpenNebula groups" . .SH "NAME" \fBonegroup\fR @@ -74,7 +74,7 @@ groupid_list Comma\-separated list of OpenNebula GROUP names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onehost.1 b/share/man/onehost.1 index 253dad2b0c..0ed54871bd 100644 --- a/share/man/onehost.1 +++ b/share/man/onehost.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEHOST" "1" "August 2013" "" "onehost(1) -- manages OpenNebula hosts" +.TH "ONEHOST" "1" "October 2013" "" "onehost(1) -- manages OpenNebula hosts" . .SH "NAME" \fBonehost\fR @@ -66,6 +66,9 @@ top Lists Hosts continuously valid options: list, delay, filter, xml, numeric, k .IP "\(bu" 4 flush \fIrange|hostid_list\fR Disables the host and reschedules all the running VMs in it\. . +.IP "\(bu" 4 +rename \fIhostid\fR \fIname\fR Renames the Host +. .IP "" 0 . .SH "ARGUMENT FORMATS" @@ -88,7 +91,7 @@ hostid_list Comma\-separated list of OpenNebula HOST names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/oneimage.1 b/share/man/oneimage.1 index 535430d810..d52cfd187f 100644 --- a/share/man/oneimage.1 +++ b/share/man/oneimage.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEIMAGE" "1" "August 2013" "" "oneimage(1) -- manages OpenNebula images" +.TH "ONEIMAGE" "1" "October 2013" "" "oneimage(1) -- manages OpenNebula images" . .SH "NAME" \fBoneimage\fR @@ -161,7 +161,7 @@ type Image type: OS, CDROM, DATABLOCK, KERNEL, RAMDISK, CONTEXT .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onetemplate.1 b/share/man/onetemplate.1 index 4ec744d289..4e735c2984 100644 --- a/share/man/onetemplate.1 +++ b/share/man/onetemplate.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONETEMPLATE" "1" "August 2013" "" "onetemplate(1) -- manages OpenNebula templates" +.TH "ONETEMPLATE" "1" "October 2013" "" "onetemplate(1) -- manages OpenNebula templates" . .SH "NAME" \fBonetemplate\fR @@ -31,12 +31,22 @@ \-\-raw string Raw string to add to the template\. Not to be confused with the RAW attribute \-\-vnc Add VNC server to the VM + \-\-vnc\-password password VNC password + \-\-vnc\-listen ip VNC IP where to listen for connections\. By + default is 0\.0\.0\.0 (all interfaces)\. + \-\-spice Add spice server to the VM + \-\-spice\-password password spice password + \-\-spice\-listen ip spice IP where to listen for connections\. By + default is 0\.0\.0\.0 (all interfaces)\. \-\-ssh [file] Add an ssh public key to the context\. If the file is omited then the user variable SSH_PUBLIC_KEY will be used\. \-\-net_context Add network contextualization parameters \-\-context line1,line2,line3 Lines to add to the context section \-\-boot device Select boot device (hd|fd|cdrom|network) + \-\-files_ds file1,file2 Add files to the contextualization CD from + thefiles datastore + \-\-init script1,script2 Script or scripts to start in context \-\-dry Just print the template \-m, \-\-multiple x Instance multiple VMs \-\-hold Creates the new VM on hold state instead of @@ -81,7 +91,7 @@ Examples: onetempate create \-\-name "test vm" \-\-memory 128 \-\-cpu 1 \e \-\-disk arch,data -valid options: name, cpu, vcpu, arch, memory, disk, nic, raw, vnc, ssh, net_context, context, boot, dry +valid options: name, cpu, vcpu, arch, memory, disk, nic, raw, vnc, vnc_password, vnc_listen, spice, spice_password, spice_listen, ssh, net_context, context, boot, files_ds, init, dry . .fi . @@ -95,7 +105,7 @@ clone \fItemplateid\fR \fIname\fR Creates a new Template from an existing one delete \fIrange|templateid_list\fR Deletes the given Image . .IP "\(bu" 4 -instantiate \fItemplateid\fR [\fIfile\fR] Creates a new VM instance from the given Template\. This VM can be managed with the \'onevm\' command valid options: name, multiple, hold, cpu, vcpu, arch, memory, disk, nic, raw, vnc, ssh, net_context, context, boot +instantiate \fItemplateid\fR [\fIfile\fR] Creates a new VM instance from the given Template\. This VM can be managed with the \'onevm\' command valid options: name, multiple, hold, cpu, vcpu, arch, memory, disk, nic, raw, vnc, vnc_password, vnc_listen, spice, spice_password, spice_listen, ssh, net_context, context, boot, files_ds, init . .IP "\(bu" 4 chgrp \fIrange|templateid_list\fR \fIgroupid\fR Changes the Template group @@ -152,7 +162,7 @@ filterflag a, all all the known VMTEMPLATEs m, mine the VMTEMPLATE belonging to .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/oneuser.1 b/share/man/oneuser.1 index d4ab60b4bc..0ba4c9f478 100644 --- a/share/man/oneuser.1 +++ b/share/man/oneuser.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEUSER" "1" "August 2013" "" "oneuser(1) -- manages OpenNebula users" +.TH "ONEUSER" "1" "October 2013" "" "oneuser(1) -- manages OpenNebula users" . .SH "NAME" \fBoneuser\fR @@ -99,7 +99,13 @@ delete \fIrange|userid_list\fR Deletes the given User passwd \fIuserid\fR [\fIpassword\fR] Changes the given User\'s password valid options: read_file, sha1, ssh, x509, key, cert, driver . .IP "\(bu" 4 -chgrp \fIrange|userid_list\fR \fIgroupid\fR Changes the User\'s main group +chgrp \fIrange|userid_list\fR \fIgroupid\fR Changes the User\'s primary group +. +.IP "\(bu" 4 +addgroup \fIrange|userid_list\fR \fIgroupid\fR Adds the User to a secondary group +. +.IP "\(bu" 4 +delgroup \fIrange|userid_list\fR \fIgroupid\fR Removes the User from a secondary group . .IP "\(bu" 4 chauth \fIuserid\fR [\fIauth\fR] [\fIpassword\fR] Changes the User\'s auth driver and its password (optional) Examples: oneuser chauth my_user core oneuser chauth my_user core new_password oneuser chauth my_user core \-r /tmp/mypass oneuser chauth my_user \-\-ssh \-\-key /home/oneadmin/\.ssh/id_rsa oneuser chauth my_user \-\-ssh \-r /tmp/public_key oneuser chauth my_user \-\-x509 \-\-cert /tmp/my_cert\.pem valid options: read_file, sha1, ssh, x509, key, cert, driver @@ -141,7 +147,7 @@ password User password .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onevdc.1 b/share/man/onevdc.1 index 4de10a9916..bccf713327 100644 --- a/share/man/onevdc.1 +++ b/share/man/onevdc.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVDC" "1" "August 2013" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" +.TH "ONEVDC" "1" "October 2013" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" . .SH "NAME" \fBonevdc\fR @@ -63,7 +63,7 @@ vdcid VDC ID .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onevm.1 b/share/man/onevm.1 index a81b5e0033..fe0ec9c7c7 100644 --- a/share/man/onevm.1 +++ b/share/man/onevm.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVM" "1" "August 2013" "" "onevm(1) -- manages OpenNebula virtual machines" +.TH "ONEVM" "1" "October 2013" "" "onevm(1) -- manages OpenNebula virtual machines" . .SH "NAME" \fBonevm\fR @@ -31,12 +31,22 @@ \-\-raw string Raw string to add to the template\. Not to be confused with the RAW attribute \-\-vnc Add VNC server to the VM + \-\-vnc\-password password VNC password + \-\-vnc\-listen ip VNC IP where to listen for connections\. By + default is 0\.0\.0\.0 (all interfaces)\. + \-\-spice Add spice server to the VM + \-\-spice\-password password spice password + \-\-spice\-listen ip spice IP where to listen for connections\. By + default is 0\.0\.0\.0 (all interfaces)\. \-\-ssh [file] Add an ssh public key to the context\. If the file is omited then the user variable SSH_PUBLIC_KEY will be used\. \-\-net_context Add network contextualization parameters \-\-context line1,line2,line3 Lines to add to the context section \-\-boot device Select boot device (hd|fd|cdrom|network) + \-\-files_ds file1,file2 Add files to the contextualization CD from + thefiles datastore + \-\-init script1,script2 Script or scripts to start in context \-\-dry Just print the template \-a, \-\-append Append new attributes to the current template \-\-schedule TIME Schedules this action to be executed afterthe @@ -98,7 +108,7 @@ Examples: \- a vm with two disks onevm create \-\-name "test vm" \-\-memory 128 \-\-cpu 1 \-\-disk arch,data -valid options: multiple, hold, name, cpu, vcpu, arch, memory, disk, nic, raw, vnc, ssh, net_context, context, boot, dry +valid options: multiple, hold, name, cpu, vcpu, arch, memory, disk, nic, raw, vnc, vnc_password, vnc_listen, spice, spice_password, spice_listen, ssh, net_context, context, boot, files_ds, init, dry . .fi . @@ -183,7 +193,7 @@ shutdown \fIrange|vmid_list\fR Shuts down the given VM\. The VM life cycle will With \-\-hard it unplugs the VM\. -States: RUNNING +States: RUNNING, UNKNOWN (with \-\-hard) valid options: schedule, hard . .fi @@ -241,7 +251,7 @@ valid options: schedule, hard . .IP "\(bu" 4 -deploy \fIrange|vmid_list\fR \fIhostid\fR Deploys the given VM in the specified Host\. This command forces the deployment, in a standard installation the Scheduler is in charge of this decision +deploy \fIrange|vmid_list\fR \fIhostid\fR [\fIdatastoreid\fR] Deploys the given VM in the specified Host\. This command forces the deployment, in a standard installation the Scheduler is in charge of this decision . .IP "" 4 . @@ -491,6 +501,9 @@ groupid OpenNebula GROUP name or id userid OpenNebula USER name or id . .IP "\(bu" 4 +datastoreid OpenNebula DATASTORE name or id +. +.IP "\(bu" 4 vmid OpenNebula VM name or id . .IP "\(bu" 4 @@ -505,7 +518,7 @@ diskid Integer .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onevnet.1 b/share/man/onevnet.1 index ac389d38c6..c5f3feaf93 100644 --- a/share/man/onevnet.1 +++ b/share/man/onevnet.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVNET" "1" "August 2013" "" "onevnet(1) -- manages OpenNebula networks" +.TH "ONEVNET" "1" "October 2013" "" "onevnet(1) -- manages OpenNebula networks" . .SH "NAME" \fBonevnet\fR @@ -104,7 +104,7 @@ filterflag a, all all the known VNETs m, mine the VNET belonging to the user in .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/man/onezone.1 b/share/man/onezone.1 index a00f9333a8..087748d7c3 100644 --- a/share/man/onezone.1 +++ b/share/man/onezone.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEZONE" "1" "August 2013" "" "onezone(1) -- manages OpenNebula zones" +.TH "ONEZONE" "1" "October 2013" "" "onezone(1) -- manages OpenNebula zones" . .SH "NAME" \fBonezone\fR @@ -53,7 +53,7 @@ zoneid Zone ID .IP "" 0 . .SH "LICENSE" -OpenNebula 4\.3\.0 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs +OpenNebula 4\.3\.80 Copyright 2002\-2013, OpenNebula Project (OpenNebula\.org), C12G Labs . .P 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 diff --git a/share/rubygems/generate b/share/rubygems/generate index 7a7ad50f31..704b61ebb0 100755 --- a/share/rubygems/generate +++ b/share/rubygems/generate @@ -21,7 +21,7 @@ require 'tmpdir' DEFAULTS={ - :version => "4.3.0", + :version => "4.3.80", :date => Time.now.strftime("%Y-%m-%d"), :dependencies => [] } diff --git a/share/scripts/context-packages/generate.sh b/share/scripts/context-packages/generate.sh index 3515d5cf00..0b3e090080 100755 --- a/share/scripts/context-packages/generate.sh +++ b/share/scripts/context-packages/generate.sh @@ -16,7 +16,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -VERSION=${VERSION:-4.3.0} +VERSION=${VERSION:-4.3.80} MAINTAINER=${MAINTAINER:-C12G Labs } LICENSE=${LICENSE:-Apache 2.0} PACKAGE_NAME=${PACKAGE_NAME:-one-context} diff --git a/src/cloud/common/CloudClient.rb b/src/cloud/common/CloudClient.rb index 770f6f2936..36aaa86459 100644 --- a/src/cloud/common/CloudClient.rb +++ b/src/cloud/common/CloudClient.rb @@ -50,7 +50,7 @@ end module CloudClient # OpenNebula version - VERSION = '4.3.0' + VERSION = '4.3.80' # ######################################################################### # Default location for the authentication file diff --git a/src/oca/java/src/org/opennebula/client/OneSystem.java b/src/oca/java/src/org/opennebula/client/OneSystem.java index 4b2fae4ba2..f899167940 100644 --- a/src/oca/java/src/org/opennebula/client/OneSystem.java +++ b/src/oca/java/src/org/opennebula/client/OneSystem.java @@ -32,7 +32,7 @@ public class OneSystem private static final String GROUP_QUOTA_INFO = "groupquota.info"; private static final String GROUP_QUOTA_UPDATE = "groupquota.update"; - public static final String VERSION = "4.3.0"; + public static final String VERSION = "4.3.80"; public OneSystem(Client client) { diff --git a/src/oca/ruby/opennebula.rb b/src/oca/ruby/opennebula.rb index 74a45b79c0..5e9feea709 100644 --- a/src/oca/ruby/opennebula.rb +++ b/src/oca/ruby/opennebula.rb @@ -54,5 +54,5 @@ require 'opennebula/system' module OpenNebula # OpenNebula version - VERSION = '4.3.0' + VERSION = '4.3.80' end diff --git a/src/onedb/fsck.rb b/src/onedb/fsck.rb index d01c217ef3..306432af17 100644 --- a/src/onedb/fsck.rb +++ b/src/onedb/fsck.rb @@ -20,7 +20,7 @@ require 'ipaddr' require 'set' module OneDBFsck - VERSION = "4.3.0" + VERSION = "4.3.80" def db_version VERSION diff --git a/src/ozones/Server/templates/index.html b/src/ozones/Server/templates/index.html index f3b170cb26..91397897a8 100644 --- a/src/ozones/Server/templates/index.html +++ b/src/ozones/Server/templates/index.html @@ -65,7 +65,7 @@
diff --git a/src/ozones/Server/templates/login.html b/src/ozones/Server/templates/login.html index 80ca0fe6df..18b7580f56 100644 --- a/src/ozones/Server/templates/login.html +++ b/src/ozones/Server/templates/login.html @@ -49,7 +49,7 @@
diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 8901ce6e94..41972cffb1 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -86,7 +86,7 @@
diff --git a/src/sunstone/views/login.erb b/src/sunstone/views/login.erb index b17d3ac7ee..6a554260f2 100644 --- a/src/sunstone/views/login.erb +++ b/src/sunstone/views/login.erb @@ -26,7 +26,7 @@ From e3ec77b41a48daac58aee138c296c868afbca120 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sun, 13 Oct 2013 20:19:13 +0200 Subject: [PATCH 22/44] feature im-collectd: Added control parameters. Install collectd driver. Added configuration for collectd in oned.conf --- install.sh | 3 +- share/etc/oned.conf | 17 ++++++ src/im_mad/collectd/OpenNebulaDriver.cc | 12 +++- src/im_mad/collectd/collectd.cc | 73 ++++++++++++++++++++++++- 4 files changed, 100 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 05303abb67..b5ab9a8862 100755 --- a/install.sh +++ b/install.sh @@ -751,7 +751,8 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/im_mad/im_exec/one_im_exec \ src/im_mad/im_exec/one_im_ssh \ src/im_mad/im_exec/one_im_sh \ - src/im_mad/ec2/one_im_ec2.rb \ + src/im_mad/im_exec/one_im_sh \ + src/im_mad/collectd/collectd \ src/im_mad/ec2/one_im_ec2 \ src/im_mad/dummy/one_im_dummy.rb \ src/im_mad/dummy/one_im_dummy \ diff --git a/share/etc/oned.conf b/share/etc/oned.conf index bb0bb4f69a..df114ea854 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -171,6 +171,23 @@ DEFAULT_DEVICE_PREFIX = "hd" # /etc/one/ if OpenNebula was installed in /) #******************************************************************************* +#------------------------------------------------------------------------------- +# Information Collector for KVM and Xen IM's. +#------------------------------------------------------------------------------- +# This driver CANNOT BE ASSIGNED TO A HOST, and needs to be used with KVM or +# Xen drivers +# -h prints this help. +# -a Address to bind the collectd sockect (defults 0.0.0.0) +# -p UDP port to listen for monitor information (default 4124) +# -f Interval in seconds to flush collected information (default 5) +# -t Number of threads for the server (defult 50) +#------------------------------------------------------------------------------- +IM_MAD = [ + name = "collectd", + executable = "collectd", + arguments = "-p 4124 -f 5 -t 50" ] +#------------------------------------------------------------------------------- + #------------------------------------------------------------------------------- # KVM Information Driver Manager Configuration # -r number of retries when monitoring a host diff --git a/src/im_mad/collectd/OpenNebulaDriver.cc b/src/im_mad/collectd/OpenNebulaDriver.cc index d629c73a7f..2d539a318a 100644 --- a/src/im_mad/collectd/OpenNebulaDriver.cc +++ b/src/im_mad/collectd/OpenNebulaDriver.cc @@ -15,12 +15,15 @@ /* -------------------------------------------------------------------------- */ #include +#include #include #include #include #include #include +#include +#include #include "OpenNebulaDriver.h" #include "ListenerThread.h" @@ -114,14 +117,20 @@ int IMCollectorDriver::init_collector() if ( sock < 0 ) { + std::cerr << strerror(errno); return -1; } im_server.sin_family = AF_INET; im_server.sin_port = htons(_port); - if ( inet_pton(AF_INET, _address.c_str(), &im_server.sin_addr.s_addr) < 0 ) + if (_address == "0.0.0.0") { + im_server.sin_addr.s_addr = htonl (INADDR_ANY); + } + else if (inet_pton(AF_INET,_address.c_str(),&im_server.sin_addr.s_addr) < 0) + { + std::cerr << strerror(errno); return -1; } @@ -129,6 +138,7 @@ int IMCollectorDriver::init_collector() if ( rc < 0 ) { + std::cerr << strerror(errno); return -1; } diff --git a/src/im_mad/collectd/collectd.cc b/src/im_mad/collectd/collectd.cc index 2c939f2bbb..256392bdaa 100644 --- a/src/im_mad/collectd/collectd.cc +++ b/src/im_mad/collectd/collectd.cc @@ -15,11 +15,78 @@ /* -------------------------------------------------------------------------- */ #include "OpenNebulaDriver.h" +#include +#include +#include +#include -int main() +static const char * usage = +"\n collectd [-h] [-a address] [-p port] [-t threads] [-f flush]\n\n" +"SYNOPSIS\n" +" Information Collector for OpenNebula. It should not be started directly\n\n" +"OPTIONS\n" +"\t-h\tprints this help.\n" +"\t-a\tAddress to bind the collectd sockect\n" +"\t-p\tUDP port to listen for monitor information\n" +"\t-f\tInterval in seconds to flush collected information\n" +"\t-t\tNumber of threads for the server\n"; + +int main(int argc, char ** argv) { - IMCollectorDriver collectd("127.0.0.1", 9876, 1, 1); + std::string address = "0.0.0.0"; + int port = 4124; + int threads = 50; + int flush = 5; + + std::istringstream iss; + int opt; + + while((opt = getopt(argc,argv,":ha:p:t:f:")) != -1) + switch(opt) + { + case 'h': + std::cout << usage; + return 0; + break; + case 'a': + address = optarg; + break; + + case 'p': + iss.clear(); + iss.str(optarg); + + iss >> port; + break; + + case 't': + iss.clear(); + iss.str(optarg); + + iss >> threads; + break; + + case 'f': + iss.clear(); + iss.str(optarg); + + iss >> flush; + break; + + default: + std::cerr << usage; + return -1; + break; + } + + + IMCollectorDriver collectd(address, port, threads, flush); + + if ( collectd.init_collector() != 0 ) + { + std::cerr << ". Could not init collectd, exiting...\n"; + return -1; + } - collectd.init_collector(); collectd.start_collector(); } From 05cf77eab18b11271056d0d36aaa350b0ef7ddc8 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Sun, 13 Oct 2013 21:34:17 +0200 Subject: [PATCH 23/44] im-collectd: collectd-client agent --- src/im_mad/im_exec/one_im_exec.rb | 3 +- .../{kvm.d => kvm-probes.d}/architecture.sh | 0 .../remotes/{kvm.d => kvm-probes.d}/cpu.sh | 0 .../remotes/{kvm.d => kvm-probes.d}/kvm.rb | 0 .../remotes/{kvm.d => kvm-probes.d}/name.sh | 0 .../remotes/{kvm.d => kvm-probes.d}/poll.sh | 0 src/im_mad/remotes/kvm.d/collectd-client.rb | 120 ++++++++++++++++++ .../remotes/kvm.d/collectd-client_control.sh | 62 +++++++++ 8 files changed, 184 insertions(+), 1 deletion(-) rename src/im_mad/remotes/{kvm.d => kvm-probes.d}/architecture.sh (100%) rename src/im_mad/remotes/{kvm.d => kvm-probes.d}/cpu.sh (100%) rename src/im_mad/remotes/{kvm.d => kvm-probes.d}/kvm.rb (100%) rename src/im_mad/remotes/{kvm.d => kvm-probes.d}/name.sh (100%) rename src/im_mad/remotes/{kvm.d => kvm-probes.d}/poll.sh (100%) create mode 100644 src/im_mad/remotes/kvm.d/collectd-client.rb create mode 100755 src/im_mad/remotes/kvm.d/collectd-client_control.sh diff --git a/src/im_mad/im_exec/one_im_exec.rb b/src/im_mad/im_exec/one_im_exec.rb index 1b2f8e5f12..42828b6f8d 100755 --- a/src/im_mad/im_exec/one_im_exec.rb +++ b/src/im_mad/im_exec/one_im_exec.rb @@ -73,7 +73,8 @@ class InformationManagerDriver < OpenNebulaDriver end end - do_action("#{@hypervisor}", number, host, :MONITOR, + # TODO: Do not hard-code the port + do_action("#{@hypervisor} #{number} 9876", number, host, :MONITOR, :script_name => 'run_probes', :base64 => true) end end diff --git a/src/im_mad/remotes/kvm.d/architecture.sh b/src/im_mad/remotes/kvm-probes.d/architecture.sh similarity index 100% rename from src/im_mad/remotes/kvm.d/architecture.sh rename to src/im_mad/remotes/kvm-probes.d/architecture.sh diff --git a/src/im_mad/remotes/kvm.d/cpu.sh b/src/im_mad/remotes/kvm-probes.d/cpu.sh similarity index 100% rename from src/im_mad/remotes/kvm.d/cpu.sh rename to src/im_mad/remotes/kvm-probes.d/cpu.sh diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb similarity index 100% rename from src/im_mad/remotes/kvm.d/kvm.rb rename to src/im_mad/remotes/kvm-probes.d/kvm.rb diff --git a/src/im_mad/remotes/kvm.d/name.sh b/src/im_mad/remotes/kvm-probes.d/name.sh similarity index 100% rename from src/im_mad/remotes/kvm.d/name.sh rename to src/im_mad/remotes/kvm-probes.d/name.sh diff --git a/src/im_mad/remotes/kvm.d/poll.sh b/src/im_mad/remotes/kvm-probes.d/poll.sh similarity index 100% rename from src/im_mad/remotes/kvm.d/poll.sh rename to src/im_mad/remotes/kvm-probes.d/poll.sh diff --git a/src/im_mad/remotes/kvm.d/collectd-client.rb b/src/im_mad/remotes/kvm.d/collectd-client.rb new file mode 100644 index 0000000000..bf332972ca --- /dev/null +++ b/src/im_mad/remotes/kvm.d/collectd-client.rb @@ -0,0 +1,120 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +require 'socket' +require 'base64' + +DIRNAME = File.dirname(__FILE__) + +CYCLE = 20 +TOTAL_HOSTS = 1000 + +SLEEP = 1 + +class CollectdClient + def initialize(hypervisor, number, host, port) + # Arguments + @hypervisor = hypervisor + @number = number.to_i + @host = host + @port = port + + # Monitorization slot + hosts_per_cycle = TOTAL_HOSTS / CYCLE + @my_slot = (@number % TOTAL_HOSTS) / hosts_per_cycle + + # Probes + run_probes_cmd = File.join(DIRNAME, '..', "run_probes") + @run_probes_cmd = "#{run_probes_cmd} #{@hypervisor}-probes" + + # Socket + @s = UDPSocket.new + end + + def run_probes + data = `#{@run_probes_cmd}` + data64 = Base64::encode64(data).strip.delete("\n") + + return data64 + end + + def send(data) + @s.send("MONITOR SUCCESS #{@number} #{data}\n", 0, @host, @port) + end + + def do_send?(current, last_send) + current_cycle = current[0] + current_slot = current[1] + + last_cycle = last_send[0] + last_slot = last_send[1] + + if last_slot < @my_slot + min_cycle = last_cycle + else + min_cycle = last_cycle + 1 + end + + if current_cycle > min_cycle + return true + elsif current_cycle < min_cycle + return false + else + return current_slot >= @my_slot + end + end + + def monitor + initial = true + data = run_probes + + last_send = nil + + loop do + t = Time.now.to_i + + current_cycle = t / CYCLE + current_slot = t % CYCLE + + current = [current_cycle, current_slot] + + if initial + last_send = current + initial = false + end + + if do_send?(current, last_send) + send data + last_send = current + + data = run_probes + end + + sleep SLEEP + end + end +end + +hypervisor = ARGV[0] +number = ARGV[1] +port = ARGV[2] + +host = ENV['SSH_CLIENT'].split.first + +client = CollectdClient.new(hypervisor, number, host, port) +client.monitor diff --git a/src/im_mad/remotes/kvm.d/collectd-client_control.sh b/src/im_mad/remotes/kvm.d/collectd-client_control.sh new file mode 100755 index 0000000000..485d802152 --- /dev/null +++ b/src/im_mad/remotes/kvm.d/collectd-client_control.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +ARGV=$* + +# Directory that contains this file +DIR=$(pwd) + +# Basename +BASENAME=$(basename $0 _control.sh) + +# Collectd client (Ruby) +CLIENT=$DIR/${BASENAME}.rb + +# Collectd client PID +CLIENT_PID_FILE=/tmp/one-collectd-client.pid + +# Launch the client +function start_client() { + /usr/bin/env ruby $CLIENT $ARGV & +} + +# Write the PID +function write_pid() { + echo $1 > $CLIENT_PID_FILE +} + +# Check if running process +function check_running() { + # Assume the process is not running if there is no pid file + test ! -f $CLIENT_PID_FILE && return 1 + + PID=$(cat $CLIENT_PID_FILE) + + if ps --no-headers -o command $PID 2>/dev/null | grep -q $BASENAME; then + return 0 + else + # Stale PID file + rm -f $CLIENT_PID_FILE + return 1 + fi +} + +if ! check_running; then + start_client + write_pid $! +fi From a7f77453fc9a022cbb564fc9c81a04b762c1e7f1 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Sun, 13 Oct 2013 21:48:10 +0200 Subject: [PATCH 24/44] im-collectd: add probes for xen and update install.sh --- install.sh | 45 ++++--- .../remotes/common.d/collectd-client.rb | 120 +++++++++++++++++ .../common.d/collectd-client_control.sh | 62 +++++++++ src/im_mad/remotes/kvm.d/collectd-client.rb | 121 +----------------- .../remotes/kvm.d/collectd-client_control.sh | 63 +-------- .../{xen.d => xen-probes.d}/architecture.sh | 0 .../remotes/{xen.d => xen-probes.d}/cpu.sh | 0 .../remotes/{xen.d => xen-probes.d}/name.sh | 0 .../remotes/{xen.d => xen-probes.d}/poll3.sh | 0 .../remotes/{xen.d => xen-probes.d}/poll4.sh | 0 .../remotes/{xen.d => xen-probes.d}/xen.rb | 0 src/im_mad/remotes/xen.d/collectd-client.rb | 1 + .../remotes/xen.d/collectd-client_control.sh | 1 + 13 files changed, 216 insertions(+), 197 deletions(-) create mode 100644 src/im_mad/remotes/common.d/collectd-client.rb create mode 100755 src/im_mad/remotes/common.d/collectd-client_control.sh mode change 100644 => 120000 src/im_mad/remotes/kvm.d/collectd-client.rb mode change 100755 => 120000 src/im_mad/remotes/kvm.d/collectd-client_control.sh rename src/im_mad/remotes/{xen.d => xen-probes.d}/architecture.sh (100%) rename src/im_mad/remotes/{xen.d => xen-probes.d}/cpu.sh (100%) rename src/im_mad/remotes/{xen.d => xen-probes.d}/name.sh (100%) rename src/im_mad/remotes/{xen.d => xen-probes.d}/poll3.sh (100%) rename src/im_mad/remotes/{xen.d => xen-probes.d}/poll4.sh (100%) rename src/im_mad/remotes/{xen.d => xen-probes.d}/xen.rb (100%) create mode 120000 src/im_mad/remotes/xen.d/collectd-client.rb create mode 120000 src/im_mad/remotes/xen.d/collectd-client_control.sh diff --git a/install.sh b/install.sh index 05303abb67..46f70748a5 100755 --- a/install.sh +++ b/install.sh @@ -264,6 +264,9 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im/kvm.d \ $VAR_LOCATION/remotes/im/xen3.d \ $VAR_LOCATION/remotes/im/xen4.d \ + $VAR_LOCATION/remotes/im/kvm-probes.d \ + $VAR_LOCATION/remotes/im/xen3-probes.d \ + $VAR_LOCATION/remotes/im/xen4-probes.d \ $VAR_LOCATION/remotes/im/vmware.d \ $VAR_LOCATION/remotes/vmm \ $VAR_LOCATION/remotes/vmm/kvm \ @@ -447,8 +450,11 @@ INSTALL_FILES=( MADS_LIB_FILES:$LIB_LOCATION/mads IM_PROBES_FILES:$VAR_LOCATION/remotes/im IM_PROBES_KVM_FILES:$VAR_LOCATION/remotes/im/kvm.d + IM_PROBES_KVM_PROBES_FILES:$VAR_LOCATION/remotes/im/kvm-probes.d IM_PROBES_XEN3_FILES:$VAR_LOCATION/remotes/im/xen3.d + IM_PROBES_XEN3_PROBES_FILES:$VAR_LOCATION/remotes/im/xen3-probes.d IM_PROBES_XEN4_FILES:$VAR_LOCATION/remotes/im/xen4.d + IM_PROBES_XEN4_PROBES_FILES:$VAR_LOCATION/remotes/im/xen4-probes.d IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.d AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509 @@ -858,23 +864,32 @@ VMM_EXEC_VMWARE_SCRIPTS="src/vmm_mad/remotes/vmware/cancel \ IM_PROBES_FILES="src/im_mad/remotes/run_probes" -IM_PROBES_KVM_FILES="src/im_mad/remotes/kvm.d/kvm.rb \ - src/im_mad/remotes/kvm.d/architecture.sh \ - src/im_mad/remotes/kvm.d/cpu.sh \ - src/im_mad/remotes/kvm.d/poll.sh \ - src/im_mad/remotes/kvm.d/name.sh" +IM_PROBES_KVM_FILES="src/im_mad/remotes/kvm.d/collectd-client_control.sh \ + src/im_mad/remotes/kvm.d/collectd-client.rb" -IM_PROBES_XEN3_FILES="src/im_mad/remotes/xen.d/xen.rb \ - src/im_mad/remotes/xen.d/architecture.sh \ - src/im_mad/remotes/xen.d/cpu.sh \ - src/im_mad/remotes/xen.d/poll3.sh \ - src/im_mad/remotes/xen.d/name.sh" +IM_PROBES_KVM_PROBES_FILES="src/im_mad/remotes/kvm-probes.d/kvm.rb \ + src/im_mad/remotes/kvm-probes.d/architecture.sh \ + src/im_mad/remotes/kvm-probes.d/cpu.sh \ + src/im_mad/remotes/kvm-probes.d/poll.sh \ + src/im_mad/remotes/kvm-probes.d/name.sh" -IM_PROBES_XEN4_FILES="src/im_mad/remotes/xen.d/xen.rb \ - src/im_mad/remotes/xen.d/architecture.sh \ - src/im_mad/remotes/xen.d/cpu.sh \ - src/im_mad/remotes/xen.d/poll4.sh \ - src/im_mad/remotes/xen.d/name.sh" +IM_PROBES_XEN3_FILES="src/im_mad/remotes/xen.d/collectd-client_control.sh \ + src/im_mad/remotes/xen.d/collectd-client.rb" + +IM_PROBES_XEN3_PROBES_FILES="src/im_mad/remotes/xen-probes.d/xen.rb \ + src/im_mad/remotes/xen-probes.d/architecture.sh \ + src/im_mad/remotes/xen-probes.d/cpu.sh \ + src/im_mad/remotes/xen-probes.d/poll3.sh \ + src/im_mad/remotes/xen-probes.d/name.sh" + +IM_PROBES_XEN4_FILES="src/im_mad/remotes/xen.d/collectd-client_control.sh \ + src/im_mad/remotes/xen.d/collectd-client.rb" + +IM_PROBES_XEN4_PROBES_FILES="src/im_mad/remotes/xen-probes.d/xen.rb \ + src/im_mad/remotes/xen-probes.d/architecture.sh \ + src/im_mad/remotes/xen-probes.d/cpu.sh \ + src/im_mad/remotes/xen-probes.d/poll4.sh \ + src/im_mad/remotes/xen-probes.d/name.sh" IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb" diff --git a/src/im_mad/remotes/common.d/collectd-client.rb b/src/im_mad/remotes/common.d/collectd-client.rb new file mode 100644 index 0000000000..bf332972ca --- /dev/null +++ b/src/im_mad/remotes/common.d/collectd-client.rb @@ -0,0 +1,120 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +require 'socket' +require 'base64' + +DIRNAME = File.dirname(__FILE__) + +CYCLE = 20 +TOTAL_HOSTS = 1000 + +SLEEP = 1 + +class CollectdClient + def initialize(hypervisor, number, host, port) + # Arguments + @hypervisor = hypervisor + @number = number.to_i + @host = host + @port = port + + # Monitorization slot + hosts_per_cycle = TOTAL_HOSTS / CYCLE + @my_slot = (@number % TOTAL_HOSTS) / hosts_per_cycle + + # Probes + run_probes_cmd = File.join(DIRNAME, '..', "run_probes") + @run_probes_cmd = "#{run_probes_cmd} #{@hypervisor}-probes" + + # Socket + @s = UDPSocket.new + end + + def run_probes + data = `#{@run_probes_cmd}` + data64 = Base64::encode64(data).strip.delete("\n") + + return data64 + end + + def send(data) + @s.send("MONITOR SUCCESS #{@number} #{data}\n", 0, @host, @port) + end + + def do_send?(current, last_send) + current_cycle = current[0] + current_slot = current[1] + + last_cycle = last_send[0] + last_slot = last_send[1] + + if last_slot < @my_slot + min_cycle = last_cycle + else + min_cycle = last_cycle + 1 + end + + if current_cycle > min_cycle + return true + elsif current_cycle < min_cycle + return false + else + return current_slot >= @my_slot + end + end + + def monitor + initial = true + data = run_probes + + last_send = nil + + loop do + t = Time.now.to_i + + current_cycle = t / CYCLE + current_slot = t % CYCLE + + current = [current_cycle, current_slot] + + if initial + last_send = current + initial = false + end + + if do_send?(current, last_send) + send data + last_send = current + + data = run_probes + end + + sleep SLEEP + end + end +end + +hypervisor = ARGV[0] +number = ARGV[1] +port = ARGV[2] + +host = ENV['SSH_CLIENT'].split.first + +client = CollectdClient.new(hypervisor, number, host, port) +client.monitor diff --git a/src/im_mad/remotes/common.d/collectd-client_control.sh b/src/im_mad/remotes/common.d/collectd-client_control.sh new file mode 100755 index 0000000000..485d802152 --- /dev/null +++ b/src/im_mad/remotes/common.d/collectd-client_control.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +ARGV=$* + +# Directory that contains this file +DIR=$(pwd) + +# Basename +BASENAME=$(basename $0 _control.sh) + +# Collectd client (Ruby) +CLIENT=$DIR/${BASENAME}.rb + +# Collectd client PID +CLIENT_PID_FILE=/tmp/one-collectd-client.pid + +# Launch the client +function start_client() { + /usr/bin/env ruby $CLIENT $ARGV & +} + +# Write the PID +function write_pid() { + echo $1 > $CLIENT_PID_FILE +} + +# Check if running process +function check_running() { + # Assume the process is not running if there is no pid file + test ! -f $CLIENT_PID_FILE && return 1 + + PID=$(cat $CLIENT_PID_FILE) + + if ps --no-headers -o command $PID 2>/dev/null | grep -q $BASENAME; then + return 0 + else + # Stale PID file + rm -f $CLIENT_PID_FILE + return 1 + fi +} + +if ! check_running; then + start_client + write_pid $! +fi diff --git a/src/im_mad/remotes/kvm.d/collectd-client.rb b/src/im_mad/remotes/kvm.d/collectd-client.rb deleted file mode 100644 index bf332972ca..0000000000 --- a/src/im_mad/remotes/kvm.d/collectd-client.rb +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, 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. # -#--------------------------------------------------------------------------- # - -require 'socket' -require 'base64' - -DIRNAME = File.dirname(__FILE__) - -CYCLE = 20 -TOTAL_HOSTS = 1000 - -SLEEP = 1 - -class CollectdClient - def initialize(hypervisor, number, host, port) - # Arguments - @hypervisor = hypervisor - @number = number.to_i - @host = host - @port = port - - # Monitorization slot - hosts_per_cycle = TOTAL_HOSTS / CYCLE - @my_slot = (@number % TOTAL_HOSTS) / hosts_per_cycle - - # Probes - run_probes_cmd = File.join(DIRNAME, '..', "run_probes") - @run_probes_cmd = "#{run_probes_cmd} #{@hypervisor}-probes" - - # Socket - @s = UDPSocket.new - end - - def run_probes - data = `#{@run_probes_cmd}` - data64 = Base64::encode64(data).strip.delete("\n") - - return data64 - end - - def send(data) - @s.send("MONITOR SUCCESS #{@number} #{data}\n", 0, @host, @port) - end - - def do_send?(current, last_send) - current_cycle = current[0] - current_slot = current[1] - - last_cycle = last_send[0] - last_slot = last_send[1] - - if last_slot < @my_slot - min_cycle = last_cycle - else - min_cycle = last_cycle + 1 - end - - if current_cycle > min_cycle - return true - elsif current_cycle < min_cycle - return false - else - return current_slot >= @my_slot - end - end - - def monitor - initial = true - data = run_probes - - last_send = nil - - loop do - t = Time.now.to_i - - current_cycle = t / CYCLE - current_slot = t % CYCLE - - current = [current_cycle, current_slot] - - if initial - last_send = current - initial = false - end - - if do_send?(current, last_send) - send data - last_send = current - - data = run_probes - end - - sleep SLEEP - end - end -end - -hypervisor = ARGV[0] -number = ARGV[1] -port = ARGV[2] - -host = ENV['SSH_CLIENT'].split.first - -client = CollectdClient.new(hypervisor, number, host, port) -client.monitor diff --git a/src/im_mad/remotes/kvm.d/collectd-client.rb b/src/im_mad/remotes/kvm.d/collectd-client.rb new file mode 120000 index 0000000000..bcef3f5682 --- /dev/null +++ b/src/im_mad/remotes/kvm.d/collectd-client.rb @@ -0,0 +1 @@ +../common.d/collectd-client.rb \ No newline at end of file diff --git a/src/im_mad/remotes/kvm.d/collectd-client_control.sh b/src/im_mad/remotes/kvm.d/collectd-client_control.sh deleted file mode 100755 index 485d802152..0000000000 --- a/src/im_mad/remotes/kvm.d/collectd-client_control.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, 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. # -#--------------------------------------------------------------------------- # - -ARGV=$* - -# Directory that contains this file -DIR=$(pwd) - -# Basename -BASENAME=$(basename $0 _control.sh) - -# Collectd client (Ruby) -CLIENT=$DIR/${BASENAME}.rb - -# Collectd client PID -CLIENT_PID_FILE=/tmp/one-collectd-client.pid - -# Launch the client -function start_client() { - /usr/bin/env ruby $CLIENT $ARGV & -} - -# Write the PID -function write_pid() { - echo $1 > $CLIENT_PID_FILE -} - -# Check if running process -function check_running() { - # Assume the process is not running if there is no pid file - test ! -f $CLIENT_PID_FILE && return 1 - - PID=$(cat $CLIENT_PID_FILE) - - if ps --no-headers -o command $PID 2>/dev/null | grep -q $BASENAME; then - return 0 - else - # Stale PID file - rm -f $CLIENT_PID_FILE - return 1 - fi -} - -if ! check_running; then - start_client - write_pid $! -fi diff --git a/src/im_mad/remotes/kvm.d/collectd-client_control.sh b/src/im_mad/remotes/kvm.d/collectd-client_control.sh new file mode 120000 index 0000000000..c062769fd0 --- /dev/null +++ b/src/im_mad/remotes/kvm.d/collectd-client_control.sh @@ -0,0 +1 @@ +../common.d/collectd-client_control.sh \ No newline at end of file diff --git a/src/im_mad/remotes/xen.d/architecture.sh b/src/im_mad/remotes/xen-probes.d/architecture.sh similarity index 100% rename from src/im_mad/remotes/xen.d/architecture.sh rename to src/im_mad/remotes/xen-probes.d/architecture.sh diff --git a/src/im_mad/remotes/xen.d/cpu.sh b/src/im_mad/remotes/xen-probes.d/cpu.sh similarity index 100% rename from src/im_mad/remotes/xen.d/cpu.sh rename to src/im_mad/remotes/xen-probes.d/cpu.sh diff --git a/src/im_mad/remotes/xen.d/name.sh b/src/im_mad/remotes/xen-probes.d/name.sh similarity index 100% rename from src/im_mad/remotes/xen.d/name.sh rename to src/im_mad/remotes/xen-probes.d/name.sh diff --git a/src/im_mad/remotes/xen.d/poll3.sh b/src/im_mad/remotes/xen-probes.d/poll3.sh similarity index 100% rename from src/im_mad/remotes/xen.d/poll3.sh rename to src/im_mad/remotes/xen-probes.d/poll3.sh diff --git a/src/im_mad/remotes/xen.d/poll4.sh b/src/im_mad/remotes/xen-probes.d/poll4.sh similarity index 100% rename from src/im_mad/remotes/xen.d/poll4.sh rename to src/im_mad/remotes/xen-probes.d/poll4.sh diff --git a/src/im_mad/remotes/xen.d/xen.rb b/src/im_mad/remotes/xen-probes.d/xen.rb similarity index 100% rename from src/im_mad/remotes/xen.d/xen.rb rename to src/im_mad/remotes/xen-probes.d/xen.rb diff --git a/src/im_mad/remotes/xen.d/collectd-client.rb b/src/im_mad/remotes/xen.d/collectd-client.rb new file mode 120000 index 0000000000..bcef3f5682 --- /dev/null +++ b/src/im_mad/remotes/xen.d/collectd-client.rb @@ -0,0 +1 @@ +../common.d/collectd-client.rb \ No newline at end of file diff --git a/src/im_mad/remotes/xen.d/collectd-client_control.sh b/src/im_mad/remotes/xen.d/collectd-client_control.sh new file mode 120000 index 0000000000..c062769fd0 --- /dev/null +++ b/src/im_mad/remotes/xen.d/collectd-client_control.sh @@ -0,0 +1 @@ +../common.d/collectd-client_control.sh \ No newline at end of file From c72841e01cd794503eba65a8c02359ed87d6a317 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 14 Oct 2013 13:39:17 +0200 Subject: [PATCH 25/44] im-collectd: read the collectd port from configuration file --- src/im_mad/im_exec/one_im_exec.rb | 15 ++++++++++++--- src/mad/ruby/DriverExecHelper.rb | 27 ++++++++++++++++++--------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/im_mad/im_exec/one_im_exec.rb b/src/im_mad/im_exec/one_im_exec.rb index 42828b6f8d..75c08fc09d 100755 --- a/src/im_mad/im_exec/one_im_exec.rb +++ b/src/im_mad/im_exec/one_im_exec.rb @@ -49,6 +49,16 @@ class InformationManagerDriver < OpenNebulaDriver # register actions register_action(:MONITOR, method("action_monitor")) + + # collectd port + @collectd_port = 4124 + begin + im_collectd = @config["IM_MAD"].select{|e| e.match(/collectd/)}[0] + @collectd_port = im_collectd.match(/-p (\d+)/)[1] + rescue + end + + File.open('/tmp/collectd_port.log','a'){|f| f.puts @collectd_port} end # Execute the run_probes in the remote host @@ -73,9 +83,8 @@ class InformationManagerDriver < OpenNebulaDriver end end - # TODO: Do not hard-code the port - do_action("#{@hypervisor} #{number} 9876", number, host, :MONITOR, - :script_name => 'run_probes', :base64 => true) + do_action("#{@hypervisor} #{number} #{@collectd_port}", number, host, + :MONITOR, :script_name => 'run_probes', :base64 => true) end end diff --git a/src/mad/ruby/DriverExecHelper.rb b/src/mad/ruby/DriverExecHelper.rb index d462db9cc1..2d9afb4f5e 100644 --- a/src/mad/ruby/DriverExecHelper.rb +++ b/src/mad/ruby/DriverExecHelper.rb @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # # This module provides an abstraction to generate an execution context for -# OpenNebula Drivers. The module has been designed to be included as part +# OpenNebula Drivers. The module has been designed to be included as part # of a driver and not to be used standalone. module DriverExecHelper # Action result strings for messages @@ -27,7 +27,7 @@ module DriverExecHelper def self.failed?(rc_str) return rc_str == RESULT[:failure] end - + #Initialize module variables def initialize_helper(directory, options) @config = read_configuration @@ -51,7 +51,7 @@ module DriverExecHelper # # METHODS FOR COMMAND LINE & ACTION PATHS - # + # # Given the action name and the parameter returns full path of the script # and appends its parameters. It uses @local_actions hash to know if the # actions is remote or local. If the local actions has defined an special @@ -96,7 +96,7 @@ module DriverExecHelper # # METHODS FOR LOGS & COMMAND OUTPUT - # + # # Sends a message to the OpenNebula core through stdout def send_message(action="-", result=RESULT[:failure], id="-", info="-") @send_mutex.synchronize { @@ -151,7 +151,7 @@ module DriverExecHelper } end - #This method returns the result in terms + #This method returns the result in terms def get_info_from_execution(command_exe) if command_exe.code == 0 result = RESULT[:success] @@ -165,10 +165,10 @@ module DriverExecHelper [result, info] end - + # - # - # Simple parser for the config file generated by OpenNebula + # + # Simple parser for the config file generated by OpenNebula def read_configuration one_config=nil @@ -192,7 +192,16 @@ module DriverExecHelper if m name=m[1].strip.upcase value=m[2].strip - config[name]=value + + if config[name] + if config[name].instance_of? Array + config[name] << value + else + config[name] = [config[name], value] + end + else + config[name]=value + end end end rescue Exception => e From f8f90e1b0fefaa658b8b0b540812d94c304d5ca3 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 14 Oct 2013 15:41:26 +0200 Subject: [PATCH 26/44] im-collectd: remove repeated files in install.sh --- install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install.sh b/install.sh index 2ce2227fcd..dea24e57d3 100755 --- a/install.sh +++ b/install.sh @@ -757,8 +757,6 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/im_mad/im_exec/one_im_exec \ src/im_mad/im_exec/one_im_ssh \ src/im_mad/im_exec/one_im_sh \ - src/im_mad/im_exec/one_im_sh \ - src/im_mad/collectd/collectd \ src/im_mad/ec2/one_im_ec2 \ src/im_mad/dummy/one_im_dummy.rb \ src/im_mad/dummy/one_im_dummy \ From 48b1e1ce9fbd824a3329a7c3035c2e49e5c733c4 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 14 Oct 2013 16:16:21 +0200 Subject: [PATCH 27/44] im-collectd: remove debug info --- src/im_mad/im_exec/one_im_exec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/im_mad/im_exec/one_im_exec.rb b/src/im_mad/im_exec/one_im_exec.rb index 75c08fc09d..457ca09e0b 100755 --- a/src/im_mad/im_exec/one_im_exec.rb +++ b/src/im_mad/im_exec/one_im_exec.rb @@ -57,8 +57,6 @@ class InformationManagerDriver < OpenNebulaDriver @collectd_port = im_collectd.match(/-p (\d+)/)[1] rescue end - - File.open('/tmp/collectd_port.log','a'){|f| f.puts @collectd_port} end # Execute the run_probes in the remote host From 4dedcda45519f7f18adf76c65a8237bb48bd1389 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 14 Oct 2013 17:14:21 +0200 Subject: [PATCH 28/44] im-collectd: collectd-client_control returns the output of a regular run_probes --- src/im_mad/remotes/common.d/collectd-client_control.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/im_mad/remotes/common.d/collectd-client_control.sh b/src/im_mad/remotes/common.d/collectd-client_control.sh index 485d802152..0f89c4c17e 100755 --- a/src/im_mad/remotes/common.d/collectd-client_control.sh +++ b/src/im_mad/remotes/common.d/collectd-client_control.sh @@ -60,3 +60,9 @@ if ! check_running; then start_client write_pid $! fi + +# This script returns the run_probes execution +HYPERVISOR=$1 +set $HYPERVISOR-probes $@ + +$DIR/../run_probes $@ From 0efc81f0ef8a446ea5a2c2657854bc4f02bae0be Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 14 Oct 2013 20:25:08 +0200 Subject: [PATCH 29/44] im-collectd: Synchronous 'onehost sync'. --- src/cli/one_helper/onehost_helper.rb | 59 +++++++++++++++++++++++++++- src/cli/onehost | 9 ++--- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index dd8f30e91b..700fd74f23 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -29,7 +29,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper def self.state_to_str(id) id = id.to_i state_str = Host::HOST_STATES[id] - + return Host::SHORT_HOST_STATES[state_str] end @@ -114,7 +114,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper "#{cpu_usage} / #{max_cpu} (#{ratio}%)" else "#{cpu_usage} / -" - end + end end end @@ -156,6 +156,61 @@ class OneHostHelper < OpenNebulaHelper::OneHelper table end + + NUM_THREADS = 15 + def sync + # Get remote_dir (implies oneadmin group) + rc = OpenNebula::System.new(@client).get_configuration + return -1, rc.message if OpenNebula.is_error?(rc) + + conf = rc + remote_dir = conf['SCRIPTS_REMOTE_DIR'] + + # Verify the existence of REMOTES_LOCATION + if !File.directory? REMOTES_LOCATION + error_msg = "'#{REMOTES_LOCATION}' does not exist. " << + "This command must be run in the frontend." + return -1,error_msg + end + + filter_flag ||= OpenNebula::Pool::INFO_ALL + + pool = factory_pool(filter_flag) + + rc = pool.info + return -1, rc.message if OpenNebula.is_error?(rc) + + i = 0 + hs_threads = Array.new + pool.each do |host| + hs_threads[i % NUM_THREADS] ||= [] + hs_threads[i % NUM_THREADS] << host['NAME'] + i+=1 + end + + host_errors = Array.new + ts = hs_threads.map do |t| + Thread.new { + t.each do |host| + sync_cmd = "scp -rp #{REMOTES_LOCATION}/. #{host}:#{remote_dir} 2> /dev/null" + `#{sync_cmd} 2>/dev/null` + host_errors << host if !$?.success? + end + } + end + + ts.each{|t| t.join} + + if host_errors.empty? + puts "All hosts updated successfully." + 0 + else + STDERR.puts "Failed to update the following hosts:" + host_errors.each{|h| STDERR.puts "* #{h}"} + -1 + end + end + private def factory(id=nil) diff --git a/src/cli/onehost b/src/cli/onehost index 108db2d3fd..8f218abef0 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -20,8 +20,10 @@ ONE_LOCATION=ENV["ONE_LOCATION"] if !ONE_LOCATION RUBY_LIB_LOCATION="/usr/lib/one/ruby" + REMOTES_LOCATION="/var/lib/one/remotes" else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" + REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/" end $: << RUBY_LIB_LOCATION @@ -168,12 +170,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :sync, sync_desc do - if ONE_LOCATION - FileUtils.touch "#{ONE_LOCATION}/var/remotes" - else - FileUtils.touch "/var/lib/one/remotes" - end - 0 + helper.sync end list_desc = <<-EOT.unindent From 9146b2ef35cbe69f77dcea8e5435498db6823564 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 15 Oct 2013 10:57:56 +0200 Subject: [PATCH 30/44] im-collectd: Add mutex to the sync command --- src/cli/one_helper/onehost_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 700fd74f23..970414c86d 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -189,12 +189,19 @@ class OneHostHelper < OpenNebulaHelper::OneHelper end host_errors = Array.new + lock = Mutex.new + ts = hs_threads.map do |t| Thread.new { t.each do |host| sync_cmd = "scp -rp #{REMOTES_LOCATION}/. #{host}:#{remote_dir} 2> /dev/null" `#{sync_cmd} 2>/dev/null` - host_errors << host if !$?.success? + + if !$?.success? + lock.synchronize { + host_errors << host + } + end end } end From 434a151b1dbe4f98bcc3b0108a6eb3160ac623ec Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 15 Oct 2013 13:36:37 +0200 Subject: [PATCH 31/44] feature #2289: Update ec2 driver to use the ruby sdk instead of the java cli Capacity and endpoint for the host are now defined in hybrid_ec2.conf based on the host name --- install.sh | 4 +- .../ec2.d/monitor => im_exec/one_im_sh_ec2} | 58 +-- src/im_mad/remotes/ec2.d/poll | 3 +- src/vmm_mad/exec/one_vmm_sh_ec2 | 35 ++ src/vmm_mad/remotes/ec2/cancel | 2 +- src/vmm_mad/remotes/ec2/deploy | 2 +- src/vmm_mad/remotes/ec2/ec2_driver.rb | 411 ++++++++++-------- src/vmm_mad/remotes/ec2/hybrid_ec2.conf | 125 ++++++ src/vmm_mad/remotes/ec2/poll | 2 +- src/vmm_mad/remotes/ec2/reboot | 2 +- src/vmm_mad/remotes/ec2/restore | 2 +- src/vmm_mad/remotes/ec2/save | 2 +- src/vmm_mad/remotes/ec2/shutdown | 2 +- 13 files changed, 424 insertions(+), 226 deletions(-) rename src/im_mad/{remotes/ec2.d/monitor => im_exec/one_im_sh_ec2} (53%) mode change 100755 => 100644 create mode 100644 src/vmm_mad/exec/one_vmm_sh_ec2 create mode 100644 src/vmm_mad/remotes/ec2/hybrid_ec2.conf diff --git a/install.sh b/install.sh index 4debea1e61..22b158bad6 100755 --- a/install.sh +++ b/install.sh @@ -904,8 +904,7 @@ IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb" IM_PROBES_GANGLIA_FILES="src/im_mad/remotes/ganglia.d/ganglia_probe" -IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/monitor \ - src/im_mad/remotes/ec2.d/poll" +IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/poll" #------------------------------------------------------------------------------- # Auth Manager drivers to be installed under $REMOTES_LOCATION/auth @@ -1172,6 +1171,7 @@ ETC_FILES="share/etc/oned.conf \ VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc" EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2rc \ + src/vmm_mad/remotes/ec2/hybrid_ec2.conf \ src/vmm_mad/remotes/ec2/ec2.conf" #------------------------------------------------------------------------------- diff --git a/src/im_mad/remotes/ec2.d/monitor b/src/im_mad/im_exec/one_im_sh_ec2 old mode 100755 new mode 100644 similarity index 53% rename from src/im_mad/remotes/ec2.d/monitor rename to src/im_mad/im_exec/one_im_sh_ec2 index c8d5506688..cd4d386a3f --- a/src/im_mad/remotes/ec2.d/monitor +++ b/src/im_mad/im_exec/one_im_sh_ec2 @@ -1,4 +1,4 @@ -#!/usr/bin/env ruby +#!/bin/bash # -------------------------------------------------------------------------- # # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # @@ -16,48 +16,20 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -ONE_LOCATION=ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" - MAD_LOCATION="/usr/lib/one/mads" +if [ -z "${ONE_LOCATION}" ]; then + MAD_LOCATION=/usr/lib/one/mads else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" - MAD_LOCATION=ONE_LOCATION+"/lib/mads" -end + MAD_LOCATION=$ONE_LOCATION/lib/mads +fi -$: << RUBY_LIB_LOCATION -$: << File.join(File.dirname(__FILE__), '../../vmm/ec2') +while getopts ":u:r:t:c" opt $@; do + case "${opt}" in + u) + export EC2_REGION="${OPTARG}" + ;; + *) + ;; + esac +done -require 'pp' -require 'OpenNebulaDriver' -require 'ec2_driver' - -host = ARGV[2] - -def monitor(host) - sinst = ENV["SMALL_INSTANCES"].to_i - linst = ENV["LARGE_INSTANCES"].to_i - xlinst = ENV["EXTRALARGE_INSTANCES"].to_i - - smem = 1048576 * 1.7 * sinst - scpu = 100 * sinst - - lmem = 1048576 * 7.5 * linst - lcpu = 400 * linst - - xlmem = 1048576 * 15 * xlinst - xlcpu = 800 * xlinst - - totalmemory = smem + lmem + xlmem - totalcpu = scpu + lcpu + xlcpu - - info="HYPERVISOR=ec2\nTOTALMEMORY=#{totalmemory}\n"<< - "TOTALCPU=#{totalcpu}\nCPUSPEED=1000\nFREEMEMORY=#{totalmemory}"<< - "\nFREECPU=#{totalcpu}\n" - info << "HOSTNAME=\"#{host}\"\n" - - puts info -end - -monitor(host) +exec $MAD_LOCATION/one_im_sh $* diff --git a/src/im_mad/remotes/ec2.d/poll b/src/im_mad/remotes/ec2.d/poll index 9ca90fd7a7..5ecdc0c7cc 100755 --- a/src/im_mad/remotes/ec2.d/poll +++ b/src/im_mad/remotes/ec2.d/poll @@ -20,7 +20,8 @@ $: << File.join(File.dirname(__FILE__), '../../vmm/ec2') require 'ec2_driver' -ec2_drv = EC2Driver.new +host = ARGV[2] +ec2_drv = EC2Driver.new(host) ec2_drv.monitor_all_vms diff --git a/src/vmm_mad/exec/one_vmm_sh_ec2 b/src/vmm_mad/exec/one_vmm_sh_ec2 new file mode 100644 index 0000000000..0ba57b93c5 --- /dev/null +++ b/src/vmm_mad/exec/one_vmm_sh_ec2 @@ -0,0 +1,35 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +if [ -z "${ONE_LOCATION}" ]; then + MAD_LOCATION=/usr/lib/one/mads +else + MAD_LOCATION=$ONE_LOCATION/lib/mads +fi + +while getopts ":u:r:t:l:s:" opt $@; do + case "${opt}" in + u) + export EC2_REGION="${OPTARG}" + ;; + *) + ;; + esac +done + +exec $MAD_LOCATION/one_vmm_sh $* diff --git a/src/vmm_mad/remotes/ec2/cancel b/src/vmm_mad/remotes/ec2/cancel index d6b31bed9e..f8ca7af888 100755 --- a/src/vmm_mad/remotes/ec2/cancel +++ b/src/vmm_mad/remotes/ec2/cancel @@ -23,7 +23,7 @@ require 'ec2_driver' deploy_id = ARGV[0] host = ARGV[1] -ec2_drv = EC2Driver.new +ec2_drv = EC2Driver.new(host) ec2_drv.cancel(deploy_id) diff --git a/src/vmm_mad/remotes/ec2/deploy b/src/vmm_mad/remotes/ec2/deploy index ce0d2e94cd..1372e04315 100755 --- a/src/vmm_mad/remotes/ec2/deploy +++ b/src/vmm_mad/remotes/ec2/deploy @@ -24,7 +24,7 @@ dfile = ARGV[0] host = ARGV[1] id = ARGV[2] -ec2_drv = EC2Driver.new(ETC_LOCATION+'/ec2.conf') +ec2_drv = EC2Driver.new(host) text=File.read(dfile) diff --git a/src/vmm_mad/remotes/ec2/ec2_driver.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb index 6e824f7217..a84bd0e242 100755 --- a/src/vmm_mad/remotes/ec2/ec2_driver.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -15,34 +15,22 @@ # limitations under the License. # # -------------------------------------------------------------------------- # -ONE_LOCATION = ENV["ONE_LOCATION"] +ONE_LOCATION = ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION) if !ONE_LOCATION - RUBY_LIB_LOCATION = "/usr/lib/one/ruby" - ETC_LOCATION = "/etc/one/" + RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION) + ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION) else - RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" - ETC_LOCATION = ONE_LOCATION + "/etc/" + RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" if !defined?(RUBY_LIB_LOCATION) + ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION) end +HYBRID_CONF = "#{ETC_LOCATION}/hybrid_ec2.conf" + # Load EC2 credentials and environment require 'yaml' - -ec2_env = "#{ETC_LOCATION}/ec2rc" -if File.exist?(ec2_env) - env = YAML::load(File.read(ec2_env)) - env.each do |key, value| - ENV[key] = value.to_s - end -end - -# Set up the environment for the driver -EC2_LOCATION = ENV["EC2_HOME"] - -if !EC2_LOCATION - STDERR.puts "EC2_HOME not set" - exit(-1) -end +require 'rubygems' +require 'aws-sdk' $: << RUBY_LIB_LOCATION @@ -60,79 +48,82 @@ class EC2Driver # EC2 commands constants EC2 = { :run => { - :cmd => "#{EC2_LOCATION}/bin/ec2-run-instances", + :cmd => :create, :args => { "AKI" => { - :opt => '--kernel' + :opt => 'kernel_id' }, "AMI" => { - :opt => '' - }, - "BLOCKDEVICEMAPPING" => { - :opt => '-b' + :opt => 'image_id' }, + #"BLOCKDEVICEMAPPING" => { + # :opt => '-b' + #}, "CLIENTTOKEN" => { - :opt => '--client-token' + :opt => 'client_token' }, "INSTANCETYPE" => { - :opt => '-t' + :opt => 'instance_type' }, "KEYPAIR" => { - :opt => '-k' + :opt => 'key_name' }, "LICENSEPOOL" => { - :opt => '--license-pool' + :opt => 'license/pool' }, "PLACEMENTGROUP" => { - :opt => '--placement-group' + :opt => 'placement/group_name' }, "PRIVATEIP" => { - :opt => '--private-ip-address' + :opt => 'private_ip_address' }, "RAMDISK" => { - :opt => '--ramdisk' + :opt => 'ramdisk_id' }, "SUBNETID" => { - :opt => '-s' + :opt => 'subnet_id' }, "TENANCY" => { - :opt => '--tenancy' + :opt => 'placement/tenancy' }, "USERDATA" => { - :opt => '-d' - }, - "USERDATAFILE" => { - :opt => '-f' + :opt => 'user_data' }, + #"USERDATAFILE" => { + # :opt => '-f' + #}, "SECURITYGROUPS" => { - :opt => '-g', - :proc => lambda {|str| str.split(',').join(' -g ')} + :opt => 'security_groups', + :proc => lambda {|str| str.split(',')} }, "AVAILABILITYZONE" => { - :opt => '--availability-zone' + :opt => 'placement/availability-zone' + }, + "EBS_OPTIMIZED" => { + :opt => 'ebs_optimized' } } }, :terminate => { - :cmd => "#{EC2_LOCATION}/bin/ec2-terminate-instances" + :cmd => :terminate }, :describe => { - :cmd => "#{EC2_LOCATION}/bin/ec2-describe-instances" + :cmd => :describe_instances }, :associate => { - :cmd => "#{EC2_LOCATION}/bin/ec2-associate-address", + :cmd => :associate_address, :args => { - "SUBNETID" => { - :opt => '-a', - :proc => lambda {|str| ''} - }, + #"SUBNETID" => { + # :opt => '-a', + # :proc => lambda {|str| ''} + #}, "ELASTICIP" => { - :opt => '' + :opt => 'public_ip' } } }, :authorize => { - :cmd => "#{EC2_LOCATION}/bin/ec2-authorize", + :cmd => :authorize, :args => { "AUTHORIZEDPORTS" => { :opt => '-p', @@ -141,184 +132,209 @@ class EC2Driver } }, :reboot => { - :cmd => "#{EC2_LOCATION}/bin/ec2-reboot-instances" + :cmd => :reboot }, :stop => { - :cmd => "#{EC2_LOCATION}/bin/ec2-stop-instances" + :cmd => :stop }, :start => { - :cmd => "#{EC2_LOCATION}/bin/ec2-start-instances" + :cmd => :start }, :tags => { - :cmd => "#{EC2_LOCATION}/bin/ec2-create-tags", + :cmd => :create_tags, :args => { "TAGS" => { :opt => '-t', - :proc => lambda {|str| str.split(',').join(' -t ')} + :proc => lambda {|str| + hash = {} + str.split(',').each {|s| + k,v = s.split('=') + hash[k] = v + } + hash + } } } } } - # EC2 constructor, loads defaults for the EC2Driver - def initialize(ec2_conf = nil) - @defaults = Hash.new + # EC2 constructor, loads credentials and endpoint + def initialize(host) + @host = host - if !ec2_conf && ENV['EC2_CONF'] - ec2_conf = ENV['EC2_CONF'] - end + @ec2_conf = ETC_LOCATION+'/ec2.conf' - if ec2_conf && File.exists?(ec2_conf) - fd = File.new(ec2_conf) - xml = REXML::Document.new fd - fd.close() + hybrid_ec2_conf = YAML::load(File.read(HYBRID_CONF)) - return if !xml || !xml.root + @instance_types = hybrid_ec2_conf['instance_types'] - ec2 = xml.root.elements["EC2"] + regions = hybrid_ec2_conf['regions'] + @region = regions[host] || regions["default"] - return if !ec2 + AWS.config( + 'access_key_id' => @region['access_key_id'], + 'secret_access_key' => @region['secret_access_key'], + 'region' => @region['region_name']) - EC2.each {|action, hash| - if hash[:args] - hash[:args].each { |key, value| - @defaults[key] = value_from_xml(ec2, key) - } - end - } - end + @ec2 = AWS.ec2 end # DEPLOY action, also sets ports and ip if needed def deploy(id, host, xml_text) ec2_info = get_deployment_info(host, xml_text) - return unless ec2_info + + load_default_template_values if !ec2_value(ec2_info, 'AMI') - msg = "Cannot find AMI in deployment file" - STDERR.puts(msg) + STDERR.puts("Cannot find AMI in deployment file") exit(-1) end - deploy_exe = exec_and_log_ec2(:run, ec2_info, "") - if deploy_exe.code != 0 - msg = deploy_exe.stderr - STDERR.puts(msg) + opts = generate_options(:run, ec2_info, { + :min_count => 1, + :max_count => 1}) + + begin + instance = AWS.ec2.instances.create(opts) + rescue => e + STDERR.puts(e.message) exit(-1) end - if !deploy_exe.stdout.match(/^INSTANCE\s*(.+?)\s/) - msg = "Could not find instance id. Check ec2-describe-instances" - STDERR.puts(msg) - exit(-1) - end - - deploy_id = $1 - - if ec2_value(ec2_info, 'AUTHORIZEDPORTS') - exec_and_log_ec2(:authorize, ec2_info, 'default') - end - - LocalCommand.run( - "#{EC2_LOCATION}/bin/ec2-create-tags #{deploy_id} -t ONE_ID=#{id}", - lambda {|str| STDERR.puts(str) }) - - if ec2_value(ec2_info, 'TAGS') - exec_and_log_ec2(:tags, ec2_info, deploy_id) - end + tags = generate_options(:tags, ec2_info) || {} + tags['ONE_ID'] = id + tags.each{ |key,value| + begin + instance.add_tag(key, :value => value) + rescue => e + STDERR.puts(e.message) + exit(-1) + end + } if ec2_value(ec2_info, 'ELASTICIP') - exec_and_log_ec2(:associate, ec2_info, "-i #{deploy_id}") + begin + instance.associate_elastic_ip(ec2_value(ec2_info, 'ELASTICIP')) + rescue => e + STDERR.puts(e.message) + exit(-1) + end end - puts(deploy_id) + puts(instance.id) end # Shutdown a EC2 instance def shutdown(deploy_id) - ec2_action(deploy_id, :terminate, ACTION[:shutdown]) + ec2_action(deploy_id, :terminate) end # Reboot a EC2 instance def reboot(deploy_id) - ec2_action(deploy_id, :reboot, ACTION[:reboot]) + ec2_action(deploy_id, :reboot) end # Cancel a EC2 instance def cancel(deploy_id) - ec2_action(deploy_id, :terminate, ACTION[:cancel]) + ec2_action(deploy_id, :terminate) end # Stop a EC2 instance def save(deploy_id) - ec2_action(deploy_id, :stop, ACTION[:save]) + ec2_action(deploy_id, :stop) end # Cancel a EC2 instance def restore(deploy_id) - ec2_action(deploy_id, :start, ACTION[:restore]) + ec2_action(deploy_id, :start) end # Get info (IP, and state) for a EC2 instance def poll(id, deploy_id) - exe = exec_and_log_ec2(:describe, nil, deploy_id) - if exe.code != 0 - STDERR.puts(exe.stderr) - exit(-1) - end - - info = parse_poll(exe.stdout, deploy_id) - puts info + i = get_instance(deploy_id) + puts parse_poll(i) end + # Get the info of all the EC2 instances. An EC2 instance must include + # the ONE_ID tag, otherwise it will be ignored def monitor_all_vms - exe = LocalCommand.run( - "#{EC2_LOCATION}/bin/ec2-describe-instances", - lambda { |str| STDERR.puts str }) + totalmemory = 0 + totalcpu = 0 + @region['capacity'].each { |name, size| + totalmemory += @instance_types[name]['memory'] * size * 1024 * 1024 + totalcpu += @instance_types[name]['cpu'] * size * 100 + } - if exe.code != 0 + host_info = "HYPERVISOR=ec2\n" + host_info << "TOTALMEMORY=#{totalmemory}\n" + host_info << "TOTALCPU=#{totalcpu}\n" + host_info << "CPUSPEED=1000\n" + host_info << "HOSTNAME=\"#{@host}\"\n" + + vms_info = "VM_POLL=YES\n" + + usedcpu = 0 + usedmemory = 0 + begin + AWS.ec2.instances.each do |i| + poll_data=parse_poll(i) + + one_id = i.tags['ONE_ID'] + + vms_info << "VM=[\n" + vms_info << " ID=#{one_id || -1},\n" + vms_info << " DEPLOY_ID=#{i.instance_id},\n" + vms_info << " POLL=\"#{poll_data}\" ]\n" + + if one_id + name = i.instance_type + usedcpu += @instance_types[name]['cpu'] * 100 + usedmemory += @instance_types[name]['memory'] * 1024 * 1024 + end + + end + rescue => e + STDERR.puts(e.message) exit(-1) end - puts "VM_POLL=YES" + host_info << "USEDMEMORY=#{usedmemory.round}\n" + host_info << "USEDCPU=#{usedcpu.round}\n" + host_info << "FREEMEMORY=#{(totalmemory - usedmemory).round}\n" + host_info << "FREECPU=#{(totalcpu - usedcpu).round}\n" - exe.stdout.split(/^RESERVATION\s.*?$/).each do |vm| - m=vm.match(/^INSTANCE\s+(\S+)/) - next if !m - - deploy_id = m[1] - - one_id='-1' - - vm.scan(/^TAG.*ONE_ID\s+(\d+)/) {|i| one_id = i.first } - - poll_data=parse_poll(vm, deploy_id) - - puts "VM=[" - puts " ID=#{one_id}," - puts " DEPLOY_ID=#{deploy_id}," - puts " POLL=\"#{poll_data}\" ]" - end + puts host_info + puts vms_info end private + # Get the EC2 section of the template. If more than one EC2 section + # the CLOUD element is used and matched with the host def get_deployment_info(host, xml_text) xml = REXML::Document.new xml_text ec2 = nil + ec2_deprecated = nil all_ec2_elements = xml.root.get_elements("//USER_TEMPLATE/EC2") # First, let's see if we have an EC2 site that matches # our desired host name all_ec2_elements.each { |element| - cloud=element.elements["CLOUD"] + cloud=element.elements["HOST"] if cloud and cloud.text.upcase == host.upcase ec2 = element + else + cloud=element.elements["CLOUD"] + if cloud and cloud.text.upcase == host.upcase + ec2_deprecated = element + end end } + ec2 ||= ec2_deprecated + if !ec2 # If we don't find the EC2 site, and ONE just # knows about one EC2 site, let's use that @@ -336,26 +352,23 @@ private ec2 end - def parse_poll(text, deploy_id) - text.match(Regexp.new("INSTANCE\\s+#{deploy_id}\\s+(.+)")) - + # Retrive the vm information from the EC2 instance + def parse_poll(instance) info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \ "#{POLL_ATTRIBUTE[:usedcpu]}=0 " \ "#{POLL_ATTRIBUTE[:nettx]}=0 " \ "#{POLL_ATTRIBUTE[:netrx]}=0" - if !$1 + if !instance.exists? info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}" else - monitor_data = $1.split(/\s+/) - - case monitor_data[3] - when "pending" + case instance.status + when :pending info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}" - when "running" + when :running info<<" #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"<< - " IP=#{monitor_data[1]}" - when "shutting-down","terminated" + " IP=#{instance.ip_address}" + when :'shutting-down', :terminated info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}" end end @@ -363,37 +376,43 @@ private info end - # Execute an EC2 command and send the SUCCESS or FAILURE signal + # Execute an EC2 command # +deploy_id+: String, VM id in EC2 # +ec2_action+: Symbol, one of the keys of the EC2 hash constant (i.e :run) - # +one_action+: String, OpenNebula action - def ec2_action(deploy_id, ec2_action, one_action) - exe = exec_and_log_ec2(ec2_action, nil, deploy_id) - if exe.code != 0 - STDERR.puts(exe.stderr) + def ec2_action(deploy_id, ec2_action) + i = get_instance(deploy_id) + + begin + i.send(EC2[ec2_action][:cmd]) + rescue => e + STDERR.puts e.message exit(-1) end end - # Execute an EC2 command and log the message if error - # This function will build the command joining the :cmd value of the EC2 - # hash, the extra_params string and the options built from the :args schema - # of the EC2 hash and the xml - # +action+: Symbol, one of the keys of the EC2 hash constant (i.e :run) - # +xml+: REXML Document, containing EC2 information - # +extra_params+: String, extra information to be added to the command - def exec_and_log_ec2(action, xml, extra_params) - cmd = EC2[action][:cmd].clone - cmd << ' ' << extra_params << ' ' if extra_params + # Generate the options for the given command from the xml provided in the + # template. The available options for each command are defined in the EC2 + # constant + def generate_options(action, xml, extra_params={}) + opts = extra_params || {} if EC2[action][:args] - cmd << EC2[action][:args].map {|k,v| + EC2[action][:args].each {|k,v| str = ec2_value(xml, k, &v[:proc]) - v[:opt] + ' ' + str if str - }.join(' ') + if str + tmp = opts + last_key = nil + v[:opt].split('/').each { |k| + tmp = tmp[last_key] if last_key + tmp[k] = {} + last_key = k + } + tmp[last_key] = str + end + } end - LocalCommand.run(cmd, lambda {|str| STDERR.puts(str) }) + opts end # Returns the value of the xml specified by the name or the default @@ -416,5 +435,51 @@ private element.text.strip if element && element.text end end + + # Load the default values that will be used to create a new instance, if + # not provided in the template. These values are defined in the EC2_CONF + # file + def load_default_template_values + @defaults = Hash.new + + if !@ec2_conf && ENV['EC2_CONF'] + @ec2_conf = ENV['EC2_CONF'] + end + + if @ec2_conf && File.exists?(@ec2_conf) + fd = File.new(@ec2_conf) + xml = REXML::Document.new fd + fd.close() + + return if !xml || !xml.root + + ec2 = xml.root.elements["EC2"] + + return if !ec2 + + EC2.each {|action, hash| + if hash[:args] + hash[:args].each { |key, value| + @defaults[key] = value_from_xml(ec2, key) + } + end + } + end + end + + # Retrive the instance from EC2 + def get_instance(id) + begin + instance = AWS.ec2.instances[id] + if instance.exists? + return instance + else + raise "Instance #{id} does not exist" + end + rescue => e + STDERR.puts e.message + exit(-1) + end + end end diff --git a/src/vmm_mad/remotes/ec2/hybrid_ec2.conf b/src/vmm_mad/remotes/ec2/hybrid_ec2.conf new file mode 100644 index 0000000000..3b11de4df7 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/hybrid_ec2.conf @@ -0,0 +1,125 @@ +regions: + default: + region_name: us-east-1 + access_key_id: + secret_access_key: + capacity: + m1.small: 5 + m1.large: 0 + m1.xlarge: 0 + us-east-1: + region_name: us-east-1 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + us-west-2: + region_name: us-west-2 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + us-west-1: + region_name: us-west-1 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + eu-west-1: + region_name: eu-west-1 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + ap-southeast-1: + region_name: ap-southeast-1 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + ap-southeast-2: + region_name: ap-southeast-2 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + ap-northeast-1: + region_name: ap-northeast-1 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: + sa-east-1: + region_name: sa-east-1 + access_key_id: + secret_access_key: + capacity: + m1.small: + m1.large: + m1.xlarge: +instance_types: + m1.small: + cpu: 1 + memory: 1.7 + m1.medium: + cpu: 1 + memory: 3.75 + m1.large: + cpu: 2 + memory: 7.5 + m1.xlarge: + cpu: 4 + memory: 15 + m3.xlarge: + cpu: 4 + memory: 15 + m3.2xlarge8: + cpu: 26 + memory: 30 + c1.medium: + cpu: 2 + memory: 1.7 + c1.xlarge: + cpu: 8 + memory: 7 + cc2.8xlarge: + cpu: 32 + memory: 60.5 + m2.xlarge: + cpu: 2 + memory: 17.1 + m2.2xlarge4: + cpu: 13 + memory: 34.2 + m2.4xlarge8: + cpu: 26 + memory: 68.4 + cr1.8xlarge: + cpu: 32 + memory: 244 + hi1.4xlarge: + cpu: 16 + memory: 60.5 + hs1.8xlarge: + cpu: 16 + memory: 117 + t1.micro: + cpu: 1 + memory: 0.615 + cg1.4xlarge: + cpu: 16 + memory: 22.5 diff --git a/src/vmm_mad/remotes/ec2/poll b/src/vmm_mad/remotes/ec2/poll index 20fb27c4d7..92a334853f 100755 --- a/src/vmm_mad/remotes/ec2/poll +++ b/src/vmm_mad/remotes/ec2/poll @@ -24,7 +24,7 @@ deploy_id = ARGV[0] host = ARGV[1] id = ARGV[2] -ec2_drv = EC2Driver.new +ec2_drv = EC2Driver.new(host) ec2_drv.poll(id, deploy_id) diff --git a/src/vmm_mad/remotes/ec2/reboot b/src/vmm_mad/remotes/ec2/reboot index 9fdc51f450..9f1bbe9859 100755 --- a/src/vmm_mad/remotes/ec2/reboot +++ b/src/vmm_mad/remotes/ec2/reboot @@ -23,7 +23,7 @@ require 'ec2_driver' deploy_id = ARGV[0] host = ARGV[1] -ec2_drv = EC2Driver.new +ec2_drv = EC2Driver.new(host) ec2_drv.reboot(deploy_id) diff --git a/src/vmm_mad/remotes/ec2/restore b/src/vmm_mad/remotes/ec2/restore index 39530e23b7..f29a8a2e60 100755 --- a/src/vmm_mad/remotes/ec2/restore +++ b/src/vmm_mad/remotes/ec2/restore @@ -25,7 +25,7 @@ host = ARGV[1] deploy_id=File.read(checkpoint_file).strip -ec2_drv = EC2Driver.new +ec2_drv = EC2Driver.new(host) ec2_drv.restore(deploy_id) diff --git a/src/vmm_mad/remotes/ec2/save b/src/vmm_mad/remotes/ec2/save index e9d5144eb8..47ab29e774 100755 --- a/src/vmm_mad/remotes/ec2/save +++ b/src/vmm_mad/remotes/ec2/save @@ -24,7 +24,7 @@ deploy_id = ARGV[0] file = ARGV[1] host = ARGV[2] -ec2_drv = EC2Driver.new +ec2_drv = EC2Driver.new(host) dir=File.dirname(file) Dir.mkdir(dir) if !Dir.exist?(dir) diff --git a/src/vmm_mad/remotes/ec2/shutdown b/src/vmm_mad/remotes/ec2/shutdown index 161d0f657b..7352e20c52 100755 --- a/src/vmm_mad/remotes/ec2/shutdown +++ b/src/vmm_mad/remotes/ec2/shutdown @@ -23,7 +23,7 @@ require 'ec2_driver' deploy_id = ARGV[0] host = ARGV[1] -ec2_drv = EC2Driver.new +ec2_drv = EC2Driver.new(host) ec2_drv.shutdown(deploy_id) From b7234a4c370e31869939d11aacc025780157d62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 15 Oct 2013 13:45:16 +0200 Subject: [PATCH 32/44] Feature #1612: Add volatile disk quotas for attach/detach operations --- include/RequestManagerVirtualMachine.h | 10 ++ include/VirtualMachine.h | 5 + src/lcm/LifeCycleStates.cc | 13 +- src/rm/RequestManagerVirtualMachine.cc | 225 +++++++++++++++++-------- src/um/QuotaVirtualMachine.cc | 4 +- src/vm/VirtualMachine.cc | 27 +++ 6 files changed, 208 insertions(+), 76 deletions(-) diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h index 789a0aebb7..cf845f2468 100644 --- a/include/RequestManagerVirtualMachine.h +++ b/include/RequestManagerVirtualMachine.h @@ -56,6 +56,16 @@ protected: PoolObjectAuth * ds_perm, AuthRequest::Operation op); + bool quota_resize_authorization( + Template * deltas, + RequestAttributes& att, + PoolObjectAuth& vm_perms); + + bool quota_resize_authorization( + int oid, + Template * deltas, + RequestAttributes& att); + int get_host_information( int hid, string& name, diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 9ea3e36d1c..0b9f50e714 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1073,6 +1073,11 @@ public: */ static bool isVolatile(const VectorAttribute * disk); + /** + * Check if the template contains a volatile disk + */ + static bool isVolatile(const Template * tmpl); + /** * Return the total SIZE of volatile disks */ diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 612caca169..5991d36541 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -1346,12 +1346,21 @@ void LifeCycleManager::attach_failure_action(int vid) tmpl.set(disk); - Quotas::quota_del(Quotas::IMAGE, uid, gid, &tmpl); - if ( disk->vector_value("IMAGE_ID", image_id) == 0 ) { + // Disk using an Image + Quotas::quota_del(Quotas::IMAGE, uid, gid, &tmpl); + imagem->release_image(oid, image_id, false); } + else // Volatile disk + { + // It is an update of the volatile counter without + // shutting destroying a VM + tmpl.add("VMS", 0); + + Quotas::quota_del(Quotas::VM, uid, gid, &tmpl); + } } } else diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 9688b42370..f53bf7171b 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -96,6 +96,120 @@ bool RequestManagerVirtualMachine::vm_authorization( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool RequestManagerVirtualMachine::quota_resize_authorization( + int oid, + Template * deltas, + RequestAttributes& att) +{ + PoolObjectAuth vm_perms; + VirtualMachine * vm = Nebula::instance().get_vmpool()->get(oid, true); + + if (vm == 0) + { + failure_response(NO_EXISTS, + get_error(object_name(PoolObjectSQL::VM),oid), + att); + + return false; + } + + vm->get_permissions(vm_perms); + + vm->unlock(); + + return quota_resize_authorization(deltas, att, vm_perms); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +bool RequestManagerVirtualMachine::quota_resize_authorization( + Template * deltas, + RequestAttributes& att, + PoolObjectAuth& vm_perms) +{ + int rc; + + string error_str; + + Nebula& nd = Nebula::instance(); + UserPool* upool = nd.get_upool(); + GroupPool* gpool = nd.get_gpool(); + + Quotas user_dquotas = nd.get_default_user_quota(); + Quotas group_dquotas = nd.get_default_group_quota(); + + if (vm_perms.uid != UserPool::ONEADMIN_ID) + { + User * user = upool->get(vm_perms.uid, true); + + if ( user != 0 ) + { + rc = user->quota.quota_update(Quotas::VM, deltas, user_dquotas, error_str); + + if (rc == false) + { + ostringstream oss; + + oss << object_name(PoolObjectSQL::USER) + << " [" << vm_perms.uid << "] " + << error_str; + + failure_response(AUTHORIZATION, + request_error(oss.str(), ""), + att); + + user->unlock(); + + return false; + } + + upool->update(user); + + user->unlock(); + } + } + + if (vm_perms.gid != GroupPool::ONEADMIN_ID) + { + Group * group = gpool->get(vm_perms.gid, true); + + if ( group != 0 ) + { + rc = group->quota.quota_update(Quotas::VM, deltas, group_dquotas, error_str); + + if (rc == false) + { + ostringstream oss; + RequestAttributes att_tmp(vm_perms.uid, -1, att); + + oss << object_name(PoolObjectSQL::GROUP) + << " [" << vm_perms.gid << "] " + << error_str; + + failure_response(AUTHORIZATION, + request_error(oss.str(), ""), + att); + + group->unlock(); + + quota_rollback(deltas, Quotas::VM, att_tmp); + + return false; + } + + gpool->update(group); + + group->unlock(); + } + } + + return true; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int RequestManagerVirtualMachine::get_default_ds_information( int cluster_id, int& ds_id, @@ -1226,10 +1340,13 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList, DispatchManager * dm = nd.get_dm(); VirtualMachineTemplate * tmpl = new VirtualMachineTemplate(); + VirtualMachineTemplate * deltas = 0; PoolObjectAuth host_perms; + PoolObjectAuth vm_perms; int rc; string error_str; + bool volatile_disk; int id = xmlrpc_c::value_int(paramList.getInt(1)); string str_tmpl = xmlrpc_c::value_string(paramList.getString(2)); @@ -1258,17 +1375,43 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList, return; } - if ( quota_authorization(tmpl, Quotas::IMAGE, att) == false ) + volatile_disk = VirtualMachine::isVolatile(tmpl); + + if ( volatile_disk ) { - delete tmpl; - return; + deltas = new VirtualMachineTemplate(*tmpl); + + deltas->add("VMS", 0); + + if (quota_resize_authorization(id, deltas, att) == false) + { + delete tmpl; + delete deltas; + + return; + } + } + else + { + if ( quota_authorization(tmpl, Quotas::IMAGE, att) == false ) + { + delete tmpl; + return; + } } rc = dm->attach(id, tmpl, error_str); if ( rc != 0 ) { - quota_rollback(tmpl, Quotas::IMAGE, att); + if ( volatile_disk ) + { + quota_rollback(deltas, Quotas::VM, att); + } + else + { + quota_rollback(tmpl, Quotas::IMAGE, att); + } failure_response(ACTION, request_error(error_str, ""), @@ -1280,6 +1423,8 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList, } delete tmpl; + delete deltas; + return; } @@ -1338,14 +1483,8 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList, int nvcpu, ovcpu; Nebula& nd = Nebula::instance(); - UserPool* upool = nd.get_upool(); - GroupPool* gpool = nd.get_gpool(); HostPool * hpool = nd.get_hpool(); - - Quotas user_dquotas = nd.get_default_user_quota(); - Quotas group_dquotas = nd.get_default_group_quota(); - - Host * host; + Host * host; Template deltas; string error_str; @@ -1494,69 +1633,9 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList, /* Check quotas */ /* ---------------------------------------------------------------------- */ - if (vm_perms.uid != UserPool::ONEADMIN_ID) + if (quota_resize_authorization(&deltas, att, vm_perms) == false) { - User * user = upool->get(vm_perms.uid, true); - - if ( user != 0 ) - { - rc = user->quota.quota_update(Quotas::VM, &deltas, user_dquotas, error_str); - - if (rc == false) - { - ostringstream oss; - - oss << object_name(PoolObjectSQL::USER) - << " [" << vm_perms.uid << "] " - << error_str; - - failure_response(AUTHORIZATION, - request_error(oss.str(), ""), - att); - - user->unlock(); - - return; - } - - upool->update(user); - - user->unlock(); - } - } - - if (vm_perms.gid != GroupPool::ONEADMIN_ID) - { - Group * group = gpool->get(vm_perms.gid, true); - - if ( group != 0 ) - { - rc = group->quota.quota_update(Quotas::VM, &deltas, group_dquotas, error_str); - - if (rc == false) - { - ostringstream oss; - RequestAttributes att_tmp(vm_perms.uid, -1, att); - - oss << object_name(PoolObjectSQL::GROUP) - << " [" << vm_perms.gid << "] " - << error_str; - - failure_response(AUTHORIZATION, - request_error(oss.str(), ""), - att); - - group->unlock(); - - quota_rollback(&deltas, Quotas::VM, att_tmp); - - return; - } - - gpool->update(group); - - group->unlock(); - } + return; } /* ---------------------------------------------------------------------- */ diff --git a/src/um/QuotaVirtualMachine.cc b/src/um/QuotaVirtualMachine.cc index 55eea64d81..7da8cb5101 100644 --- a/src/um/QuotaVirtualMachine.cc +++ b/src/um/QuotaVirtualMachine.cc @@ -150,7 +150,9 @@ bool QuotaVirtualMachine::update(Template * tmpl, vm_request.insert(make_pair("CPU", delta_cpu)); } - if ( tmpl->get("VOLATILE_SIZE", delta_size) == true ) + delta_size = VirtualMachine::get_volatile_disk_size(tmpl); + + if ( delta_size != 0 ) { vm_request.insert(make_pair("VOLATILE_SIZE", delta_size)); } diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index ed31b37327..85b8bf1bb0 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2018,6 +2018,7 @@ VectorAttribute * VirtualMachine::delete_attach_disk() return 0; } + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -2033,6 +2034,32 @@ bool VirtualMachine::isVolatile(const VectorAttribute * disk) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool VirtualMachine::isVolatile(const Template * tmpl) +{ + vector disks; + int num_disks = tmpl->get("DISK", disks); + + for (int i = 0 ; i < num_disks ; i++) + { + const VectorAttribute * disk = dynamic_cast(disks[i]); + + if (disk == 0) + { + continue; + } + + if (VirtualMachine::isVolatile(disk)) + { + return true; + } + } + + return false; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + float VirtualMachine::get_volatile_disk_size(Template * tmpl) { float size = 0; From 675f0b646d27004b6dacbecd3bf23fe4b126bb47 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 15 Oct 2013 15:41:22 +0200 Subject: [PATCH 33/44] bug #2280: Fixed sed -E --> sed -e for ESX Also, some single quotes problem over ssh --- src/datastore_mad/remotes/vmfs/monitor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datastore_mad/remotes/vmfs/monitor b/src/datastore_mad/remotes/vmfs/monitor index c335f3fadd..f88824d3c1 100755 --- a/src/datastore_mad/remotes/vmfs/monitor +++ b/src/datastore_mad/remotes/vmfs/monitor @@ -64,10 +64,10 @@ set -e USED_MB=\$($DU -sLm ${BASE_PATH%/} 2>/dev/null | $CUT -f1) -DF_STR=\$($DF -m | grep ${BASE_PATH%/} | $SED 's/ \+/:/g') +DF_STR=\$($DF -m | grep ${BASE_PATH%/} | sed -e 's/ \+/:/g') -TOTAL_MB=\$(echo \$DF_STR | $CUT -d':' -f 2) -FREE_MB=\$(echo \$DF_STR | $CUT -d':' -f 4) +TOTAL_MB=\$(echo \$DF_STR | $CUT -d: -f 2) +FREE_MB=\$(echo \$DF_STR | $CUT -d: -f 4) echo "USED_MB=\$USED_MB" echo "TOTAL_MB=\$TOTAL_MB" From 44c8e4da9c970128ccbe16ad735e19ce7ab632d6 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 15 Oct 2013 17:11:47 +0200 Subject: [PATCH 34/44] Bug #2362: Identify if multiple valued attribute is being change and add to array instead of overwritting --- src/sunstone/public/js/sunstone-util.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index c2804934b9..1641c756bc 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -1868,7 +1868,14 @@ function insert_extended_template_table(template_json,resource_type,resource_id, if ( new_value != "" && new_key != "" ) { var template_json_bk = $.extend({}, template_json); - template_json[$.trim(new_key)] = $.trim(new_value); + if(template_json[$.trim(new_key)] && (template_json[$.trim(new_key)] instanceof Array)) + { + template_json[$.trim(new_key)].push($.trim(new_value)); + } + else + { + template_json[$.trim(new_key)]=$.trim(new_value); + } template_str = convert_template_to_string(template_json,unshown_values); Sunstone.runAction(resource_type+".update_template",resource_id,template_str); From 0b818bd37330901a15a37472f6fca967e7844352 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 15 Oct 2013 17:55:20 +0200 Subject: [PATCH 35/44] im-collectd: the core only sends updates the first time the host is monitored. --- src/im/InformationManager.cc | 5 +---- src/xml/ObjectXML.cc | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/im/InformationManager.cc b/src/im/InformationManager.cc index f8efeddd62..d5614b9ec4 100644 --- a/src/im/InformationManager.cc +++ b/src/im/InformationManager.cc @@ -98,8 +98,6 @@ int InformationManager::start() return -1; } - utime(remotes_location.c_str(), 0); - NebulaLog::log("InM",Log::INFO,"Starting Information Manager..."); pthread_attr_init (&pattr); @@ -257,8 +255,7 @@ void InformationManager::timer_action() { bool update_remotes = false; - if ((sb.st_mtime != 0) && - (sb.st_mtime > host->get_last_monitored())) + if (host->get_last_monitored() == 0) { update_remotes = true; } diff --git a/src/xml/ObjectXML.cc b/src/xml/ObjectXML.cc index 1417d6f898..40f140768b 100644 --- a/src/xml/ObjectXML.cc +++ b/src/xml/ObjectXML.cc @@ -292,8 +292,8 @@ int ObjectXML::xpath(unsigned long long& value, const char * xpath_expr, int ObjectXML::xpath(time_t& value, const char * xpath_expr, const time_t& def) { - int int_val; - int int_def = static_cast(def); + unsigned long long int_val; + unsigned long long int_def = static_cast(def); int rc; rc = xpath(int_val, xpath_expr, int_def); From 97f63c3659a6a13dbe02bed8fef50106bf60108c Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 15 Oct 2013 17:58:10 +0200 Subject: [PATCH 36/44] im-collectd: the collectd-client stops if it receives a onehost sync --- src/cli/one_helper/onehost_helper.rb | 7 +++++++ src/im_mad/remotes/common.d/collectd-client.rb | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 970414c86d..0692a9c71d 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -173,6 +173,10 @@ class OneHostHelper < OpenNebulaHelper::OneHelper return -1,error_msg end + # Touch the update file + FileUtils.touch(File.join(REMOTES_LOCATION,'.update')) + + # Get the Host pool filter_flag ||= OpenNebula::Pool::INFO_ALL pool = factory_pool(filter_flag) @@ -180,6 +184,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper rc = pool.info return -1, rc.message if OpenNebula.is_error?(rc) + # Assign hosts to threads i = 0 hs_threads = Array.new pool.each do |host| @@ -188,6 +193,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper i+=1 end + # Run the jobs in threads host_errors = Array.new lock = Mutex.new @@ -206,6 +212,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper } end + # Wait for threads to finish ts.each{|t| t.join} if host_errors.empty? diff --git a/src/im_mad/remotes/common.d/collectd-client.rb b/src/im_mad/remotes/common.d/collectd-client.rb index bf332972ca..3ebfb7f636 100644 --- a/src/im_mad/remotes/common.d/collectd-client.rb +++ b/src/im_mad/remotes/common.d/collectd-client.rb @@ -20,6 +20,7 @@ require 'socket' require 'base64' DIRNAME = File.dirname(__FILE__) +REMOTE_DIR_UPDATE = File.join(DIRNAME, '../../.update') CYCLE = 20 TOTAL_HOSTS = 1000 @@ -42,6 +43,9 @@ class CollectdClient run_probes_cmd = File.join(DIRNAME, '..', "run_probes") @run_probes_cmd = "#{run_probes_cmd} #{@hypervisor}-probes" + # Get last update + @last_update = get_last_update + # Socket @s = UDPSocket.new end @@ -86,6 +90,9 @@ class CollectdClient last_send = nil loop do + # Stop the execution if we receive the update signal + exit 0 if stop? + t = Time.now.to_i current_cycle = t / CYCLE @@ -108,6 +115,14 @@ class CollectdClient sleep SLEEP end end + + def get_last_update + File.stat(REMOTE_DIR_UPDATE).mtime.to_i rescue 0 + end + + def stop? + get_last_update.to_i != @last_update.to_i + end end hypervisor = ARGV[0] From 36e80dbdf7b8dc2a3d92a233e2621c9cb54c9f86 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 15 Oct 2013 18:05:16 +0200 Subject: [PATCH 37/44] Evolving OpenNebula description --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 687277f083..043ac07130 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -OpenNebula - The OpenSource Toolkit for Cloud Computing +OpenNebula - Flexible Enterprise Cloud Made Simple ## DESCRIPTION -OpenNebula is an open-source project aimed at building the industry standard -open source cloud computing tool to manage the complexity and heterogeneity of -distributed data center infrastructures. +OpenNebula is an open-source project delivering a simple but feature-rich and +flexible solution to build and manage enterprise clouds and virtualized data centers. Complete documentation can be found at From 6588fe5a9de5dab5e94d8cdbc683a5921e3398be Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 15 Oct 2013 18:24:49 +0200 Subject: [PATCH 38/44] Bug #2355: Now Sunstone datastore DS knows if it should maintain state or be cleared (for instance, when Reset button is clicked) --- src/sunstone/public/js/plugins/datastores-tab.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index a0367c3798..e6c497d3dd 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -1047,6 +1047,8 @@ function setupCreateDatastoreDialog(){ $create_datastore_dialog.remove(); setupCreateDatastoreDialog(); + window.ds_wizard_is_not_first="false"; + popUpCreateDatastoreDialog(); }); @@ -1055,6 +1057,8 @@ function setupCreateDatastoreDialog(){ $create_datastore_dialog.remove(); setupCreateDatastoreDialog(); + window.ds_wizard_is_not_first="false"; + popUpCreateDatastoreDialog(); $("a[href='#datastore_manual']").click(); }); @@ -1155,8 +1159,12 @@ function popUpCreateDatastoreDialog(){ $('select#datastore_cluster_raw',$create_datastore_dialog).html(clusters_sel()); $create_datastore_dialog.reveal(); $("input#name",$create_datastore_dialog).focus(); - hide_all($create_datastore_dialog); - select_filesystem(); + if(window.ds_wizard_is_not_first != "true") + { + hide_all($create_datastore_dialog); + select_filesystem(); + window.ds_wizard_is_not_first="true"; + } } //Prepares autorefresh From 74edd8b23dbb178d0009190abb6a10d46de7b3b3 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 15 Oct 2013 18:47:15 +0200 Subject: [PATCH 39/44] im-collectd: onehost sync allows specific hosts or cluster to update --- src/cli/one_helper/onehost_helper.rb | 11 ++++++++++- src/cli/onehost | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 0692a9c71d..a190e7bb31 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -158,7 +158,9 @@ class OneHostHelper < OpenNebulaHelper::OneHelper NUM_THREADS = 15 - def sync + def sync(host_ids, options) + cluster_id = options[:cluster] + # Get remote_dir (implies oneadmin group) rc = OpenNebula::System.new(@client).get_configuration return -1, rc.message if OpenNebula.is_error?(rc) @@ -187,7 +189,14 @@ class OneHostHelper < OpenNebulaHelper::OneHelper # Assign hosts to threads i = 0 hs_threads = Array.new + pool.each do |host| + if host_ids + next if !host_ids.include?(host['ID'].to_i) + elsif cluster_id + next if host['CLUSTER_ID'].to_i != cluster_id + end + hs_threads[i % NUM_THREADS] ||= [] hs_threads[i % NUM_THREADS] << host['NAME'] i+=1 diff --git a/src/cli/onehost b/src/cli/onehost index 8f218abef0..145f3bc616 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -74,6 +74,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do } CREAT_OPTIONS = [ IM, VMM, VNET, OneClusterHelper::CLUSTER ] + SYNC_OPTIONS = [ OneClusterHelper::CLUSTER ] ######################################################################## # Formatters for arguments @@ -166,11 +167,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do sync_desc = <<-EOT.unindent Synchronizes probes in /var/lib/one/remotes ($ONE_LOCATION/var/remotes in self-contained installations) with Hosts. - The copy is performed the next time the Host is monitored + Examples: + onehost sync + onehost sync -c myCluster + onehost sync host01,host02,host03 EOT - command :sync, sync_desc do - helper.sync + command :sync, sync_desc, [:range,:hostid_list, nil], :options=>SYNC_OPTIONS do + helper.sync(args[0],options) end list_desc = <<-EOT.unindent From 359e974f83e6172780217cf596422aba2ff60f5f Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 16 Oct 2013 17:33:31 +0200 Subject: [PATCH 40/44] feature #2289: Add scripts for actions not supported --- src/vmm_mad/remotes/ec2/attach_disk | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/attach_nic | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/detach_disk | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/detach_nic | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/migrate | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/migrate_local | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/reset | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/snapshot_create | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/snapshot_delete | 20 ++++++++++++++++++++ src/vmm_mad/remotes/ec2/snapshot_revert | 20 ++++++++++++++++++++ 10 files changed, 200 insertions(+) create mode 100644 src/vmm_mad/remotes/ec2/attach_disk create mode 100755 src/vmm_mad/remotes/ec2/attach_nic create mode 100755 src/vmm_mad/remotes/ec2/detach_disk create mode 100755 src/vmm_mad/remotes/ec2/detach_nic create mode 100755 src/vmm_mad/remotes/ec2/migrate create mode 100755 src/vmm_mad/remotes/ec2/migrate_local create mode 100755 src/vmm_mad/remotes/ec2/reset create mode 100755 src/vmm_mad/remotes/ec2/snapshot_create create mode 100755 src/vmm_mad/remotes/ec2/snapshot_delete create mode 100755 src/vmm_mad/remotes/ec2/snapshot_revert diff --git a/src/vmm_mad/remotes/ec2/attach_disk b/src/vmm_mad/remotes/ec2/attach_disk new file mode 100644 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/attach_disk @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/attach_nic b/src/vmm_mad/remotes/ec2/attach_nic new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/attach_nic @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/detach_disk b/src/vmm_mad/remotes/ec2/detach_disk new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/detach_disk @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/detach_nic b/src/vmm_mad/remotes/ec2/detach_nic new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/detach_nic @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/migrate b/src/vmm_mad/remotes/ec2/migrate new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/migrate @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/migrate_local b/src/vmm_mad/remotes/ec2/migrate_local new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/migrate_local @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/reset b/src/vmm_mad/remotes/ec2/reset new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/reset @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/snapshot_create b/src/vmm_mad/remotes/ec2/snapshot_create new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/snapshot_create @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/snapshot_delete b/src/vmm_mad/remotes/ec2/snapshot_delete new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/snapshot_delete @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 diff --git a/src/vmm_mad/remotes/ec2/snapshot_revert b/src/vmm_mad/remotes/ec2/snapshot_revert new file mode 100755 index 0000000000..110243efc2 --- /dev/null +++ b/src/vmm_mad/remotes/ec2/snapshot_revert @@ -0,0 +1,20 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2013, 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. # +#--------------------------------------------------------------------------- # + +SCRIPT_NAME=$(basename $0) +echo "Action $SCRIPT_NAME not supported" 1>&2 From 2a77c2a5d912a92a0a84f93ac218576936e5f883 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 16 Oct 2013 17:37:11 +0200 Subject: [PATCH 41/44] feature #2289: Rename ec2.conf (ec2_driver.default) and hybrid_ec2.conf (ec2_driver.conf) --- src/im_mad/im_exec/one_im_sh_ec2 | 35 ---------------- src/vmm_mad/exec/one_vmm_sh_ec2 | 35 ---------------- .../ec2/{hybrid_ec2.conf => ec2_driver.conf} | 0 .../ec2/{ec2.conf => ec2_driver.default} | 8 ++-- src/vmm_mad/remotes/ec2/ec2rc | 41 ------------------- 5 files changed, 4 insertions(+), 115 deletions(-) delete mode 100644 src/im_mad/im_exec/one_im_sh_ec2 delete mode 100644 src/vmm_mad/exec/one_vmm_sh_ec2 rename src/vmm_mad/remotes/ec2/{hybrid_ec2.conf => ec2_driver.conf} (100%) rename src/vmm_mad/remotes/ec2/{ec2.conf => ec2_driver.default} (87%) delete mode 100644 src/vmm_mad/remotes/ec2/ec2rc diff --git a/src/im_mad/im_exec/one_im_sh_ec2 b/src/im_mad/im_exec/one_im_sh_ec2 deleted file mode 100644 index cd4d386a3f..0000000000 --- a/src/im_mad/im_exec/one_im_sh_ec2 +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, 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. # -#--------------------------------------------------------------------------- # - -if [ -z "${ONE_LOCATION}" ]; then - MAD_LOCATION=/usr/lib/one/mads -else - MAD_LOCATION=$ONE_LOCATION/lib/mads -fi - -while getopts ":u:r:t:c" opt $@; do - case "${opt}" in - u) - export EC2_REGION="${OPTARG}" - ;; - *) - ;; - esac -done - -exec $MAD_LOCATION/one_im_sh $* diff --git a/src/vmm_mad/exec/one_vmm_sh_ec2 b/src/vmm_mad/exec/one_vmm_sh_ec2 deleted file mode 100644 index 0ba57b93c5..0000000000 --- a/src/vmm_mad/exec/one_vmm_sh_ec2 +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, 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. # -#--------------------------------------------------------------------------- # - -if [ -z "${ONE_LOCATION}" ]; then - MAD_LOCATION=/usr/lib/one/mads -else - MAD_LOCATION=$ONE_LOCATION/lib/mads -fi - -while getopts ":u:r:t:l:s:" opt $@; do - case "${opt}" in - u) - export EC2_REGION="${OPTARG}" - ;; - *) - ;; - esac -done - -exec $MAD_LOCATION/one_vmm_sh $* diff --git a/src/vmm_mad/remotes/ec2/hybrid_ec2.conf b/src/vmm_mad/remotes/ec2/ec2_driver.conf similarity index 100% rename from src/vmm_mad/remotes/ec2/hybrid_ec2.conf rename to src/vmm_mad/remotes/ec2/ec2_driver.conf diff --git a/src/vmm_mad/remotes/ec2/ec2.conf b/src/vmm_mad/remotes/ec2/ec2_driver.default similarity index 87% rename from src/vmm_mad/remotes/ec2/ec2.conf rename to src/vmm_mad/remotes/ec2/ec2_driver.default index a8272d6237..95673cffbe 100644 --- a/src/vmm_mad/remotes/ec2/ec2.conf +++ b/src/vmm_mad/remotes/ec2/ec2_driver.default @@ -16,19 +16,19 @@ - +