Cluster Node
s¶
Cluster
s are made of Node
s.
The Node
interface is backend agnostic.
Node
s are generally used to run commands.
Node
s are either manually constructed in order to create a from_nodes()
, or they are retrieved from an existing Cluster
.
-
class
dcos_e2e.node.
Node
(public_ip_address, private_ip_address, default_ssh_user, ssh_key_path)¶ Parameters: - public_ip_address¶ – The public IP address of the node.
- private_ip_address¶ – The IP address used by the DC/OS component running on this node.
- default_ssh_user¶ – The default username to use for SSH connections.
- ssh_key_path¶ – The path to an SSH key which can be used to SSH to
the node as the
default_ssh_user
user.
-
public_ip_address
¶ The public IP address of the node.
-
private_ip_address
¶ The IP address used by the DC/OS component running on this node.
-
default_ssh_user
¶ The default username to use for SSH connections.
Running a Command on a Node¶
There are two methods used to run commands on Node
s.
run
and popen
are roughly equivalent to their subprocess
namesakes.
-
Node.
run
(args, user=None, log_output_live=False, env=None, shell=False, tty=False)¶ Run a command on this node the given user.
Parameters: - args¶ – The command to run on the node.
- user¶ – The username to SSH as. If
None
then thedefault_ssh_user
is used instead. - log_output_live¶ – If
True
, log output live. IfTrue
, stderr is merged into stdout in the return value. - env¶ – Environment variables to be set on the node before running the command. A mapping of environment variable names to values.
- shell¶ – If
False
(the default), each argument is passed as a literal value to the command. If True, the command line is interpreted as a shell command, with a special meaning applied to some characters (e.g. $, &&, >). This means the caller must quote arguments if they may contain these special characters, including whitespace. - tty¶ – If
True
, allocate a pseudo-tty. This means that the users terminal is attached to the streams of the process. This means that the values of stdout and stderr will not be in the returnedsubprocess.CompletedProcess
.
Return type: Returns: The representation of the finished process.
Raises: subprocess.CalledProcessError
– The process exited with a non-zero code.
-
Node.
popen
(args, user=None, env=None, shell=False)¶ Open a pipe to a command run on a node as the given user.
Parameters: - args¶ – The command to run on the node.
- user¶ – The user to open a pipe for a command for over SSH.
If None the
default_ssh_user
is used instead. - env¶ – Environment variables to be set on the node before running the command. A mapping of environment variable names to values.
- shell¶ – If False (the default), each argument is passed as a literal value to the command. If True, the command line is interpreted as a shell command, with a special meaning applied to some characters (e.g. $, &&, >). This means the caller must quote arguments if they may contain these special characters, including whitespace.
Return type: Returns: The pipe object attached to the specified process.