diff --git a/core/_tests/helpers/test_http.py b/core/_tests/helpers/test_http.py deleted file mode 100644 index e899dcb76..000000000 --- a/core/_tests/helpers/test_http.py +++ /dev/null @@ -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), - )) diff --git a/core/helpers/http.py b/core/helpers/http.py deleted file mode 100644 index 0b5dc47cb..000000000 --- a/core/helpers/http.py +++ /dev/null @@ -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) diff --git a/doc/helpers.rst b/doc/helpers.rst index 0617e70d7..75714924d 100644 --- a/doc/helpers.rst +++ b/doc/helpers.rst @@ -46,11 +46,6 @@ Eb tables .. automodule:: fuelweb_test.helpers.eb_tables :members: -Exceptions ----------- -.. automodule:: fuelweb_test.helpers.exceptions - :members: - Fuel Actions ------------ .. automodule:: fuelweb_test.helpers.fuel_actions @@ -66,11 +61,6 @@ Granular Deployment Checkers .. automodule:: fuelweb_test.helpers.granular_deployment_checkers :members: -Http ----- -.. automodule:: fuelweb_test.helpers.http - :members: - Ironic Actions -------------- .. automodule:: fuelweb_test.helpers.ironic_actions diff --git a/fuelweb_test/helpers/exceptions.py b/fuelweb_test/helpers/exceptions.py deleted file mode 100644 index ebb074b25..000000000 --- a/fuelweb_test/helpers/exceptions.py +++ /dev/null @@ -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. diff --git a/fuelweb_test/helpers/http.py b/fuelweb_test/helpers/http.py deleted file mode 100644 index 08dfb8bb1..000000000 --- a/fuelweb_test/helpers/http.py +++ /dev/null @@ -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'] diff --git a/fuelweb_test/helpers/metaclasses.py b/fuelweb_test/helpers/metaclasses.py index f84787bb3..11adcb46a 100644 --- a/fuelweb_test/helpers/metaclasses.py +++ b/fuelweb_test/helpers/metaclasses.py @@ -15,7 +15,7 @@ from warnings import warn warn( - 'fuelweb_test.helpers.metaclasses.SingletonMeta is deprected:' + 'fuelweb_test.helpers.metaclasses.SingletonMeta is deprecated:' 'class is moved to devops.helpers.metaclasses.\n' 'Due to it was single metaclass in file, this file will be deleted in a' 'short time!', diff --git a/fuelweb_test/helpers/os_actions.py b/fuelweb_test/helpers/os_actions.py index 7a02e7bc6..b2f395203 100644 --- a/fuelweb_test/helpers/os_actions.py +++ b/fuelweb_test/helpers/os_actions.py @@ -13,17 +13,13 @@ # under the License. import random -import traceback -from warnings import warn from devops.error import TimeoutError from devops.helpers import helpers -from devops.helpers.ssh_client import SSHAuth from proboscis import asserts from fuelweb_test import logger from fuelweb_test.helpers import common -from fuelweb_test.settings import SSH_IMAGE_CREDENTIALS class OpenStackActions(common.Common): @@ -360,38 +356,6 @@ class OpenStackActions(common.Common): if host.host_name != srv_host_name and 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): tenant_list = self.keystone.tenants.list() for ten in tenant_list: diff --git a/fuelweb_test/helpers/ssh_manager.py b/fuelweb_test/helpers/ssh_manager.py index ef2e73a41..8cdec080d 100644 --- a/fuelweb_test/helpers/ssh_manager.py +++ b/fuelweb_test/helpers/ssh_manager.py @@ -17,7 +17,6 @@ from distutils.version import StrictVersion # pylint: enable=no-name-in-module # pylint: enable=import-error -import json import os import posixpath import re @@ -31,7 +30,6 @@ from devops.helpers.ssh_client import SSHClient from paramiko import RSAKey from paramiko.ssh_exception import AuthenticationException import six -import yaml from fuelweb_test import logger 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().check_call.\n' '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: assert_ec_equal = [0] @@ -339,54 +337,6 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)): with remote.sudo(enforce=sudo): 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): remote = self.get_remote(ip=ip, port=port) return remote.open(path, mode) diff --git a/fuelweb_test/helpers/utils.py b/fuelweb_test/helpers/utils.py index 77a558254..a91e41f34 100644 --- a/fuelweb_test/helpers/utils.py +++ b/fuelweb_test/helpers/utils.py @@ -471,79 +471,6 @@ def cond_upload(remote, source, target, condition=''): 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): """ Deserialize json_string and return object diff --git a/fuelweb_test/models/environment.py b/fuelweb_test/models/environment.py index 84360e11f..250a1cd56 100644 --- a/fuelweb_test/models/environment.py +++ b/fuelweb_test/models/environment.py @@ -15,8 +15,6 @@ import logging import re import time -import traceback -from warnings import warn from devops.helpers.helpers import tcp_ping_ from devops.helpers.helpers import wait_pass @@ -713,27 +711,6 @@ class EnvironmentModel(six.with_metaclass(SingletonMeta, object)): .format(echo_cmd, echo_result['stderr'])) 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 def describe_other_admin_interfaces(self, admin): admin_networks = [iface.network.name for iface in admin.interfaces]