Prepare for fuel-devops 2.9.22 API changes

Use intermediate layers while test adoptation in process.
Mark as deprecated methods, which is completely covered by
devops implementation.

Change-Id: I4cb87cc1d5f7184cd5400a5f03358068e528d93a
This commit is contained in:
Alexey Stepanov 2016-07-31 20:25:05 +03:00
parent db27cd6407
commit 754b0230d9
4 changed files with 50 additions and 7 deletions

View File

@ -13,6 +13,7 @@
# under the License.
import random
from warnings import warn
from devops.error import TimeoutError
from devops.helpers import helpers
@ -354,6 +355,12 @@ class OpenStackActions(common.Common):
@staticmethod
def execute_through_host(ssh, vm_host, cmd, creds=()):
warn(
'execute_throw_host(ssh=SSHClient(), ...) is deprecated '
'in favor of '
'SSHClient().execute_through_host(hostname, cmd, auth, ...)',
DeprecationWarning
)
logger.debug("Making intermediate transport")
intermediate_transport = ssh._ssh.get_transport()

View File

@ -201,10 +201,19 @@ class SSHManager(object):
if yamlify and jsonify:
raise ValueError('Conflicting arguments: yamlify and jsonify!')
result = self.execute(ip=ip, port=port, cmd=cmd)
orig_result = self.execute(ip=ip, port=port, cmd=cmd)
result['stdout_str'] = ''.join(result['stdout']).strip()
result['stderr_str'] = ''.join(result['stderr']).strip()
# Now create fallback result
# TODO(astepanov): switch to SSHClient output after tests adoptation
# TODO(astepanov): process whole parameters on SSHClient().check_call()
result = {
'stdout': orig_result['stdout'],
'stderr': orig_result['stderr'],
'exit_code': orig_result['exit_code'],
'stdout_str': ''.join(orig_result['stdout']).strip(),
'stderr_str': ''.join(orig_result['stderr']).strip(),
}
details_log = (
"Host: {host}\n"

View File

@ -28,6 +28,7 @@ import signal
import string
import time
import traceback
from warnings import warn
import netaddr
from proboscis import asserts
@ -456,6 +457,13 @@ def cond_upload(remote, source, target, condition=''):
def run_on_remote(*args, **kwargs):
warn(
'This is old deprecated method, which should not be used anymore. '
'please use remote.execute() and remote.check_call() instead.\n'
'Starting from fuel-devops 2.9.22 this methods will return all '
'required data.',
DeprecationWarning
)
if 'jsonify' in kwargs:
if kwargs['jsonify']:
return run_on_remote_get_results(*args, **kwargs)['stdout_json']
@ -467,7 +475,6 @@ def run_on_remote(*args, **kwargs):
def run_on_remote_get_results(remote, cmd, clear=False, err_msg=None,
jsonify=False, assert_ec_equal=None,
raise_on_assert=True):
# TODO(ivankliuk): move it to devops.helpers.SSHClient
"""Execute ``cmd`` on ``remote`` and return result.
:param remote: devops.helpers.helpers.SSHClient
@ -479,12 +486,26 @@ def run_on_remote_get_results(remote, cmd, clear=False, err_msg=None,
:return: dict
:raise: Exception
"""
warn(
'run_on_remote_get_results() is deprecated in favor of '
'remote.check_call() \n'
'Starting from fuel-devops 2.9.22 this methods will return whole '
'required data.',
DeprecationWarning
)
if assert_ec_equal is None:
assert_ec_equal = [0]
result = remote.execute(cmd)
orig_result = remote.execute(cmd)
result['stdout_str'] = ''.join(result['stdout']).strip()
result['stderr_str'] = ''.join(result['stderr']).strip()
# now create fallback result for compatibility reasons (UTF-8)
result = {
'stdout': orig_result['stdout'],
'stderr': orig_result['stderr'],
'exit_code': orig_result['exit_code'],
'stdout_str': ''.join(orig_result['stdout']).strip(),
'stderr_str': ''.join(orig_result['stderr']).strip()
}
details_log = (
"Host: {host}\n"

View File

@ -15,6 +15,7 @@
import logging
import re
import time
from warnings import warn
from devops.helpers.helpers import tcp_ping_
from devops.helpers.helpers import wait_pass
@ -712,6 +713,11 @@ class EnvironmentModel(object):
@staticmethod
@logwrap
def execute_remote_cmd(remote, cmd, exit_code=0):
warn(
'execute_remote_cmd(remote, cmd) is deprecated in favor of '
'SSHClient().check_call()',
DeprecationWarning
)
result = remote.execute(cmd)
assert_equal(result['exit_code'], exit_code,
'Failed to execute "{0}" on remote host: {1}'.