Skip to content
Snippets Groups Projects
Commit 903a08e1 authored by Florent Thiery's avatar Florent Thiery
Browse files

add timeout to ssh test

parent 18b7bd6e
No related branches found
No related tags found
No related merge requests found
......@@ -11,11 +11,22 @@ import subprocess
import imp
from datetime import datetime
GREEN = '\033[92m'
RED = '\033[91m'
DEF = '\033[0m'
os.chdir(os.path.dirname(__file__))
def test_ssh(server):
status, out = subprocess.getstatusoutput('ssh -o StrictHostKeyChecking=no %s ls /tmp' % server)
return status == 0
def test_ssh(ip):
cmd = 'ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp' % ip
print('Connecting to MediaVault: %s' % cmd)
try:
subprocess.check_output(cmd, shell=True, timeout=2)
print('%sLogged in successfully%s' % (GREEN, DEF))
except subprocess.CalledProcessError:
print('%sFailed to login using SSH, run ssh-copy-id %s %s' % (RED, ip, DEF))
return False
return True
def test_last_backup_is_recent(server, client):
path = '/backup/%s/current' % client
......@@ -50,4 +61,5 @@ if os.path.isfile('../utils.py'):
else:
sys.exit(2)
else:
print('No BURP_SERVER defined in config, untestable')
sys.exit(2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment