diff --git a/src/mad/ruby/VirtualMachineDriver.rb b/src/mad/ruby/VirtualMachineDriver.rb index 0d3909d220..e97105d167 100644 --- a/src/mad/ruby/VirtualMachineDriver.rb +++ b/src/mad/ruby/VirtualMachineDriver.rb @@ -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) diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index 9e84bcfca8..909ada6d5b 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -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 #