ui_tests: add function to run cmd on UI host

Run shell command on the UI system using "admin"
user's passwd from conf.

https://pagure.io/freeipa/issue/7441

Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Michal Reznik
2018-03-24 14:23:47 +01:00
committed by Christian Heimes
parent 95de6f061c
commit 18e8c964f5
+28
View File
@@ -30,6 +30,7 @@ import re
import os
from functools import wraps
import unittest
import paramiko
# pylint: disable=import-error
from six.moves.urllib.error import URLError
@@ -1643,6 +1644,33 @@ class UI_driver(object):
self.find(ssh_pub, By.CSS_SELECTOR).click()
self.facet_button_click('save')
def run_cmd_on_ui_host(self, cmd):
"""
Run "shell" command on the UI system using "admin" user's passwd from
conf.
Use only where API does not fit.
cmd (str): command to run
"""
login = self.config.get('ipa_admin')
hostname = self.config.get('ipa_server')
password = self.config.get('ipa_password')
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=hostname, username=login, password=password)
ssh.exec_command(cmd)
except paramiko.AuthenticationException:
self.skip('Authentication to server {} failed'.format(hostname))
except paramiko.SSHException as e:
self.skip('Unable to establish SSH connection: {}'.format(e))
except Exception as e:
self.skip('Unable to proceed: {}'.format(e))
finally:
ssh.close()
def has_class(self, el, cls):
"""
Check if el has CSS class