mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
#2262 (vCenter) wait poweron/off to be performed
(cherry picked from commit 53e4d999f3b89f047586f5d9bd1808d5ba0df4ea)
This commit is contained in:
parent
b3998de882
commit
575f0d840d
@ -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
|
||||
|
22
src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.conf
Normal file
22
src/vmm_mad/remotes/lib/vcenter_driver/vcenter_driver.conf
Normal file
@ -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
|
@ -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
|
||||
|
@ -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?
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user