Drop heslpers as announced previously

1. Drop empty fuelweb_test/helpers/exceptions.py
2. Drop unused anymore fuelweb_test/helpers/http.py
3. Drop execute_throw_remote, run_in_remote, run_on_remote_get_results,
execute_remote_cmd.
4. Drop unused private deserializers from SSHManager
5. Fix misprint in deprecation message

Change-Id: I56a220e49f44a4f22b2b3499acf022fef923b323
This commit is contained in:
Alexey Stepanov 2016-09-01 08:14:22 +03:00
parent ebd7594294
commit fee216eb0d
10 changed files with 2 additions and 310 deletions

View File

@ -1,21 +0,0 @@
from __future__ import absolute_import
import unittest
# pylint: disable=import-error
from mock import call
from mock import patch
# pylint: enable=import-error
from core.helpers.http import HTTPClientZabbix
@patch('core.helpers.http.request')
class TestHTTPClientZabbix(unittest.TestCase):
def test_init(self, req):
url = 'http://localhost'
client = HTTPClientZabbix(url=url)
self.assertEqual(client.url, url)
req.assert_has_calls((
call.build_opener(req.HTTPHandler),
))

View File

@ -1,50 +0,0 @@
# Copyright 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
from warnings import warn
# pylint: disable=import-error
# noinspection PyUnresolvedReferences
from six.moves.urllib import request
# pylint: enable=import-error
class HTTPClientZabbix(object):
"""HTTPClientZabbix.""" # TODO documentation
def __init__(self, url):
warn(
'HTTPClientZabbix is deprecated and not used now. '
'It will be dropped in short term period.',
DeprecationWarning
)
self.url = url
self.opener = request.build_opener(request.HTTPHandler)
def get(self, endpoint=None, cookie=None):
req = request.Request(self.url + endpoint)
if cookie:
req.add_header('cookie', cookie)
return self.opener.open(req)
def post(self, endpoint=None, data=None, content_type="text/css",
cookie=None):
if not data:
data = {}
req = request.Request(self.url + endpoint, data=json.dumps(data))
req.add_header('Content-Type', content_type)
if cookie:
req.add_header('cookie', cookie)
return self.opener.open(req)

View File

@ -46,11 +46,6 @@ Eb tables
.. automodule:: fuelweb_test.helpers.eb_tables .. automodule:: fuelweb_test.helpers.eb_tables
:members: :members:
Exceptions
----------
.. automodule:: fuelweb_test.helpers.exceptions
:members:
Fuel Actions Fuel Actions
------------ ------------
.. automodule:: fuelweb_test.helpers.fuel_actions .. automodule:: fuelweb_test.helpers.fuel_actions
@ -66,11 +61,6 @@ Granular Deployment Checkers
.. automodule:: fuelweb_test.helpers.granular_deployment_checkers .. automodule:: fuelweb_test.helpers.granular_deployment_checkers
:members: :members:
Http
----
.. automodule:: fuelweb_test.helpers.http
:members:
Ironic Actions Ironic Actions
-------------- --------------
.. automodule:: fuelweb_test.helpers.ironic_actions .. automodule:: fuelweb_test.helpers.ironic_actions

View File

@ -1,13 +0,0 @@
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -1,32 +0,0 @@
# Copyright 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
from traceback import print_stack
from warnings import warn
from fuelweb_test import logger
from core.helpers.http import HTTPClientZabbix
msg = (
'fuelweb_test.helpers.http is deprecated and will be dropped '
'on 14.09.2016. Please use core.models.collector_client instead'
)
warn(msg)
print_stack()
logger.critical(msg)
__all__ = ['HTTPClientZabbix']

View File

@ -15,7 +15,7 @@
from warnings import warn from warnings import warn
warn( warn(
'fuelweb_test.helpers.metaclasses.SingletonMeta is deprected:' 'fuelweb_test.helpers.metaclasses.SingletonMeta is deprecated:'
'class is moved to devops.helpers.metaclasses.\n' 'class is moved to devops.helpers.metaclasses.\n'
'Due to it was single metaclass in file, this file will be deleted in a' 'Due to it was single metaclass in file, this file will be deleted in a'
'short time!', 'short time!',

View File

@ -13,17 +13,13 @@
# under the License. # under the License.
import random import random
import traceback
from warnings import warn
from devops.error import TimeoutError from devops.error import TimeoutError
from devops.helpers import helpers from devops.helpers import helpers
from devops.helpers.ssh_client import SSHAuth
from proboscis import asserts from proboscis import asserts
from fuelweb_test import logger from fuelweb_test import logger
from fuelweb_test.helpers import common from fuelweb_test.helpers import common
from fuelweb_test.settings import SSH_IMAGE_CREDENTIALS
class OpenStackActions(common.Common): class OpenStackActions(common.Common):
@ -360,38 +356,6 @@ class OpenStackActions(common.Common):
if host.host_name != srv_host_name and if host.host_name != srv_host_name and
host._info['service'] == 'compute'] host._info['service'] == 'compute']
def get_md5sum(self, file_path, controller_ssh, vm_ip, creds=()):
warn(
'get_md5sum is deprecated due to legacy API usage',
DeprecationWarning)
logger.info("Get file md5sum and compare it with previous one")
out = self.execute_through_host(
controller_ssh, vm_ip, "md5sum {:s}".format(file_path), creds)
return out['stdout']
@staticmethod
def execute_through_host(ssh, vm_host, cmd, creds=()):
msg = (
'execute_throw_host(ssh=SSHClient(), ...) is deprecated '
'in favor of '
'SSHClient().execute_through_host(hostname, cmd, auth, ...).\n'
'{}'.format("".join(traceback.format_stack())))
warn(msg, DeprecationWarning)
logger.warning(msg)
logger.critical(
'This method could be deleted on 01.09.2016 '
'without any announcement!')
if not creds:
creds = (
SSH_IMAGE_CREDENTIALS['username'],
SSH_IMAGE_CREDENTIALS['password']
)
return ssh.execute_through_host(
hostname=vm_host,
cmd=cmd,
auth=SSHAuth(*creds)
)
def get_tenant(self, tenant_name): def get_tenant(self, tenant_name):
tenant_list = self.keystone.tenants.list() tenant_list = self.keystone.tenants.list()
for ten in tenant_list: for ten in tenant_list:

View File

@ -17,7 +17,6 @@
from distutils.version import StrictVersion from distutils.version import StrictVersion
# pylint: enable=no-name-in-module # pylint: enable=no-name-in-module
# pylint: enable=import-error # pylint: enable=import-error
import json
import os import os
import posixpath import posixpath
import re import re
@ -31,7 +30,6 @@ from devops.helpers.ssh_client import SSHClient
from paramiko import RSAKey from paramiko import RSAKey
from paramiko.ssh_exception import AuthenticationException from paramiko.ssh_exception import AuthenticationException
import six import six
import yaml
from fuelweb_test import logger from fuelweb_test import logger
from fuelweb_test.settings import SSH_FUEL_CREDENTIALS from fuelweb_test.settings import SSH_FUEL_CREDENTIALS
@ -298,7 +296,7 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
'SSHManager().execute_on_remote is deprecated in favor of ' 'SSHManager().execute_on_remote is deprecated in favor of '
'SSHManager().check_call.\n' 'SSHManager().check_call.\n'
'Please, do not use this method in any new tests. ' 'Please, do not use this method in any new tests. '
'Old code will be updated later.' 'Old code will be updated later.', DeprecationWarning
) )
if assert_ec_equal is None: if assert_ec_equal is None:
assert_ec_equal = [0] assert_ec_equal = [0]
@ -339,54 +337,6 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
with remote.sudo(enforce=sudo): with remote.sudo(enforce=sudo):
return remote.execute_async(cmd) return remote.execute_async(cmd)
@staticmethod
def _json_deserialize(json_string):
""" Deserialize json_string and return object
:param json_string: string or list with json
:return: obj
:raise: Exception
"""
warn(
'_json_deserialize is not used anymore and will be removed later',
DeprecationWarning)
if isinstance(json_string, list):
json_string = ''.join(json_string).strip()
try:
obj = json.loads(json_string)
except Exception:
logger.error(
"Unable to deserialize. Actual string:\n"
"{}".format(json_string))
raise
return obj
@staticmethod
def _yaml_deserialize(yaml_string):
""" Deserialize yaml_string and return object
:param yaml_string: string or list with yaml
:return: obj
:raise: Exception
"""
warn(
'_yaml_deserialize is not used anymore and will be removed later',
DeprecationWarning)
if isinstance(yaml_string, list):
yaml_string = ''.join(yaml_string).strip()
try:
obj = yaml.safe_load(yaml_string)
except Exception:
logger.error(
"Unable to deserialize. Actual string:\n"
"{}".format(yaml_string))
raise
return obj
def open_on_remote(self, ip, path, mode='r', port=22): def open_on_remote(self, ip, path, mode='r', port=22):
remote = self.get_remote(ip=ip, port=port) remote = self.get_remote(ip=ip, port=port)
return remote.open(path, mode) return remote.open(path, mode)

View File

@ -471,79 +471,6 @@ def cond_upload(remote, source, target, condition=''):
return files_count return files_count
def run_on_remote(*args, **kwargs):
msg = (
'run_on_remote() is old deprecated method, '
'which should not be used anymore. '
'please use remote.check_call() instead.\n'
'Starting from fuel-devops 2.9.22 this methods will return all '
'required data.\n'
'{}'.format("".join(traceback.format_stack())))
warn(msg, DeprecationWarning)
logger.warning(msg)
logger.critical(
'This method could be deleted on 01.09.2016 without any announcement!')
if 'jsonify' in kwargs:
if kwargs['jsonify']:
return run_on_remote_get_results(*args, **kwargs)['stdout_json']
else:
return run_on_remote_get_results(*args, **kwargs)['stdout']
@logwrap
def run_on_remote_get_results(remote, cmd, clear=False, err_msg=None,
jsonify=False, assert_ec_equal=None,
raise_on_assert=True):
"""Execute ``cmd`` on ``remote`` and return result.
:param remote: devops.helpers.helpers.SSHClient
:param cmd: command to execute on remote host
:param clear: clear SSH session
:param err_msg: custom error message
:param assert_ec_equal: list of expected exit_code
:param raise_on_assert: Boolean
:return: dict
:raise: Exception
"""
msg = (
'run_on_remote_get_results() is old deprecated method, '
'which should not be used anymore. '
'please use remote.check_call() instead.\n'
'Starting from fuel-devops 2.9.22 this methods will return all '
'required data.\n'
'{}'.format("".join(traceback.format_stack())))
warn(msg, DeprecationWarning)
logger.warning(msg)
logger.critical(
'This method could be deleted on 01.09.2016 without any announcement!')
if assert_ec_equal is None:
assert_ec_equal = [0]
orig_result = remote.check_call(
command=cmd,
error_info=err_msg,
expected=assert_ec_equal,
raise_on_err=raise_on_assert
)
# 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()
}
if clear:
remote.clear()
if jsonify:
result['stdout_json'] = orig_result.stdout_json
return result
def json_deserialize(json_string): def json_deserialize(json_string):
""" """
Deserialize json_string and return object Deserialize json_string and return object

View File

@ -15,8 +15,6 @@
import logging import logging
import re import re
import time import time
import traceback
from warnings import warn
from devops.helpers.helpers import tcp_ping_ from devops.helpers.helpers import tcp_ping_
from devops.helpers.helpers import wait_pass from devops.helpers.helpers import wait_pass
@ -713,27 +711,6 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)):
.format(echo_cmd, echo_result['stderr'])) .format(echo_cmd, echo_result['stderr']))
return resolv_conf['stdout'] return resolv_conf['stdout']
@staticmethod
@logwrap
def execute_remote_cmd(remote, cmd, exit_code=0):
msg = (
'execute_remote_cmd() is old deprecated method, '
'which should not be used anymore. '
'please use remote.check_call() instead.\n'
'Starting from fuel-devops 2.9.22 this methods will return all '
'required data.\n'
'{}'.format("".join(traceback.format_stack())))
warn(msg, DeprecationWarning)
logger.warning(msg)
logger.critical(
'This method could be deleted on 01.09.2016 '
'without any announcement!')
result = remote.check_call(
command=cmd,
expected=[exit_code],
)
return result['stdout']
@logwrap @logwrap
def describe_other_admin_interfaces(self, admin): def describe_other_admin_interfaces(self, admin):
admin_networks = [iface.network.name for iface in admin.interfaces] admin_networks = [iface.network.name for iface in admin.interfaces]