Since we're python3 only, we don't need six anymore.

Change-Id: I82c35f364315129a41dd5cbea64c0c5a50662026
(cherry picked from commit 4d511679e8)
This commit is contained in:
Alex Schultz 2021-09-24 10:59:29 -06:00 committed by Brendan Shephard
parent 0021766610
commit 3956b20a97
26 changed files with 100 additions and 104 deletions

View File

@ -11,7 +11,6 @@ python-ironicclient!=2.5.2,!=2.7.1,!=3.0.0,>=2.3.0 # Apache-2.0
python-mistralclient!=3.2.0,>=3.1.0 # Apache-2.0
python-openstackclient>=5.2.0 # Apache-2.0
simplejson>=3.5.1 # MIT
six>=1.10.0 # MIT
osc-lib>=2.3.0 # Apache-2.0
tripleo-common>=15.2.0 # Apache-2.0
cryptography>=2.1 # BSD/Apache-2.0

View File

@ -13,11 +13,11 @@
# under the License.
#
import configparser
import os
import sys
from osc_lib.i18n import _
from six.moves import configparser
from tripleo_common.image import kolla_builder
TRIPLEO_HEAT_TEMPLATES = "/usr/share/openstack-tripleo-heat-templates/"

View File

@ -137,7 +137,7 @@ class TestExport(TestCase):
mock_get_stack.return_value = self.mock_stack
self.mock_open = mock.mock_open(
read_data='{"an_key":"an_value","ovn_dbs_vip":"vip"}')
with mock.patch('six.moves.builtins.open', self.mock_open):
with mock.patch('builtins.open', self.mock_open):
data = export.export_stack(heat, "overcloud", should_filter=True)
expected = \
@ -229,7 +229,7 @@ class TestExport(TestCase):
self.assertEqual(mock_passwords, data)
def test_export_ceph_net_key(self):
with mock.patch('six.moves.builtins.open', self.mock_open_ceph_global):
with mock.patch('builtins.open', self.mock_open_ceph_global):
mon_key = export.export_ceph_net_key('dcn0',
config_download_dir='/foo')
self.assertEqual(mon_key, 'storage_ip')
@ -237,7 +237,7 @@ class TestExport(TestCase):
'/foo/dcn0/global_vars.yaml', 'r')
def test_export_storage_ips(self):
with mock.patch('six.moves.builtins.open', self.mock_open_ceph_inv):
with mock.patch('builtins.open', self.mock_open_ceph_inv):
storage_ips = export.export_storage_ips('dcn0',
config_download_dir='/foo',
ceph_net_key='foo_ip')
@ -260,7 +260,7 @@ class TestExport(TestCase):
'fsid': 'a5a22d37-e01f-4fa0-a440-c72585c7487f',
'dashboard_enabled': False
}
with mock.patch('six.moves.builtins.open', self.mock_open_ceph_all):
with mock.patch('builtins.open', self.mock_open_ceph_all):
data = export.export_ceph('dcn0', 'openstack',
config_download_dir='/foo',
mon_ips=['192.168.24.42'])

View File

@ -197,7 +197,7 @@ class TestHeatPodLauncher(base.TestCase):
mock_untar.side_effect = untar
mock_open = mock.mock_open()
with mock.patch('six.moves.builtins.open', mock_open):
with mock.patch('builtins.open', mock_open):
# pylint: disable=bad-str-strip-call
launcher.do_restore_db()
self.assertEqual(mock.call(str(three), launcher.heat_dir),
@ -211,7 +211,7 @@ class TestHeatPodLauncher(base.TestCase):
self.run.reset_mock()
two.touch()
mock_open = mock.mock_open()
with mock.patch('six.moves.builtins.open', mock_open):
with mock.patch('builtins.open', mock_open):
# pylint: disable=bad-str-strip-call
launcher.do_restore_db()
self.assertEqual(mock.call(str(two), launcher.heat_dir),

View File

@ -44,8 +44,8 @@ from tripleoclient import utils
from tripleoclient.tests import base
from tripleoclient.tests import fakes
from six.moves.configparser import ConfigParser
from six.moves.urllib import error as url_error
from configparser import ConfigParser
from urllib import error as url_error
from ansible_runner import Runner
@ -212,10 +212,12 @@ class TestRunAnsiblePlaybook(TestCase):
extra_vars=arglist
)
@mock.patch('six.moves.builtins.open')
@mock.patch('os.chmod')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.utils.makedirs')
@mock.patch('os.path.exists', side_effect=(False, True, True))
def test_run_with_timeout(self, mock_exists, mock_mkdir, mock_open):
def test_run_with_timeout(self, mock_exists, mock_mkdir, mock_open,
mock_chmod):
ansible_runner.ArtifactLoader = mock.MagicMock()
ansible_runner.Runner.run = mock.MagicMock(return_value=('', 0))
ansible_runner.runner_config = mock.MagicMock()
@ -233,7 +235,7 @@ class TestRunAnsiblePlaybook(TestCase):
mock_open.mock_calls)
@mock.patch('os.chmod')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.utils.makedirs')
@mock.patch('os.path.exists', side_effect=(False, True, True))
def test_run_with_extravar_file(self, mock_exists, mock_mkdir, mock_open,
@ -1495,7 +1497,7 @@ class TestStoreCliParam(TestCase):
self.a = 1
dt = datetime.datetime(2017, 11, 22)
with mock.patch("six.moves.builtins.open", mock_file):
with mock.patch("builtins.open", mock_file):
with mock.patch('tripleoclient.utils.datetime') as mock_date:
mock_date.datetime.now.return_value = dt
utils.store_cli_param("overcloud plan list", ArgsFake())
@ -1506,7 +1508,7 @@ class TestStoreCliParam(TestCase):
]
mock_file.assert_has_calls(expected_call, any_order=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('os.path.isdir')
@mock.patch('os.path.exists')
def test_fail_to_write_data(self, mock_exists, mock_isdir, mock_open):
@ -1576,7 +1578,7 @@ class ProcessMultipleEnvironments(TestCase):
'parse', autospec=True, return_value=dict())
@mock.patch('yaml.safe_dump', autospec=True)
@mock.patch('yaml.safe_load', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tempfile.NamedTemporaryFile', autospec=True)
def test_rewrite_env_files(self,
mock_temp, mock_open,
@ -1819,13 +1821,13 @@ class TestDeploymentPythonInterpreter(TestCase):
class TestWaitApiPortReady(TestCase):
@mock.patch('six.moves.urllib.request.urlopen')
@mock.patch('urllib.request.urlopen')
def test_success(self, urlopen_mock):
has_errors = utils.wait_api_port_ready(8080)
self.assertFalse(has_errors)
@mock.patch(
'six.moves.urllib.request.urlopen',
'urllib.request.urlopen',
side_effect=[
url_error.HTTPError("", 201, None, None, None), socket.timeout,
url_error.URLError("")
@ -1838,7 +1840,7 @@ class TestWaitApiPortReady(TestCase):
self.assertEqual(sleep_mock.call_count, 30)
@mock.patch(
'six.moves.urllib.request.urlopen',
'urllib.request.urlopen',
side_effect=[
socket.timeout,
url_error.URLError(""),
@ -1851,7 +1853,7 @@ class TestWaitApiPortReady(TestCase):
self.assertEqual(sleep_mock.call_count, 4)
@mock.patch(
'six.moves.urllib.request.urlopen',
'urllib.request.urlopen',
side_effect=[
socket.timeout,
url_error.URLError(""),
@ -1864,7 +1866,7 @@ class TestWaitApiPortReady(TestCase):
self.assertEqual(urlopen_mock.call_count, 3)
self.assertEqual(sleep_mock.call_count, 3)
@mock.patch('six.moves.urllib.request.urlopen', side_effect=NameError)
@mock.patch('urllib.request.urlopen', side_effect=NameError)
@mock.patch('time.sleep')
def test_dont_retry_at_unknown_exception(self, urlopen_mock, sleep_mock):
with self.assertRaises(NameError):

View File

@ -14,9 +14,9 @@
#
import fixtures
from io import StringIO
import os
import shutil
import six
import tempfile
import yaml
@ -227,7 +227,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
def _custom_create_params_env(parameters, tht_root,
stack):
for key, value in six.iteritems(parameters):
for key, value in parameters.items():
self.assertEqual(value, expected_parameters[key])
parameter_defaults = {"parameter_defaults": parameters}
return parameter_defaults
@ -350,7 +350,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'CtlplaneNetworkAttributes': {}}}
mock_process_env.return_value = {}, parameters_env
mock_open_context = mock.mock_open()
with mock.patch('six.moves.builtins.open', mock_open_context):
with mock.patch('builtins.open', mock_open_context):
self.cmd.take_action(parsed_args)
self.assertTrue(orchestration_client.stacks.create.called)
@ -1028,7 +1028,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
def _custom_create_params_env(parameters, tht_root,
stack):
for key, value in six.iteritems(parameters):
for key, value in parameters.items():
self.assertEqual(value, expected_parameters[key])
parameter_defaults = {"parameter_defaults": parameters}
return parameter_defaults
@ -1777,7 +1777,7 @@ class TestGetDeploymentStatus(utils.TestCommand):
@mock.patch("tripleoclient.workflows.deployment.get_deployment_status")
def test_get_deployment_status(self, mock_get_deployment_status):
parsed_args = self.check_parser(self.cmd, [], [])
self.cmd.app.stdout = six.StringIO()
self.cmd.app.stdout = StringIO()
status = 'DEPLOY_SUCCESS'
mock_get_deployment_status.return_value = status

View File

@ -50,7 +50,7 @@ class TestOvercloudExternalUpdateRun(fakes.TestOvercloudExternalUpdateRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_update_with_user_and_tags(self, mock_open, mock_execute,
mock_expanduser, update_ansible,
mock_run, mock_run_prepare):
@ -77,7 +77,7 @@ class TestOvercloudExternalUpdateRun(fakes.TestOvercloudExternalUpdateRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_update_with_user_and_extra_vars(self, mock_open, mock_execute,
mock_expanduser, update_ansible,
mock_run, mock_run_prepare):

View File

@ -48,7 +48,7 @@ class TestOvercloudExternalUpgradeRun(fakes.TestOvercloudExternalUpgradeRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_upgrade_with_user_and_tags(self, mock_open, mock_execute,
mock_expanduser, update_ansible,
mock_run, mock_run_prepare):
@ -75,7 +75,7 @@ class TestOvercloudExternalUpgradeRun(fakes.TestOvercloudExternalUpgradeRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_upgrade_with_user_and_extra_vars(self, mock_open, mock_execute,
mock_expanduser, update_ansible,
mock_run, mock_run_prepare):

View File

@ -527,7 +527,7 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
}
]
mock_open = mock.mock_open(read_data=json.dumps(file_return_nodes))
with mock.patch('six.moves.builtins.open', mock_open):
with mock.patch('builtins.open', mock_open):
self.cmd.take_action(parsed_args)
nodes_list = copy.deepcopy(self.nodes_list)

View File

@ -39,7 +39,7 @@ class TestOvercloudUpdatePrepare(fakes.TestOvercloudUpdatePrepare):
@mock.patch('tripleoclient.utils.ensure_run_as_normal_user')
@mock.patch('tripleoclient.utils.prompt_user_for_confirmation',
return_value=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('os.path.abspath')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@ -77,7 +77,7 @@ class TestOvercloudUpdatePrepare(fakes.TestOvercloudUpdatePrepare):
@mock.patch('os.path.abspath')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'take_action', autospec=True)
def test_update_out(self, mock_deploy, mock_open, mock_copy, mock_yaml,
@ -124,7 +124,7 @@ class TestOvercloudUpdateRun(fakes.TestOvercloudUpdateRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_update_with_no_limit(
self, mock_open, mock_execute, mock_expanduser, update_ansible,
mock_confirm):

View File

@ -51,7 +51,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
@mock.patch('tripleoclient.v1.overcloud_upgrade.UpgradePrepare.log',
autospec=True)
@mock.patch('yaml.safe_load')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_upgrade_out(self,
mock_open,
mock_yaml,
@ -106,7 +106,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
@mock.patch('tripleoclient.utils.get_stack',
autospec=True)
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('yaml.safe_load')
def test_upgrade_failed(self, mock_yaml, mock_open,
add_env, mock_get_stack, mock_overcloud_deploy,
@ -170,7 +170,7 @@ class TestOvercloudUpgradeRun(fakes.TestOvercloudUpgradeRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_upgrade_limit_with_playbook_and_user(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible,
mock_run, mock_run_prepare, mock_confirm):
@ -201,7 +201,7 @@ class TestOvercloudUpgradeRun(fakes.TestOvercloudUpgradeRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_upgrade_nodes_with_playbook_no_skip_tags(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible,
mock_run, mock_run_prepare, mock_confirm):
@ -220,7 +220,7 @@ class TestOvercloudUpgradeRun(fakes.TestOvercloudUpgradeRun):
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_upgrade_with_no_limit(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'

View File

@ -14,18 +14,18 @@
#
import fixtures
from io import StringIO
import mock
import os
import requests
import shutil
import six
import sys
import tempfile
from urllib import parse
import uuid
import yaml
from osc_lib import exceptions as oscexc
from six.moves.urllib import parse
from tripleo_common.image import image_uploader
from tripleo_common.image import kolla_builder
from tripleoclient import constants
@ -901,7 +901,7 @@ class TestTripleoImagePrepareDefault(TestPluginV1):
self.app.command_options = [
'tripleo', 'container', 'image', 'prepare', 'default'
] + arglist
self.cmd.app.stdout = six.StringIO()
self.cmd.app.stdout = StringIO()
cmd = container_image.TripleOImagePrepareDefault(self.app, None)
parsed_args = self.check_parser(cmd, arglist, verifylist)
@ -971,7 +971,7 @@ class TestContainerImageBuild(TestPluginV1):
# Get the command object to test
self.cmd = container_image.BuildImage(self.app, None)
self.cmd.app.stdout = six.StringIO()
self.cmd.app.stdout = StringIO()
self.uuid = str(uuid.uuid4())
self.temp_dir = os.path.join(self.useFixture(
fixtures.TempDir()).join())

View File

@ -46,7 +46,7 @@ class TestOvercloudExport(utils.TestCommand):
mock_exists.return_value = False
mock_export_passwords.return_value = {'key': 'value'}
mock_export_stack.return_value = {'key0': 'value0'}
with mock.patch('six.moves.builtins.open', self.mock_open):
with mock.patch('builtins.open', self.mock_open):
self.cmd.take_action(parsed_args)
mock_export_passwords.assert_called_once_with(
self.app.client_manager.orchestration,
@ -78,7 +78,7 @@ class TestOvercloudExport(utils.TestCommand):
verifylist = [('stack', 'foo')]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
mock_exists.return_value = False
with mock.patch('six.moves.builtins.open', self.mock_open):
with mock.patch('builtins.open', self.mock_open):
self.cmd.take_action(parsed_args)
mock_export_passwords.assert_called_once_with(
self.app.client_manager.orchestration,
@ -106,7 +106,7 @@ class TestOvercloudExport(utils.TestCommand):
('config_download_dir', '/tmp/bar')]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
mock_exists.return_value = False
with mock.patch('six.moves.builtins.open', self.mock_open):
with mock.patch('builtins.open', self.mock_open):
self.cmd.take_action(parsed_args)
mock_export_passwords.assert_called_once_with(
self.app.client_manager.orchestration,
@ -132,7 +132,7 @@ class TestOvercloudExport(utils.TestCommand):
('no_password_excludes', True)]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
mock_exists.return_value = False
with mock.patch('six.moves.builtins.open', self.mock_open):
with mock.patch('builtins.open', self.mock_open):
self.cmd.take_action(parsed_args)
mock_export_passwords.assert_called_once_with(
self.app.client_manager.orchestration,

View File

@ -59,7 +59,7 @@ class TestOvercloudExportCeph(utils.TestCommand):
data['parameter_defaults']['CephExternalMultiConfig'] = [expected]
mock_export_ceph.return_value = expected
with mock.patch('six.moves.builtins.open', self.mock_open):
with mock.patch('builtins.open', self.mock_open):
self.cmd.take_action(parsed_args)
path = os.path.join(os.environ.get('HOME'),
'overcloud-deploy', 'dcn0', 'config-download')

View File

@ -63,7 +63,7 @@ class TestGenerateFencingParameters(utils.TestCommand):
mock_gen_fence.return_value = '{"result":[]}'
with mock.patch('six.moves.builtins.open', mock_open_context):
with mock.patch('builtins.open', mock_open_context):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)

View File

@ -214,7 +214,7 @@ class TestDeployUndercloud(TestPluginV1):
mock_exists.return_value = False
mock_open_context = mock.mock_open()
with mock.patch('six.moves.builtins.open', mock_open_context):
with mock.patch('builtins.open', mock_open_context):
self.cmd._update_passwords_env(self.temp_homedir, 'stack')
mock_open_handle = mock_open_context()
@ -403,7 +403,7 @@ class TestDeployUndercloud(TestPluginV1):
'_setup_heat_environments', autospec=True)
@mock.patch('yaml.safe_dump', autospec=True)
@mock.patch('yaml.safe_load', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tempfile.NamedTemporaryFile', autospec=True)
@mock.patch('tripleo_common.image.kolla_builder.'
'container_images_prepare_multi')
@ -520,7 +520,7 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('yaml.safe_load', return_value={}, autospec=True)
@mock.patch('yaml.safe_dump', autospec=True)
@mock.patch('os.path.isfile', return_value=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_process_hieradata_overrides', autospec=True)
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
@ -722,7 +722,7 @@ class TestDeployUndercloud(TestPluginV1):
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('getpass.getuser', return_value='stack')
@mock.patch('os.mkdir')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_populate_templates_dir')
@mock.patch('tripleoclient.utils.archive_deploy_artifacts',
@ -817,7 +817,7 @@ class TestDeployUndercloud(TestPluginV1):
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('getpass.getuser', return_value='stack')
@mock.patch('os.mkdir')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_populate_templates_dir')
@mock.patch('tripleoclient.utils.archive_deploy_artifacts',
@ -902,7 +902,7 @@ class TestDeployUndercloud(TestPluginV1):
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('getpass.getuser', return_value='stack')
@mock.patch('os.mkdir')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_populate_templates_dir')
@mock.patch('tripleoclient.utils.archive_deploy_artifacts',
@ -1058,7 +1058,7 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('os.chmod')
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.mkdir')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_populate_templates_dir')
@mock.patch('tripleoclient.utils.archive_deploy_artifacts',
@ -1117,7 +1117,7 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('os.chmod')
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.mkdir')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_populate_templates_dir')
@mock.patch('tripleoclient.utils.archive_deploy_artifacts',

View File

@ -56,7 +56,7 @@ class TestUndercloudInstall(TestPluginV1):
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.geteuid', return_value=1001)
@mock.patch('getpass.getuser', return_value='stack')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('shutil.copy')
@mock.patch('os.mkdir')
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
@ -397,7 +397,7 @@ class TestUndercloudInstall(TestPluginV1):
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.geteuid', return_value=1001)
@mock.patch('getpass.getuser', return_value='stack')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('shutil.copy')
@mock.patch('os.mkdir')
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
@ -460,7 +460,7 @@ class TestUndercloudInstall(TestPluginV1):
# TODO(cjeanner) drop once we have proper oslo.privsep
@mock.patch('os.geteuid', return_value=1001)
@mock.patch('getpass.getuser', return_value='stack')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('shutil.copy')
@mock.patch('os.mkdir')
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)

View File

@ -77,7 +77,7 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
mock_isfile.return_value = True
with mock.patch("os.path.isdir", autospec=True) as mock_isdir:
mock_isdir.return_value = True
with mock.patch('six.moves.builtins.open', mock_open):
with mock.patch('builtins.open', mock_open):
with mock.patch(
"tripleoclient.v2.tripleo_container_image.Build"
".find_image",
@ -88,7 +88,7 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
def test_find_image(self):
mock_open = mock.mock_open(read_data='---\ntcib_option: "data"')
with mock.patch('six.moves.builtins.open', mock_open):
with mock.patch('builtins.open', mock_open):
image = self.cmd.find_image("keystone", "some/path", "base-image")
self.assertEqual(image, {"tcib_option": "data"})

View File

@ -37,7 +37,7 @@ class TestParameterWorkflows(utils.TestCommand):
self.app.client_manager.baremetal = mock.Mock()
@mock.patch('yaml.safe_load')
@mock.patch("six.moves.builtins.open")
@mock.patch("builtins.open")
@mock.patch('tripleoclient.utils.run_ansible_playbook', autospec=True)
@mock.patch('tripleoclient.utils.get_tripleo_ansible_inventory',
autospec=True)
@ -81,7 +81,7 @@ class TestParameterWorkflows(utils.TestCommand):
mock_playbook.assert_has_calls(calls, any_order=True)
@mock.patch('yaml.safe_load')
@mock.patch("six.moves.builtins.open")
@mock.patch("builtins.open")
@mock.patch('tripleoclient.utils.run_ansible_playbook', autospec=True)
@mock.patch('tripleoclient.utils.get_tripleo_ansible_inventory',
autospec=True)

View File

@ -20,6 +20,7 @@ try:
except AttributeError:
collectionsAbc = collections
import configparser
import csv
import datetime
import errno
@ -38,7 +39,6 @@ import pwd
import re
import shutil
import simplejson
import six
import socket
import subprocess
import sys
@ -59,12 +59,11 @@ from heatclient.exc import HTTPNotFound
from osc_lib import exceptions as oscexc
from osc_lib.i18n import _
from oslo_concurrency import processutils
from six.moves import configparser
from heatclient import exc as hc_exc
from six.moves.urllib import error as url_error
from six.moves.urllib import parse as url_parse
from six.moves.urllib import request
from urllib import error as url_error
from urllib import parse as url_parse
from urllib import request
from tenacity import retry
from tenacity.stop import stop_after_attempt, stop_after_delay
@ -183,7 +182,7 @@ def _encode_envvars(env):
:type env: `dict`.
"""
for key, value in env.items():
env[key] = six.text_type(value)
env[key] = str(value)
else:
return env
@ -362,7 +361,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
def _inventory(inventory):
if inventory:
if isinstance(inventory, six.string_types):
if isinstance(inventory, str):
# check is file path
if os.path.exists(inventory):
return inventory
@ -739,11 +738,11 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
def convert(data):
"""Recursively converts dictionary keys,values to strings."""
if isinstance(data, six.string_types):
if isinstance(data, str):
return str(data)
elif isinstance(data, collectionsAbc.Mapping):
return dict(map(convert, six.iteritems(data)))
elif isinstance(data, collectionsAbc.Iterable):
if isinstance(data, collectionsAbc.Mapping):
return dict(map(convert, data.items()))
if isinstance(data, collectionsAbc.Iterable):
return type(data)(map(convert, data))
else:
return data
@ -1202,7 +1201,7 @@ def check_stack_network_matches_env_files(stack, environment):
"""
def _get_networks(registry):
nets = set()
for k, v in six.iteritems(registry):
for k, v in registry.items():
if (k.startswith('OS::TripleO::Network::')
and not k.startswith('OS::TripleO::Network::Port')
and v != 'OS::Heat::None'):
@ -1589,7 +1588,7 @@ def replace_links_in_template(template_part, link_replacement):
def replaced_dict_value(key, value):
if ((key == 'get_file' or key == 'type') and
isinstance(value, six.string_types)):
isinstance(value, str)):
return link_replacement.get(value, value)
else:
return replace_links_in_template(value, link_replacement)
@ -1599,8 +1598,8 @@ def replace_links_in_template(template_part, link_replacement):
if isinstance(template_part, dict):
return {k: replaced_dict_value(k, v)
for k, v in six.iteritems(template_part)}
elif isinstance(template_part, list):
for k, v in template_part.items()}
if isinstance(template_part, list):
return list(map(replaced_list_value, template_part))
else:
return template_part
@ -1615,7 +1614,7 @@ def relative_link_replacement(link_replacement, current_dir):
"""
return {k: os.path.relpath(v, current_dir)
for k, v in six.iteritems(link_replacement)}
for k, v in link_replacement.items()}
def load_environment_directories(directories):
@ -1935,14 +1934,14 @@ def process_multiple_environments(created_env_files, tht_root,
# See bug https://bugs.launchpad.net/tripleo/+bug/1625783
# for details on why this is needed (backwards-compatibility)
log.debug("Error %s processing environment file %s"
% (six.text_type(ex), env_path))
% (str(ex), env_path))
# Use the temporary path as it's possible the environment
# itself was rendered via jinja.
with open(env_path, 'r') as f:
env_map = yaml.safe_load(f)
env_registry = env_map.get('resource_registry', {})
env_dirname = os.path.dirname(os.path.abspath(env_path))
for rsrc, rsrc_path in six.iteritems(env_registry):
for rsrc, rsrc_path in env_registry.items():
# We need to calculate the absolute path relative to
# env_path not cwd (which is what abspath uses).
abs_rsrc_path = os.path.normpath(

View File

@ -16,6 +16,7 @@
import copy
import datetime
import errno
from io import StringIO
import json
import logging
import os
@ -27,8 +28,7 @@ import uuid
from osc_lib import exceptions as oscexc
from osc_lib.i18n import _
import six
from six.moves.urllib import parse
from urllib import parse
import yaml
from tripleo_common.image.builder import buildah
@ -45,7 +45,7 @@ from tripleoclient import utils
def build_env_file(params, command_options):
f = six.StringIO()
f = StringIO()
f.write('# Generated with the following on %s\n#\n' %
datetime.datetime.now().isoformat())
f.write('# openstack %s\n#\n\n' %

View File

@ -23,8 +23,8 @@ from prettytable import PrettyTable
from pwd import getpwuid
import re
import shutil
import six
import time
import urllib
import yaml
from heatclient.common import template_utils
@ -408,7 +408,7 @@ class DeployOvercloud(command.Command):
# an FQDN depending on how what it's configured to output in the
# tripleo-heat-templates. Such a configuration can be done by
# overriding the EndpointMap through parameter_defaults.
overcloud_ip_or_fqdn = six.moves.urllib.parse.urlparse(
overcloud_ip_or_fqdn = urllib.parse.urlparse(
overcloud_endpoint).hostname
keystone_admin_ip = utils.get_endpoint('KeystoneAdmin', stack)

View File

@ -19,7 +19,6 @@ import os
import ipaddress
from osc_lib.i18n import _
import six
import yaml
from tripleoclient import command
@ -87,7 +86,7 @@ class ValidateOvercloudNetenv(command.Command):
objs = []
for x in networks:
try:
objs += [ipaddress.ip_network(six.u(x))]
objs += [ipaddress.ip_network(str(x))]
except ValueError:
self.log.error('Invalid address: %s', x)
self.error_count += 1
@ -108,13 +107,13 @@ class ValidateOvercloudNetenv(command.Command):
for pool in pooldata:
try:
ip_start = ipaddress.ip_address(
six.u(pool['start']))
str(pool['start']))
except ValueError:
self.log.error('Invalid address: %s' % ip_start)
self.error_count += 1
ip_start = None
try:
ip_end = ipaddress.ip_address(six.u(pool['end']))
ip_end = ipaddress.ip_address(str(pool['end']))
except ValueError:
self.log.error('Invalid address: %s' % ip_start)
self.error_count += 1
@ -132,7 +131,7 @@ class ValidateOvercloudNetenv(command.Command):
subnet_item = poolitem.split('AllocationPools')[0] + 'NetCidr'
try:
subnet_obj = ipaddress.ip_network(
six.u(filedata[subnet_item]))
str(filedata[subnet_item]))
except ValueError:
self.log.error('Invalid address: %s', subnet_item)
self.error_count += 1
@ -150,7 +149,7 @@ class ValidateOvercloudNetenv(command.Command):
def check_vlan_ids(self, vlans):
invertdict = {}
for k, v in six.iteritems(vlans):
for k, v in vlans.items():
self.log.info('Checking Vlan ID {}'.format(k))
if v not in invertdict:
invertdict[v] = k

View File

@ -16,6 +16,7 @@
import collections
import copy
import datetime
from io import StringIO
import ipaddress
import json
import logging
@ -27,7 +28,6 @@ from openstack import exceptions as openstack_exc
from osc_lib import exceptions as oscexc
from osc_lib.i18n import _
from osc_lib import utils
import six
import yaml
from tripleoclient import command
@ -111,7 +111,7 @@ class DeleteNode(command.Command):
node_hostnames = [i['hostname'] for i in nodes if 'hostname' in i]
formatter = table.TableFormatter()
output = six.StringIO()
output = StringIO()
formatter.emit_list(
column_names=['hostname', 'name', 'id'],
data=nodes_data,
@ -637,7 +637,7 @@ class ExtractProvisionedNode(command.Command):
data.append(role)
# Write the file header
file_data = six.StringIO()
file_data = StringIO()
file_data.write('# Generated with the following on %s\n#\n' %
datetime.datetime.now().isoformat())
file_data.write('# openstack %s\n#\n\n' %
@ -650,7 +650,7 @@ class ExtractProvisionedNode(command.Command):
if parsed_args.output:
if (os.path.exists(parsed_args.output)
and not parsed_args.yes and sys.stdin.isatty()):
prompt_response = six.moves.input(
prompt_response = input(
('Overwrite existing file %s [y/N]?' % parsed_args.output)
).lower()
if not prompt_response.startswith('y'):

View File

@ -14,13 +14,13 @@
#
import argparse
import configparser
import json
import logging
import netaddr
import os
import pwd
import shutil
import six
import subprocess
import sys
import tempfile
@ -31,7 +31,6 @@ import yaml
from cliff import command
from heatclient.common import template_utils
from osc_lib.i18n import _
from six.moves import configparser
from tripleoclient import constants
from tripleoclient import exceptions
@ -1431,9 +1430,9 @@ class Deploy(command.Command):
try:
self._standalone_deploy(parsed_args)
except Exception as ex:
self.log.error("Exception: %s" % six.text_type(ex))
self.log.error("Exception: %s" % str(ex))
self.log.error(traceback.print_exc())
raise exceptions.DeploymentError(six.text_type(ex))
raise exceptions.DeploymentError(str(ex))
finally:
# Copy clouds.yaml from /etc/openstack so credentials can be
# read by the deployment user and not only root.

View File

@ -19,8 +19,6 @@ import re
import uuid
import yaml
import six
from osc_lib.i18n import _
from oslo_config import cfg
@ -387,7 +385,7 @@ class Build(command.Command):
self.image_paths[key] = os.path.join(work_dir, key)
utils.makedirs(dir_path=self.image_paths[key])
self.make_dir_tree(tree=value, work_dir=self.image_paths[key])
elif isinstance(tree, six.string_types):
elif isinstance(tree, str):
self.image_paths[tree] = os.path.join(work_dir, tree)
utils.makedirs(dir_path=self.image_paths[tree])