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

F #4393: JAVA OCA for diskResize

This commit is contained in:
Ruben S. Montero 2016-12-18 20:48:53 +01:00
parent 43df8151ff
commit 3e9e0e8807
2 changed files with 41 additions and 6 deletions

View File

@ -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{
* </ul>
*
* @param action The action name to be performed, can be:<br>
*
*
* "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{
* <li>3 delete</li>
* <li>4 delete-recreate</li>
* </ul>
*
*
* @return If an error occurs the error message contains the reason.
*/
public OneResponse recover(int operation)

View File

@ -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}