Package comodit_client :: Package api :: Module host :: Class Instance

Class Instance


Host instance entity representation. An instance is associated to a host when it is provisioned. It has properties describing the VM or physical machine associated to the host (e.g. its IP address, public DNS name, etc.) and features operations related to VM handling: start, pause, resume, power-off and shutdown.

Instance Methods
 
create(self)
Creates a remote host instance using this object's state for initialization.
string
get_ip(self, interface)
Retrieves the IP address associated to given interface from instance properties.
string
get_property(self, key)
Retrieves the value of a property.
 
start(self)
Starts instance.
 
pause(self)
Pauses instance.
 
resume(self)
Resumes instance's execution (after pause).
 
shutdown(self)
Shuts instance down.
 
poweroff(self)
Powers instance off.
 
show_properties(self, indent=0)
Prints instance's properties to standard output in a user-friendly way.
string
wait_for_property(self, key, time_out=0)
Waits until a property with given key appears (or a time-out occurs) in remote instance's state and returns its value.
string
wait_for_address(self, time_out=0)
Waits until remote instance's IP address or DNS name is known.

Inherited from entity.Entity: __init__, delete, dump, load, refresh, rename, show, update

Inherited from util.json_wrapper.JsonWrapper: dump_json, get_json, load_json, print_json, set_json

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
string identifier
Identifier of the entity.
string organization
The name of the organization owning the host this instance is attached to.
string environment
The name of the environment owning the host this instance is attached to.
string host
The name of this instance's host.
string state
Instance's state.
string hostname
Instance's hostname.
Vnc vnc
Fetches instance's VNC connection data from server.
string agent_state
Agent's state.
list of Property properties
Instance's properties.

Inherited from entity.Entity: client, description, label, name, url, uuid

Inherited from object: __class__

Method Details

create(self)

 

Creates a remote host instance using this object's state for initialization. If there are properties associated to this object, a "fake" provisioning is executed: host is set in provisioning state and properties are associated to the instance, but no VM creation is actually triggered. This allows to re-import an instance linked to a VM or machine that was already provisioned.

Raises:
Overrides: entity.Entity.create

get_ip(self, interface)

 

Retrieves the IP address associated to given interface from instance properties.

Parameters:
  • interface (string) - An interface name (e.g. eth0).
Returns: string
An IP address or None if no address was found.

get_property(self, key)

 

Retrieves the value of a property.

Parameters:
  • key (string) - Property's key.
Returns: string
Property value or None if no property was found.

show_properties(self, indent=0)

 

Prints instance's properties to standard output in a user-friendly way.

Parameters:
  • indent (int) - The number of spaces to put in front of each displayed line.

wait_for_property(self, key, time_out=0)

 

Waits until a property with given key appears (or a time-out occurs) in remote instance's state and returns its value. If a time-out occurred, the method returns None.

Parameters:
  • key (string) - Property's key.
  • time_out (int) - A time-out expressed in seconds. A time-out of 0 seconds means no time-out (method can wait forever).
Returns: string
The value associated to given key.

wait_for_address(self, time_out=0)

 

Waits until remote instance's IP address or DNS name is known. If a time-out occurred, the method may return None. The returned value is one of the following (in a decreasing priority order i.e. first available is returned):

  1. Public DNS name
  2. Public IP address
  3. eth0 IP address
Parameters:
  • time_out (int) - A time-out expressed in seconds. A time-out of 0 seconds means no time-out (method can wait forever).
Returns: string
The instance's address.

Property Details

identifier

Identifier of the entity. The identifier is unique in entity's collection and can therefore be used to get the entity. This value is generally entity's name but may also be the UUID or another field depending on entity type.

Get Method:
unreachable.identifier(self)
Type:
string

organization

The name of the organization owning the host this instance is attached to.

Get Method:
unreachable.organization(self) - The name of the organization owning the host this instance is attached to.
Type:
string

environment

The name of the environment owning the host this instance is attached to.

Get Method:
unreachable.environment(self) - The name of the environment owning the host this instance is attached to.
Type:
string

host

The name of this instance's host.

Get Method:
unreachable.host(self) - The name of this instance's host.
Type:
string

state

Instance's state. Possible values are: UNDEFINED, PENDING, RUNNING, PAUSED, STOPPED.

Get Method:
unreachable.state(self) - Instance's state.
Type:
string

hostname

Instance's hostname.

Get Method:
unreachable.hostname(self) - Instance's hostname.
Type:
string

vnc

Fetches instance's VNC connection data from server.

Get Method:
unreachable.vnc(self) - Fetches instance's VNC connection data from server.
Type:
Vnc

agent_state

Agent's state. Possible values are 'Up' and 'Down'.

Get Method:
unreachable.agent_state(self) - Agent's state.
Type:
string

properties

Instance's properties.

Get Method:
unreachable.properties(self) - Instance's properties.
Type:
list of Property