Skip to content

Commit

Permalink
Feature 1896 - Use Information from drv_action (#3214)
Browse files Browse the repository at this point in the history
* F #1896: Get host id from drv_action on shutdown

Signed-off-by: Sergio Vega <svega@opennebula.systems>

* F #1896: Get host id from drv_action on every supported action

Signed-off-by: Sergio Vega <svega@opennebula.systems>

* F #1896: Enhance vCenter driver actions pool calls

(cherry picked from commit 9227577)
  • Loading branch information
sergiojvg authored and tinova committed Apr 29, 2019
1 parent bfe6c41 commit 7d65da8
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 24 deletions.
19 changes: 14 additions & 5 deletions src/vmm_mad/exec/one_vmm_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def cancel(id, drv_message)
# SAVE action, stops the VM and saves its state, network is cleaned up
#
def save(id, drv_message)
xml_data = decode(drv_message)
action = VmmAction.new(self, id, :save, drv_message)

steps=[
Expand Down Expand Up @@ -609,33 +610,39 @@ def migrate(id, drv_message)
# POLL action, gets information of a VM
#
def poll(id, drv_message)
xml_data = decode(drv_message)

data = decode(drv_message)
host = data.elements['HOST'].text
deploy_id = data.elements['DEPLOY_ID'].text

do_action("#{deploy_id} #{host}", id, host, ACTION[:poll])
do_action("#{deploy_id} #{host}", id, host, ACTION[:poll], {:stdin => xml_data})
end

#
# REBOOT action, reboots a running VM
#
def reboot(id, drv_message)
xml_data = decode(drv_message)

data = decode(drv_message)
host = data.elements['HOST'].text
deploy_id = data.elements['DEPLOY_ID'].text

do_action("#{deploy_id} #{host}", id, host, ACTION[:reboot])
do_action("#{deploy_id} #{host}", id, host, ACTION[:reboot], {:stdin => xml_data})
end

#
# RESET action, resets a running VM
#
def reset(id, drv_message)
xml_data = decode(drv_message)

data = decode(drv_message)
host = data.elements['HOST'].text
deploy_id = data.elements['DEPLOY_ID'].text

do_action("#{deploy_id} #{host}", id, host, ACTION[:reset])
do_action("#{deploy_id} #{host}", id, host, ACTION[:reset], {:stdin => xml_data})
end

#
Expand Down Expand Up @@ -761,7 +768,8 @@ def snapshot_revert(id, drv_message)
id,
host,
ACTION[:snapshot_revert],
:script_name => "snapshot_revert")
:script_name => "snapshot_revert",
:stdin => xml_data)
end

#
Expand All @@ -780,7 +788,8 @@ def snapshot_delete(id, drv_message)
id,
host,
ACTION[:snapshot_delete],
:script_name => "snapshot_delete")
:script_name => "snapshot_delete",
:stdin => xml_data)
end

#
Expand Down
7 changes: 4 additions & 3 deletions src/vmm_mad/remotes/vcenter/poll
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ vm_ref = ARGV[0]
vc_cluster_name = ARGV[1]
vm_id = ARGV[2]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool,
vc_cluster_name)
host_id = host['ID']
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')

host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
Expand Down
7 changes: 4 additions & 3 deletions src/vmm_mad/remotes/vcenter/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ require 'vcenter_driver'
vm_ref = ARGV[0]
vc_cluster_name = ARGV[1]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool,
vc_cluster_name)
host_id = host['ID']
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')

host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
Expand Down
7 changes: 4 additions & 3 deletions src/vmm_mad/remotes/vcenter/reset
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ require 'vcenter_driver'
vm_ref = ARGV[0]
vc_cluster_name = ARGV[1]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool,
vc_cluster_name)
host_id = host['ID']
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')

host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
Expand Down
8 changes: 5 additions & 3 deletions src/vmm_mad/remotes/vcenter/restore
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ require 'vcenter_driver'
vm_ref = ARGV[2]
vc_cluster_name = ARGV[-1]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool,
vc_cluster_name)
host_id = host['ID']
drv_action_enc = STDIN.read.delete("\n")
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),
'VMM_DRIVER_ACTION_DATA')
host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
Expand Down
4 changes: 1 addition & 3 deletions src/vmm_mad/remotes/vcenter/save
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ vm_ref = ARGV[0]
vm_id = ARGV[3]
vc_cluster_name = ARGV[-1]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
host_id = host['ID']

drv_action_enc = STDIN.read.delete("\n")
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),
'VMM_DRIVER_ACTION_DATA')
host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

lcm_state = drv_action['/VMM_DRIVER_ACTION_DATA/VM/LCM_STATE']
check_valid(lcm_state, 'lcm_state')
Expand Down
6 changes: 4 additions & 2 deletions src/vmm_mad/remotes/vcenter/snapshot_delete
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ vm_ref = ARGV[0]
snap_id = ARGV[1]
vc_cluster_name = ARGV[3]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
host_id = host['ID']
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')

host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
Expand Down
6 changes: 4 additions & 2 deletions src/vmm_mad/remotes/vcenter/snapshot_revert
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ vm_ref = ARGV[0]
snap_id = ARGV[1]
vc_cluster_name = ARGV[3]

host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
host_id = host['ID']
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')

host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']

begin
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
Expand Down

0 comments on commit 7d65da8

Please sign in to comment.