5. Workspace instances

Classes presented in this section have methods for working with instances. They are built on the rerobots API, but some methods do not correspond directly to rerobots API calls. In practice, Instance will provide everything needed for working with a single workspace instance, without need for raw calls from API client objects.

5.1. Example

import rerobots

inst = rerobots.Instance(['fixed_misty2'])
print(inst.get_status())

5.2. Instance class

class rerobots.Instance(workspace_types=None, wdeployment_id=None, instance_id=None, api_token=None, headers=None, apic=None)

client for a workspace instance

At least one of workspace_types or wdeployment_id must be given. If both are provided (not None), consistency is checked: the type of the workspace deployment of the given identifier is compared with the given type. If they differ, no instance is created, and ValueError is raised.

If instance_id is given, then attempt to attach this class to an existing instance. In this case, neither workspace_types or wdeployment_id is required. If they are provided, then consistency is checked.

The optional parameter apic is an instance of APIClient. If it is not given, then an APIClient object is instantiated internally from the parameters api_token etc., corresponding to parameters APIClient of the same name.

exec_ssh(command, timeout=None, get_files=False)

Execute command via SSH.

https://docs.paramiko.org/en/2.4/api/client.html#paramiko.client.SSHClient.exec_command

If get_files=True, then return files of stdin, stdout, and stderr.

get_file(remotepath, localpath)

Get file from remote host.

For the general case, the underlying Paramiko SFTP object is available from sftp_client().

put_file(localpath, remotepath)

Put local file onto remote host.

For the general case, the underlying Paramiko SFTP object is available from sftp_client().

sftp_client()

Get Paramiko SFTP client.

Note that methods put_file() and get_file() are small wrappers to put() and get() of this Paramiko class.

Read about it at https://docs.paramiko.org/en/2.4/api/sftp.html

start_sshclient()

Create SSH client to instance.

This method is a prerequisite to exec_ssh(), which executes remote terminal commands.