From 3e9e0e8807737ddf2096635025c2424322153ee0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sun, 18 Dec 2016 20:48:53 +0100 Subject: [PATCH] F #4393: JAVA OCA for diskResize --- .../opennebula/client/vm/VirtualMachine.java | 45 ++++++++++++++++--- src/oca/ruby/opennebula/virtual_machine.rb | 2 +- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index 5e255453da..dbbfa9488d 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -51,6 +51,7 @@ public class VirtualMachine extends PoolElement{ private static final String DISKSNAPSHOTCREATE = METHOD_PREFIX + "disksnapshotcreate"; private static final String DISKSNAPSHOTREVERT = METHOD_PREFIX + "disksnapshotrevert"; private static final String DISKSNAPSHOTDELETE = METHOD_PREFIX + "disksnapshotdelete"; + private static final String DISKRESIZE = METHOD_PREFIX + "diskresize"; private static final String UPDATECONF = METHOD_PREFIX + "updateconf"; private static final String[] VM_STATES = @@ -148,7 +149,10 @@ public class VirtualMachine extends PoolElement{ "DISK_SNAPSHOT_REVERT", "DISK_SNAPSHOT_DELETE", "PROLOG_MIGRATE_UNKNOWN", - "PROLOG_MIGRATE_UNKNOWN_FAILURE" + "PROLOG_MIGRATE_UNKNOWN_FAILURE", + "DISK_RESIZE", + "DISK_RESIZE_POWEROFF", + "DISK_RESIZE_UNDEPLOYED" }; private static final String[] SHORT_LCM_STATES = @@ -214,7 +218,10 @@ public class VirtualMachine extends PoolElement{ "snap", // DISK_SNAPSHOT_REVERT "snap", // DISK_SNAPSHOT_DELETE "migr", // PROLOG_MIGRATE_UNKNOWN - "fail" // PROLOG_MIGRATE_UNKNOWN_FAILURE + "fail", // PROLOG_MIGRATE_UNKNOWN_FAILURE + "drsz", // DISK_RESIZE + "drsz", // DISK_RESIZE_POWEROFF + "drsz" // DISK_RESIZE_UNDEPLOYED }; /** @@ -568,6 +575,21 @@ public class VirtualMachine extends PoolElement{ return client.call(DISKSNAPSHOTDELETE, id, diskId, snapId); } + /** + * Resize VM disk + * + * @param client XML-RPC Client. + * @param id The VM id of the target VM. + * @param diskId Id of the disk + * @param newSize for the disk + * @return diskId of resized disk, or error message + */ + public static OneResponse diskResize(Client client, int id, + int diskId, long newSize) + { + return client.call(DISKRESIZE, id, diskId, String.valueOf(newSize)); + } + /** * Recovers a stuck VM. * @@ -647,11 +669,11 @@ public class VirtualMachine extends PoolElement{ * * * @param action The action name to be performed, can be:
- * + * * "terminate-hard", "terminate", "undeploy-hard", "undeploy", * "poweroff-hard", "poweroff", "reboot-hard", "reboot", "hold", * "release", "stop", "suspend", "resume", "resched", "unresched" - * + * * @return If an error occurs the error message contains the reason. */ protected OneResponse action(String action) @@ -1000,6 +1022,19 @@ public class VirtualMachine extends PoolElement{ return diskSnapshotDelete(client, id, diskId, snapId); } + /** + * Resize VM disk + * + * @param client XML-RPC Client. + * @param id The VM id of the target VM. + * @param diskId Id of the disk + * @param newSize for the disk + * @return diskId of resized disk, or error message + */ + public OneResponse diskResize(int diskId, long newSize) + { + return diskResize(client, id, diskId, newSize); + } /** * Recovers a stuck VM. * @@ -1011,7 +1046,7 @@ public class VirtualMachine extends PoolElement{ *
  • 3 delete
  • *
  • 4 delete-recreate
  • * - * + * * @return If an error occurs the error message contains the reason. */ public OneResponse recover(int operation) diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 77a0720e7b..534f715d5f 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -200,7 +200,7 @@ module OpenNebula "PROLOG_MIGRATE_UNKNOWN_FAILURE" => "fail", "DISK_RESIZE" => "drsz", "DISK_RESIZE_POWEROFF" => "drsz", - "DISK_RESIZE_UNDEPLOYED" => "drsz", + "DISK_RESIZE_UNDEPLOYED" => "drsz" } MIGRATE_REASON=%w{NONE ERROR USER}