cc_staff
32
edits
No edit summary |
No edit summary |
||
Line 82: | Line 82: | ||
{{Command|rsync -a datadir/a robot:scratch/testdata}} | {{Command|rsync -a datadir/a robot:scratch/testdata}} | ||
</translate> | </translate> | ||
= Automation using Python and Paramiko = | |||
If you are using the <code>paramiko</code> Python module to automate your workflow, this is how you can make it work with the robot nodes: | |||
<source lang=python> | |||
# ==================================================================================================== | |||
#! /usr/bin/env python3 | |||
# ==================================================================================================== | |||
import os | |||
import paramiko | |||
# ==================================================================================================== | |||
key = paramiko.Ed25519Key.from_private_key_file("/home/username/.ssh/cc_allowed") | |||
user = "username" | |||
host = "robot.graham.alliancecan.ca" | |||
ssh = paramiko.SSHClient() | |||
# If the host is not known, it is OK. | |||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |||
ssh.connect(hostname=host, username=user, pkey=key) | |||
cmd = "ls -l" | |||
stdin, stdout, stderr = ssh.exec_command(cmd) | |||
print("".join(stdout.readlines())) | |||
ssh.close() | |||
# ==================================================================================================== | |||
</source> | |||
This code connects to the robot node on '''Graham''' using an automation key specified in CCDB and | |||
executes the <code>ls -l</code> command to get the list of files. | |||
Then prints the list to the screen. |