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_user, ssh_key_path, default_transport=<Transport.SSH: 1>)¶ Parameters: - public_ip_address (
IPv4Address
) – The public IP address of the node. - private_ip_address (
IPv4Address
) – The IP address used by the DC/OS component running on this node. - default_user (
str
) – The default username to use for connections. - ssh_key_path (
Path
) – The path to an SSH key which can be used to SSH to the node as thedefault_user
user. - default_transport (
Transport
) – The transport to use for communicating with nodes.
-
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_user
¶ The default username to use for connections.
-
default_transport
¶ The transport used to communicate with the node.
- public_ip_address (
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, transport=None)¶ Run a command on this node the given user.
Parameters: - args (
List
[str
]) – The command to run on the node. - user (
Optional
[str
]) – The username to communicate as. IfNone
then thedefault_user
is used instead. - log_output_live (
bool
) – IfTrue
, log output live. IfTrue
, stderr is merged into stdout in the return value. - env (
Optional
[Dict
[str
,Any
]]) – Environment variables to be set on the node before running the command. A mapping of environment variable names to values. - shell (
bool
) – IfFalse
(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 (
bool
) – IfTrue
, 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
. - transport (
Optional
[Transport
]) – The transport to use for communicating with nodes. IfNone
, theNode
’sdefault_transport
is used.
Return type: Returns: The representation of the finished process.
Raises: subprocess.CalledProcessError
– The process exited with a non-zero code.ValueError
–log_output_live
andtty
are both set toTrue
.
- args (
-
Node.
popen
(args, user=None, env=None, shell=False, transport=None)¶ Open a pipe to a command run on a node as the given user.
Parameters: - args (
List
[str
]) – The command to run on the node. - user (
Optional
[str
]) – The user to open a pipe for a command for over. If None thedefault_user
is used instead. - env (
Optional
[Dict
[str
,Any
]]) – Environment variables to be set on the node before running the command. A mapping of environment variable names to values. - shell (
bool
) – 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. - transport (
Optional
[Transport
]) – The transport to use for communicating with nodes. IfNone
, theNode
’sdefault_transport
is used.
Return type: Returns: The pipe object attached to the specified process.
- args (
Sending a File to a Node¶
-
Node.
send_file
(local_path, remote_path, user=None, transport=None)¶ Copy a file to this node.
Parameters: - local_path (
Path
) – The path on the host of the file to send. - remote_path (
Path
) – The path on the node to place the file. - user (
Optional
[str
]) – The name of the remote user to send the file. IfNone
, thedefault_user
is used instead. - transport (
Optional
[Transport
]) – The transport to use for communicating with nodes. IfNone
, theNode
’sdefault_transport
is used.
Return type: None
- local_path (