Package comodit_client :: Package api :: Module host :: Class Host

Class Host


A host. A host is part of an environment and has settings associated to it. It features a list of installed applications, is associated to a platform and a distribution. Applications, distribution and platform associated to a host can be configured using settings, the configuration of each application, distribution and platform is contained by a context. When a host is provisioned, an instance is associated to it.

The definition of a host can be modified by the user, however operations may have to be undergone on host's instance: changes are queued and are being processed by ComodIT. As long as changes are pending, host's instance does not yet meet the new definition.

Another reason for which a host's instance does comply with the definition of ComodIT is the modification on the host's instance of resources managed by ComodIT, for example the deletion of an application's file. In this case, a compliance error is associated to the host.

A host entity owns the following collections:

Nested Classes
  State
The states a host can be in.
Instance Methods
 
add_application(self, app_name)
Adds an application to install on this host.
InstanceCollection
instance(self)
Instantiates host's instance collection.
Instance
get_instance(self)
Fetches host's instance.
Instance
provision(self)
Triggers host's provisioning.
string
render_app_file(self, app_name, file_name)
Fetches the rendered version of an application's file.
string
render_dist_file(self, file_name)
Fetches the rendered version of a distribution's file.
string
render_plat_file(self, file_name)
Fetches the rendered version of a platform's file.
string
get_app_link(self, app_name, file_name, short=False)
Requests a one-time URL for a rendered application file.
string
get_dist_link(self, file_name, short=False)
Requests a one-time URL for a rendered distribution file.
string
get_plat_link(self, file_name, short=False)
Requests a one-time URL for a rendered platform file.
Host
clone(self)
Requests the cloning of remote host.
ApplicationContextCollection
applications(self)
Instantiates application contexts collection.
ApplicationContext
get_application(self, name)
Fetches an application context from server.
PlatformContextCollection
platform(self)
Instantiates platform context collection.
PlatformContext
get_platform(self)
Fetches the platform context from server.
DistributionContextCollection
distribution(self)
Instantiates distribution context collection.
DistributionContext
get_distribution(self)
Fetches the distribution context from server.
ChangeCollection
changes(self)
Instantiates changes collection.
Change
get_change(self, num)
Fetches a change from server.
AuditLogCollection
audit_logs(self)
Instantiates audit logs collection.
ComplianceCollection
compliance(self)
Instantiates compliance errors collection.
ComplianceError
get_compliance_error(self, identifier)
Fetches a particular compliance error from server.
 
live_update_file(self, app_name, file_name)
Requests the update of a file on provisioned machine.
 
live_restart_service(self, app_name, svc_name)
Requests the restart of a service on provisioned machine.
 
live_update_service(self, app_name, svc_name)
Requests the update of a service on provisioned machine.
 
live_enable_service(self, app_name, svc_name)
Enables a service on a machine.
 
live_disable_service(self, app_name, svc_name)
Disables a service on a machine.
 
live_install_package(self, app_name, pkg_name)
Requests the (re-)installation of a package on provisioned machine.
 
install(self, name, settings={})
Installs an application on this host.
 
uninstall(self, name)
Uninstalls an application from this host.
 
wait_for_state(self, state, time_out=0)
Waits until host has requested state.
 
wait_for_pending_changes(self, time_out=0)
Waits until host has no more pending changes.

Inherited from settings.HasSettings: add_link_setting, add_property_setting, add_setting, add_simple_setting, get_setting, settings

Inherited from entity.Entity: __init__, create, 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 organization
The name of the organization this host is part of.
string environment
The name of the environment this host is part of.
string platform_name
The name of the platform associated to this host.
string distribution_name
The name of the distribution associated to this host.
list of string application_names
The name of the applications installed on to this host.
State state
The host's state.

Inherited from settings.HasSettings: settings_f

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

Inherited from object: __class__

Method Details

add_application(self, app_name)

 

Adds an application to install on this host. This field is only considered by the server at creation time. In order to install an application on this host later, use Host.install() or explicitly create an application context (see Host.applications()).

instance(self)

 

Instantiates host's instance collection. This collection contains at most one element.

Returns: InstanceCollection
The host's instance collection.

get_instance(self)

 

Fetches host's instance.

Returns: Instance
Host's instance.

provision(self)

 

Triggers host's provisioning. A distribution and a platform must be associated to the host in order to provision it.

Returns: Instance
The host's instance.

render_app_file(self, app_name, file_name)

 

Fetches the rendered version of an application's file. The returned value is a file-like object like returned by urllib2.urlopen. See ComodIT documentation for more information about file rendering.

Parameters:
  • app_name (string) - The name of the application.
  • file_name (string) - The name of the file to render.
Returns: string
a reader to the content.

render_dist_file(self, file_name)

 

Fetches the rendered version of a distribution's file. The returned value is a file-like object like returned by urllib2.urlopen. See ComodIT documentation for more information about file rendering.

Parameters:
  • file_name (string) - The name of the file to render.
Returns: string
a reader to the content.

render_plat_file(self, file_name)

 

Fetches the rendered version of a platform's file. The returned value is a file-like object like returned by urllib2.urlopen. See ComodIT documentation for more information about file rendering.

Parameters:
  • file_name (string) - The name of the file to render.
Returns: string
a reader to the content.

get_app_link(self, app_name, file_name, short=False)

 

Requests a one-time URL for a rendered application file. A one-time URL is accessible without authentication but has a limited life-time.

Parameters:
  • app_name (string) - The name of application.
  • file_name (string) - The name of file.
  • short (bool) - If true, a shorter URL is generated.
Returns: string
A one-time URL.

get_dist_link(self, file_name, short=False)

 

Requests a one-time URL for a rendered distribution file. A one-time URL is accessible without authentication but has a limited life-time.

Parameters:
  • file_name (string) - The name of file.
  • short (bool) - If true, a shorter URL is generated.
Returns: string
A one-time URL.

get_plat_link(self, file_name, short=False)

 

Requests a one-time URL for a rendered platform file. A one-time URL is accessible without authentication but has a limited life-time.

Parameters:
  • file_name (string) - The name of file.
  • short (bool) - If true, a shorter URL is generated.
Returns: string
A one-time URL.

clone(self)

 

Requests the cloning of remote host. Cloned host have DEFINED state.

Returns: Host
The representation of host's clone.

applications(self)

 

Instantiates application contexts collection.

Returns: ApplicationContextCollection
Application contexts collection.

get_application(self, name)

 

Fetches an application context from server.

Parameters:
  • name (string) - Application's name.
Returns: ApplicationContext
Requested application context.

platform(self)

 

Instantiates platform context collection.

Returns: PlatformContextCollection
Platform context collection.

get_platform(self)

 

Fetches the platform context from server.

Returns: PlatformContext
The platform context.

distribution(self)

 

Instantiates distribution context collection.

Returns: DistributionContextCollection
Distribution context collection.

get_distribution(self)

 

Fetches the distribution context from server.

Returns: DistributionContext
The distribution context.

changes(self)

 

Instantiates changes collection.

Returns: ChangeCollection
Changes collection.

get_change(self, num)

 

Fetches a change from server.

Parameters:
  • num (string) - The order number of the change.
Returns: Change
The change.

audit_logs(self)

 

Instantiates audit logs collection.

Returns: AuditLogCollection
Audit logs collection.

compliance(self)

 

Instantiates compliance errors collection.

Returns: ComplianceCollection
Compliance errors collection.

get_compliance_error(self, identifier)

 

Fetches a particular compliance error from server.

Parameters:
  • identifier (ComplianceError) - Compliance error's identifier. It must have the following form: 'applications/app_name/collection/id' where app_name is the name of an application installed on the host, collection on of (services, files, packages, users, groups, repos) and id the name of the application's resource.
Returns: ComplianceError
The compliance error.

live_update_file(self, app_name, file_name)

 

Requests the update of a file on provisioned machine. This may, for instance, solve a compliance error linked to target file by resetting file's content to its original value. A change is queued and exposes the result of the operation.

Parameters:
  • app_name (string) - The name of file's application.
  • file_name (string) - The file's name.

live_restart_service(self, app_name, svc_name)

 

Requests the restart of a service on provisioned machine. This may, for instance, solve a compliance error linked to target service by resetting its state. A change is queued and exposes the result of the operation.

Parameters:
  • app_name (string) - The name of service's application.
  • svc_name (string) - The service's name.

live_update_service(self, app_name, svc_name)

 

Requests the update of a service on provisioned machine. This may, for instance, solve a compliance error linked to target service by resetting its state. A change is queued and exposes the result of the operation.

Parameters:
  • app_name (string) - The name of service's application.
  • svc_name (string) - The service's name.

live_enable_service(self, app_name, svc_name)

 

Enables a service on a machine.

Parameters:
  • app_name (string) - The name of service's application.
  • svc_name (string) - The service's name.

live_disable_service(self, app_name, svc_name)

 

Disables a service on a machine.

Parameters:
  • app_name (string) - The name of service's application.
  • svc_name (string) - The service's name.

live_install_package(self, app_name, pkg_name)

 

Requests the (re-)installation of a package on provisioned machine. This may, for instance, solve a compliance error linked to target package having been removed. A change is queued and exposes the result of the operation.

Parameters:
  • app_name (string) - The name of file's application.
  • pkg_name (string) - The package's name.

install(self, name, settings={})

 

Installs an application on this host.

Parameters:
  • name (string) - The name of the application to install.
  • settings (dict) - The configuration of the application. It is given in the form of a dict of strings: key-values are the key-values of the settings to create i.e. dictionary {"k":"v"} implies the creation of a single setting having key "k" and value "v". Value may be any valid JSON object.

uninstall(self, name)

 

Uninstalls an application from this host.

Parameters:
  • name (string) - The name of the application.

wait_for_state(self, state, time_out=0)

 

Waits until host has requested state.

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

wait_for_pending_changes(self, time_out=0)

 

Waits until host has no more pending changes.

Parameters:
  • time_out (int) - A time-out expressed in seconds. A time-out of 0 seconds means no time-out (method can wait forever).

Property Details

organization

The name of the organization this host is part of.

Get Method:
unreachable.organization(self) - The name of the organization this host is part of.
Type:
string

environment

The name of the environment this host is part of.

Get Method:
unreachable.environment(self) - The name of the environment this host is part of.
Set Method:
unreachable.environment(self, name) - Sets the environment this host is part of.
Type:
string

platform_name

The name of the platform associated to this host.

Get Method:
unreachable.platform_name(self) - The name of the platform associated to this host.
Set Method:
unreachable.platform_name(self, platform) - Sets the name of the platform associated to this host.
Type:
string

distribution_name

The name of the distribution associated to this host.

Get Method:
unreachable.distribution_name(self) - The name of the distribution associated to this host.
Set Method:
unreachable.distribution_name(self, distribution) - Sets the name of the distribution associated to this host.
Type:
string

application_names

The name of the applications installed on to this host.

Get Method:
unreachable.application_names(self) - The name of the applications installed on to this host.
Set Method:
unreachable.application_names(self, applications) - Sets the applications installed on this host.
Type:
list of string

state

The host's state.

Get Method:
unreachable.state(self) - The host's state.
Type:
State