Drop most of six importings
This update is to drop six, and also Python2 support. However, only `tacker/test/common/helpers.py` which defines a set of functions for Python2 is remained because `compact_byte()` is called from several test classes. Although it'is not so quite hard to drop, better to be done in another patch because so many changes shouldn't be included in a update. Here is a summary of changes. * Remove all six importing other than `helpers.py`. * Revise the order of importing modules becaseu it's checked strictly more in the recent pep8 test. * For the update, it removes a test `test_json_with_utf()` defined in `tacker/tests/unit/test_wsgi.py` because it's required only for Python2 and can be skipped for Python3, so no need to keep anymore. * Remove six from `requirements.txt` and `lower-constraints.txt`. Partial-bug: #1778644 Change-Id: Ib37fd00ab6836e4efc04d1c14c10f312379c7212 Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
This commit is contained in:
parent
78a753d564
commit
a3377de871
@ -127,7 +127,6 @@ Routes==2.3.1
|
||||
rsa==3.4.2
|
||||
setuptools==21.0.0
|
||||
simplejson==3.13.2
|
||||
six==1.10.0
|
||||
snowballstemmer==1.2.1
|
||||
sqlalchemy-filters==0.10.0
|
||||
sqlalchemy-migrate==0.11.0
|
||||
|
@ -19,7 +19,6 @@ WebOb>=1.7.1 # MIT
|
||||
python-heatclient>=1.10.0 # Apache-2.0
|
||||
python-keystoneclient>=3.8.0 # Apache-2.0
|
||||
alembic>=0.8.10 # MIT
|
||||
six>=1.10.0 # MIT
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
oslo.concurrency>=3.26.0 # Apache-2.0
|
||||
oslo.config>=5.2.0 # Apache-2.0
|
||||
|
@ -15,9 +15,5 @@
|
||||
|
||||
import gettext
|
||||
|
||||
import six
|
||||
|
||||
if six.PY2:
|
||||
gettext.install('tacker', unicode=1)
|
||||
else:
|
||||
gettext.install('tacker')
|
||||
gettext.install('tacker')
|
||||
|
@ -11,10 +11,13 @@
|
||||
# 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 urllib import parse
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.vnfm.monitor_drivers.token import Token
|
||||
from tacker import wsgi
|
||||
|
@ -19,7 +19,7 @@ from oslo_config import cfg
|
||||
import oslo_i18n
|
||||
from oslo_log import log as logging
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from six.moves.urllib import parse as urllib_parse
|
||||
from urllib import parse as urllib_parse
|
||||
from webob import exc
|
||||
|
||||
from tacker._i18n import _
|
||||
|
@ -20,7 +20,6 @@ import abc
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from tacker.common import exceptions as exception
|
||||
|
||||
@ -30,8 +29,7 @@ SUPPORTED_OP_ONE = ['eq', 'neq', 'gt', 'lt', 'gte', 'lte']
|
||||
SUPPORTED_OP_MULTI = ['in', 'nin', 'cont', 'ncont']
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseFilter(object):
|
||||
class BaseFilter(object, metaclass=abc.ABCMeta):
|
||||
"""Abstract base class for Filter classes."""
|
||||
|
||||
@abc.abstractmethod
|
||||
@ -185,8 +183,7 @@ class Filter(BaseFilter):
|
||||
|
||||
for value in self.values:
|
||||
error = False
|
||||
if attribute_info[1] == 'string' and not isinstance(value,
|
||||
six.string_types):
|
||||
if attribute_info[1] == 'string' and not isinstance(value, str):
|
||||
error = True
|
||||
elif attribute_info[1] == 'number':
|
||||
if not strutils.is_int_like(value):
|
||||
|
@ -16,7 +16,6 @@
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
import six
|
||||
|
||||
from tacker.api.common import _filters
|
||||
from tacker.common import exceptions as exception
|
||||
@ -68,8 +67,7 @@ class ParseStateMeta(type):
|
||||
return super(ParseStateMeta, mcs).__new__(mcs, name, bases, cls_dict)
|
||||
|
||||
|
||||
@six.add_metaclass(ParseStateMeta)
|
||||
class ParseState(object):
|
||||
class ParseState(object, metaclass=ParseStateMeta):
|
||||
"""Implement the core of parsing the policy language.
|
||||
|
||||
Uses a greedy reduction algorithm to reduce a sequence of tokens into
|
||||
|
@ -21,7 +21,6 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
import routes
|
||||
import six
|
||||
import webob.dec
|
||||
import webob.exc
|
||||
|
||||
@ -35,8 +34,7 @@ from tacker import wsgi
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class PluginInterface(object):
|
||||
class PluginInterface(object, metaclass=abc.ABCMeta):
|
||||
|
||||
@classmethod
|
||||
def __subclasshook__(cls, klass):
|
||||
|
@ -18,7 +18,6 @@ import re
|
||||
import netaddr
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.common import exceptions as n_exc
|
||||
@ -94,7 +93,7 @@ def _validate_string_or_none(data, max_len=None):
|
||||
|
||||
|
||||
def _validate_string(data, max_len=None):
|
||||
if not isinstance(data, six.string_types):
|
||||
if not isinstance(data, str):
|
||||
msg = _("'%s' is not a valid string") % data
|
||||
LOG.debug(msg)
|
||||
return msg
|
||||
@ -472,7 +471,7 @@ def _validate_non_negative(data, valid_values=None):
|
||||
|
||||
|
||||
def convert_to_boolean(data):
|
||||
if isinstance(data, six.string_types):
|
||||
if isinstance(data, str):
|
||||
val = data.lower()
|
||||
if val == "true" or val == "1":
|
||||
return True
|
||||
@ -539,7 +538,7 @@ def convert_none_to_empty_dict(value):
|
||||
def convert_to_list(data):
|
||||
if data is None:
|
||||
return []
|
||||
elif hasattr(data, '__iter__') and not isinstance(data, six.string_types):
|
||||
elif hasattr(data, '__iter__') and not isinstance(data, str):
|
||||
return list(data)
|
||||
else:
|
||||
return [data]
|
||||
|
@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import routes as routes_mapper
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from urllib import parse as urlparse
|
||||
import webob
|
||||
import webob.dec
|
||||
import webob.exc
|
||||
|
@ -21,8 +21,6 @@ Common parameter types for validating request Body.
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
import six
|
||||
|
||||
|
||||
def _is_printable(char):
|
||||
"""determine if a unicode code point is printable.
|
||||
@ -40,7 +38,7 @@ def _is_printable(char):
|
||||
|
||||
def _get_all_chars():
|
||||
for i in range(0xFFFF):
|
||||
yield six.unichr(i)
|
||||
yield chr(i)
|
||||
|
||||
|
||||
# build a regex that matches all printable characters. This allows
|
||||
|
@ -23,7 +23,6 @@ from jsonschema import exceptions as jsonschema_exc
|
||||
import netaddr
|
||||
from oslo_utils import uuidutils
|
||||
import rfc3986
|
||||
import six
|
||||
import webob
|
||||
|
||||
from tacker.common import exceptions as exception
|
||||
@ -65,7 +64,7 @@ def validate_mac_address_or_none(instance):
|
||||
|
||||
def _validate_query_parameter_without_value(parameter_name, instance):
|
||||
"""The query parameter is a flag without a value."""
|
||||
if not (isinstance(instance, six.text_type) and len(instance)):
|
||||
if not (isinstance(instance, str) and len(instance)):
|
||||
return True
|
||||
|
||||
msg = _("The parameter '%s' is a flag. It shouldn't contain any value.")
|
||||
@ -156,5 +155,4 @@ class _SchemaValidator(object):
|
||||
except TypeError as ex:
|
||||
# NOTE: If passing non string value to patternProperties parameter,
|
||||
# TypeError happens. Here is for catching the TypeError.
|
||||
detail = six.text_type(ex)
|
||||
raise exception.ValidationError(detail=detail)
|
||||
raise exception.ValidationError(detail=str(ex))
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import datetime
|
||||
import requests
|
||||
import six
|
||||
import tacker.conf
|
||||
import webob
|
||||
|
||||
@ -34,8 +33,8 @@ import json
|
||||
import re
|
||||
import traceback
|
||||
|
||||
from six.moves import http_client
|
||||
from six.moves.urllib import parse
|
||||
from http import client as http_client
|
||||
from urllib import parse
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.api.schemas import vnf_lcm
|
||||
@ -186,9 +185,8 @@ class VnfLcmController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
except Exception as exc:
|
||||
msg = _("Encountered error while fetching vnf: %s") % id
|
||||
LOG.debug("{}: {}".format(msg, six.text_type(exc)))
|
||||
raise webob.exc.HTTPInternalServerError(explanation=six.
|
||||
text_type(exc))
|
||||
LOG.debug("{}: {}".format(msg, str(exc)))
|
||||
raise webob.exc.HTTPInternalServerError(explanation=str(exc))
|
||||
return vnf
|
||||
|
||||
def _validate_flavour_and_inst_level(self, context, req_body,
|
||||
@ -463,11 +461,11 @@ class VnfLcmController(wsgi.Controller):
|
||||
return wsgi.ResponseObject(result, headers=headers)
|
||||
|
||||
except nfvo.VimDefaultNotDefined as exc:
|
||||
raise webob.exc.HTTPBadRequest(explanation=six.text_type(exc))
|
||||
raise webob.exc.HTTPBadRequest(explanation=str(exc))
|
||||
except(sqlexc.SQLAlchemyError, Exception)\
|
||||
as exc:
|
||||
raise webob.exc.HTTPInternalServerError(
|
||||
explanation=six.text_type(exc))
|
||||
explanation=str(exc))
|
||||
except webob.exc.HTTPNotFound as e:
|
||||
return self._make_problem_detail(str(e), 404,
|
||||
'Not Found')
|
||||
@ -566,7 +564,7 @@ class VnfLcmController(wsgi.Controller):
|
||||
self._validate_flavour_and_inst_level(context, req_body,
|
||||
vnf_instance)
|
||||
except exceptions.NotFound as ex:
|
||||
raise webob.exc.HTTPBadRequest(explanation=six.text_type(ex))
|
||||
raise webob.exc.HTTPBadRequest(explanation=str(ex))
|
||||
|
||||
instantiate_vnf_request = \
|
||||
objects.InstantiateVnfRequest.obj_from_primitive(
|
||||
|
@ -13,10 +13,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from http import client as http_client
|
||||
from io import BytesIO
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import webob
|
||||
import zipfile
|
||||
from zipfile import ZipFile
|
||||
|
||||
from glance_store import exceptions as store_exceptions
|
||||
from oslo_config import cfg
|
||||
@ -24,11 +28,6 @@ from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import http_client
|
||||
import webob
|
||||
import zipfile
|
||||
from zipfile import ZipFile
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.api.schemas import vnf_packages
|
||||
@ -256,7 +255,7 @@ class VnfPkgmController(wsgi.Controller):
|
||||
zip_file_size)
|
||||
else:
|
||||
chunk_size = zip_file_size
|
||||
response.headers['Content-Length'] = six.text_type(chunk_size)
|
||||
response.headers['Content-Length'] = str(chunk_size)
|
||||
return response
|
||||
|
||||
def _get_csar_zip_data(self, uuid, location, offset=0, chunk_size=None):
|
||||
@ -489,8 +488,7 @@ class VnfPkgmController(wsgi.Controller):
|
||||
get_vnf_package_vnfd(context, vnf_package)
|
||||
except exceptions.FailedToGetVnfdData as e:
|
||||
LOG.error(e.msg)
|
||||
raise webob.exc.HTTPInternalServerError(
|
||||
explanation=six.text_type(e.msg))
|
||||
raise webob.exc.HTTPInternalServerError(explanation=str(e.msg))
|
||||
|
||||
if 'text/plain' in accept_headers:
|
||||
# Checking for yaml files only. This is required when there is
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import six
|
||||
import tempfile
|
||||
|
||||
from cryptography import fernet
|
||||
@ -140,10 +139,7 @@ class KubernetesHTTPAPI(object):
|
||||
ca_cert = re.sub(r'END\nCERT', r'END CERT', ca_cert)
|
||||
try:
|
||||
with open(file_path, 'w') as f:
|
||||
if six.PY2:
|
||||
f.write(ca_cert.decode('utf-8'))
|
||||
else:
|
||||
f.write(ca_cert)
|
||||
f.write(ca_cert)
|
||||
LOG.debug('ca cert temp file successfully stored in %s',
|
||||
file_path)
|
||||
except IOError:
|
||||
|
@ -12,26 +12,26 @@
|
||||
# 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 copy import deepcopy
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from urllib.parse import urlparse
|
||||
from urllib import request as urllib2
|
||||
import yaml
|
||||
import zipfile
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from toscaparser.prereq.csar import CSAR
|
||||
from toscaparser.tosca_template import ToscaTemplate
|
||||
import zipfile
|
||||
|
||||
from tacker.common import exceptions
|
||||
import tacker.conf
|
||||
from tacker.extensions import vnfm
|
||||
import urllib.request as urllib2
|
||||
|
||||
|
||||
HASH_DICT = {
|
||||
|
@ -28,6 +28,7 @@ import random
|
||||
import re
|
||||
import signal
|
||||
import socket
|
||||
from stevedore import driver
|
||||
import string
|
||||
import sys
|
||||
|
||||
@ -38,9 +39,8 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
from six.moves import urllib
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from stevedore import driver
|
||||
import urllib
|
||||
from urllib import parse as urlparse
|
||||
try:
|
||||
from eventlet import sleep
|
||||
except ImportError:
|
||||
|
@ -17,7 +17,6 @@ from datetime import datetime
|
||||
import weakref
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
from sqlalchemy.orm import exc as orm_exc
|
||||
from sqlalchemy import sql
|
||||
|
||||
@ -94,13 +93,13 @@ class CommonDbMixin(object):
|
||||
model_hooks = self._model_query_hooks.get(model, {})
|
||||
for _name, hooks in model_hooks.items():
|
||||
query_hook = hooks.get('query')
|
||||
if isinstance(query_hook, six.string_types):
|
||||
if isinstance(query_hook, str):
|
||||
query_hook = getattr(self, query_hook, None)
|
||||
if query_hook:
|
||||
query = query_hook(context, model, query)
|
||||
|
||||
filter_hook = hooks.get('filter')
|
||||
if isinstance(filter_hook, six.string_types):
|
||||
if isinstance(filter_hook, str):
|
||||
filter_hook = getattr(self, filter_hook, None)
|
||||
if filter_hook:
|
||||
query_filter = filter_hook(context, model, query_filter)
|
||||
@ -146,7 +145,7 @@ class CommonDbMixin(object):
|
||||
model_hooks = self._model_query_hooks.get(model, {})
|
||||
for _name, hooks in model_hooks.items():
|
||||
result_filter = hooks.get('result_filters', None)
|
||||
if isinstance(result_filter, six.string_types):
|
||||
if isinstance(result_filter, str):
|
||||
result_filter = getattr(self, result_filter, None)
|
||||
|
||||
if result_filter:
|
||||
@ -159,7 +158,7 @@ class CommonDbMixin(object):
|
||||
for func in self._dict_extend_functions.get(
|
||||
resource_type, []):
|
||||
args = (response, db_object)
|
||||
if isinstance(func, six.string_types):
|
||||
if isinstance(func, str):
|
||||
func = getattr(self, func, None)
|
||||
else:
|
||||
# must call unbound method - use self as 1st argument
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six import moves
|
||||
import sqlalchemy
|
||||
from sqlalchemy.orm.properties import RelationshipProperty
|
||||
|
||||
@ -85,7 +84,7 @@ def paginate_query(query, model, limit, sorts, marker_obj=None):
|
||||
criteria_list = []
|
||||
for i, sort in enumerate(sorts):
|
||||
crit_attrs = [(getattr(model, sorts[j][0]) == marker_values[j])
|
||||
for j in moves.xrange(i)]
|
||||
for j in range(i)]
|
||||
model_attr = getattr(model, sort[0])
|
||||
if sort[1]:
|
||||
crit_attrs.append((model_attr > marker_values[i]))
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.api import extensions
|
||||
from tacker.api.v1 import attributes as attr
|
||||
@ -137,8 +135,8 @@ class Common_services(extensions.ExtensionDescriptor):
|
||||
return version_map.get(version, {})
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class CommonServicesPluginBase(service_base.NFVPluginBase):
|
||||
class CommonServicesPluginBase(service_base.NFVPluginBase,
|
||||
metaclass=abc.ABCMeta):
|
||||
def get_plugin_name(self):
|
||||
return constants.COMMONSERVICES
|
||||
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.api import extensions
|
||||
from tacker.api.v1 import attributes as attr
|
||||
@ -870,8 +868,7 @@ class Nfvo(extensions.ExtensionDescriptor):
|
||||
return version_map.get(version, {})
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class NFVOPluginBase(service_base.NFVPluginBase):
|
||||
class NFVOPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||
def get_plugin_name(self):
|
||||
return constants.NFVO
|
||||
|
||||
|
@ -11,15 +11,13 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import six
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.common import exceptions
|
||||
from tacker.services import service_base
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class NSPluginBase(service_base.NFVPluginBase):
|
||||
class NSPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_nsd(self, context, nsd):
|
||||
|
@ -14,13 +14,11 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import six
|
||||
|
||||
from tacker.services import service_base
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VNFFGPluginBase(service_base.NFVPluginBase):
|
||||
class VNFFGPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_vnffgd(self, context, vnffgd):
|
||||
|
@ -16,7 +16,6 @@
|
||||
import abc
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.api import extensions
|
||||
@ -607,8 +606,7 @@ class Vnfm(extensions.ExtensionDescriptor):
|
||||
return version_map.get(version, {})
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VNFMPluginBase(service_base.NFVPluginBase):
|
||||
class VNFMPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||
def get_plugin_name(self):
|
||||
return constants.VNFM
|
||||
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
import base64
|
||||
import os
|
||||
import urllib
|
||||
|
||||
import glance_store
|
||||
from glance_store import exceptions as store_exceptions
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import units
|
||||
from six.moves import urllib
|
||||
|
||||
from tacker.common import exceptions
|
||||
from tacker.common import utils
|
||||
@ -148,8 +148,7 @@ def _get_csar_chunks(package_uuid, location, offset, chunk_size):
|
||||
def _add_basic_auth(request, username, password):
|
||||
"""A helper function to add basic authentication.
|
||||
|
||||
This function adds basic authentication information to a six.moves.urllib
|
||||
request.
|
||||
This function adds basic authentication information to a urllib request.
|
||||
"""
|
||||
auth_str = base64.encodestring(('%s:%s' % (
|
||||
username, password)).encode()).decode().strip()
|
||||
|
@ -19,11 +19,8 @@ Key manager API
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class KeyManager(object):
|
||||
class KeyManager(object, metaclass=abc.ABCMeta):
|
||||
"""Base Key Manager Interface
|
||||
|
||||
A Key Manager is responsible for creating, reading, and deleting keys.
|
||||
|
@ -15,13 +15,10 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from tacker.api import extensions
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VimAbstractDriver(extensions.PluginInterface):
|
||||
class VimAbstractDriver(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_type(self):
|
||||
|
@ -15,7 +15,6 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from keystoneauth1 import exceptions
|
||||
@ -253,10 +252,7 @@ class OpenStack_Driver(abstract_vim_driver.VimAbstractDriver,
|
||||
key_file = os.path.join(CONF.vim_keys.openstack, vim_id)
|
||||
try:
|
||||
with open(key_file, 'wb') as f:
|
||||
if six.PY2:
|
||||
f.write(fernet_key.decode('utf-8'))
|
||||
else:
|
||||
f.write(fernet_key)
|
||||
f.write(fernet_key)
|
||||
LOG.debug('VIM auth successfully stored for vim %s',
|
||||
vim_id)
|
||||
except IOError:
|
||||
|
@ -12,13 +12,10 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from tacker.api import extensions
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VnffgAbstractDriver(extensions.PluginInterface):
|
||||
class VnffgAbstractDriver(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_type(self):
|
||||
|
@ -23,7 +23,6 @@ from oslo_log import log as logging
|
||||
from oslo_policy import policy
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from tacker._i18n import _
|
||||
from tacker.api.v1 import attributes
|
||||
@ -297,7 +296,7 @@ class OwnerCheck(policy.Check):
|
||||
LOG.exception('Policy check error while calling %s!', f)
|
||||
match = self.match % target
|
||||
if self.kind in creds:
|
||||
return match == six.text_type(creds[self.kind])
|
||||
return match == str(creds[self.kind])
|
||||
return False
|
||||
|
||||
|
||||
|
@ -15,13 +15,10 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from tacker.api import extensions
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class NFVPluginBase(extensions.PluginInterface):
|
||||
class NFVPluginBase(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||
"""Define base interface for any Advanced Service plugin."""
|
||||
supported_extension_aliases = []
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
from copy import deepcopy
|
||||
import ddt
|
||||
import os
|
||||
from six.moves import urllib
|
||||
import tempfile
|
||||
import time
|
||||
import urllib
|
||||
import zipfile
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -16,7 +16,6 @@
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import six
|
||||
from webob import exc
|
||||
|
||||
from tacker.api.v1 import base as v1_base
|
||||
@ -126,7 +125,7 @@ class VIMCreateTestCase(base.TestCase):
|
||||
exp = self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
request, vim_dict)
|
||||
self.assertEqual(msg, six.text_type(exp))
|
||||
self.assertEqual(msg, str(exp))
|
||||
|
||||
@ddt.data("", " ", None, 123)
|
||||
def test_create_vim_with_invalid_type(self, value):
|
||||
@ -152,7 +151,7 @@ class VIMCreateTestCase(base.TestCase):
|
||||
exp = self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
request, vim_dict)
|
||||
self.assertEqual(msg, six.text_type(exp))
|
||||
self.assertEqual(msg, str(exp))
|
||||
|
||||
@ddt.data('', 'testing', {})
|
||||
def test_create_vim_invalid_vim_project(self, value):
|
||||
@ -167,4 +166,4 @@ class VIMCreateTestCase(base.TestCase):
|
||||
exp = self.assertRaises(exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
request, vim_dict)
|
||||
self.assertEqual(msg, six.text_type(exp))
|
||||
self.assertEqual(msg, str(exp))
|
||||
|
@ -19,8 +19,7 @@ from unittest import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_policy import policy as common_policy
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from urllib import parse as urlparse
|
||||
import webob
|
||||
from webob import exc
|
||||
import webtest
|
||||
@ -932,8 +931,7 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
|
||||
return_value.update(initial_input['port'])
|
||||
|
||||
instance = self.plugin.return_value
|
||||
instance.get_network.return_value = {'tenant_id':
|
||||
six.text_type(tenant_id)}
|
||||
instance.get_network.return_value = {'tenant_id': str(tenant_id)}
|
||||
instance.get_ports_count.return_value = 1
|
||||
instance.create_port.return_value = return_value
|
||||
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
||||
|
@ -21,15 +21,16 @@ import json
|
||||
import os
|
||||
import requests
|
||||
import shutil
|
||||
import six.moves.urllib.error as urlerr
|
||||
import sys
|
||||
import tacker.conf
|
||||
import unittest
|
||||
from unittest import mock
|
||||
import urllib
|
||||
from urllib import error as urlerr
|
||||
import yaml
|
||||
|
||||
from glance_store import exceptions as store_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves import urllib
|
||||
|
||||
from tacker import auth
|
||||
from tacker.common import coordination
|
||||
@ -37,6 +38,7 @@ from tacker.common import csar_utils
|
||||
from tacker.common import driver_manager
|
||||
from tacker.common import exceptions
|
||||
from tacker.conductor import conductor_server
|
||||
import tacker.conf
|
||||
from tacker import context
|
||||
from tacker import context as t_context
|
||||
from tacker.db.db_sqlalchemy import models
|
||||
@ -59,8 +61,6 @@ from tacker.tests import utils
|
||||
from tacker.tests import uuidsentinel
|
||||
from tacker.vnfm import nfvo_client as test_nfvo_client
|
||||
from tacker.vnfm import vim_client
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
|
||||
CONF = tacker.conf.CONF
|
||||
|
@ -102,7 +102,7 @@ class TestCli(base.BaseTestCase):
|
||||
with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
|
||||
fc.return_value.get_heads.return_value = heads
|
||||
fc.return_value.get_current_head.return_value = heads[0]
|
||||
with mock.patch('six.moves.builtins.open') as mock_open:
|
||||
with mock.patch('builtins.open') as mock_open:
|
||||
mock_open.return_value.__enter__ = lambda s: s
|
||||
mock_open.return_value.__exit__ = mock.Mock()
|
||||
mock_open.return_value.read.return_value = file_content
|
||||
@ -148,7 +148,7 @@ class TestCli(base.BaseTestCase):
|
||||
with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
|
||||
fc.return_value.get_heads.return_value = ['a']
|
||||
fc.return_value.get_current_head.return_value = 'a'
|
||||
with mock.patch('six.moves.builtins.open') as mock_open:
|
||||
with mock.patch('builtins.open') as mock_open:
|
||||
mock_open.return_value.__enter__ = lambda s: s
|
||||
mock_open.return_value.__exit__ = mock.Mock()
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
from unittest import mock
|
||||
|
||||
import glance_store
|
||||
from six.moves import urllib
|
||||
import six.moves.urllib.error as urlerr
|
||||
import urllib
|
||||
from urllib import error as urlerr
|
||||
|
||||
from tacker.common import exceptions
|
||||
import tacker.conf
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from tacker.objects import base
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.unit import base as test_base
|
||||
@ -24,8 +22,6 @@ class TestString(test_base.TestCase):
|
||||
super(TestString, self).setUp()
|
||||
self.field = fields.StringField()
|
||||
self.coerce_good_values = [('foo', 'foo'), (1, '1'), (True, 'True')]
|
||||
if six.PY2:
|
||||
self.coerce_good_values.append((int(1), '1'))
|
||||
self.coerce_bad_values = [None]
|
||||
|
||||
def test_stringify(self):
|
||||
|
@ -15,15 +15,14 @@
|
||||
|
||||
"""Test of Policy Engine For Tacker"""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import fixtures
|
||||
import six
|
||||
import io
|
||||
from unittest import mock
|
||||
from urllib import request as urlrequest
|
||||
|
||||
from oslo_policy import policy as common_policy
|
||||
from oslo_serialization import jsonutils as json
|
||||
from oslo_utils import importutils
|
||||
from six.moves.urllib import request as urlrequest
|
||||
|
||||
import tacker
|
||||
from tacker.api.v1 import attributes
|
||||
@ -127,7 +126,7 @@ class PolicyTestCase(base.BaseTestCase):
|
||||
def test_enforce_http_true(self):
|
||||
|
||||
def fakeurlopen(url, post_data):
|
||||
return six.StringIO("True")
|
||||
return io.StringIO("True")
|
||||
|
||||
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
||||
action = "example:get_http"
|
||||
@ -138,7 +137,7 @@ class PolicyTestCase(base.BaseTestCase):
|
||||
def test_enforce_http_false(self):
|
||||
|
||||
def fakeurlopen(url, post_data):
|
||||
return six.StringIO("False")
|
||||
return io.StringIO("False")
|
||||
|
||||
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
||||
action = "example:get_http"
|
||||
|
@ -14,20 +14,18 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
from unittest import mock
|
||||
|
||||
import oslo_i18n
|
||||
import socket
|
||||
|
||||
from oslo_config import cfg
|
||||
import six.moves.urllib.request as urllibrequest
|
||||
import testtools
|
||||
from unittest import mock
|
||||
from urllib import request as urllibrequest
|
||||
import webob
|
||||
import webob.exc
|
||||
|
||||
from oslo_config import cfg
|
||||
import oslo_i18n
|
||||
|
||||
from tacker.common import exceptions as exception
|
||||
from tacker.tests import base
|
||||
from tacker.tests.common import helpers
|
||||
from tacker import wsgi
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -467,18 +465,6 @@ class JSONDictSerializerTest(base.BaseTestCase):
|
||||
|
||||
self.assertEqual(expected_json, result)
|
||||
|
||||
# The tested behaviour is only meant to be witnessed in Python 2, so it is
|
||||
# OK to skip this test with Python 3.
|
||||
@helpers.requires_py2
|
||||
def test_json_with_utf8(self):
|
||||
input_dict = dict(servers=dict(a=(2, '\xe7\xbd\x91\xe7\xbb\x9c')))
|
||||
expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}'
|
||||
serializer = wsgi.JSONDictSerializer()
|
||||
result = serializer.serialize(input_dict)
|
||||
result = result.replace(b'\n', b'').replace(b' ', b'')
|
||||
|
||||
self.assertEqual(expected_json, result)
|
||||
|
||||
def test_json_with_unicode(self):
|
||||
input_dict = dict(servers=dict(a=(2, u'\u7f51\u7edc')))
|
||||
expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}'
|
||||
|
@ -16,8 +16,6 @@
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
from six import moves
|
||||
|
||||
from tacker.tests import base
|
||||
from tacker.tests import post_mortem_debug
|
||||
|
||||
@ -64,7 +62,7 @@ class TestGetIgnoredTraceback(base.BaseTestCase):
|
||||
|
||||
tb = root_tb
|
||||
tracebacks = [tb]
|
||||
for x in moves.xrange(len(ignored_bit_array) - 1):
|
||||
for x in range(len(ignored_bit_array) - 1):
|
||||
tb.tb_next = mock.Mock()
|
||||
tb = tb.tb_next
|
||||
tracebacks.append(tb)
|
||||
|
@ -12,19 +12,19 @@
|
||||
# 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 unittest import mock
|
||||
|
||||
import codecs
|
||||
import os
|
||||
|
||||
import ddt
|
||||
from http import client as http_client
|
||||
import json
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves import http_client
|
||||
import os
|
||||
from unittest import mock
|
||||
import urllib
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from tacker.api.vnflcm.v1 import controller
|
||||
from tacker.api.vnflcm.v1 import sync_resource
|
||||
from tacker.common import exceptions
|
||||
|
@ -12,10 +12,9 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import six.moves.urllib.error as urlerr
|
||||
import testtools
|
||||
from unittest import mock
|
||||
from urllib import error as urlerr
|
||||
|
||||
from tacker.vnfm.monitor_drivers.http_ping import http_ping
|
||||
|
||||
@ -26,7 +25,7 @@ class TestVNFMonitorHTTPPing(testtools.TestCase):
|
||||
super(TestVNFMonitorHTTPPing, self).setUp()
|
||||
self.monitor_http_ping = http_ping.VNFMonitorHTTPPing()
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_monitor_call_for_success(self, mock_urlopen):
|
||||
test_vnf = {}
|
||||
test_kwargs = {
|
||||
@ -36,7 +35,7 @@ class TestVNFMonitorHTTPPing(testtools.TestCase):
|
||||
test_kwargs)
|
||||
mock_urlopen.assert_called_once_with('http://a.b.c.d:80', timeout=5)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_monitor_call_for_failure(self, mock_urlopen):
|
||||
mock_urlopen.side_effect = urlerr.URLError("MOCK Error")
|
||||
test_vnf = {}
|
||||
|
@ -12,16 +12,18 @@
|
||||
# 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 unittest import mock
|
||||
|
||||
|
||||
import ddt
|
||||
from http import client as http_client
|
||||
import json
|
||||
import os
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves import http_client
|
||||
from six.moves import urllib
|
||||
from unittest import mock
|
||||
import urllib
|
||||
from webob import exc
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from tacker.api.vnfpkgm.v1 import controller
|
||||
from tacker.common import exceptions as tacker_exc
|
||||
from tacker.conductor.conductorrpc.vnf_pkgm_rpc import VNFPackageRPCAPI
|
||||
|
@ -15,11 +15,8 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VnfInstanceAbstractDriver(object):
|
||||
class VnfInstanceAbstractDriver(object, metaclass=abc.ABCMeta):
|
||||
|
||||
@abc.abstractmethod
|
||||
def instantiate_vnf(self, context, vnf_instance_id, instantiate_vnf_req):
|
||||
|
@ -16,7 +16,6 @@
|
||||
import copy
|
||||
import io
|
||||
import os
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from oslo_config import cfg
|
||||
@ -373,7 +372,7 @@ def _create_grant_request(vnfd_dict, package_uuid):
|
||||
artifacts = value.get('artifacts', {})
|
||||
for artifact, sw_image in artifacts.items():
|
||||
artifact_image_path = None
|
||||
if isinstance(sw_image, six.string_types):
|
||||
if isinstance(sw_image, str):
|
||||
artifact_image_path = sw_image
|
||||
elif sw_image.get('type') == 'tosca.artifacts.nfv.SwImage':
|
||||
artifact_image_path = sw_image.get('file', {})
|
||||
|
@ -18,7 +18,6 @@ from datetime import datetime
|
||||
import functools
|
||||
import inspect
|
||||
import re
|
||||
import six
|
||||
import time
|
||||
import traceback
|
||||
import yaml
|
||||
@ -533,7 +532,7 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
|
||||
"%(id)s before respawning. The vnf is in "
|
||||
"inconsistent state. Error: %(error)s")
|
||||
LOG.error(err_msg % {"id": vnf_instance.id,
|
||||
"error": six.text_type(exc)})
|
||||
"error": str(exc)})
|
||||
raise exceptions.VnfHealFailed(id=vn |