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.
MonitoringAlertCollection
alerts(self)
Instantiates MonitorinAlert collection.
file-like object
get_file_content(self, path)
Retrieves the content of a file on a host's instance.
string
get_status(self, collection, sensor)
Retrieves the value of a monitoring sensor on a host's instance.
 
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.
 
forget(self)
Forgets instance.
 
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.
 
wait_for_state(self, state, time_out=0)
Waits until instance has requested state.
 
create_image(self, image)
Creates an image based on provided template.

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

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

Inherited from object: __long__, __native__, __nonzero__, __unicode__, next

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

Properties
string name
Name of this 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, identifier, label, 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.

alerts(self)

 

Instantiates MonitorinAlert collection.

Returns: MonitoringAlertCollection
MonitoringAlert collection.

get_file_content(self, path)

 

Retrieves the content of a file on a host's instance.

Parameters:
  • path (string) - The absolute path to a particular file.
Returns: file-like object
a reader to file's content.

get_status(self, collection, sensor)

 

Retrieves the value of a monitoring sensor on a host's instance.

Parameters:
  • collection (string) - The collection to query (e.g. host, apache).
  • sensor (string) - The specific sensor to query.
Returns: string
the value read from the sensor.

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.

wait_for_state(self, state, time_out=0)

 

Waits until instance has requested state.

Parameters:
  • state (string) - The expected state (see Instance.State).
  • time_out (int) - A time-out expressed in seconds. A time-out of 0 seconds means no time-out (method can wait forever).

create_image(self, image)

 

Creates an image based on provided template.

Parameters:
  • image (Image) - the image template

Property Details

name

Name of this entity.

Get Method:
unreachable.name(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