1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

F #4393: add resize_disk action to one_vmm_exec

This commit is contained in:
Javi Fontan 2016-11-23 19:23:53 +01:00
parent f7888c5808
commit 256b1dc39d
2 changed files with 44 additions and 0 deletions

View File

@ -50,6 +50,7 @@ class VirtualMachineDriver < OpenNebulaDriver
:attach_nic => "ATTACHNIC",
:detach_nic => "DETACHNIC",
:disk_snapshot_create => "DISKSNAPSHOTCREATE",
:resize_disk => "RESIZEDISK",
:update_sg => "UPDATESG"
}
@ -93,6 +94,7 @@ class VirtualMachineDriver < OpenNebulaDriver
register_action(ACTION[:attach_nic].to_sym, method("attach_nic"))
register_action(ACTION[:detach_nic].to_sym, method("detach_nic"))
register_action(ACTION[:disk_snapshot_create].to_sym, method("disk_snapshot_create"))
register_action(ACTION[:resize_disk].to_sym, method("resize_disk"))
register_action(ACTION[:update_sg].to_sym, method("update_sg"))
end
@ -203,6 +205,11 @@ class VirtualMachineDriver < OpenNebulaDriver
send_message(ACTION[:disk_snapshot_create],RESULT[:failure],id,error)
end
def resize_disk(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:resize_disk],RESULT[:failure],id,error)
end
def update_sg(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:update_sg],RESULT[:failure],id,error)

View File

@ -780,6 +780,43 @@ class ExecDriver < VirtualMachineDriver
:script_name => "snapshot_delete")
end
#
# RESIZEDISK action, resizes a disk on a running VM
#
def resize_disk(id, drv_message)
action = ACTION[:resize_disk]
xml_data = decode(drv_message)
tm_command = ensure_xpath(xml_data, id, action, 'TM_COMMAND') || return
size = xml_data.elements['SIZE'].text.strip
disk_id = xml_data.elements['DISK_ID'].text.strip
action = VmmAction.new(self, id, :resize_disk, drv_message)
steps = [
# Perform a PROLOG on the disk
{
:driver => :tm,
:action => :tm_resize,
:parameters => tm_command.split
},
# Run the attach vmm script
{
:driver => :vmm,
:action => :resize_disk,
:parameters => [
:deploy_id,
disk_id,
size,
drv_message,
:host
]
}
]
action.run(steps)
end
#
# CLEANUP action, frees resources allocated in a host: VM and disk images
#