server operations¶
- class reemote.operations.server.script.Script(text: str = None, guard: bool = True, sudo: bool = False, su: bool = False)[source]¶
Bases:
objectA class to encapsulate the functionality of shell scripts in Unix-like operating systems. It allows users to specify a shell script that is executed on all hosts. additional command-line options, and the ability to execute the command with elevated privileges (sudo).
- text¶
The shell script.
- Type:
str
- guard¶
If False the commands will not be executed.
- Type:
bool
- sudo¶
If True, the commands will be executed with sudo privileges.
- Type:
bool
- su¶
If True, the commands will be executed with su privileges.
- Type:
bool
Examples:
from reemote.operations.server.script import Script # Execute a shell command on all hosts yield Script(text="echo Hello World") # The result is available in stdout print(r.cp.stdout)
- Usage:
This class is designed to be used in a generator-based workflow where commands are yielded for execution.
Notes
Commands are constructed based on the sudo, and su flags.
- class reemote.operations.server.callback.Callback(host: str = None, callback: Callable = None, guard: bool = True)[source]¶
Bases:
objectA class to encapsulate the functionality of python callbacks. It allows users to specify an asynch callable function that is executed for all hosts. additional command-line options, and the ability to execute the command with elevated privileges (sudo).
- guard¶
If False the commands will not be executed.
- Type:
bool
Examples:
async def callable_function(host_info, global_info, command, cp, caller): if host_info["host"] == caller.host: print(f"callback called for host {caller.host}") class Demonstrate_callback: def execute(self): from reemote.operations.server.callback import Callback from reemote.operations.server.shell import Shell r = yield Shell("echo 'Hello World!'") print(r.cp.stdout) yield Callback(host="10.156.135.16", callback=callable_function)
- Usage:
This class is designed to be used in a generator-based workflow where commands are yielded for execution.
Notes
Commands are constructed based on the sudo, and su flags.
- class reemote.operations.server.shell.Shell(cmd: str, guard: bool = True, sudo: bool = False, su: bool = False)[source]¶
Bases:
objectA class to encapsulate the functionality of shell commands in Unix-like operating systems. It allows users to specify a shell command that is executed on all hosts. additional command-line options, and the ability to execute the command with elevated privileges (sudo).
- cmd¶
The shell command.
- Type:
str
- guard¶
If False the commands will not be executed.
- Type:
bool
- sudo¶
If True, the commands will be executed with sudo privileges.
- Type:
bool
- su¶
If True, the commands will be executed with su privileges.
- Type:
bool
Examples:
# Execute a shell command on all hosts r = yield Shell("echo Hello World") # The result is available in stdout print(r.cp.stdout)
- Usage:
This class is designed to be used in a generator-based workflow where commands are yielded for execution.
Notes
Commands are constructed based on the sudo, and su flags.