mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #1772: Add vm resize method to Java OCA
This commit is contained in:
parent
9e9f40d718
commit
5b2750d483
@ -41,6 +41,7 @@ public class VirtualMachine extends PoolElement{
|
||||
private static final String DETACH = METHOD_PREFIX + "detach";
|
||||
private static final String RENAME = METHOD_PREFIX + "rename";
|
||||
private static final String UPDATE = METHOD_PREFIX + "update";
|
||||
private static final String RESIZE = METHOD_PREFIX + "resize";
|
||||
|
||||
private static final String[] VM_STATES =
|
||||
{
|
||||
@ -184,6 +185,25 @@ public class VirtualMachine extends PoolElement{
|
||||
return client.call(UPDATE, id, new_template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the VM capacity
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The id of the target vm.
|
||||
* @param cpu the new CPU value
|
||||
* @param memory the new MEMORY value
|
||||
* @param vcpu the new VCPU value
|
||||
* @param enforce If it is set to true, the host capacity
|
||||
* will be checked. This will only affect oneadmin requests, regular users
|
||||
* resize requests will always be enforced
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public static OneResponse resize(Client client, int id,
|
||||
double cpu, int memory, int vcpu, boolean enforce)
|
||||
{
|
||||
return client.call(RESIZE, id, cpu, memory, vcpu, enforce);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the information of the given VM.
|
||||
*
|
||||
@ -571,6 +591,22 @@ public class VirtualMachine extends PoolElement{
|
||||
return client.call(UPDATE, id, new_template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes this VM's capacity
|
||||
*
|
||||
* @param cpu the new CPU value
|
||||
* @param memory the new MEMORY value
|
||||
* @param vcpu the new VCPU value
|
||||
* @param enforce If it is set to true, the host capacity
|
||||
* will be checked. This will only affect oneadmin requests, regular users
|
||||
* resize requests will always be enforced
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse resize(double cpu, int memory, int vcpu, boolean enforce)
|
||||
{
|
||||
return client.call(RESIZE, id, cpu, memory, vcpu, enforce);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Helpers
|
||||
// =================================
|
||||
|
@ -341,4 +341,14 @@ public class VirtualMachineTest
|
||||
res = vm.info();
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resize()
|
||||
{
|
||||
res = vm.resize(2.5, 512, 0, true);
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
res = vm.resize(1, 128, 2, false);
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,8 @@ module OpenNebula
|
||||
# @param memory [Integer] the new MEMORY value
|
||||
# @param vcpu [Integer] the new VCPU value
|
||||
# @param enforce [true|false] If it is set to true, the host capacity
|
||||
# will be checked
|
||||
# will be checked. This will only affect oneadmin requests, regular users
|
||||
# resize requests will always be enforced
|
||||
#
|
||||
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
||||
# otherwise
|
||||
|
Loading…
x
Reference in New Issue
Block a user