Remove six.moves
Replace the following items with Python 3 style code. - six.moves.configparser - six.moves.StringIO - six.moves.cStringIO - six.moves.urllib - six.moves.builtins - six.moves.range - six.moves.xmlrpc_client - six.moves.http_client - six.moves.http_cookies - six.moves.queue - six.moves.zip - six.moves.reload_module - six.StringIO - six.BytesIO Subsequent patches will replace other six usages. Change-Id: Ib2c406327fef2fb4868d8050fc476a7d17706e23 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
parent
4ac4a04d18
commit
1d0a0e8c20
@ -20,11 +20,10 @@ It is used via a single directive in the .rst file
|
||||
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import re
|
||||
import sys
|
||||
|
||||
from six.moves import configparser
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers import rst
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves import range
|
||||
from webob import exc
|
||||
|
||||
import nova.conf
|
||||
|
@ -16,11 +16,11 @@
|
||||
import collections
|
||||
import itertools
|
||||
import re
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
|
@ -13,9 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import strutils
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from oslo_utils import strutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.api_version_request \
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import iso8601
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import common
|
||||
|
@ -26,6 +26,7 @@ import functools
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from dateutil import parser as dateutil_parser
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
@ -40,7 +41,6 @@ from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
import prettytable
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from sqlalchemy.engine import url as sqla_url
|
||||
|
||||
from nova.cmd import common as cmd_common
|
||||
|
@ -35,7 +35,6 @@ from oslo_utils import timeutils
|
||||
from oslo_utils import units
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
from nova.accelerator import cyborg
|
||||
from nova import availability_zones
|
||||
|
@ -55,7 +55,6 @@ from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import units
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
from nova.accelerator import cyborg
|
||||
from nova import block_device
|
||||
|
@ -702,7 +702,7 @@ class ComputeTaskManager(base.Base):
|
||||
return
|
||||
|
||||
elevated = context.elevated()
|
||||
for (instance, host_list) in six.moves.zip(instances, host_lists):
|
||||
for (instance, host_list) in zip(instances, host_lists):
|
||||
host = host_list.pop(0)
|
||||
if is_reschedule:
|
||||
# If this runs in the superconductor, the first instance will
|
||||
@ -1523,7 +1523,7 @@ class ComputeTaskManager(base.Base):
|
||||
instances = []
|
||||
host_az = {} # host=az cache to optimize multi-create
|
||||
|
||||
for (build_request, request_spec, host_list) in six.moves.zip(
|
||||
for (build_request, request_spec, host_list) in zip(
|
||||
build_requests, request_specs, host_lists):
|
||||
instance = build_request.get_new_instance(context)
|
||||
# host_list is a list of one or more Selection objects, the first
|
||||
@ -1605,8 +1605,7 @@ class ComputeTaskManager(base.Base):
|
||||
block_device_mapping, tags,
|
||||
cell_mapping_cache)
|
||||
|
||||
zipped = six.moves.zip(build_requests, request_specs, host_lists,
|
||||
instances)
|
||||
zipped = zip(build_requests, request_specs, host_lists, instances)
|
||||
for (build_request, request_spec, host_list, instance) in zipped:
|
||||
if instance is None:
|
||||
# Skip placeholders that were buried in cell0 or had their
|
||||
@ -1758,7 +1757,7 @@ class ComputeTaskManager(base.Base):
|
||||
def _cleanup_build_artifacts(self, context, exc, instances, build_requests,
|
||||
request_specs, block_device_mappings, tags,
|
||||
cell_mapping_cache):
|
||||
for (instance, build_request, request_spec) in six.moves.zip(
|
||||
for (instance, build_request, request_spec) in zip(
|
||||
instances, build_requests, request_specs):
|
||||
# Skip placeholders that were buried in cell0 or had their
|
||||
# build requests deleted by the user before instance create.
|
||||
|
@ -17,7 +17,6 @@
|
||||
import socket
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six.moves
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
@ -45,7 +44,7 @@ def acquire_port(host):
|
||||
|
||||
start, stop = _get_port_range()
|
||||
|
||||
for port in six.moves.range(start, stop):
|
||||
for port in range(start, stop):
|
||||
if (host, port) in ALLOCATED_PORTS:
|
||||
continue
|
||||
try:
|
||||
|
@ -19,15 +19,15 @@ Leverages websockify.py by Joel Martin
|
||||
'''
|
||||
|
||||
import copy
|
||||
from http import cookies as Cookie
|
||||
import socket
|
||||
import sys
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
from six.moves import http_cookies as Cookie
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import websockify
|
||||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
|
@ -35,7 +35,6 @@ from oslo_utils import importutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import Boolean
|
||||
|
@ -40,7 +40,6 @@ from oslo_serialization import jsonutils
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
|
@ -17,6 +17,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import urllib
|
||||
|
||||
import netaddr
|
||||
from neutronclient.common import exceptions as n_exc
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
@ -26,7 +28,6 @@ from oslo_utils import excutils
|
||||
from oslo_utils import netutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import urllib
|
||||
from webob import exc
|
||||
|
||||
from nova import context as nova_context
|
||||
|
@ -10,9 +10,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import versionutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from sqlalchemy.sql.expression import asc
|
||||
from sqlalchemy.sql import false
|
||||
from sqlalchemy.sql import true
|
||||
|
@ -13,12 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from oslo_db.exception import DBDuplicateEntry
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from nova.db import api as db
|
||||
from nova import exception
|
||||
|
@ -22,7 +22,6 @@ Weighing Functions.
|
||||
import random
|
||||
|
||||
from oslo_log import log as logging
|
||||
from six.moves import range
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
import nova.conf
|
||||
|
@ -17,12 +17,12 @@
|
||||
import collections
|
||||
import re
|
||||
import sys
|
||||
from urllib import parse
|
||||
|
||||
import os_resource_classes as orc
|
||||
import os_traits
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from nova.compute import flavors
|
||||
from nova.compute import utils as compute_utils
|
||||
|
@ -14,8 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import urllib
|
||||
|
||||
from eventlet import tpool
|
||||
from six.moves import urllib
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
|
@ -24,6 +24,7 @@ inline callbacks.
|
||||
import nova.monkey_patch # noqa
|
||||
|
||||
import abc
|
||||
import builtins
|
||||
import collections
|
||||
import contextlib
|
||||
import copy
|
||||
@ -50,7 +51,6 @@ from oslo_versionedobjects import fixture as ovo_fixture
|
||||
from oslotest import base
|
||||
from oslotest import mock_fixture
|
||||
import six
|
||||
from six.moves import builtins
|
||||
import testtools
|
||||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
@ -903,7 +903,7 @@ def patch_open(patched_path, read_data):
|
||||
selective patching based on the path. In this case something like
|
||||
like this may be more appropriate:
|
||||
|
||||
@mock.patch(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_my_code(self, mock_open):
|
||||
...
|
||||
mock_open.assert_called_once_with(path)
|
||||
@ -916,6 +916,6 @@ def patch_open(patched_path, read_data):
|
||||
return m(patched_path)
|
||||
return real_open(path, *args, **kwargs)
|
||||
|
||||
with mock.patch.object(builtins, 'open') as mock_open:
|
||||
with mock.patch('builtins.open') as mock_open:
|
||||
mock_open.side_effect = selective_fake_open
|
||||
yield m
|
||||
|
@ -12,10 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from urllib import parse
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import requests
|
||||
from six.moves.urllib import parse
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -14,8 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from nova import context
|
||||
from nova import objects
|
||||
|
@ -13,10 +13,10 @@
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
from urllib import parse
|
||||
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from nova.tests.functional.api_sample_tests import test_servers
|
||||
import nova.tests.functional.api_samples_test_base as astb
|
||||
|
@ -10,13 +10,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import collections
|
||||
from io import StringIO
|
||||
import mock
|
||||
|
||||
import fixtures
|
||||
from neutronclient.common import exceptions as neutron_client_exc
|
||||
import os_resource_classes as orc
|
||||
from oslo_utils.fixture import uuidsentinel
|
||||
from six.moves import StringIO
|
||||
|
||||
from nova.cmd import manage
|
||||
from nova import config
|
||||
|
@ -13,8 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import mock
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import common
|
||||
|
@ -19,9 +19,9 @@ and as a WSGI layer
|
||||
"""
|
||||
|
||||
import copy
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import mock
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import images as images_v21
|
||||
|
@ -17,11 +17,12 @@
|
||||
Tests dealing with HTTP rate-limiting.
|
||||
"""
|
||||
|
||||
from http import client as httplib
|
||||
from io import StringIO
|
||||
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
from six.moves import http_client as httplib
|
||||
from six.moves import StringIO
|
||||
|
||||
from nova.api.openstack.compute import limits as limits_v21
|
||||
from nova.api.openstack.compute import views
|
||||
|
@ -19,6 +19,7 @@ import copy
|
||||
import datetime
|
||||
import ddt
|
||||
import functools
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import fixtures
|
||||
import iso8601
|
||||
@ -32,8 +33,6 @@ from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import testtools
|
||||
import webob
|
||||
|
||||
|
@ -19,7 +19,6 @@ import mock
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import timeutils
|
||||
from six.moves import range
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import simple_tenant_usage as \
|
||||
|
@ -15,6 +15,7 @@
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
import urllib
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
@ -22,7 +23,6 @@ from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
import six
|
||||
from six.moves import urllib
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
|
@ -20,7 +20,6 @@ from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import routes
|
||||
import six
|
||||
from six.moves import range
|
||||
import webob.dec
|
||||
|
||||
from nova.api import auth as api_auth
|
||||
|
@ -12,11 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from io import StringIO
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_log import log as logging
|
||||
from oslo_reports import guru_meditation_report as gmr
|
||||
from six.moves import StringIO
|
||||
|
||||
from nova.cmd import baseproxy
|
||||
from nova import config
|
||||
|
@ -17,11 +17,11 @@
|
||||
Unit tests for the common functions used by different CLI interfaces.
|
||||
"""
|
||||
|
||||
from io import StringIO
|
||||
import sys
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from six.moves import StringIO
|
||||
|
||||
from nova.cmd import common as cmd_common
|
||||
from nova.db import api
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
from io import StringIO
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
@ -24,7 +25,6 @@ from oslo_db import exception as db_exc
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils.fixture import uuidsentinel
|
||||
from oslo_utils import uuidutils
|
||||
from six.moves import StringIO
|
||||
|
||||
from nova.cmd import manage
|
||||
from nova import conf
|
||||
|
@ -17,9 +17,10 @@
|
||||
Unit tests for the nova-policy-check CLI interfaces.
|
||||
"""
|
||||
|
||||
from io import StringIO
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from six.moves import StringIO
|
||||
|
||||
from nova.cmd import policy
|
||||
import nova.conf
|
||||
|
@ -20,11 +20,12 @@ Unit tests for the nova-status CLI interfaces.
|
||||
# nova/tests/functional/test_nova_status.py. Those tests use the external
|
||||
# PlacementFixture, which is only available in functioanl tests.
|
||||
|
||||
from io import StringIO
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import os
|
||||
from six.moves import StringIO
|
||||
import tempfile
|
||||
import yaml
|
||||
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
|
@ -17,7 +17,6 @@
|
||||
import socket
|
||||
|
||||
import mock
|
||||
import six.moves
|
||||
|
||||
from nova.console import serial
|
||||
from nova import exception
|
||||
@ -74,10 +73,10 @@ class SerialTestCase(test.NoDBTestCase):
|
||||
port_range='%d:%d' % (start, stop),
|
||||
group='serial_console')
|
||||
|
||||
for port in six.moves.range(start, stop):
|
||||
for port in range(start, stop):
|
||||
self.assertEqual(port, serial.acquire_port('127.0.0.1'))
|
||||
|
||||
for port in six.moves.range(start, stop):
|
||||
for port in range(start, stop):
|
||||
self.assertEqual(port, serial.acquire_port('127.0.0.2'))
|
||||
|
||||
self.assertEqual(10, len(serial.ALLOCATED_PORTS))
|
||||
|
@ -37,7 +37,6 @@ from oslo_utils.fixture import uuidsentinel
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy.dialects import sqlite
|
||||
from sqlalchemy.exc import OperationalError
|
||||
|
@ -24,7 +24,6 @@ library to work with nova.
|
||||
import fnmatch
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves import range
|
||||
|
||||
|
||||
class Store(object):
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
from io import StringIO
|
||||
import urllib.parse as urlparse
|
||||
|
||||
import cryptography
|
||||
@ -27,8 +28,6 @@ from glanceclient.v2 import schemas
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
import mock
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
import six
|
||||
from six.moves import StringIO
|
||||
import testtools
|
||||
|
||||
import nova.conf
|
||||
@ -556,7 +555,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
default of not allowing direct URI transfers is set.
|
||||
"""
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
def test_download_no_data_no_dest_path_v2(self, show_mock, open_mock):
|
||||
client = mock.MagicMock()
|
||||
@ -572,7 +571,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
ctx, 2, 'data', args=(mock.sentinel.image_id,))
|
||||
self.assertEqual(mock.sentinel.image_chunks, res)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
def test_download_data_no_dest_path_v2(self, show_mock, open_mock):
|
||||
client = mock.MagicMock()
|
||||
@ -596,7 +595,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
)
|
||||
self.assertFalse(data.close.called)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2._safe_fsync')
|
||||
def test_download_no_data_dest_path_v2(self, fsync_mock, show_mock,
|
||||
@ -625,7 +624,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
)
|
||||
writer.close.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
def test_download_data_dest_path_v2(self, show_mock, open_mock):
|
||||
# NOTE(jaypipes): This really shouldn't be allowed, but because of the
|
||||
@ -654,7 +653,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
)
|
||||
self.assertFalse(data.close.called)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
def test_download_data_dest_path_write_fails_v2(
|
||||
self, show_mock, open_mock):
|
||||
@ -675,7 +674,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
self.assertRaises(FakeDiskException, service.download, ctx,
|
||||
mock.sentinel.image_id, data=Exceptionator())
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
def test_download_no_returned_image_data_v2(
|
||||
self, show_mock, open_mock):
|
||||
@ -691,7 +690,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
# TODO(stephenfin): Drop this test since it's not possible to run in
|
||||
# production
|
||||
@mock.patch('os.path.getsize', return_value=1)
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2._get_transfer_method')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
def test_download_direct_file_uri_v2(
|
||||
@ -727,7 +726,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
|
||||
@mock.patch('glanceclient.common.utils.IterableWithLength')
|
||||
@mock.patch('os.path.getsize', return_value=1)
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.LOG')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2._get_verifier')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2._get_transfer_method')
|
||||
@ -820,7 +819,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
ctx = mock.sentinel.ctx
|
||||
writer = mock.MagicMock()
|
||||
|
||||
with mock.patch.object(six.moves.builtins, 'open') as open_mock:
|
||||
with mock.patch('builtins.open') as open_mock:
|
||||
open_mock.return_value = writer
|
||||
service = glance.GlanceImageServiceV2(client)
|
||||
res = service.download(ctx, mock.sentinel.image_id,
|
||||
@ -873,7 +872,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase):
|
||||
ctx = mock.sentinel.ctx
|
||||
writer = mock.MagicMock()
|
||||
|
||||
with mock.patch.object(six.moves.builtins, 'open') as open_mock:
|
||||
with mock.patch('builtins.open') as open_mock:
|
||||
open_mock.return_value = writer
|
||||
service = glance.GlanceImageServiceV2(client)
|
||||
res = service.download(ctx, mock.sentinel.image_id,
|
||||
@ -966,7 +965,7 @@ class TestDownloadSignatureVerification(test.NoDBTestCase):
|
||||
msg = ('Image signature verification succeeded for image %s')
|
||||
mock_log.info.assert_called_once_with(msg, image_id)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.LOG')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
@mock.patch('cursive.signature_utils.get_verifier')
|
||||
@ -1051,7 +1050,7 @@ class TestDownloadSignatureVerification(test.NoDBTestCase):
|
||||
context=None, image_id=None,
|
||||
data=None, dst_path=None)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('cursive.signature_utils.get_verifier')
|
||||
@mock.patch('nova.image.glance.LOG')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
|
@ -17,6 +17,7 @@
|
||||
"""Matcher classes to be used inside of the testtools assertThat framework."""
|
||||
|
||||
import copy
|
||||
import io
|
||||
import pprint
|
||||
|
||||
from lxml import etree
|
||||
@ -411,7 +412,7 @@ class XMLMatches(object):
|
||||
if isinstance(text_or_bytes, six.text_type):
|
||||
text_or_bytes = text_or_bytes.encode("utf-8")
|
||||
parser = etree.XMLParser(encoding="UTF-8")
|
||||
return etree.parse(six.BytesIO(text_or_bytes), parser)
|
||||
return etree.parse(io.BytesIO(text_or_bytes), parser)
|
||||
|
||||
def __init__(self, expected, allow_mixed_nodes=False,
|
||||
skip_empty_text_nodes=True, skip_values=('DONTCARE',)):
|
||||
|
@ -32,7 +32,6 @@ from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import requests_mock
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
from nova import context
|
||||
from nova.db.sqlalchemy import api as db_api
|
||||
|
@ -18,7 +18,6 @@ from neutronclient.common import exceptions as n_exc
|
||||
from neutronclient.neutron import v2_0 as neutronv20
|
||||
from neutronclient.v2_0 import client
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from six.moves import range
|
||||
|
||||
from nova import context
|
||||
from nova import exception
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import urllib.parse as urlparse
|
||||
|
||||
from oslo_db.exception import DBDuplicateEntry
|
||||
from oslo_utils.fixture import uuidsentinel
|
||||
from oslo_utils import timeutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from nova import exception
|
||||
from nova.objects import console_auth_token as token_obj
|
||||
|
@ -19,7 +19,6 @@ import os
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from six.moves import builtins
|
||||
|
||||
from nova import exception
|
||||
from nova.pci import utils
|
||||
@ -95,8 +94,7 @@ class GetFunctionByIfnameTestCase(test.NoDBTestCase):
|
||||
@mock.patch.object(os, 'readlink')
|
||||
def test_virtual_function(self, mock_readlink, *args):
|
||||
mock_readlink.return_value = '../../../0000.00.00.1'
|
||||
with mock.patch.object(
|
||||
builtins, 'open', side_effect=IOError()):
|
||||
with mock.patch('builtins.open', side_effect=IOError()):
|
||||
address, physical_function = utils.get_function_by_ifname('eth0')
|
||||
self.assertEqual(address, '0000.00.00.1')
|
||||
self.assertFalse(physical_function)
|
||||
@ -129,14 +127,12 @@ class IsPhysicalFunctionTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch('os.path.isdir', return_value=True)
|
||||
def test_virtual_function(self, *args):
|
||||
with mock.patch.object(
|
||||
builtins, 'open', side_effect=IOError()):
|
||||
with mock.patch('builtins.open', side_effect=IOError()):
|
||||
self.assertFalse(utils.is_physical_function(*self.pci_args))
|
||||
|
||||
@mock.patch('os.path.isdir', return_value=True)
|
||||
def test_physical_function(self, *args):
|
||||
with mock.patch.object(
|
||||
builtins, 'open', mock.mock_open(read_data='4')):
|
||||
with mock.patch('builtins.open', mock.mock_open(read_data='4')):
|
||||
self.assertTrue(utils.is_physical_function(*self.pci_args))
|
||||
|
||||
@mock.patch('os.path.isdir', return_value=False)
|
||||
|
@ -12,9 +12,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from io import StringIO
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from six.moves import StringIO
|
||||
|
||||
import nova.privsep.idmapshift
|
||||
from nova import test
|
||||
|
@ -18,7 +18,6 @@ import binascii
|
||||
import ddt
|
||||
import mock
|
||||
import os
|
||||
import six
|
||||
|
||||
import nova.privsep.libvirt
|
||||
from nova import test
|
||||
@ -134,10 +133,8 @@ class LibvirtTestCase(test.NoDBTestCase):
|
||||
return orig_import(module, *args)
|
||||
|
||||
with test.nested(
|
||||
mock.patch.object(six.moves.builtins, 'open',
|
||||
new=mock.mock_open()),
|
||||
mock.patch.object(six.moves.builtins, '__import__',
|
||||
side_effect=fake_import),
|
||||
mock.patch('builtins.open', new=mock.mock_open()),
|
||||
mock.patch('builtins.__import__', side_effect=fake_import),
|
||||
) as (mock_open, mock_import):
|
||||
nova.privsep.libvirt.readpty('/fake/path')
|
||||
|
||||
@ -158,8 +155,7 @@ class LibvirtTestCase(test.NoDBTestCase):
|
||||
|
||||
def test_create_nmdev(self):
|
||||
mock_open = mock.mock_open()
|
||||
with mock.patch.object(six.moves.builtins, 'open',
|
||||
new=mock_open) as mock_open:
|
||||
with mock.patch('builtins.open', new=mock_open) as mock_open:
|
||||
nova.privsep.libvirt.create_mdev('phys', 'mdevtype',
|
||||
uuid='fakeuuid')
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
import mock
|
||||
import os
|
||||
import six
|
||||
import tempfile
|
||||
|
||||
from nova import exception
|
||||
@ -35,8 +34,7 @@ class FileTestCase(test.NoDBTestCase):
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
def test_readfile(self, mock_exists):
|
||||
mock_open = mock.mock_open(read_data='hello world')
|
||||
with mock.patch.object(six.moves.builtins, 'open',
|
||||
new=mock_open):
|
||||
with mock.patch('builtins.open', new=mock_open):
|
||||
self.assertEqual('hello world',
|
||||
nova.privsep.path.readfile('/fake/path'))
|
||||
|
||||
@ -49,8 +47,7 @@ class FileTestCase(test.NoDBTestCase):
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
def test_write(self, mock_exists):
|
||||
mock_open = mock.mock_open()
|
||||
with mock.patch.object(six.moves.builtins, 'open',
|
||||
new=mock_open):
|
||||
with mock.patch('builtins.open', new=mock_open):
|
||||
nova.privsep.path.writefile('/fake/path/file', 'w', 'foo')
|
||||
|
||||
handle = mock_open()
|
||||
|
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
import copy
|
||||
import time
|
||||
from urllib import parse
|
||||
|
||||
import fixtures
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
@ -19,7 +20,6 @@ import os_resource_classes as orc
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
|
||||
import nova.conf
|
||||
from nova import context
|
||||
|
@ -19,7 +19,6 @@ import inspect
|
||||
|
||||
import mock
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from six.moves import range
|
||||
|
||||
from nova import filters
|
||||
from nova import loadables
|
||||
|
@ -16,6 +16,7 @@
|
||||
Tests for Crypto module.
|
||||
"""
|
||||
|
||||
import io
|
||||
import os
|
||||
|
||||
from castellan.common import exception as castellan_exception
|
||||
@ -25,7 +26,6 @@ import mock
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
import paramiko
|
||||
import six
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova import crypto
|
||||
@ -210,7 +210,7 @@ class KeyPairTest(test.NoDBTestCase):
|
||||
self.assertEqual(bits, pkey.key_size)
|
||||
|
||||
def test_generate_key_pair_mocked_private_key(self):
|
||||
keyin = six.StringIO()
|
||||
keyin = io.StringIO()
|
||||
keyin.write(self.rsa_prv)
|
||||
keyin.seek(0)
|
||||
key = paramiko.RSAKey.from_private_key(keyin)
|
||||
|
@ -55,7 +55,7 @@ class TestJsonRef(test.NoDBTestCase):
|
||||
d = copy.deepcopy(input)
|
||||
|
||||
@mock.patch('oslo_serialization.jsonutils.load')
|
||||
@mock.patch('six.moves.builtins.open', new_callable=mock.mock_open())
|
||||
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
||||
def test_resolve_ref(self, mock_open, mock_json_load):
|
||||
mock_json_load.return_value = {'baz': 13}
|
||||
|
||||
@ -70,7 +70,7 @@ class TestJsonRef(test.NoDBTestCase):
|
||||
mock_open.assert_called_once_with('some/base/path/another.json', 'r+b')
|
||||
|
||||
@mock.patch('oslo_serialization.jsonutils.load')
|
||||
@mock.patch('six.moves.builtins.open', new_callable=mock.mock_open())
|
||||
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
||||
def test_resolve_ref_recursively(self, mock_open, mock_json_load):
|
||||
mock_json_load.side_effect = [
|
||||
# this is the content of direct_ref.json
|
||||
@ -94,7 +94,7 @@ class TestJsonRef(test.NoDBTestCase):
|
||||
'r+b')
|
||||
|
||||
@mock.patch('oslo_serialization.jsonutils.load')
|
||||
@mock.patch('six.moves.builtins.open', new_callable=mock.mock_open())
|
||||
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
||||
def test_resolve_ref_with_override(self, mock_open, mock_json_load):
|
||||
mock_json_load.return_value = {'baz': 13,
|
||||
'boo': 42}
|
||||
@ -112,7 +112,7 @@ class TestJsonRef(test.NoDBTestCase):
|
||||
mock_open.assert_called_once_with('some/base/path/another.json', 'r+b')
|
||||
|
||||
@mock.patch('oslo_serialization.jsonutils.load')
|
||||
@mock.patch('six.moves.builtins.open', new_callable=mock.mock_open())
|
||||
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
||||
def test_resolve_ref_with_nested_override(self, mock_open, mock_json_load):
|
||||
mock_json_load.return_value = {'baz': 13,
|
||||
'boo': {'a': 1,
|
||||
@ -134,7 +134,7 @@ class TestJsonRef(test.NoDBTestCase):
|
||||
mock_open.assert_called_once_with('some/base/path/another.json', 'r+b')
|
||||
|
||||
@mock.patch('oslo_serialization.jsonutils.load')
|
||||
@mock.patch('six.moves.builtins.open', new_callable=mock.mock_open())
|
||||
@mock.patch('builtins.open', new_callable=mock.mock_open())
|
||||
def test_resolve_ref_with_override_having_refs(self, mock_open,
|
||||
mock_json_load):
|
||||
mock_json_load.side_effect = [
|
||||
|
@ -13,12 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import importlib
|
||||
import inspect
|
||||
import os
|
||||
|
||||
from oslo_utils import importutils
|
||||
import osprofiler.opts as profiler
|
||||
import six.moves as six
|
||||
|
||||
from nova import conf
|
||||
from nova import test
|
||||
@ -44,7 +44,7 @@ class TestProfiler(test.NoDBTestCase):
|
||||
# reinitialize the metaclass after enabling osprofiler
|
||||
profiler.set_defaults(conf.CONF)
|
||||
self.flags(enabled=True, group='profiler')
|
||||
six.reload_module(importutils.import_module('nova.manager'))
|
||||
importlib.reload(importutils.import_module('nova.manager'))
|
||||
|
||||
classes = [
|
||||
'nova.compute.api.API',
|
||||
@ -64,7 +64,7 @@ class TestProfiler(test.NoDBTestCase):
|
||||
for clsname in classes:
|
||||
# give the metaclass and trace_cls() decorator a chance to patch
|
||||
# methods of the classes above
|
||||
six.reload_module(
|
||||
importlib.reload(
|
||||
importutils.import_module(clsname.rsplit('.', 1)[0]))
|
||||
cls = importutils.import_class(clsname)
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
import ddt
|
||||
import mock
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from six.moves import range
|
||||
|
||||
from nova.compute import api as compute
|
||||
import nova.conf
|
||||
|
@ -60,6 +60,5 @@ class TestUtilsTestCase(test.TestCase):
|
||||
self.assertTrue(test_utils.is_ipv6_supported())
|
||||
|
||||
with fixtures.MonkeyPatch('sys.platform', 'linux2'):
|
||||
with fixtures.MonkeyPatch('six.moves.builtins.open',
|
||||
fake_open):
|
||||
with fixtures.MonkeyPatch('builtins.open', fake_open):
|
||||
self.assertFalse(test_utils.is_ipv6_supported())
|
||||
|
@ -260,7 +260,7 @@ class TestCachedFile(test.NoDBTestCase):
|
||||
|
||||
fake_contents = "lorem ipsum"
|
||||
|
||||
with mock.patch('six.moves.builtins.open',
|
||||
with mock.patch('builtins.open',
|
||||
mock.mock_open(read_data=fake_contents)):
|
||||
fresh, data = utils.read_cached_file("/this/is/a/fake")
|
||||
|
||||
|
@ -19,7 +19,6 @@ import socket
|
||||
import sys
|
||||
|
||||
import mock
|
||||
from six.moves import range
|
||||
|
||||
from nova.compute import flavors
|
||||
import nova.conf
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
import mock
|
||||
from os_win import utilsfactory
|
||||
from six.moves import builtins
|
||||
|
||||
from nova import test
|
||||
|
||||
@ -26,8 +25,8 @@ class HyperVBaseTestCase(test.NoDBTestCase):
|
||||
super(HyperVBaseTestCase, self).setUp()
|
||||
|
||||
self._mock_wmi = mock.MagicMock()
|
||||
wmi_patcher = mock.patch.object(builtins, 'wmi', create=True,
|
||||
new=self._mock_wmi)
|
||||
wmi_patcher = mock.patch('builtins.wmi', create=True,
|
||||
new=self._mock_wmi)
|
||||
platform_patcher = mock.patch('sys.platform', 'win32')
|
||||
utilsfactory_patcher = mock.patch.object(utilsfactory, '_get_class')
|
||||
|
||||
|
@ -16,7 +16,6 @@ import os
|
||||
import time
|
||||
|
||||
import mock
|
||||
from six.moves import builtins
|
||||
|
||||
from nova import exception
|
||||
from nova.tests.unit.virt.hyperv import test_base
|
||||
@ -121,8 +120,8 @@ class PathUtilsTestCase(test_base.HyperVBaseTestCase):
|
||||
fake_windows_error = WindowsError
|
||||
self._pathutils.check_create_dir = mock.MagicMock(
|
||||
side_effect=WindowsError(pathutils.ERROR_INVALID_NAME))
|
||||
with mock.patch.object(builtins, 'WindowsError',
|
||||
fake_windows_error, create=True):
|
||||
with mock.patch('builtins.WindowsError',
|
||||
fake_windows_error, create=True):
|
||||
self.assertRaises(exception.AdminRequired,
|
||||
self._pathutils._get_instances_sub_dir,
|
||||
fake_dir_name)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from six.moves import builtins
|
||||
|
||||
from nova import exception
|
||||
from nova.tests.unit.virt.hyperv import test_base
|
||||
@ -89,7 +88,7 @@ class SerialConsoleOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
self._serialops.get_serial_console,
|
||||
mock.sentinel.instance_name)
|
||||
|
||||
@mock.patch.object(builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch("os.path.exists")
|
||||
def test_get_console_output_exception(self, fake_path_exists, fake_open):
|
||||
self._serialops._pathutils.get_vm_console_log_paths.return_value = [
|
||||
|
@ -60,7 +60,6 @@ from oslo_utils import units
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_utils import versionutils
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
from nova.api.metadata import base as instance_metadata
|
||||
from nova.compute import manager
|
||||
@ -15739,8 +15738,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||
with test.nested(
|
||||
mock.patch('os.path.exists',
|
||||
side_effect=mock_path_exists),
|
||||
mock.patch.object(six.moves.builtins, 'open',
|
||||
fake_open)):
|
||||
mock.patch('builtins.open', fake_open)):
|
||||
log_data = drvr.get_console_output(self.context,
|
||||
instance)
|
||||
finally:
|
||||
@ -20764,7 +20762,7 @@ class TestGuestConfigSysinfoSerialOS(test.NoDBTestCase):
|
||||
self.flags(sysinfo_serial="os", group="libvirt")
|
||||
theuuid = "56b40135-a973-4eb3-87bb-a2382a3e6dbc"
|
||||
with test.nested(
|
||||
mock.patch.object(six.moves.builtins, "open",
|
||||
mock.patch('builtins.open',
|
||||
mock.mock_open(read_data=theuuid)),
|
||||
self.patch_exists("/etc/machine-id", True)):
|
||||
self._test_get_guest_config_sysinfo_serial(theuuid)
|
||||
@ -20772,8 +20770,7 @@ class TestGuestConfigSysinfoSerialOS(test.NoDBTestCase):
|
||||
def test_get_guest_config_sysinfo_serial_os_empty_machine_id(self):
|
||||
self.flags(sysinfo_serial="os", group="libvirt")
|
||||
with test.nested(
|
||||
mock.patch.object(six.moves.builtins, "open",
|
||||
mock.mock_open(read_data="")),
|
||||
mock.patch('builtins.open', mock.mock_open(read_data="")),
|
||||
self.patch_exists("/etc/machine-id", True)):
|
||||
self.assertRaises(exception.NovaException,
|
||||
self._test_get_guest_config_sysinfo_serial,
|
||||
|
@ -23,10 +23,8 @@ import mock
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import builtins
|
||||
import testtools
|
||||
|
||||
|
||||
from nova.compute import vm_states
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
@ -959,7 +957,7 @@ SwapCached: 0 kB
|
||||
Active: 8381604 kB
|
||||
""")
|
||||
with test.nested(
|
||||
mock.patch.object(builtins, "open", m, create=True),
|
||||
mock.patch('builtins.open', m, create=True),
|
||||
mock.patch.object(host.Host, "get_connection"),
|
||||
) as (mock_file, mock_conn):
|
||||
mock_conn().getInfo.return_value = [
|
||||
@ -996,7 +994,7 @@ Active: 8381604 kB
|
||||
""")
|
||||
|
||||
with test.nested(
|
||||
mock.patch.object(six.moves.builtins, "open", m, create=True),
|
||||
mock.patch('builtins.open', m, create=True),
|
||||
mock.patch.object(host.Host,
|
||||
"list_guests"),
|
||||
mock.patch.object(libvirt_driver.LibvirtDriver,
|
||||
@ -1232,8 +1230,7 @@ Active: 8381604 kB
|
||||
read_data="""cg /cgroup/cpu,cpuacct cg opt1,cpu,opt3 0 0
|
||||
cg /cgroup/memory cg opt1,opt2 0 0
|
||||
""")
|
||||
with mock.patch(
|
||||
"six.moves.builtins.open", m, create=True):
|
||||
with mock.patch('builtins.open', m, create=True):
|
||||
self.assertTrue(self.host.is_cpu_control_policy_capable())
|
||||
|
||||
def test_is_cpu_control_policy_capable_ko(self):
|
||||
@ -1241,11 +1238,10 @@ cg /cgroup/memory cg opt1,opt2 0 0
|
||||
read_data="""cg /cgroup/cpu,cpuacct cg opt1,opt2,opt3 0 0
|
||||
cg /cgroup/memory cg opt1,opt2 0 0
|
||||
""")
|
||||
with mock.patch(
|
||||
"six.moves.builtins.open", m, create=True):
|
||||
with mock.patch('builtins.open', m, create=True):
|
||||
self.assertFalse(self.host.is_cpu_control_policy_capable())
|
||||
|
||||
@mock.patch('six.moves.builtins.open', side_effect=IOError)
|
||||
@mock.patch('builtins.open', side_effect=IOError)
|
||||
def test_is_cpu_control_policy_capable_ioerror(self, mock_open):
|
||||
self.assertFalse(self.host.is_cpu_control_policy_capable())
|
||||
|
||||
@ -1321,26 +1317,26 @@ class TestLibvirtSEVUnsupported(TestLibvirtSEV):
|
||||
'/sys/module/kvm_amd/parameters/sev')
|
||||
|
||||
@mock.patch.object(os.path, 'exists', return_value=True)
|
||||
@mock.patch.object(builtins, 'open', mock.mock_open(read_data="0\n"))
|
||||
@mock.patch('builtins.open', mock.mock_open(read_data="0\n"))
|
||||
def test_kernel_parameter_zero(self, fake_exists):
|
||||
self.assertFalse(self.host._kernel_supports_amd_sev())
|
||||
fake_exists.assert_called_once_with(
|
||||
'/sys/module/kvm_amd/parameters/sev')
|
||||
|
||||
@mock.patch.object(os.path, 'exists', return_value=True)
|
||||
@mock.patch.object(builtins, 'open', mock.mock_open(read_data="1\n"))
|
||||
@mock.patch('builtins.open', mock.mock_open(read_data="1\n"))
|
||||
def test_kernel_parameter_one(self, fake_exists):
|
||||
self.assertTrue(self.host._kernel_supports_amd_sev())
|
||||
fake_exists.assert_called_once_with(
|
||||
'/sys/module/kvm_amd/parameters/sev')
|
||||
|
||||
@mock.patch.object(os.path, 'exists', return_value=True)
|
||||
@mock.patch.object(builtins, 'open', mock.mock_open(read_data="1\n"))
|
||||
@mock.patch('builtins.open', mock.mock_open(read_data="1\n"))
|
||||
def test_unsupported_without_feature(self, fake_exists):
|
||||
self.assertFalse(self.host.supports_amd_sev)
|
||||
|
||||
@mock.patch.object(os.path, 'exists', return_value=True)
|
||||
@mock.patch.object(builtins, 'open', mock.mock_open(read_data="1\n"))
|
||||
@mock.patch('builtins.open', mock.mock_open(read_data="1\n"))
|
||||
@mock.patch.object(vc, '_domain_capability_features',
|
||||
new=vc._domain_capability_features_with_SEV_unsupported)
|
||||
def test_unsupported_with_feature(self, fake_exists):
|
||||
@ -1351,7 +1347,7 @@ class TestLibvirtSEVSupported(TestLibvirtSEV):
|
||||
"""Libvirt driver tests for when AMD SEV support is present."""
|
||||
|
||||
@mock.patch.object(os.path, 'exists', return_value=True)
|
||||
@mock.patch.object(builtins, 'open', mock.mock_open(read_data="1\n"))
|
||||
@mock.patch('builtins.open', mock.mock_open(read_data="1\n"))
|
||||
@mock.patch.object(vc, '_domain_capability_features',
|
||||
new=vc._domain_capability_features_with_SEV)
|
||||
def test_supported_with_feature(self, fake_exists):
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
|
||||
@ -24,7 +25,6 @@ from oslo_concurrency import processutils
|
||||
from oslo_log import formatters
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from six.moves import cStringIO
|
||||
|
||||
from nova.compute import manager as compute_manager
|
||||
import nova.conf
|
||||
@ -42,7 +42,7 @@ CONF = nova.conf.CONF
|
||||
def intercept_log_messages():
|
||||
try:
|
||||
mylog = logging.getLogger('nova')
|
||||
stream = cStringIO()
|
||||
stream = io.StringIO()
|
||||
handler = logging.logging.StreamHandler(stream)
|
||||
handler.setFormatter(formatters.ContextFormatter())
|
||||
mylog.logger.addHandler(handler)
|
||||
|
@ -26,7 +26,6 @@ from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import fileutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
import six
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova import context
|
||||
@ -549,19 +548,19 @@ sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
|
||||
|
||||
# Source is given, and matches source in /proc/mounts
|
||||
proc_mnt = mock.mock_open(read_data=proc_with_mnt)
|
||||
with mock.patch.object(six.moves.builtins, "open", proc_mnt):
|
||||
with mock.patch('builtins.open', proc_mnt):
|
||||
self.assertTrue(libvirt_utils.is_mounted(mount_path, source))
|
||||
|
||||
# Source is given, and doesn't match source in /proc/mounts
|
||||
proc_mnt = mock.mock_open(read_data=proc_wrong_mnt)
|
||||
with mock.patch.object(six.moves.builtins, "open", proc_mnt):
|
||||
with mock.patch('builtins.open', proc_mnt):
|
||||
self.assertFalse(libvirt_utils.is_mounted(mount_path, source))
|
||||
|
||||
# Source is given, and mountpoint isn't present in /proc/mounts
|
||||
# Note that this shouldn't occur, as os.path.ismount should have
|
||||
# previously returned False in this case.
|
||||
proc_umnt = mock.mock_open(read_data=proc_without_mnt)
|
||||
with mock.patch.object(six.moves.builtins, "open", proc_umnt):
|
||||
with mock.patch('builtins.open', proc_umnt):
|
||||
self.assertFalse(libvirt_utils.is_mounted(mount_path, source))
|
||||
|
||||
def test_find_disk_file_device(self):
|
||||
|
@ -15,10 +15,8 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from nova import test
|
||||
|
||||
from nova.virt.powervm import image
|
||||
|
||||
|
||||
@ -28,7 +26,7 @@ class TestImage(test.TestCase):
|
||||
@mock.patch('nova.image.glance.API', autospec=True)
|
||||
def test_stream_blockdev_to_glance(self, mock_api, mock_chown):
|
||||
mock_open = mock.mock_open()
|
||||
with mock.patch.object(six.moves.builtins, 'open', new=mock_open):
|
||||
with mock.patch('builtins.open', new=mock_open):
|
||||
image.stream_blockdev_to_glance('context', mock_api, 'image_id',
|
||||
'metadata', '/dev/disk')
|
||||
mock_chown.assert_called_with('/dev/disk')
|
||||
|
@ -122,7 +122,7 @@ class TestDiskImage(test.NoDBTestCase):
|
||||
response = io.StringIO(six.text_type(PROC_MOUNTS_CONTENTS))
|
||||
mock_open.return_value = response
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_mount(self, mock_open):
|
||||
self.mock_proc_mounts(mock_open)
|
||||
image = '/tmp/fake-image'
|
||||
@ -139,7 +139,7 @@ class TestDiskImage(test.NoDBTestCase):
|
||||
self.assertEqual(diskimage._mounter, fakemount)
|
||||
self.assertEqual(dev, '/dev/fake')
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_umount(self, mock_open):
|
||||
self.mock_proc_mounts(mock_open)
|
||||
|
||||
@ -159,7 +159,7 @@ class TestDiskImage(test.NoDBTestCase):
|
||||
diskimage.umount()
|
||||
self.assertIsNone(diskimage._mounter)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_teardown(self, mock_open):
|
||||
self.mock_proc_mounts(mock_open)
|
||||
|
||||
|
@ -16,7 +16,6 @@ import copy
|
||||
import mock
|
||||
import os
|
||||
from oslo_utils.fixture import uuidsentinel
|
||||
import six
|
||||
|
||||
from nova.compute import provider_tree
|
||||
from nova import conf
|
||||
@ -331,7 +330,7 @@ class TestZVMDriver(test.NoDBTestCase):
|
||||
allocations=None, network_info=self._network_info,
|
||||
block_device_info=None)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.get_remote_image_service')
|
||||
@mock.patch('nova.virt.zvm.utils.ConnectorClient.call')
|
||||
def test_snapshot(self, call, get_image_service, mock_open):
|
||||
@ -421,7 +420,7 @@ class TestZVMDriver(test.NoDBTestCase):
|
||||
mock_delete.assert_called_once_with(image_id)
|
||||
image_service.delete.assert_called_once_with(self._context, image_id)
|
||||
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('builtins.open')
|
||||
@mock.patch('nova.image.glance.get_remote_image_service')
|
||||
@mock.patch('nova.virt.zvm.utils.ConnectorClient.call')
|
||||
@mock.patch('nova.virt.zvm.hypervisor.Hypervisor.image_delete')
|
||||
|
@ -46,7 +46,6 @@ from oslo_utils import importutils
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
|
@ -27,7 +27,7 @@ def _load_config():
|
||||
# Don't load in global context, since we can't assume
|
||||
# these modules are accessible when distutils uses
|
||||
# this module
|
||||
from six.moves import configparser
|
||||
import configparser
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
|
@ -25,6 +25,7 @@ import gzip
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from openstack import exceptions as sdk_exc
|
||||
from oslo_log import log as logging
|
||||
@ -33,7 +34,6 @@ from oslo_service import loopingcall
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from tooz import hashring as hash_ring
|
||||
|
||||
from nova.api.metadata import base as instance_metadata
|
||||
|
@ -73,7 +73,6 @@ from oslo_utils import timeutils
|
||||
from oslo_utils import units
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
from nova.api.metadata import base as instance_metadata
|
||||
from nova.api.metadata import password
|
||||
@ -5835,7 +5834,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
def _create_serial_consoles(self, guest_cfg, num_ports, char_dev_cls,
|
||||
log_path):
|
||||
for port in six.moves.range(num_ports):
|
||||
for port in range(num_ports):
|
||||
console = char_dev_cls()
|
||||
console.port = port
|
||||
console.type = "tcp"
|
||||
@ -7409,7 +7408,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
parent_device, supported_types)
|
||||
|
||||
chosen_mdevs = []
|
||||
for c in six.moves.range(vgpus_asked):
|
||||
for c in range(vgpus_asked):
|
||||
chosen_mdev = None
|
||||
if mdevs_available:
|
||||
# Take the first available mdev
|
||||
@ -9682,7 +9681,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
if CONF.serial_console.enabled:
|
||||
num_ports = hardware.get_number_of_serial_ports(
|
||||
instance.flavor, instance.image_meta)
|
||||
for port in six.moves.range(num_ports):
|
||||
for port in range(num_ports):
|
||||
migrate_data.serial_listen_ports.append(
|
||||
serial_console.acquire_port(
|
||||
migrate_data.serial_listen_addr))
|
||||
|
@ -13,9 +13,10 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from zvmconnector import connector
|
||||
|
||||
from oslo_utils import fileutils
|
||||
|
@ -22,6 +22,7 @@ import collections
|
||||
import copy
|
||||
import functools
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
from cinderclient import api_versions as cinder_api_versions
|
||||
from cinderclient import apiclient as cinder_apiclient
|
||||
@ -36,7 +37,6 @@ from oslo_utils import excutils
|
||||
from oslo_utils import strutils
|
||||
import retrying
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
||||
from nova import availability_zones as az
|
||||
import nova.conf
|
||||
|
Loading…
x
Reference in New Issue
Block a user