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:
parent
72326563e7
commit
0c21907598
@ -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),
|
||||
))
|
@ -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)
|
@ -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
|
||||
@ -61,11 +56,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
|
||||
|
@ -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.
|
@ -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']
|
@ -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!',
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
@ -30,7 +29,6 @@ from devops.helpers.metaclasses import SingletonMeta
|
||||
from devops.helpers.ssh_client import SSHClient
|
||||
from paramiko import RSAKey
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from fuelweb_test import logger
|
||||
from fuelweb_test.settings import SSH_CREDENTIALS
|
||||
@ -268,7 +266,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]
|
||||
@ -309,54 +307,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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -703,27 +701,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]
|
||||
|
Loading…
Reference in New Issue
Block a user