diff --git a/install.sh b/install.sh index 6172fcc989..45e66bb4c3 100755 --- a/install.sh +++ b/install.sh @@ -1347,7 +1347,8 @@ EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2_driver.conf \ AZ_ETC_FILES="src/vmm_mad/remotes/az/az_driver.conf \ src/vmm_mad/remotes/az/az_driver.default" -VCENTER_ETC_FILES="src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.default" +VCENTER_ETC_FILES="src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.default \ + src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.conf" #------------------------------------------------------------------------------- # Virtualization drivers config. files, to be installed under $ETC_LOCATION diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.conf b/src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.conf new file mode 100644 index 0000000000..b29f1006a7 --- /dev/null +++ b/src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.conf @@ -0,0 +1,22 @@ +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + +#******************************************************************************* +# vCenter Driver Configuration file +#******************************************************************************* + +# Default timeout to complete deploy +:vm_poweron_wait_default: 300 diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/vi_client.rb b/src/vmm_mad/remotes/lib/vcenter_driver/vi_client.rb index 57415730d3..140ece9158 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/vi_client.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/vi_client.rb @@ -15,20 +15,21 @@ #--------------------------------------------------------------------------- # require 'openssl' +require 'yaml' module VCenterDriver class VIClient attr_accessor :vim attr_accessor :rp - attr_accessor :vc_name + attr_accessor :vc_name def initialize(opts, host_id = -1) opts = {:insecure => true}.merge(opts) @host_id = host_id @vim = RbVmomi::VIM.connect(opts) @vc_name = opts[:host] if opts[:host] - + @vcenter_conf = load_vcenter_configuration # Get ccr and get rp ccr_ref = opts.delete(:ccr) if ccr_ref @@ -46,6 +47,19 @@ class VIClient end end + def load_vcenter_configuration + vcenter_conf = YAML::load(File.open("/etc/one/vcenter_driver.conf")) + vcenter_conf + end + + def get_property_vcenter_conf(key) + if @vcenter_conf.key?(key) + return @vcenter_conf[key] + else + return nil + end + end + def rp_confined? !!@rp end diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb index 9c80f8fad5..2393d2e0e2 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -1483,6 +1483,15 @@ class VirtualMachine < Template return self['_ref'] end + def wait_deploy_timeout + timeout_deploy = @vi_client.get_property_vcenter_conf(:vm_poweron_wait_default) + time_start = Time.now + begin + time_running = Time.now - time_start + sleep(2) + end until(is_powered_on? && time_running.to_i < timeout_deploy) + raise 'Reached deploy timeout' if time_running.to_i >= timeout_deploy + end def storagepod_clonevm_task(vc_template, vcenter_name, clone_spec, storpod, vcenter_vm_folder_object, dc) @@ -2987,7 +2996,8 @@ class VirtualMachine < Template end def poweron - @item.PowerOnVM_Task.wait_for_completion + @item.PowerOnVM_Task.wait_for_completion + wait_deploy_timeout end def is_powered_on? diff --git a/src/vmm_mad/remotes/vcenter/deploy b/src/vmm_mad/remotes/vcenter/deploy index 060a27713f..288ef2162a 100755 --- a/src/vmm_mad/remotes/vcenter/deploy +++ b/src/vmm_mad/remotes/vcenter/deploy @@ -66,9 +66,6 @@ begin vm.reconfigure vm.poweron - - wait_deploy_timeout(vm) - vm.set_running(true) vm.one_item.update("VCENTER_ESX_HOST = #{vm['runtime.host.name']}", true)