Image (OpenNebula Cloud API)
Description: declaration: package: org.opennebula.client.image, class: Image

Package org.opennebula.client.image

# Class Image

java.lang.Object
org.opennebula.client.PoolElement
org.opennebula.client.image.Image

public class Image extends PoolElement
This class represents an OpenNebula image. 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
  ``
  `Image(int id, Client client)`
  Creates a new Image representation.
  `protected`
  `Image(Node xmlElement, Client client)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static OneResponse`
  `allocate(Client client, String description, int datastoreId)`
  Allocates a new Image in OpenNebula.
  `static OneResponse`
  `allocate(Client client, String description, int datastoreId, boolean no_check_capacity)`
  Allocates a new Image 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 Image 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 Image 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
  `OneResponse`
  `chtype(String type)`
  Changes the Image type
  `static OneResponse`
  `chtype(Client client, int id, String type)`
  Changes the Image type
  `OneResponse`
  `clone(String name)`
  Clones this Image into a new one
  `OneResponse`
  `clone(String name, int targetDS)`
  Clones this Image into a new one
  `static OneResponse`
  `clone(Client client, int id, String name, int targetDS)`
  Clones this Image into a new one
  `OneResponse`
  `delete(boolean force)`
  Deletes the image from OpenNebula.
  `static OneResponse`
  `delete(Client client, int id, boolean force)`
  Deletes an image from OpenNebula.
  `OneResponse`
  `disable()`
  Disables the image.
  `OneResponse`
  `enable()`
  Enables the image.
  `OneResponse`
  `enable(boolean enable)`
  Enables or disables the image.
  `static OneResponse`
  `enable(Client client, int id, boolean enable)`
  Enables or disables an image.
  `OneResponse`
  `info()`
  Retrieves the information of the Image.
  `static OneResponse`
  `info(Client client, int id)`
  Retrieves the information of the given Image.
  `static OneResponse`
  `info(Client client, int id, boolean decrypt)`
  Retrieves the information of the given Image.
  `boolean`
  `isEnabled()`
  Returns true if the image is enabled.
  `OneResponse`
  `lock(int level)`
  Lock this Image
  `static OneResponse`
  `lock(Client client, int id, int level)`
  lock this Image
  `OneResponse`
  `nonpersistent()`
  Sets the Image as persistent or not persistent.
  `OneResponse`
  `persistent()`
  Sets the Image as persistent
  `OneResponse`
  `persistent(boolean persistent)`
  Sets the Image as persistent or not persistent.
  `static OneResponse`
  `persistent(Client client, int id, boolean persistent)`
  Sets the Image as persistent or not persistent.
  `OneResponse`
  `publish()`
  Publishes the image.
  `OneResponse`
  `publish(boolean publish)`
  Publishes or unpublishes the image.
  `static OneResponse`
  `publish(Client client, int id, boolean publish)`
  Publishes or unpublishes an image.
  `OneResponse`
  `rename(String name)`
  Renames this Image
  `static OneResponse`
  `rename(Client client, int id, String name)`
  Renames this Image
  `String`
  `shortStateStr()`
  Returns the short length string state of the Image.
  `String`
  `shortTypeStr()`
  Returns the type of the Image as a short String.
  `OneResponse`
  `snapshotDelete(int snapId)`
  Deletes Image from snapshot
  `static OneResponse`
  `snapshotDelete(Client client, int id, int snapId)`
  Deletes Image from snapshot
  `OneResponse`
  `snapshotFlatten(int snapId)`
  Flattens an image snapshot
  `static OneResponse`
  `snapshotFlatten(Client client, int id, int snapId)`
  Flattens an image snapshot
  `OneResponse`
  `snapshotRevert(int snapId)`
  Reverts Image state to a previous snapshot
  `static OneResponse`
  `snapshotRevert(Client client, int id, int snapId)`
  Reverts Image state to a previous snapshot
  `String`
  `stateString()`
  Returns the state of the Image.
  `int`
  `type()`
  Returns the type of the Image.
  `String`
  `typeStr()`
  Returns the type of the Image as a String.
  `OneResponse`
  `unlock()`
  Unlock this Image
  `static OneResponse`
  `unlock(Client client, int id)`
  Unlock this Image
  `OneResponse`
  `unpublish()`
  Unpublishes the image.
  `OneResponse`
  `update(String new_template)`
  Replaces the template contents.
  `OneResponse`
  `update(String new_template, boolean append)`
  Replaces the template contents.
  `static OneResponse`
  `update(Client client, int id, String new_template, boolean append)`
  Replaces the template contents.

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

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

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

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

- ## Constructor Details

  - ### Image

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

  - ### Image

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

- ## Method Details

  - ### allocate

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

  - ### allocate

    public static OneResponse allocate(Client client, String description, int datastoreId, boolean no_check_capacity)
    Allocates a new Image in OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `description` - A string containing the template of the image.
      `datastoreId` - The Datastore ID
      `no_check_capacity` - to check datastore capacity
    Returns:
      If successful the message contains the associated id generated for this Image.

  - ### info

    public static OneResponse info(Client client, int id)
    Retrieves the information of the given Image.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id for the image 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 Image.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id for the Image 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, boolean force)
    Deletes an image from OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target image we want to delete.
      `force` - Ignore errors
    Returns:
      A encapsulated response.

  - ### update

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

  - ### enable

    public static OneResponse enable(Client client, int id, boolean enable)
    Enables or disables an image.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target image we want to modify.
      `enable` - True for enabling, false for disabling.
    Returns:
      If successful the message contains the image id.

  - ### persistent

    public static OneResponse persistent(Client client, int id, boolean persistent)
    Sets the Image as persistent or not persistent.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target image we want to modify.
      `persistent` - True to make it persistent, false non-persistent
    Returns:
      If successful the message contains the image id.

  - ### publish

    public static OneResponse publish(Client client, int id, boolean publish)
    Publishes or unpublishes an image.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target image we want to modify.
      `publish` - True for publishing, false for unpublishing.
    Returns:
      If successful the message contains the image 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 image id of the target image 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 Image permissions
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target image we want to modify.
      `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 octed , 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.

  - ### chtype

    public static OneResponse chtype(Client client, int id, String type)
    Changes the Image type
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target image we want to modify.
      `type` - The new Image type
    Returns:
      If an error occurs the error message contains the reason.

  - ### clone

    public static OneResponse clone(Client client, int id, String name, int targetDS)
    Clones this Image into a new one
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id of the target Image.
      `name` - Name for the new Image.
      `targetDS` - The ID of the target datastore. Set to -1 to use the current one.
    Returns:
      If successful the message contains the new Image ID.

  - ### rename

    public static OneResponse rename(Client client, int id, String name)
    Renames this Image
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id of the target Image.
      `name` - New name for the Image.
    Returns:
      If an error occurs the error message contains the reason.

  - ### snapshotDelete

    public static OneResponse snapshotDelete(Client client, int id, int snapId)
    Deletes Image from snapshot
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id of the target Image.
      `snapId` - ID of the snapshot to delete
    Returns:
      If an error occurs the error message contains the reason.

  - ### snapshotRevert

    public static OneResponse snapshotRevert(Client client, int id, int snapId)
    Reverts Image state to a previous snapshot
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id of the target Image.
      `snapId` - ID of the snapshot to revert to
    Returns:
      If an error occurs the error message contains the reason.

  - ### snapshotFlatten

    public static OneResponse snapshotFlatten(Client client, int id, int snapId)
    Flattens an image snapshot
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id of the target Image.
      `snapId` - ID of the snapshot to flatten
    Returns:
      If an error occurs the error message contains the reason.

  - ### lock

    public static OneResponse lock(Client client, int id, int level)
    lock this Image
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id.
      `level` - Lock level.
    Returns:
      If an error occurs the error message contains the reason.

  - ### unlock

    public static OneResponse unlock(Client client, int id)
    Unlock this Image
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Image id.
    Returns:
      If an error occurs the error message contains the reason.

  - ### info

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

  - ### delete

    public OneResponse delete(boolean force)
    Deletes the image from OpenNebula.
    Parameters:
      `force` - Ignore errors
    Returns:
      A encapsulated response.

  - ### update

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

  - ### update

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

  - ### enable

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

  - ### enable

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

  - ### disable

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

  - ### persistent

    public OneResponse persistent(boolean persistent)
    Sets the Image as persistent or not persistent.
    Parameters:
      `persistent` - True for enabling, false for disabling.
    Returns:
      If successful the message contains the image id.

  - ### persistent

    public OneResponse persistent()
    Sets the Image as persistent
    Returns:
      If successful the message contains the image id.

  - ### nonpersistent

    public OneResponse nonpersistent()
    Sets the Image as persistent or not persistent.
    Returns:
      If successful the message contains the image id.

  - ### publish

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

  - ### publish

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

  - ### unpublish

    public OneResponse unpublish()
    Unpublishes the image.
    Returns:
      If successful the message contains the image 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 Image 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.

  - ### chtype

    public OneResponse chtype(String type)
    Changes the Image type
    Parameters:
      `type` - The new Image type
    Returns:
      If an error occurs the error message contains the reason.

  - ### clone

    public OneResponse clone(String name)
    Clones this Image into a new one
    Parameters:
      `name` - Name for the new Image.
    Returns:
      If successful the message contains the new Image ID.

  - ### clone

    public OneResponse clone(String name, int targetDS)
    Clones this Image into a new one
    Parameters:
      `name` - Name for the new Image.
      `targetDS` - The ID of the target datastore.
    Returns:
      If successful the message contains the new Image ID.

  - ### rename

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

  - ### snapshotDelete

    public OneResponse snapshotDelete(int snapId)
    Deletes Image from snapshot
    Parameters:
      `snapId` - ID of the snapshot to delete
    Returns:
      If an error occurs the error message contains the reason.

  - ### snapshotRevert

    public OneResponse snapshotRevert(int snapId)
    Reverts Image state to a previous snapshot
    Parameters:
      `snapId` - ID of the snapshot to revert to
    Returns:
      If an error occurs the error message contains the reason.

  - ### snapshotFlatten

    public OneResponse snapshotFlatten(int snapId)
    Flattens an image snapshot
    Parameters:
      `snapId` - ID of the snapshot to flatten
    Returns:
      If an error occurs the error message contains the reason.

  - ### lock

    public OneResponse lock(int level)
    Lock this Image
    Parameters:
      `level` - Lock level.
    Returns:
      If an error occurs the error message contains the reason.

  - ### unlock

    public OneResponse unlock()
    Unlock this Image
    Returns:
      If an error occurs the error message contains the reason.

  - ### stateString

    public String stateString()
    Returns the state of the Image.
    The method `info()` must be called before.
    Returns:
      The state of the Image.

  - ### shortStateStr

    public String shortStateStr()
    Returns the short length string state of the Image.
    The method `info()` must be called before.
    Returns:
      The short length string state of the Image.

  - ### type

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

  - ### typeStr

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

  - ### shortTypeStr

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

  - ### isEnabled

    public boolean isEnabled()
    Returns true if the image is enabled.
    Returns:
      True if the image is enabled.