5. Saving state with client objects

Most of the time, your custom actions will probably want to pass around some sort of logged in session - whether it be ssh, ftp, etc. You’ll also want to be able to save more than one session.

5.1. The Clients object

The client object is defined in elsware.support.Clients, it allows you to save and retrieve session objects.

In any action, you can use this to save a session:

#create some sort of session
session_obj=SSHSession().login(user,ip,password) #simplified for example
#now save it
self.deployment.clients.set_client(servername,protocol,session_obj)

This allows you to save multiple sessions for the same protocol, when connected to different servers. In any other action, you can get that session object back to run operations with it like this:

session=self.deployment.clients.get_client(servername,protocol)

Table Of Contents

Previous topic

4. Writing Your Own Actions

Next topic

6. Acessing messages, exceptions, and tracebacks

This Page