moler.device package

Submodules

moler.device.abstract_device module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.abstract_device.AbstractDevice

Bases: object

add_neighbour_device(neighbour_device, bidirectional=True)

Adds neighbour device to this device.

Parameters:
  • neighbour_device – device object or string with device name.
  • bidirectional – If True then this device will be added to f_device.
Returns:

None

configure_logger(name, propagate)

Configures logger.

Parameters:
  • name – Name of logger
  • propagate – Set True if you want to propagate logs, False otherwise (recommended)
Returns:

None

current_state

Getter of current state.

Returns:String with the name of current state.
establish_connection()

Establishes connection to real device.

Returns:None
get_cmd(cmd_name, cmd_params=None, check_state=True, for_state=None)

Returns instance of command connected with the device.

Parameters:
  • cmd_name – name of commands, name of class (without package), for example “cd”.
  • cmd_params – dict with command parameters.
  • check_state – if True then before execute of command the state of device will be check if the same as when command was created. If False the device state is not checked.
  • for_state – if None then command object for current state is returned, otherwise object for for_state is returned.
Returns:

Instance of command

get_event(event_name, event_params=None, check_state=True, for_state=None)

Return instance of event connected with the device.

Parameters:
  • event_name – name of event, name of class (without package).
  • event_params – dict with event parameters.
  • check_state – if True then before execute of event the state of device will be check if the same as when event was created. If False the device state is not checked.
  • for_state – if None then event object for current state is returned, otherwise object for for_state is returned.
Returns:

Event object

get_neighbour_devices(device_type)

Returns list of neighbour devices of passed type.

Parameters:device_type – type of device. If None then all neighbour devices will be returned.
Returns:list of devices.
goto_state(state, timeout=-1, rerun=0, send_enter_after_changed_state=False, log_stacktrace_on_fail=True, keep_state=True)

Goes to state.

Parameters:
  • state – name of state to go.
  • timeout – Time in seconds when break transitions if still not success.
  • rerun – How many times try to rerun command(s) when device is still not in requested state.
  • send_enter_after_changed_state – Set True to send enter after enters proper state.
  • log_stacktrace_on_fail – Set True to log exceptions if command to enter state failed.
  • keep_state – if True and state is changed without goto_state then device tries to change state to state

defined by goto_state. :return: None

has_established_connection()

Checks if connection is established to real device.

Returns:True if connection is established, False otherwise.
name

Getter of device name.

Returns:String with the device name.
on_connection_lost(connection)

Method to call by Moler framework when connection is lost.

Parameters:connection – Connection object.
Returns:None
on_connection_made(connection)

Method to call by Moler framework when connection is established.

Parameters:connection – Connection object.
Returns:None
public_name

Getter for publicly used device name.

Internal name of device (.name attribute) may be modified by device itself in some circumstances (to not overwrite logs). However, public_name is guaranteed to be preserved as it was set by external/client code.

Returns:String with the device alias name.
register_device_removal_callback(callback)

Registers callable to be called (notified) when device is removed.

Parameters:callback – callable to call when device is being removed.
Returns:None
remove()

Closes device, if any command or event is attached to this device they will be finished.

Returns:None
run(cmd_name, **kwargs)

Wrapper for simple use command: creates command, runs it and waits till it ends.

Parameters:
  • cmd_name – name of class of command.
  • kwargs – dict with parameters for command constructor.
Returns:

object from command get_result (mainly dict).

start(cmd_name, **kwargs)

Wrapper for simple use command: creates command and runs it.

Parameters:
  • cmd_name – name of class of command.
  • kwargs – dict with parameters for command constructor.
Returns:

command object

moler.device.adbremote module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.adbremote.AdbRemote(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.unixremote.UnixRemote

AdbRemote device class.

Example of device in yaml configuration file: -without PROXY_PC:

ADB_1:

DEVICE_CLASS: moler.device.adbremote.AdbRemote CONNECTION_HOPS:

UNIX_LOCAL:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
UNIX_REMOTE:
ADB_SHELL:

execute_command: adb_shell # default value; default command is: adb shell command_params:

serial_number: ‘f57e6b7d’ # to create: adb -s f57e6b7d shell expected_prompt: ‘shell@adbhost: $’
ADB_SHELL:
UNIX_REMOTE:
execute_command: exit # default value
adb_shell = 'ADB_SHELL'
adb_shell_root = 'ADB_SHELL_ROOT'

moler.device.adbremote2 module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.adbremote2.AdbRemote2(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.unixremote2.UnixRemote2

AdbRemote device class.

Example of device in yaml configuration file:

  • with PROXY_PC and io “terminal”: ADB_1:

    DEVICE_CLASS: moler.device.adbremote2.AdbRemote2 CONNECTION_HOPS:

    UNIX_LOCAL:
    PROXY_PC:

    execute_command: ssh # default value command_params:

    expected_prompt: proxy_pc_prompt host: host_ip login: login password: password

    PROXY_PC:
    UNIX_REMOTE:

    execute_command: ssh # default value command_params:

    expected_prompt: unix_remote_prompt host: host_ip login: login password: password

    UNIX_REMOTE:
    ADB_SHELL:

    execute_command: adb_shell # default value command_params:

    serial_number: ‘f57e6b7d’

  • with PROXY_PC and remote-access-io like “sshshell”: ADB_1:

    DEVICE_CLASS: moler.device.adbremote2.AdbRemote2 CONNECTION_DESC:

    io_type: sshshell host: host_ip login: login password: password

    CONNECTION_HOPS:
    PROXY_PC:
    UNIX_REMOTE:

    execute_command: ssh # default value command_params:

    expected_prompt: unix_remote_prompt host: host_ip login: login password: password

    UNIX_REMOTE:
    ADB_SHELL:

    execute_command: adb_shell # default value command_params:

    serial_number: ‘f57e6b7d’

-without PROXY_PC and io “terminal”:
ADB_1:

DEVICE_CLASS: moler.device.adbremote2.AdbRemote2 CONNECTION_HOPS:

UNIX_LOCAL:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
UNIX_REMOTE:
ADB_SHELL:

execute_command: adb_shell # default value command_params:

serial_number: ‘f57e6b7d’
-without PROXY_PC and remote-access-io like “sshshell”:
ADB_1:

DEVICE_CLASS: moler.device.adbremote2.AdbRemote2 CONNECTION_DESC:

io_type: sshshell host: host_ip login: login password: password
CONNECTION_HOPS:
UNIX_REMOTE:
ADB_SHELL:

execute_command: adb_shell # default value command_params:

serial_number: ‘f57e6b7d’

moler.device.atremote module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.atremote.AtRemote(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.unixremote.UnixRemote

AtRemote device class.

Example of device in yaml configuration file: -without PROXY_PC:

AT_1:

DEVICE_CLASS: moler.device.atremote.AtRemote CONNECTION_HOPS:

UNIX_LOCAL:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
UNIX_REMOTE:
AT_REMOTE:

execute_command: plink_serial # default value command_params:

serial_devname: ‘COM5’
AT_REMOTE:
UNIX_REMOTE:
execute_command: ctrl_c # default value
at_remote = 'AT_REMOTE'

moler.device.device module

Package Open Source functionality of Moler.

class moler.device.device.DeviceFactory

Bases: object

classmethod create_all_devices(ignore_exception=False)

Creates all devices from config.

Parameters:ignore_exception – Set False to raise an exception when cannot create device. True to ignore and create other devices.
Returns:None
classmethod differences_between_devices_descriptions(already_device_name, requested_device_def)

Checks if two device description are the same.

Parameters:
  • already_device_name – Name of device already created by Moler
  • requested_device_def – Description od device provided to create. The name is the same as above.
Returns:

Empty string if descriptions are the same, if not the string with differences.

classmethod forget_device_handler(device_name)

Function to call to forget device.

Parameters:device_name – Name of device
Returns:None
classmethod get_cloned_device(source_device, new_name, initial_state=None, establish_connection=True, lazy_cmds_events=False, io_connection=None, additional_params=None)

Creates (if necessary) and returns new device based on existed device.

Parameters:
  • source_device – Reference to base device or name of base device.
  • new_name – Name of new device.
  • initial_state – Initial state of created device. If None then state of source device will be used.
  • establish_connection – True to open connection, False if it does not matter.
  • lazy_cmds_events – set False to load all commands and events when device is initialized, set True to load commands and events when they are required for the first time.
  • io_connection – connection for device. Ignored if device is already created.
  • additional_params – dict with parameter(s) specific for the device. Will be passed to the constructor. If no specific parameter then set to None.
Returns:

Device object.

classmethod get_device(name=None, device_class=None, connection_desc=None, connection_hops=None, initial_state=None, establish_connection=True, lazy_cmds_events=False, io_connection=None, additional_params=None)

Return connection instance of given io_type/variant.

Parameters:
  • name – name of device defined in configuration.
  • device_class – ‘moler.device.unixlocal.UnixLocal’, ‘moler.device.unixremote.UnixRemote’, …
  • connection_desc – ‘io_type’ and ‘variant’ of device connection. Ignored if device already created or argument io_connection is passed.
  • connection_hops – connection hops to create device SM.
  • initial_state – initial state for device e.g. UNIX_REMOTE.
  • establish_connection – True to open connection, False if it does not matter.
  • lazy_cmds_events – set False to load all commands and events when device is initialized, set True to load commands and events when they are required for the first time.
  • io_connection – connection for device. Ignored if device is already created.
  • additional_params – dict with parameter(s) specific for the device. Will be passed to the constructor. If no specific parameter then set to None.
Returns:

requested device.

classmethod get_devices_by_type(device_type)

Returns list of devices filtered by device_type.

Parameters:device_type – type of device. If None then return all devices.
Returns:List of devices. Can be an empty list.
classmethod remove_all_devices(clear_device_history=False)

Remove all created devices.

Parameters:clear_device_history – set True to clear the history of devices. Caution: you may overwrite your logs!
Returns:None
classmethod remove_device(name)

Removes device. All commands and events are being finished when device is removed.

Parameters:name – name of device..
Returns:None.
classmethod was_any_device_deleted()

Checks if any device was deleted. :return: True if any device was deleted, False otherwise

moler.device.juniper_ex module

JuniperEX module.

class moler.device.juniper_ex.JuniperEX(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.junipergeneric.JuniperGeneric

Juniperex device class.

Example of device in yaml configuration file: - with PROXY_PC:

JUNIPER_EX_PROXY_PC:

DEVICE_CLASS: moler.device.juniper_ex.JuniperEX CONNECTION_HOPS:

PROXY_PC:
CLI:

execute_command: ssh command_params:

host: cli_host login: cli_login password: password
UNIX_LOCAL:
PROXY_PC:

execute_command: ssh command_params:

expected_prompt: “proxy_pc#” host: proxy_pc_host login: proxy_pc_login password: password
CLI:
PROXY_PC:

execute_command: exit command_params:

expected_prompt: “proxy_pc#”
  • without PROXY_PC: JUNIPER_EX:

    DEVICE_CLASS: moler.device.juniper_ex.JuniperEX CONNECTION_HOPS:

    UNIX_LOCAL:
    CLI:

    execute_command: ssh # default value command_params:

    host: cli_host login: cli_login password: password

moler.device.junipergeneric module

Juniper Generic module.

class moler.device.junipergeneric.JuniperGeneric(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.proxy_pc.ProxyPc

Junipergeneric device class.

cli = 'CLI'
configure = 'CONFIGURE'

moler.device.pdu_aten module

PduAten device class.

class moler.device.pdu_aten.PduAten(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.proxy_pc.ProxyPc

PDU Aten device class.

Example of device in yaml configuration file: - with PROXY_PC:

PDU_1:

DEVICE_CLASS: moler.device.pdu_aten.PduAten CONNECTION_HOPS:

PROXY_PC:
PDU:

execute_command: telnet # default value command_params:

host: 10.0.0.1
PDU:
PROXY_PC:

execute_command: exit_telnet # default value command_params:

expected_prompt: proxy_pc.*>
UNIX_LOCAL:
PROXY_PC:

execute_command: ssh # default value command_params:

expected_prompt: proxy_pc.*> host: 10.0.0.2 login: user password: password
-without PROXY_PC:
PDU_1:

DEVICE_CLASS: moler.device.pdu_aten.PduAten CONNECTION_HOPS:

UNIX_LOCAL:
PDU:

execute_command: telnet # default value command_params:

host: 10.0.0.1
pdu = 'PDU'

moler.device.proxy_pc module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.proxy_pc.ProxyPc(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.unixlocal.UnixLocal

proxy_pc = 'PROXY_PC'

moler.device.proxy_pc2 module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.proxy_pc2.ProxyPc2(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.unixlocal.UnixLocal

goto_state(state, *args, **kwargs)

Goes to specific state.

on_connection_lost(connection)

Execute action when connection lost. :param connection: device connection. :return: Nothing.

on_connection_made(connection)

Execute action when connection made. :param connection: device connection. :return: Nothing.

moler.device.proxy_pc2.want_local_unix_state(io_type=None, io_connection=None)

Check if device is intended to work with local machine or remote ones only. :return: True for local.

moler.device.scpi module

SCPI device class

class moler.device.scpi.Scpi(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.proxy_pc.ProxyPc

Scpi device class.

Example of device in yaml configuration file: - with PROXY_PC:

SCPI_1: DEVICE_CLASS: moler.device.scpi.Scpi CONNECTION_HOPS:

PROXY_PC:
SCPI:

execute_command: telnet # default value command_params:

expected_prompt: SCPI> host: 10.0.0.1 port: 99999
SCPI:
PROXY_PC:

execute_command: exit_telnet # default value command_params:

expected_prompt: proxy_pc.*>
UNIX_LOCAL:
PROXY_PC:

execute_command: ssh # default value command_params:

expected_prompt: proxy_pc.*> host: 10.0.0.2 login: user password: password
-without PROXY_PC:
SCPI_1:

DEVICE_CLASS: moler.device.scpi.Scpi CONNECTION_HOPS:

UNIX_LOCAL:
SCPI:

execute_command: telnet # default value command_params:

expected_prompt: SCPI> host: 10.0.0.1 port: 99999
scpi = 'SCPI'

moler.device.state_machine module

class moler.device.state_machine.StateMachine(model='self', states=None, initial='initial', transitions=None, send_event=False, auto_transitions=True, ordered_transitions=False, ignore_invalid_triggers=None, before_state_change=None, after_state_change=None, name=None, queued=False, prepare_event=None, finalize_event=None, **kwargs)

Bases: transitions.core.Machine

set_state(state, model=None)

Sets state of StateMachine.

Parameters:
  • state – name of state to set.
  • model – model.
Returns:

None.

moler.device.textualdevice module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.textualdevice.TextualDevice(sm_params=None, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.abstract_device.AbstractDevice

add_neighbour_device(neighbour_device, bidirectional=True)

Adds neighbour device to this device.

Parameters:
  • neighbour_device – device object or string with device name.
  • bidirectional – If True then this device will be added to f_device.
Returns:

None

await_goto_state(timeout=10)

Waits till goto_state chain is empty. :param timeout: timeout in seconds. :return: None :raise DeviceChangeStateFailure: if the goto_state chain is not empty and timeout occurs.

build_trigger_to_state(state)
calc_timeout_for_command(passed_timeout, configurations)
cmds = 'cmd'
configure_logger(name, propagate)

Configures logger.

Parameters:
  • name – Name of logger
  • propagate – Set True if you want to propagate logs, False otherwise (recommended)
Returns:

None

connection_hops = 'CONNECTION_HOPS'
current_state

Getter of current state.

Returns:String with the name of current state.
disable_logging()

Disable logging incoming data. :return: None

enable_logging()

Enable logging incoming data. :return: None

establish_connection()

Establishes real connection to device. You have to call this method before device is full operable.

Returns:None
events = 'event'
exchange_io_connection(io_connection)
classmethod from_named_connection(connection_name)
get_cmd(cmd_name, cmd_params=None, check_state=True, for_state=None)

Returns instance of command connected with the device. :param cmd_name: name of commands, name of class (without package), for example “cd”. :param cmd_params: dict with command parameters. :param check_state: if True then before execute of command the state of device will be check if the same

as when command was created. If False the device state is not checked.
Parameters:for_state – if None then command object for current state is returned, otherwise object for for_state is returned.
Returns:Instance of command
get_configurations(source_state, dest_state)
get_event(event_name, event_params=None, check_state=True, for_state=None)

Return instance of event connected with the device. :param event_name: name of event, name of class (without package). :param event_params: dict with event parameters. :param check_state: if True then before execute of event the state of device will be check if the same

as when event was created. If False the device state is not checked.
Parameters:for_state – if None then event object for current state is returned, otherwise object for for_state is returned.
Returns:Event object
get_neighbour_devices(device_type)

Returns list of neighbour devices of passed type.

Parameters:device_type – type of device. If None then all neighbour devices will be returned.
Returns:list of devices.
get_observer(observer_name, observer_type, observer_exception, check_state=True, for_state=None, **kwargs)
get_prompt()
goto_state(state, timeout=-1, rerun=0, send_enter_after_changed_state=False, log_stacktrace_on_fail=True, keep_state=False, timeout_multiply=1.0)

Goes to specific state.

Parameters:
  • state – Name to state to change on the device.
  • timeout – Timeout for changing state, if negative then timeout from commands are taken.
  • rerun – How many times rerun the procedure before it fails.
  • send_enter_after_changed_state – If True then enter is sent after state is changed. False nothing is sent.
  • log_stacktrace_on_fail – Set True to have stacktrace in logs when failed, otherwise False.
  • keep_state – if True and state is changed without goto_state then device tries to change state to state

defined by goto_state. :param timeout_multiply: how many times multiply passed timeout to get final timeout. :return: None :raise: DeviceChangeStateFailure if cannot change the state of device.

goto_state_bg(state, keep_state=False)

Starts to go to state. Returns immediately. :param state: name of state. :param keep_state: if True and state is changed without goto_state then device tries to change state to state defined by goto_state. :return: None

has_established_connection()

Checks if connection is established to real device.

Returns:True if connection is established, False otherwise.
name

Getter of device name.

Returns:String with the device name.
not_connected = 'NOT_CONNECTED'
on_connection_lost(connection)

Method to call by Moler framework when connection is lost.

Parameters:connection – Connection object.
Returns:None
on_connection_made(connection)

Method to call by Moler framework when connection is established.

Parameters:connection – Connection object.
Returns:None
public_name

Getter for publicly used device name.

Internal name of device (.name attribute) may be modified by device itself in some circumstances (to not overwrite logs). However, public_name is guaranteed to be preserved as it was set by external/client code.

Returns:String with the device alias name.
remove()

Closes device, if any command or event is attached to this device they will be finished.

Returns:None
run(cmd_name, **kwargs)

Wrapper for simple use:

return ux.run(‘cd’, path=”/home/user/”)

Command/observer object is created locally

set_all_prompts_on_line(value=True)

Set True to check all prompts on line. False to interrupt after 1st prompt (default). :param value: True to check all prompts on line. False to interrupt after 1st prompt (default). :return: None

set_logging_suffix(suffix)

Set logging suffix. :param suffix: Suffix for device log. Use None for no suffix. :return: None

start(cmd_name, **kwargs)

Wrapper for simple use:

localhost_ping = ux.start(‘ping’, destination=”localhost”, options=”-c 5”) … result = localhost_ping.await_done()

result = await localhost_ping # py3 notation

Command/observer object is created locally

moler.device.unixlocal module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.unixlocal.UnixLocal(sm_params=None, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.textualdevice.TextualDevice

UnixLocal device class.

Example of device in yaml configuration file: UNIX_1:

DEVICE_CLASS: moler.device.unixlocal.UnixLocal
UNIX_2:

DEVICE_CLASS: moler.device.unixlocal.UnixLocal ‘CONNECTION_HOPS’: {

‘UNIX_LOCAL’: {
‘UNIX_LOCAL_ROOT’: {
“command_params”: {
“password”: “root_password”, “expected_prompt”: r’local_root_prompt’,

}

}

}

}

on_connection_lost(connection)

Execute action when connection lost. :param connection: device connection. :return: None.

on_connection_made(connection)

Execute action when connection made. :param connection: device connection. :return: None.

unix_local = 'UNIX_LOCAL'
unix_local_root = 'UNIX_LOCAL_ROOT'

moler.device.unixremote module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.unixremote.UnixRemote(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.proxy_pc.ProxyPc

UnixRemote device class.

Example of device in yaml configuration file: - with PROXY_PC:

UNIX_1:

DEVICE_CLASS: moler.device.unixremote.UnixRemote CONNECTION_HOPS:

PROXY_PC:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
UNIX_REMOTE:
PROXY_PC:

execute_command: exit # default value command_params:

expected_prompt: proxy_pc_prompt
UNIX_LOCAL:
PROXY_PC:

execute_command: ssh # default value command_params:

expected_prompt: proxy_pc_prompt host: host_ip login: login password: password
-without PROXY_PC:
UNIX_1:

DEVICE_CLASS: moler.device.unixremote.UnixRemote CONNECTION_HOPS:

UNIX_LOCAL:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
unix_remote = 'UNIX_REMOTE'
unix_remote_root = 'UNIX_REMOTE_ROOT'

moler.device.unixremote2 module

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state

class moler.device.unixremote2.UnixRemote2(sm_params, name=None, io_connection=None, io_type=None, variant=None, io_constructor_kwargs=None, initial_state=None, lazy_cmds_events=False)

Bases: moler.device.proxy_pc2.ProxyPc2

UnixRemote2 device class.

Example of device in yaml configuration file: - with PROXY_PC and io “terminal”:

UNIX_1:

DEVICE_CLASS: moler.device.unixremote2.UnixRemote2 CONNECTION_HOPS:

UNIX_LOCAL:
PROXY_PC:

execute_command: ssh # default value command_params:

expected_prompt: proxy_pc_prompt host: host_ip login: login password: password
PROXY_PC:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
  • with PROXY_PC and remote-access-io like “sshshell”: UNIX_1:

    DEVICE_CLASS: moler.device.unixremote2.UnixRemote2 CONNECTION_DESC:

    io_type: sshshell host: host_ip login: login password: password

    CONNECTION_HOPS:
    PROXY_PC:
    UNIX_REMOTE:

    execute_command: ssh # default value command_params:

    expected_prompt: unix_remote_prompt host: host_ip login: login password: password

-without PROXY_PC and io “terminal”:
UNIX_1:

DEVICE_CLASS: moler.device.unixremote2.UnixRemote2 CONNECTION_HOPS:

UNIX_LOCAL:
UNIX_REMOTE:

execute_command: ssh # default value command_params:

expected_prompt: unix_remote_prompt host: host_ip login: login password: password
-without PROXY_PC and remote-access-io like “sshshell”:
UNIX_1:

DEVICE_CLASS: moler.device.unixremote2.UnixRemote2 CONNECTION_DESC:

io_type: sshshell host: host_ip login: login password: password

(no need for CONNECTION_HOPS since we jump directly from NOT_CONNECTED to UNIX_REMOTE using sshshell)

on_connection_made(connection)

Execute action when connection made. :param connection: device connection. :return: Nothing.

Module contents

Moler’s device has 2 main responsibilities: - be the factory that returns commands of that device - be the state machine that controls which commands may run in given state