mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
M #-: Add missing Java API methods (#1323)
This commit is contained in:
parent
a626c9fc07
commit
a4e6e50a7b
@ -39,6 +39,7 @@ public class User extends PoolElement{
|
||||
private static final String ADDGROUP = METHOD_PREFIX + "addgroup";
|
||||
private static final String DELGROUP = METHOD_PREFIX + "delgroup";
|
||||
private static final String LOGIN = METHOD_PREFIX + "login";
|
||||
private static final String ENABLE = METHOD_PREFIX + "enable";
|
||||
|
||||
/**
|
||||
* Creates a new User representation.
|
||||
@ -280,6 +281,21 @@ public class User extends PoolElement{
|
||||
return client.call(LOGIN, username, token, expire, egid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables a User
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The user id of the target user we want to modify.
|
||||
* @param enable True for enabling, false for disabling.
|
||||
* @return If successful the message contains the User id.
|
||||
*/
|
||||
public static OneResponse enable(Client client,
|
||||
int id,
|
||||
boolean enable)
|
||||
{
|
||||
return client.call(ENABLE, id, enable);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Instanced object XML-RPC methods
|
||||
// =================================
|
||||
@ -422,7 +438,7 @@ public class User extends PoolElement{
|
||||
*/
|
||||
public OneResponse login(String token, int expire)
|
||||
{
|
||||
return client.call(LOGIN, getName(), token, expire);
|
||||
return login(client, getName(), token, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -438,7 +454,19 @@ public class User extends PoolElement{
|
||||
*/
|
||||
public OneResponse login(String token, int expire, int egid)
|
||||
{
|
||||
return client.call(LOGIN, getName(), token, expire, egid);
|
||||
return login(client, getName(), token, expire, egid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables a User
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param enable True for enabling, false for disabling.
|
||||
* @return If successful the message contains the User id.
|
||||
*/
|
||||
public OneResponse enable(boolean enable)
|
||||
{
|
||||
return enable(client, id, enable);
|
||||
}
|
||||
|
||||
// =================================
|
||||
|
@ -57,6 +57,8 @@ public class VirtualMachine extends PoolElement{
|
||||
private static final String SCHEDADD = METHOD_PREFIX + "schedadd";
|
||||
private static final String SCHEDDELETE = METHOD_PREFIX + "scheddelete";
|
||||
private static final String SCHEDUPDATE = METHOD_PREFIX + "schedupdate";
|
||||
private static final String LOCK = METHOD_PREFIX + "lock";
|
||||
private static final String UNLOCK = METHOD_PREFIX + "unlock";
|
||||
|
||||
private static final String[] VM_STATES =
|
||||
{
|
||||
@ -696,6 +698,31 @@ public class VirtualMachine extends PoolElement{
|
||||
return client.call(RECOVER, id, operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock this VM
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The VM id.
|
||||
* @param level Lock level (use (1), manage (2), admin (3), all (4))
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public static OneResponse lock(Client client, int id, int level)
|
||||
{
|
||||
return client.call(LOCK, id, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock this VM
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The VM id.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public static OneResponse unlock(Client client, int id)
|
||||
{
|
||||
return client.call(UNLOCK, id);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Instanced object XML-RPC methods
|
||||
// =================================
|
||||
@ -1207,6 +1234,27 @@ public class VirtualMachine extends PoolElement{
|
||||
return recover(client, id, operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock this VM
|
||||
*
|
||||
* @param level Lock level (use (1), manage (2), admin (3), all (4))
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse lock(int level)
|
||||
{
|
||||
return lock(client, id, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock this VM
|
||||
*
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse unlock()
|
||||
{
|
||||
return unlock(client, id);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Helpers
|
||||
// =================================
|
||||
|
@ -36,6 +36,9 @@ public class VirtualMachinePool extends Pool implements Iterable<VirtualMachine>
|
||||
private static final String INFO_EXTENDED_METHOD = "vmpool.infoextended";
|
||||
private static final String INFO_SET_METHOD = "vmpool.infoset";
|
||||
private static final String MONITORING = "vmpool.monitoring";
|
||||
private static final String ACCOUNTING = "vmpool.accounting";
|
||||
private static final String SHOWBACK = "vmpool.showback";
|
||||
private static final String CALCULATE_SHOWBACK = "vmpool.calculateshowback";
|
||||
|
||||
/**
|
||||
* Flag for Virtual Machines in any state.
|
||||
@ -290,6 +293,97 @@ public class VirtualMachinePool extends Pool implements Iterable<VirtualMachine>
|
||||
return client.call(MONITORING, filter, num);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the virtual machine history records.
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param filter Filter flag to use. Possible values:
|
||||
* <ul>
|
||||
* <li>{@link Pool#ALL}: All Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE}: Connected user's Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE_GROUP}: Connected user's Virtual Machines, and
|
||||
* the ones in his group</li>
|
||||
* <li>{@link Pool#GROUP}: User's primary group Virtual Machines</li>
|
||||
* <li>>= 0 UID User's Virtual Machines</li>
|
||||
* </ul>
|
||||
* @param start_time: Start time for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a left boundary.
|
||||
* @param end_time: End time for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a right boundary.
|
||||
* @return If successful the message contains the string
|
||||
* with the information returned by OpenNebula.
|
||||
*/
|
||||
public static OneResponse accounting(Client client, int filter,
|
||||
int start_time, int end_time)
|
||||
{
|
||||
return client.call(ACCOUNTING, filter, start_time, end_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the virtual machine showback records
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param filter Filter flag to use. Possible values:
|
||||
* <ul>
|
||||
* <li>{@link Pool#ALL}: All Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE}: Connected user's Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE_GROUP}: Connected user's Virtual Machines, and
|
||||
* the ones in his group</li>
|
||||
* <li>{@link Pool#GROUP}: User's primary group Virtual Machines</li>
|
||||
* <li>>= 0 UID User's Virtual Machines</li>
|
||||
* </ul>
|
||||
* @param first_month First month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a left boundary.
|
||||
* @param first_year First year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a left boundary.
|
||||
* @param last_month Last month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a right boundary.
|
||||
* @param last_year Last year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a right boundary.
|
||||
* @return If successful the message contains the string
|
||||
* with the information returned by OpenNebula.
|
||||
*/
|
||||
public static OneResponse showback(Client client, int filter,
|
||||
int first_month, int first_year,
|
||||
int last_month, int last_year)
|
||||
{
|
||||
return client.call(SHOWBACK, filter,
|
||||
first_month, first_year,
|
||||
last_month, last_year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes all the history records, and stores the monthly cost for each VM
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param filter Filter flag to use. Possible values:
|
||||
* <ul>
|
||||
* <li>{@link Pool#ALL}: All Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE}: Connected user's Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE_GROUP}: Connected user's Virtual Machines, and
|
||||
* the ones in his group</li>
|
||||
* <li>{@link Pool#GROUP}: User's primary group Virtual Machines</li>
|
||||
* <li>>= 0 UID User's Virtual Machines</li>
|
||||
* </ul>
|
||||
* @param first_month First month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a left boundary.
|
||||
* @param first_year First year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a left boundary.
|
||||
* @param last_month Last month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a right boundary.
|
||||
* @param last_year Last year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a right boundary.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public static OneResponse calculateshowback(Client client, int filter,
|
||||
int first_month, int first_year,
|
||||
int last_month, int last_year)
|
||||
{
|
||||
return client.call(CALCULATE_SHOWBACK, filter,
|
||||
first_month, first_year,
|
||||
last_month, last_year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the xml representation of all or part of the
|
||||
* Virtual Machines in the pool. The filter used is the one set in
|
||||
@ -411,6 +505,94 @@ public class VirtualMachinePool extends Pool implements Iterable<VirtualMachine>
|
||||
return monitoring(client, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the virtual machine history records.
|
||||
*
|
||||
* @param filter Filter flag to use. Possible values:
|
||||
* <ul>
|
||||
* <li>{@link Pool#ALL}: All Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE}: Connected user's Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE_GROUP}: Connected user's Virtual Machines, and
|
||||
* the ones in his group</li>
|
||||
* <li>{@link Pool#GROUP}: User's primary group Virtual Machines</li>
|
||||
* <li>>= 0 UID User's Virtual Machines</li>
|
||||
* </ul>
|
||||
* @param start_time: Start time for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a left boundary.
|
||||
* @param end_time: End time for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a right boundary.
|
||||
* @return If successful the message contains the string
|
||||
* with the information returned by OpenNebula.
|
||||
*/
|
||||
public OneResponse accounting(int filter,
|
||||
int start_time, int end_time)
|
||||
{
|
||||
return accounting(client, filter, start_time, end_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the virtual machine showback records
|
||||
*
|
||||
* @param filter Filter flag to use. Possible values:
|
||||
* <ul>
|
||||
* <li>{@link Pool#ALL}: All Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE}: Connected user's Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE_GROUP}: Connected user's Virtual Machines, and
|
||||
* the ones in his group</li>
|
||||
* <li>{@link Pool#GROUP}: User's primary group Virtual Machines</li>
|
||||
* <li>>= 0 UID User's Virtual Machines</li>
|
||||
* </ul>
|
||||
* @param first_month First month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a left boundary.
|
||||
* @param first_year First year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a left boundary.
|
||||
* @param last_month Last month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a right boundary.
|
||||
* @param last_year Last year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a right boundary.
|
||||
* @return If successful the message contains the string
|
||||
* with the information returned by OpenNebula.
|
||||
*/
|
||||
public OneResponse showback(int filter,
|
||||
int first_month, int first_year,
|
||||
int last_month, int last_year)
|
||||
{
|
||||
return showback(client, filter,
|
||||
first_month, first_year,
|
||||
last_month, last_year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes all the history records, and stores the monthly cost for each VM
|
||||
*
|
||||
* @param filter Filter flag to use. Possible values:
|
||||
* <ul>
|
||||
* <li>{@link Pool#ALL}: All Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE}: Connected user's Virtual Machines</li>
|
||||
* <li>{@link Pool#MINE_GROUP}: Connected user's Virtual Machines, and
|
||||
* the ones in his group</li>
|
||||
* <li>{@link Pool#GROUP}: User's primary group Virtual Machines</li>
|
||||
* <li>>= 0 UID User's Virtual Machines</li>
|
||||
* </ul>
|
||||
* @param first_month First month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a left boundary.
|
||||
* @param first_year First year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a left boundary.
|
||||
* @param last_month Last month for the time interval. January is 1.
|
||||
* Can be -1, in which case the time interval won’t have a right boundary.
|
||||
* @param last_year Last year for the time interval. Can be -1,
|
||||
* in which case the time interval won’t have a right boundary.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse calculateshowback(int filter,
|
||||
int first_month, int first_year,
|
||||
int last_month, int last_year)
|
||||
{
|
||||
return calculateshowback(client, filter,
|
||||
first_month, first_year,
|
||||
last_month, last_year);
|
||||
}
|
||||
|
||||
public Iterator<VirtualMachine> iterator()
|
||||
{
|
||||
AbstractList<VirtualMachine> ab = new AbstractList<VirtualMachine>()
|
||||
|
Loading…
x
Reference in New Issue
Block a user