Host (OpenNebula Cloud API)
Description: declaration: package: org.opennebula.client.host, class: Host

Package org.opennebula.client.host

# Class Host

java.lang.Object
org.opennebula.client.PoolElement
org.opennebula.client.host.Host

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

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `Host.Status`

- ## Field Summary

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

  `client, id, xml, xpath`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static OneResponse`
  `allocate(Client client, String hostname, String im, String vmm)`
  Allocates a new host in OpenNebula
  `static OneResponse`
  `allocate(Client client, String hostname, String im, String vmm, int clusterId)`
  Allocates a new host in OpenNebula
  `OneResponse`
  `delete()`
  Deletes the host from OpenNebula.
  `static OneResponse`
  `delete(Client client, int id)`
  Deletes a host from OpenNebula.
  `OneResponse`
  `disable()`
  Disables the host
  `OneResponse`
  `enable()`
  Enables the host.
  `OneResponse`
  `info()`
  Loads the xml representation of the host.
  `static OneResponse`
  `info(Client client, int id)`
  Retrieves the information of the given host.
  `static OneResponse`
  `info(Client client, int id, boolean decrypt)`
  Retrieves the information of the given Host.
  `boolean`
  `isEnabled()`
  Returns true if the host is enabled.
  `OneResponse`
  `monitoring()`
  Retrieves the monitoring information of the given host, in XML
  `static OneResponse`
  `monitoring(Client client, int id)`
  Retrieves the monitoring information of the given host, in XML
  `OneResponse`
  `offline()`
  Sets the host offline
  `OneResponse`
  `rename(String name)`
  Renames this Host.
  `static OneResponse`
  `rename(Client client, int id, String name)`
  Renames this Host.
  `String`
  `shortStateStr()`
  Returns the short length string state of the Host.
  `String`
  `stateStr()`
  Returns the state of the Host.
  `static OneResponse`
  `status(Client client, int id, Host.Status status)`
  Enables or disables a given host.
  `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

  - ### Host

    public Host(int id, Client client)
    Creates a new Host representation.
    Parameters:
      `id` - The host id (hid) of the machine.
      `client` - XML-RPC Client.

  - ### Host

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

- ## Method Details

  - ### allocate

    public static OneResponse allocate(Client client, String hostname, String im, String vmm, int clusterId)
    Allocates a new host in OpenNebula
    Parameters:
      `client` - XML-RPC Client.
      `hostname` - Hostname of the machine we want to add
      `im` - The name of the information manager (im_mad_name), this values are taken from the oned.conf with the tag name IM_MAD (name)
      `vmm` - The name of the virtual machine manager mad name (vmm_mad_name), this values are taken from the oned.conf with the tag name VM_MAD (name)
      `clusterId` - The cluster ID. If it is -1, this host won't be added to any cluster.
    Returns:
      If successful the message contains the associated id generated for this host

  - ### allocate

    public static OneResponse allocate(Client client, String hostname, String im, String vmm)
    Allocates a new host in OpenNebula
    Parameters:
      `client` - XML-RPC Client.
      `hostname` - Hostname of the machine we want to add
      `im` - The name of the information manager (im_mad_name), this values are taken from the oned.conf with the tag name IM_MAD (name)
      `vmm` - The name of the virtual machine manager mad name (vmm_mad_name), this values are taken from the oned.conf with the tag name VM_MAD (name)
    Returns:
      If successful the message contains the associated id generated for this host

  - ### info

    public static OneResponse info(Client client, int id)
    Retrieves the information of the given host.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The host id (hid) of the target machine.
    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 Host.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The Host id for the Host 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 host from OpenNebula.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The host id (hid) of the target machine.
    Returns:
      A encapsulated response.

  - ### status

    public static OneResponse status(Client client, int id, Host.Status status)
    Enables or disables a given host.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The host id (hid) of the target machine.
      `status` - Host status
    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 host 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 host id.

  - ### monitoring

    public static OneResponse monitoring(Client client, int id)
    Retrieves the monitoring information of the given host, in XML
    Parameters:
      `client` - XML-RPC Client.
      `id` - The host id (hid) of the target machine.
    Returns:
      If successful the message contains the string with the monitoring information returned by OpenNebula.

  - ### rename

    public static OneResponse rename(Client client, int id, String name)
    Renames this Host.
    Parameters:
      `client` - XML-RPC Client.
      `id` - The image id of the target host we want to modify.
      `name` - New name for the Host
    Returns:
      If successful the message contains the host id.

  - ### info

    public OneResponse info()
    Loads the xml representation of the host. The info is also stored internally.
    See Also:
      - `info(Client, int)`

  - ### delete

    public OneResponse delete()
    Deletes the host from OpenNebula.
    See Also:
      - `delete(Client, int)`

  - ### enable

    public OneResponse enable()
    Enables the host.
    Returns:
      A encapsulated response.

  - ### disable

    public OneResponse disable()
    Disables the host
    Returns:
      A encapsulated response.

  - ### offline

    public OneResponse offline()
    Sets the host offline
    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 host 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 host id.

  - ### monitoring

    public OneResponse monitoring()
    Retrieves the monitoring information of the given host, in XML
    Returns:
      If successful the message contains the string with the monitoring information returned by OpenNebula.

  - ### rename

    public OneResponse rename(String name)
    Renames this Host.
    Parameters:
      `name` - New name for the Host
    Returns:
      If successful the message contains the host id.

  - ### stateStr

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

  - ### shortStateStr

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

  - ### isEnabled

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