diff --git a/install.sh b/install.sh index f1ddb4b2fb..2a0724e99f 100755 --- a/install.sh +++ b/install.sh @@ -1056,7 +1056,6 @@ TM_DEV_FILES="src/tm_mad/dev/clone \ TM_VCENTER_FILES="src/tm_mad/vcenter/clone \ src/tm_mad/vcenter/ln \ src/tm_mad/vcenter/mv \ - src/tm_mad/vcenter/mv.rb \ src/tm_mad/vcenter/mvds \ src/tm_mad/vcenter/cpds \ src/tm_mad/vcenter/premigrate \ diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 024de00b0a..c054fc641a 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -532,7 +532,7 @@ VM_MAD = [ IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, resume, delete, reboot, reboot-hard, resched, unresched, poweroff, poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, - snap-create, snap-delete, migrate" + snap-create, snap-delete, migrate, live-migrate" ] #------------------------------------------------------------------------------- diff --git a/src/tm_mad/vcenter/mv b/src/tm_mad/vcenter/mv index f94528d574..0588526bd5 100755 --- a/src/tm_mad/vcenter/mv +++ b/src/tm_mad/vcenter/mv @@ -24,10 +24,10 @@ DSID=$4 if [ -z "${ONE_LOCATION}" ]; then TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh - EXEC_DRIVER=/var/lib/one/remotes/tm/vcenter/mv.rb + MIGRATE_DRIVER=/var/lib/one/remotes/vmm/vcenter/migrate else TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh - EXEC_DRIVER=$ONE_LOCATION/var/remotes/tm/vcenter/mv.rb + MIGRATE_DRIVER=$ONE_LOCATION/var/remotes/vmm/vcenter/migrate fi . $TMCOMMON @@ -45,6 +45,6 @@ if [ "$SRC" == "$DST" ]; then exit 0 fi -ruby $EXEC_DRIVER $HOST_ORIG $HOST_DEST $VMID $DSID +ruby $MIGRATE_DRIVER $HOST_DEST $HOST_ORIG $VMID $DSID exit 0 diff --git a/src/tm_mad/vcenter/mv.rb b/src/tm_mad/vcenter/mv.rb deleted file mode 100644 index 057ba7c334..0000000000 --- a/src/tm_mad/vcenter/mv.rb +++ /dev/null @@ -1,69 +0,0 @@ -# ---------------------------------------------------------------------------- # -# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems # -# # -# 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 !defined?(ONE_LOCATION) - -if !ONE_LOCATION - RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION) -else - RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION) -end - -$: << RUBY_LIB_LOCATION -$: << File.dirname(__FILE__) - -require 'vcenter_driver' - -SRC = ARGV[0] -DST = ARGV[1] -WMID = ARGV[2] -DSID = ARGV[3] - -begin - one_client = OpenNebula::Client.new - - pool = OpenNebula::HostPool.new(one_client) - pool.info - - src_id = pool["/HOST_POOL/HOST[NAME='#{SRC}']/ID"].to_i - dst_id = pool["/HOST_POOL/HOST[NAME='#{DST}']/ID"].to_i - - vi_client = VCenterDriver::VIClient.new_from_host(src_id) - - # required one objects - vm = OpenNebula::VirtualMachine.new_with_id(WMID, one_client) - dst_host = OpenNebula::Host.new_with_id(dst_id, one_client) - - # get info - vm.info - dst_host.info - - # required vcenter objects - vc_vm = VCenterDriver::VirtualMachine.new_from_ref(vm["/VM/DEPLOY_ID"], vi_client) - dst_host = VCenterDriver::ClusterComputeResource.new_from_ref(dst_host["/HOST/TEMPLATE/VCENTER_CCR_REF"],vi_client).item - - config = {:cluster => dst_host } - vc_vm.migrate(config) - -rescue Exception => e - message = "Cannot migrate for VM #{WMID}"\ - "failed due to "\ - "\"#{e.message}\"\n#{e.backtrace}" - STDERR.puts error_message(message) - exit -1 -ensure - vi_client.close_connection if vi_client -end diff --git a/src/vmm_mad/remotes/vcenter/migrate b/src/vmm_mad/remotes/vcenter/migrate deleted file mode 120000 index 9c454e8cd4..0000000000 --- a/src/vmm_mad/remotes/vcenter/migrate +++ /dev/null @@ -1 +0,0 @@ -../common/not_supported.sh \ No newline at end of file diff --git a/src/vmm_mad/remotes/vcenter/migrate b/src/vmm_mad/remotes/vcenter/migrate new file mode 100755 index 0000000000..4254367d37 --- /dev/null +++ b/src/vmm_mad/remotes/vcenter/migrate @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby + +# ---------------------------------------------------------------------------- # +# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems # +# # +# 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 !defined?(ONE_LOCATION) + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION) +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION) +end + +$: << RUBY_LIB_LOCATION +$: << File.dirname(__FILE__) + + +require 'vcenter_driver' + +vm_id = ARGV[-2] +src_host = ARGV[-3] +dst_host = ARGV[-4] + +begin + one_client = OpenNebula::Client.new + + pool = OpenNebula::HostPool.new(one_client) + pool.info + + src_id = pool["/HOST_POOL/HOST[NAME='#{src_host}']/ID"].to_i + dst_id = pool["/HOST_POOL/HOST[NAME='#{dst_host}']/ID"].to_i + + vi_client = VCenterDriver::VIClient.new_from_host(src_id) + + # required one objects + vm = OpenNebula::VirtualMachine.new_with_id(vm_id, one_client) + dst_host = OpenNebula::Host.new_with_id(dst_id, one_client) + + # get info + vm.info + dst_host.info + + # required vcenter objects + vc_vm = VCenterDriver::VirtualMachine.new_from_ref(vm["/VM/DEPLOY_ID"], vi_client) + dst_host = VCenterDriver::ClusterComputeResource.new_from_ref(dst_host["/HOST/TEMPLATE/VCENTER_CCR_REF"],vi_client).item + + config = {:cluster => dst_host } + vc_vm.migrate(config) + +rescue Exception => e + message = "Cannot migrate for VM #{vm_id}"\ + "failed due to "\ + "\"#{e.message}\"\n#{e.backtrace}" + STDERR.puts error_message(message) + exit -1 +ensure + vi_client.close_connection if vi_client +end