mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #2911: Add VNC support for vCenter
This commit is contained in:
parent
62797c024a
commit
745bcb73ae
@ -172,9 +172,13 @@ class OpenNebulaVNC
|
||||
end
|
||||
|
||||
# Proxy data
|
||||
host = vm_resource['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME']
|
||||
vnc_port = vm_resource['TEMPLATE/GRAPHICS/PORT']
|
||||
vnc_pw = vm_resource['TEMPLATE/GRAPHICS/PASSWD']
|
||||
host = vm_resource['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME']
|
||||
vnc_port = vm_resource['TEMPLATE/GRAPHICS/PORT']
|
||||
vnc_pw = vm_resource['TEMPLATE/GRAPHICS/PASSWD']
|
||||
|
||||
if vm_resource['TEMPLATE/ESX_HOST'] # It is behind a vCenter
|
||||
host = vm_resource['TEMPLATE/ESX_HOST']
|
||||
end
|
||||
|
||||
# Generate token random_str: host:port
|
||||
random_str = rand(36**20).to_s(36) #random string a-z0-9 length 20
|
||||
|
@ -463,7 +463,18 @@ class VCenterVm
|
||||
:name => "one-#{vmid}",
|
||||
:spec => clone_spec).wait_for_completion
|
||||
|
||||
return rc.config.uuid
|
||||
vm_uuid = rc.config.uuid
|
||||
|
||||
vnc_port = xml.root.elements["/VM/TEMPLATE/GRAPHICS/PORT"]
|
||||
|
||||
if vnc_port
|
||||
spec = RbVmomi::VIM.VirtualMachineConfigSpec(:extraConfig =>
|
||||
[{:key=>"remotedisplay.vnc.enabled", :value=>"TRUE"},
|
||||
{:key=>"remotedisplay.vnc.port", :value=>vnc_port.text}])
|
||||
rc.ReconfigVM_Task(:spec => spec).wait_for_completion
|
||||
end
|
||||
|
||||
return vm_uuid
|
||||
end
|
||||
|
||||
############################################################################
|
||||
@ -478,7 +489,7 @@ class VCenterVm
|
||||
vm = connection.find_vm_template(deploy_id)
|
||||
|
||||
vm.PowerOffVM_Task.wait_for_completion
|
||||
vm.UnregisterVM.wait_for_completion
|
||||
vm.Destroy_Task.wait_for_completion
|
||||
end
|
||||
|
||||
############################################################################
|
||||
@ -520,7 +531,7 @@ class VCenterVm
|
||||
|
||||
vm = connection.find_vm_template(deploy_id)
|
||||
|
||||
vm.PowerOnVM_Task.wait_for_completion
|
||||
vm.RebootGuest.wait_for_completion
|
||||
end
|
||||
|
||||
############################################################################
|
||||
@ -650,6 +661,8 @@ class VCenterVm
|
||||
# Check for negative values
|
||||
@used_memory = 0 if @used_memory.to_i < 0
|
||||
@used_cpu = 0 if @used_cpu.to_i < 0
|
||||
|
||||
@esx_host = @vm.summary.runtime.host.name
|
||||
end
|
||||
|
||||
########################################################################
|
||||
@ -664,7 +677,8 @@ class VCenterVm
|
||||
str_info << "USEDCPU=" << @used_cpu.to_s << " "
|
||||
str_info << "USEDMEMORY="<< @used_memory.to_s << " "
|
||||
str_info << "NETRX=" << @net_rx.to_s << " "
|
||||
str_info << "NETTX=" << @net_tx.to_s
|
||||
str_info << "NETTX=" << @net_tx.to_s << " "
|
||||
str_info << "ESX_HOST=" << @esx_host.to_s
|
||||
end
|
||||
|
||||
########################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user