24 lines
756 B
Python
24 lines
756 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
py_check = """
|
|
from awx.main.models import Job
|
|
job = Job.objects.get(id=134)
|
|
lines = job.result_stdout.split('\\n')
|
|
for i, l in enumerate(lines):
|
|
if 'failed:' in l.lower() or 'fatal:' in l.lower():
|
|
print('\\n'.join(lines[max(0, i-5):min(len(lines), i+15)]))
|
|
"""
|
|
|
|
cmd = f"kubectl exec -i -n awx -c awx-task deployment/awx-task -- awx-manage shell_plus --quiet << 'EOF'\n{py_check}\nEOF"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
print(stdout.read().decode())
|
|
ssh.close()
|
|
|