Datastore (OpenNebula Cloud API)
Description: declaration: package: org.opennebula.client.datastore, class: Datastore

Package org.opennebula.client.datastore

# Class Datastore

java.lang.Object
org.opennebula.client.PoolElement
org.opennebula.client.datastore.Datastore

public class Datastore extends PoolElement
This class represents an OpenNebula datastore. It also offers static XML-RPC call wrappers.

- ## Field Summary

  ### Fields inherited from class org.opennebula.client.PoolElement

  `client, id, xml, xpath`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `Datastore(int id, Client client)`
  Creates a new Datastore representation.
  `protected`
  `Datastore(Node xmlElement, Client client)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static OneResponse`
  `allocate(Client client, String description)`
  Allocates a new Datastore in OpenNebula.
  `static OneResponse`
  `allocate(Client client, String description, int clusterId)`
  Allocates a new Datastore in OpenNebula.
  `OneResponse`
  `chgrp(int gid)`
  Changes the group
  `OneResponse`
  `chmod(int octet)`
  Changes the permissions
  `OneResponse`
  `chmod(int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a)`
  Changes the datastore permissions
  `OneResponse`
  `chmod(String octet)`
  Changes the permissions
  `static OneResponse`
  `chmod(Client client, int id, int octet)`
  Changes the permissions
  `static OneResponse`
  `chmod(Client client, int id, int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a)`
  Changes the datastore permissions
  `static OneResponse`
  `chmod(Client client, int id, String octet)`
  Changes the permissions
  `OneResponse`
  `chown(int uid)`
  Changes the owner
  `OneResponse`
  `chown(int uid, int gid)`
  Changes the owner/group
  `static OneResponse`
  `chown(Client client, int id, int uid, int gid)`
  Changes the owner/group
  `boolean`
  `contains(int id)`
  Returns whether or not the image is part of this datastore
  `OneResponse`
  `delete()`
  Deletes the datastore from OpenNebula.
  `static OneResponse`
  `delete(Client client, int id)`
  Deletes a datastore from OpenNebula.
  `OneResponse`
  `disable()`
  Disables the datastore.
  `OneResponse`
  `enable()`
  Enables the datastore.
  `OneResponse`
  `enable(boolean enable)`
  Enables or disables the datastore.
  `static OneResponse`
  `enable(Client client, int id, boolean enable)`
  Enables or disables this Datastore.
  `OneResponse`
  `info()`
  Retrieves the information of the Datastore.
  `static OneResponse`
  `info(Client client, int id)`
  Retrieves the information of the given Datastore.
  `static OneResponse`
  `info(Client client, int id, boolean decrypt)`
  Retrieves the information of the given Datastore.
  `OneResponse`
  `publish()`
  Publishes the datastore.
  `OneResponse`
  `publish(boolean publish)`
  Publishes or unpublishes the datastore.
  `static OneResponse`
  `publish(Client client, int id, boolean publish)`
  Publishes or unpublishes a datastore.
  `OneResponse`
  `rename(String name)`
  Renames this Datastore
  `static OneResponse`
  `rename(Client client, int id, String name)`
  Renames this Datastore.
  `String`
  `shortStateStr()`
  Returns the state of the Datastore as a short String.
  `String`
  `shortTypeStr()`
  Returns the type of the Datastore as a short String.
  `int`
  `state()`
  Returns the state of the Datastore.
  `String`
  `stateStr()`
  Returns the state of the Datastore as a String.
  `int`
  `type()`
  Returns the type of the Datastore.
  `String`
  `typeStr()`
  Returns the type of the Datastore as a String.
  `OneResponse`
  `unpublish()`
  Unpublishes the datastore.
  `OneResponse`
  `update(String new_template)`
  Replaces the datastore template.
  `OneResponse`
  `update(String new_template, boolean append)`
  Replaces the datastore template.
  `static OneResponse`
  `update(Client client, int id, String new_template, boolean append)`
  Replaces the datastore contents.

  ### Methods inherited from class org.opennebula.client.PoolElement

  `chmod, chmod, chmod, getId, getName, gid, id, processInfo, uid, xpath`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Datastore

    public Datastore(int id, Client client)
    Creates a new Datastore representation.
    Parameters:
      `id` - The datastore id.
      `client` - XML-RPC Client.

  - ### Datastore

    protected Datastore(Node xmlElement, Client client)
    See Also:
      - `PoolElement`

- ## Method Details

  - ### allocate

    public static OneResponse allocate(Client client, String description, int clusterId)
    Allocates a new Datastore in OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `description` - A string containing the template of the datastore.
      `clusterId` - Id of the cluster. If it is -1, this datastore won't be added to any cluster.
    Returns:
      If successful the message contains the associated id generated for this Datastore.

  - ### allocate

    public static OneResponse allocate(Client client, String description)
    Allocates a new Datastore in OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `description` - A string containing the template of the datastore.
    Returns:
      If successful the message contains the associated id generated for this Datastore.

  - ### info

    public static OneResponse info(Client client, int id)
    Retrieves the information of the given Datastore.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The datastore id to retrieve the information from
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### info

    public static OneResponse info(Client client, int id, boolean decrypt)
    Retrieves the information of the given Datastore.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Datastore id for the Datastore to retrieve the information from
      `decrypt` - If true decrypt sensitive attributes
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### delete

    public static OneResponse delete(Client client, int id)
    Deletes a datastore from OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target datastore we want to delete.
    Returns:
      A encapsulated response.

  - ### update

    public static OneResponse update(Client client, int id, String new_template, boolean append)
    Replaces the datastore contents.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target datastore we want to modify.
      `new_template` - New datastore contents.
      `append` - True to append new attributes instead of replace the whole template
    Returns:
      If successful the message contains the datastore id.

  - ### publish

    public static OneResponse publish(Client client, int id, boolean publish)
    Publishes or unpublishes a datastore.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target datastore we want to modify.
      `publish` - True for publishing, false for unpublishing.
    Returns:
      If successful the message contains the datastore id.

  - ### chown

    public static OneResponse chown(Client client, int id, int uid, int gid)
    Changes the owner/group
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target datastore we want to modify.
      `uid` - The new owner user ID. Set it to -1 to leave the current one.
      `gid` - The new group ID. Set it to -1 to leave the current one.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chmod

    public static OneResponse chmod(Client client, int id, int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a)
    Changes the datastore permissions
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target datastore.
      `owner_u` - 1 to allow, 0 deny, -1 do not change
      `owner_m` - 1 to allow, 0 deny, -1 do not change
      `owner_a` - 1 to allow, 0 deny, -1 do not change
      `group_u` - 1 to allow, 0 deny, -1 do not change
      `group_m` - 1 to allow, 0 deny, -1 do not change
      `group_a` - 1 to allow, 0 deny, -1 do not change
      `other_u` - 1 to allow, 0 deny, -1 do not change
      `other_m` - 1 to allow, 0 deny, -1 do not change
      `other_a` - 1 to allow, 0 deny, -1 do not change
    Returns:
      If an error occurs the error message contains the reason.

  - ### chmod

    public static OneResponse chmod(Client client, int id, String octet)
    Changes the permissions
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target object.
      `octet` - Permissions octet, e.g. 640
    Returns:
      If an error occurs the error message contains the reason.

  - ### chmod

    public static OneResponse chmod(Client client, int id, int octet)
    Changes the permissions
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target object.
      `octet` - Permissions octed , e.g. 640
    Returns:
      If an error occurs the error message contains the reason.

  - ### rename

    public static OneResponse rename(Client client, int id, String name)
    Renames this Datastore.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target object.
      `name` - New name for the Datastore
    Returns:
      If successful the message contains the datastore id.

  - ### enable

    public static OneResponse enable(Client client, int id, boolean enable)
    Enables or disables this Datastore.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The id of the target object.
      `enable` - True for enabling, false for disabling.
    Returns:
      If successful the message contains the datastore id.

  - ### info

    public OneResponse info()
    Retrieves the information of the Datastore.
    Returns:
      If successful the message contains the string with the information returned by OpenNebula.

  - ### delete

    public OneResponse delete()
    Deletes the datastore from OpenNebula.
    Returns:
      A encapsulated response.

  - ### update

    public OneResponse update(String new_template)
    Replaces the datastore template.
    Parameters:
      `new_template` - New datastore template.
    Returns:
      If successful the message contains the datastore id.

  - ### update

    public OneResponse update(String new_template, boolean append)
    Replaces the datastore template.
    Parameters:
      `new_template` - New datastore template.
      `append` - True to append new attributes instead of replace the whole template
    Returns:
      If successful the message contains the datastore id.

  - ### publish

    public OneResponse publish(boolean publish)
    Publishes or unpublishes the datastore.
    Parameters:
      `publish` - True for publishing, false for unpublishing.
    Returns:
      If successful the message contains the datastore id.

  - ### publish

    public OneResponse publish()
    Publishes the datastore.
    Returns:
      If successful the message contains the datastore id.

  - ### unpublish

    public OneResponse unpublish()
    Unpublishes the datastore.
    Returns:
      If successful the message contains the datastore id.

  - ### chown

    public OneResponse chown(int uid, int gid)
    Changes the owner/group
    Parameters:
      `uid` - The new owner user ID. Set it to -1 to leave the current one.
      `gid` - The new group ID. Set it to -1 to leave the current one.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chown

    public OneResponse chown(int uid)
    Changes the owner
    Parameters:
      `uid` - The new owner user ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chgrp

    public OneResponse chgrp(int gid)
    Changes the group
    Parameters:
      `gid` - The new group ID.
    Returns:
      If an error occurs the error message contains the reason.

  - ### chmod

    public OneResponse chmod(int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a)
    Changes the datastore permissions
    Parameters:
      `owner_u` - 1 to allow, 0 deny, -1 do not change
      `owner_m` - 1 to allow, 0 deny, -1 do not change
      `owner_a` - 1 to allow, 0 deny, -1 do not change
      `group_u` - 1 to allow, 0 deny, -1 do not change
      `group_m` - 1 to allow, 0 deny, -1 do not change
      `group_a` - 1 to allow, 0 deny, -1 do not change
      `other_u` - 1 to allow, 0 deny, -1 do not change
      `other_m` - 1 to allow, 0 deny, -1 do not change
      `other_a` - 1 to allow, 0 deny, -1 do not change
    Returns:
      If an error occurs the error message contains the reason.

  - ### chmod

    public OneResponse chmod(String octet)
    Changes the permissions
    Parameters:
      `octet` - Permissions octed , e.g. 640
    Returns:
      If an error occurs the error message contains the reason.

  - ### chmod

    public OneResponse chmod(int octet)
    Changes the permissions
    Parameters:
      `octet` - Permissions octed , e.g. 640
    Returns:
      If an error occurs the error message contains the reason.

  - ### rename

    public OneResponse rename(String name)
    Renames this Datastore
    Parameters:
      `name` - New name for the Datastore.
    Returns:
      If an error occurs the error message contains the reason.

  - ### enable

    public OneResponse enable(boolean enable)
    Enables or disables the datastore.
    Parameters:
      `enable` - True for enabling, false for disabling.
    Returns:
      If successful the message contains the datastore id.

  - ### enable

    public OneResponse enable()
    Enables the datastore.
    Returns:
      If successful the message contains the datastore id.

  - ### disable

    public OneResponse disable()
    Disables the datastore.
    Returns:
      If successful the message contains the datastore id.

  - ### type

    public int type()
    Returns the type of the Datastore.
    Returns:
      The type of the Datastore.

  - ### typeStr

    public String typeStr()
    Returns the type of the Datastore as a String.
    Returns:
      The type of the Datastore as a String.

  - ### shortTypeStr

    public String shortTypeStr()
    Returns the type of the Datastore as a short String.
    Returns:
      The type of the Datastore as a short String.

  - ### state

    public int state()
    Returns the state of the Datastore.
    Overrides:
      `state` in class `PoolElement`
    Returns:
      The state of the Datastore.

  - ### stateStr

    public String stateStr()
    Returns the state of the Datastore as a String.
    Returns:
      The state of the Datastore as a String.

  - ### shortStateStr

    public String shortStateStr()
    Returns the state of the Datastore as a short String.
    Returns:
      The state of the Datastore as a short String.

  - ### contains

    public boolean contains(int id)
    Returns whether or not the image is part of this datastore
    Parameters:
      `id` - The image ID.
    Returns:
      Whether or not the image is part of this datastore.