mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
Feature #3456: DS enable/disable in java oca
This commit is contained in:
parent
6685f75af8
commit
f89e100ad5
@ -36,11 +36,16 @@ public class Datastore extends PoolElement
|
||||
private static final String CHOWN = METHOD_PREFIX + "chown";
|
||||
private static final String CHMOD = METHOD_PREFIX + "chmod";
|
||||
private static final String RENAME = METHOD_PREFIX + "rename";
|
||||
private static final String ENABLE = METHOD_PREFIX + "enable";
|
||||
|
||||
private static final String[] DATASTORE_TYPES = {"IMAGE", "SYSTEM", "FILE"};
|
||||
|
||||
private static final String[] SHORT_DATASTORE_TYPES = {"img", "sys", "fil"};
|
||||
|
||||
private static final String[] DATASTORE_STATES = {"READY", "DISABLED"};
|
||||
|
||||
private static final String[] SHORT_DATASTORE_STATES = {"rdy", "disa"};
|
||||
|
||||
/**
|
||||
* Creates a new Datastore representation.
|
||||
* @param id The datastore id.
|
||||
@ -217,7 +222,7 @@ public class Datastore extends PoolElement
|
||||
* Renames this Datastore.
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The image id of the target host we want to modify.
|
||||
* @param id The id of the target object.
|
||||
* @param name New name for the Datastore
|
||||
* @return If successful the message contains the datastore id.
|
||||
*/
|
||||
@ -226,6 +231,19 @@ public class Datastore extends PoolElement
|
||||
return client.call(RENAME, id, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables this Datastore.
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The id of the target object.
|
||||
* @param enable True for enabling, false for disabling.
|
||||
* @return If successful the message contains the datastore id.
|
||||
*/
|
||||
public static OneResponse enable(Client client, int id, boolean enable)
|
||||
{
|
||||
return client.call(ENABLE, id, enable);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Instanced object XML-RPC methods
|
||||
// =================================
|
||||
@ -398,6 +416,37 @@ public class Datastore extends PoolElement
|
||||
return rename(client, id, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the datastore.
|
||||
*
|
||||
* @param enable True for enabling, false for disabling.
|
||||
* @return If successful the message contains the datastore id.
|
||||
*/
|
||||
public OneResponse enable(boolean enable)
|
||||
{
|
||||
return enable(client, id, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the datastore.
|
||||
*
|
||||
* @return If successful the message contains the datastore id.
|
||||
*/
|
||||
public OneResponse enable()
|
||||
{
|
||||
return enable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the datastore.
|
||||
*
|
||||
* @return If successful the message contains the datastore id.
|
||||
*/
|
||||
public OneResponse disable()
|
||||
{
|
||||
return enable(false);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Helpers
|
||||
// =================================
|
||||
@ -434,6 +483,39 @@ public class Datastore extends PoolElement
|
||||
return type != -1 ? SHORT_DATASTORE_TYPES[type] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the Datastore.
|
||||
*
|
||||
* @return The state of the Datastore.
|
||||
*/
|
||||
public int state()
|
||||
{
|
||||
String state = xpath("STATE");
|
||||
return state != null ? Integer.parseInt( state ) : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the Datastore as a String.
|
||||
*
|
||||
* @return The state of the Datastore as a String.
|
||||
*/
|
||||
public String stateStr()
|
||||
{
|
||||
int state = state();
|
||||
return state != -1 ? DATASTORE_STATES[state] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the Datastore as a short String.
|
||||
*
|
||||
* @return The state of the Datastore as a short String.
|
||||
*/
|
||||
public String shortStateStr()
|
||||
{
|
||||
int state = state();
|
||||
return state != -1 ? SHORT_DATASTORE_STATES[state] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the image is part of this datastore
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user