Package comodit_client :: Package api

Package api

The modules in this package provide classes that describe entities handled by a ComodIT server (hosts, applications, etc.) as well as tools easing the handling of these entities.

All ComodIT entity representations inherit from Entity class which defines generic operations, in particular creation, update and deletion of remote entities. Note that a Entity instance is only the local (i.e. in RAM) representation of a remote instance. Therefore, altering the state of a local instance does not automatically update remote object (see Entity class for more details).

Entities are accessed through collections. Each collection is represented by a class that inherits from Collection. Collections may be associated to a particular entity. In this case, the entity owns the collection and all the entities in the collection. Collections that are not associated to an entity are called root collections. These are accessible through an instance of Client which represents a connection to a ComodIT server. This object is mandatory to any interaction with a server using this library.

Any entity is reachable starting from one of root collections' entity. Indeed, ComodIT's data model defines the following structure (each item represents an entity type or collection, entity representation is given; when an item has a sub-list, it means each entity of the collection has a collection associated to it):

Below script illustrates the usage of defined classes. org is an instance of Organization, host is an instance of Host.

>>> from comodit_client.api import Client
... # Connect to ComodIT
... client = Client('', 'UUU', 'PPP')
... # Create host
... org = client.get_organization('OOO')
... host = org.get_environment('Default').hosts().create('my-new-host', '', 'Demo Platform', 'Demo Distribution')
... # Provision host
... host.provision()
... host.wait_for_state('READY')
... # Install an application
... host.install('Wordpress', {'wp_admin_password': 'XXX', 'wp_admin_email': 'YYY@ZZZ'})
... host.wait_for_pending_changes()
... # Retrieve instance's hostname
... hostname = host.get_instance().get_property('publicDnsName')
... print "Wordpress available at http://" + hostname + "/"
... # Delete host and its instance
... host.get_instance().delete()
... host.delete()

Represents a connection to a particular ComodIT server.
  __package__ = 'comodit_client.api'