slap interface documentation

interface slapos.slap.interface.slap.IException

Classes which implement IException are used to report errors.

interface slapos.slap.interface.slap.INotFoundError

Extends: slapos.slap.interface.slap.IException

Classes which implement INotFoundError are used to report missing information on the slap server.

interface slapos.slap.interface.slap.IRequester

Classes which implement IRequester can request software instance to the slapgrid server.

getInformation(partition_reference)

Get information about an existing instance. If it is called from a Computer Partition, get information about Software Instance of the instance tree.

partition_reference – local reference of the instance used by the recipe
to identify the instances.
request(software_release, software_type, partition_reference, shared=False, partition_parameter_kw=None, filter_kw=None)

Request software release instantiation to slapgrid server.

Returns a new computer partition document, where this software release will be installed.

software_release – URI of the software release
which has to be instantiated

software_type – type of component provided by software_release

partition_reference – local reference of the instance used by the recipe
to identify the instances.

shared – boolean to use a shared service

partition_parameter_kw – dictionary of parameter used to fill the
parameter dictionary of newly created partition.
filter_kw – dictionary of filtering parameter to select the requested
computer partition.

computer_guid - computer of the requested partition partition_type - virtio, slave, full, limited port - port provided by the requested partition

Example:
request(’http://example.com/foo/bar’, ‘typeA’, ‘mysql_1’)
interface slapos.slap.interface.slap.ISoftwareRelease

Software release interface specification

available()

Notify (to the slapgrid server) that the software release is available.

building()

Notify (to the slapgrid server) that the software release is not available and under creation.

getState()

Returns a string representing the expected state of the software installation.

The result can be: available, destroyed

getURI()

Returns a string representing the URI of the software release.

getComputerId()

Returns a string representing the identifier of the computer where the SR is installed.

destroyed()

Notify (to the slapgrid server) that the software installation has been correctly destroyed.

error(error_log)

Notify (to the slapgrid server) that the software installation is not available and reports an error.

error_log – a text describing the error
It can be a traceback for example.
interface slapos.slap.interface.slap.IComputerPartition

Extends: slapos.slap.interface.slap.IRequester

Computer Partition interface specification

Classes which implement IComputerPartition can propagate the computer partition state to the SLAPGRID server and request new computer partition creation.

rename(partition_reference, slave_reference=None)

Change the partition reference of a partition

partition_reference – new local reference of the instance used by the recipe
to identify the instances.

slave_reference – current reference of the slave instance to modify

setComputerPartitionRelatedInstanceList(instance_reference_list)

Set relation between this Instance and all his children.

instance_reference_list – list of instances requested by this Computer
Partition.
getInstanceGuid()

Returns a string representing the unique identifier of the instance inside the slapgrid server.

getState()

Returns a string representing the expected state of the computer partition.

The result can be: started, stopped, destroyed

setUsage(usage_log)

Associate a usage log to the computer partition. This method does not report the usage to the slapgrid server. See IComputer.report.

usage_log – a text describing the computer partition usage.
It can be an XML for example.
error(error_log)

Notify (to the slapgrid server) that the software instance is not available and reports an error.

error_log – a text describing the error
It can be a traceback for example.
getInstanceParameterDict()

Returns a dictionary of instance parameters.

The contained values can be used to fill the software instantiation profile.

getStatus()

Returns a dictionary containing the latest status of the computer partition. The dictionary keys are:

user – user who reported the latest status created_at – date of the status text – message log of the status
getId()

Returns a string representing the identifier of the computer partition inside the slapgrid server.

destroyed()

Notify (to the slapgrid server) that the software instance has been correctly destroyed.

getAccessStatus()

Get latest computer partition Access message state

getConnectionParameterDict()

Returns a dictionary of connection parameters.

The contained values are connection parameters of a compute partition.

started()

Notify (to the slapgrid server) that the software instance is available and started.

getType()

Returns the Software Type of the instance.

getCertificate()

Returns a dictionary containing the authentication certificates associated to the computer partition. The dictionary keys are:

key – value is a SSL key certificate – value is a SSL certificate

Raise an INotFoundError if no software release is associated.

bang(log)

Report a problem detected on a computer partition. This will trigger the re-instantiation of all partitions in the instance tree.

log – a text explaining why the method was called

getInstanceParameter(key)

Returns the instance parameter associated to the key.

Raise an INotFoundError if no key is defined.

key – a string name of the parameter

setConnectionDict(connection_dict, slave_reference=None)

Store the connection parameters associated to a partition.

connection_dict – dictionary of parameter used to fill the
connection dictionary of the partition.

slave_reference – current reference of the slave instance to modify

getSoftwareRelease()

Returns the software release associate to the computer partition.

Raise an INotFoundError if no software release is associated.

stopped()

Notify (to the slapgrid server) that the software instance is available and stopped.

getConnectionParameter(key)

Return the connection parameter associate to the key.

Raise an INotFoundError if no key is defined.

key – a string name of the parameter

getFullHostingIpAddressList()

Returns a dictionary containing the latest status of the computer partition.

interface slapos.slap.interface.slap.IComputer

Computer interface specification

Classes which implement IComputer can fetch information from the slapgrid server to know which Software Releases and Software Instances have to be installed.

getInformation()

Get information about current computer. If it is called from a Computer, get information about itself.

updateConfiguration(configuration_xml)

Report the current computer configuration.

configuration_xml – computer XML description generated by slapformat

getStatus()

Returns a dictionary containing the latest status of the computer. The dictionary keys are:

user – user who reported the latest status created_at – date of the status text – message log of the status
reportUsage(computer_partition_list)

Report the computer usage to the slapgrid server. IComputerPartition.setUsage has to be called on each computer partition to define each usage.

computer_partition_list – a list of computer partition for which the usage
needs to be reported.
bang(log)

Report a problem detected on a computer. This will trigger IComputerPartition.bang on all instances hosted by the Computer.

log – a text explaining why the method was called

getSoftwareReleaseList()

Returns the list of software release which has to be supplied by the computer.

Raise an INotFoundError if computer_guid doesn’t exist.

generateCertificate()

Returns a dictionary containing the new certificate files for the computer. The dictionary keys are:

key – key file certificate – certificate file

Raise ValueError is another certificate is already valid.

revokeCertificate()

Revoke current computer certificate.

Raise ValueError is there is not valid certificate.

getComputerPartitionList()

Returns the list of configured computer partitions associated to this computer.

Raise an INotFoundError if computer_guid doesn’t exist.

interface slapos.slap.interface.slap.IOpenOrder

Extends: slapos.slap.interface.slap.IRequester

Open Order interface specification

Classes which implement Open Order describe which kind of software instances is requested by a given client.

requestComputer(computer_reference)

Request a computer to slapgrid server.

Returns a new computer document.

computer_reference – local reference of the computer

interface slapos.slap.interface.slap.ISupply

Supply interface specification

Classes which implement Supply describe which kind of software releases a given client is ready to supply.

supply(software_release, computer_guid=None)

Tell that given client is ready to supply given software release

software_release – URI of the software release
which has to be instantiated
computer_guid – the identifier of the computer inside the slapgrid
server.
interface slapos.slap.interface.slap.slap

Initialize slap connection to the slapgrid server

Slapgrid server URL is defined during the slap library installation, as recipes should not use another server.

initializeConnection(slapgrid_uri, authentification_key=None)

Initialize the connection parameters to the slapgrid servers.

slapgrid_uri – URI the slapgrid server connector

authentification_key – string the authenticate the agent. (Yes, there’s a typo in the argument name)

Example: https://slapos.server/slap_interface

registerSoftwareRelease(software_release)

Instantiate a software release in the slap library.

software_release – URI of the software release definition

registerToken()

Instantiate an token in the slap library.

registerSupply()

Instantiate a supply in the slap library.

getComputerDict()

Get the list of existing computer for the current user.

registerComputer(computer_guid)

Instantiate a computer in the slap library.

computer_guid – the identifier of the computer inside the slapgrid server.

registerComputerPartition(computer_guid, partition_id)

Instantiate a computer partition in the slap library.

computer_guid – the identifier of the computer inside the slapgrid server.

partition_id – the identifier of the computer partition inside the
slapgrid server.

Raise an INotFoundError if computer_guid doesn’t exist.

getOpenOrderDict()

Get the list of existing open orders (services) for the current user.

getSoftwareReleaseListFromSoftwareProduct(software_product_reference, software_release_url)

Get the list of Software Releases from a product or from another related Software Release, from a Software Product point of view.

registerOpenOrder()

Instantiate an open order in the slap library.