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
|
rsa==3.4.2
|
||||||
setuptools==21.0.0
|
setuptools==21.0.0
|
||||||
simplejson==3.13.2
|
simplejson==3.13.2
|
||||||
six==1.10.0
|
|
||||||
snowballstemmer==1.2.1
|
snowballstemmer==1.2.1
|
||||||
sqlalchemy-filters==0.10.0
|
sqlalchemy-filters==0.10.0
|
||||||
sqlalchemy-migrate==0.11.0
|
sqlalchemy-migrate==0.11.0
|
||||||
|
|
|
@ -19,7 +19,6 @@ WebOb>=1.7.1 # MIT
|
||||||
python-heatclient>=1.10.0 # Apache-2.0
|
python-heatclient>=1.10.0 # Apache-2.0
|
||||||
python-keystoneclient>=3.8.0 # Apache-2.0
|
python-keystoneclient>=3.8.0 # Apache-2.0
|
||||||
alembic>=0.8.10 # MIT
|
alembic>=0.8.10 # MIT
|
||||||
six>=1.10.0 # MIT
|
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
stevedore>=1.20.0 # Apache-2.0
|
||||||
oslo.concurrency>=3.26.0 # Apache-2.0
|
oslo.concurrency>=3.26.0 # Apache-2.0
|
||||||
oslo.config>=5.2.0 # Apache-2.0
|
oslo.config>=5.2.0 # Apache-2.0
|
||||||
|
|
|
@ -15,9 +15,5 @@
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
if six.PY2:
|
gettext.install('tacker')
|
||||||
gettext.install('tacker', unicode=1)
|
|
||||||
else:
|
|
||||||
gettext.install('tacker')
|
|
||||||
|
|
|
@ -11,10 +11,13 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from urllib import parse
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from six.moves.urllib import parse
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.vnfm.monitor_drivers.token import Token
|
from tacker.vnfm.monitor_drivers.token import Token
|
||||||
from tacker import wsgi
|
from tacker import wsgi
|
||||||
|
|
|
@ -19,7 +19,7 @@ from oslo_config import cfg
|
||||||
import oslo_i18n
|
import oslo_i18n
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_policy import policy as oslo_policy
|
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 webob import exc
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
|
|
|
@ -20,7 +20,6 @@ import abc
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.common import exceptions as exception
|
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']
|
SUPPORTED_OP_MULTI = ['in', 'nin', 'cont', 'ncont']
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseFilter(object, metaclass=abc.ABCMeta):
|
||||||
class BaseFilter(object):
|
|
||||||
"""Abstract base class for Filter classes."""
|
"""Abstract base class for Filter classes."""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -185,8 +183,7 @@ class Filter(BaseFilter):
|
||||||
|
|
||||||
for value in self.values:
|
for value in self.values:
|
||||||
error = False
|
error = False
|
||||||
if attribute_info[1] == 'string' and not isinstance(value,
|
if attribute_info[1] == 'string' and not isinstance(value, str):
|
||||||
six.string_types):
|
|
||||||
error = True
|
error = True
|
||||||
elif attribute_info[1] == 'number':
|
elif attribute_info[1] == 'number':
|
||||||
if not strutils.is_int_like(value):
|
if not strutils.is_int_like(value):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api.common import _filters
|
from tacker.api.common import _filters
|
||||||
from tacker.common import exceptions as exception
|
from tacker.common import exceptions as exception
|
||||||
|
@ -68,8 +67,7 @@ class ParseStateMeta(type):
|
||||||
return super(ParseStateMeta, mcs).__new__(mcs, name, bases, cls_dict)
|
return super(ParseStateMeta, mcs).__new__(mcs, name, bases, cls_dict)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(ParseStateMeta)
|
class ParseState(object, metaclass=ParseStateMeta):
|
||||||
class ParseState(object):
|
|
||||||
"""Implement the core of parsing the policy language.
|
"""Implement the core of parsing the policy language.
|
||||||
|
|
||||||
Uses a greedy reduction algorithm to reduce a sequence of tokens into
|
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_log import log as logging
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import routes
|
import routes
|
||||||
import six
|
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
|
@ -35,8 +34,7 @@ from tacker import wsgi
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class PluginInterface(object, metaclass=abc.ABCMeta):
|
||||||
class PluginInterface(object):
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __subclasshook__(cls, klass):
|
def __subclasshook__(cls, klass):
|
||||||
|
|
|
@ -18,7 +18,6 @@ import re
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.common import exceptions as n_exc
|
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):
|
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
|
msg = _("'%s' is not a valid string") % data
|
||||||
LOG.debug(msg)
|
LOG.debug(msg)
|
||||||
return msg
|
return msg
|
||||||
|
@ -472,7 +471,7 @@ def _validate_non_negative(data, valid_values=None):
|
||||||
|
|
||||||
|
|
||||||
def convert_to_boolean(data):
|
def convert_to_boolean(data):
|
||||||
if isinstance(data, six.string_types):
|
if isinstance(data, str):
|
||||||
val = data.lower()
|
val = data.lower()
|
||||||
if val == "true" or val == "1":
|
if val == "true" or val == "1":
|
||||||
return True
|
return True
|
||||||
|
@ -539,7 +538,7 @@ def convert_none_to_empty_dict(value):
|
||||||
def convert_to_list(data):
|
def convert_to_list(data):
|
||||||
if data is None:
|
if data is None:
|
||||||
return []
|
return []
|
||||||
elif hasattr(data, '__iter__') and not isinstance(data, six.string_types):
|
elif hasattr(data, '__iter__') and not isinstance(data, str):
|
||||||
return list(data)
|
return list(data)
|
||||||
else:
|
else:
|
||||||
return [data]
|
return [data]
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import routes as routes_mapper
|
import routes as routes_mapper
|
||||||
import six.moves.urllib.parse as urlparse
|
from urllib import parse as urlparse
|
||||||
import webob
|
import webob
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
|
@ -21,8 +21,6 @@ Common parameter types for validating request Body.
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
def _is_printable(char):
|
def _is_printable(char):
|
||||||
"""determine if a unicode code point is printable.
|
"""determine if a unicode code point is printable.
|
||||||
|
@ -40,7 +38,7 @@ def _is_printable(char):
|
||||||
|
|
||||||
def _get_all_chars():
|
def _get_all_chars():
|
||||||
for i in range(0xFFFF):
|
for i in range(0xFFFF):
|
||||||
yield six.unichr(i)
|
yield chr(i)
|
||||||
|
|
||||||
|
|
||||||
# build a regex that matches all printable characters. This allows
|
# build a regex that matches all printable characters. This allows
|
||||||
|
|
|
@ -23,7 +23,6 @@ from jsonschema import exceptions as jsonschema_exc
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import rfc3986
|
import rfc3986
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from tacker.common import exceptions as exception
|
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):
|
def _validate_query_parameter_without_value(parameter_name, instance):
|
||||||
"""The query parameter is a flag without a value."""
|
"""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
|
return True
|
||||||
|
|
||||||
msg = _("The parameter '%s' is a flag. It shouldn't contain any value.")
|
msg = _("The parameter '%s' is a flag. It shouldn't contain any value.")
|
||||||
|
@ -156,5 +155,4 @@ class _SchemaValidator(object):
|
||||||
except TypeError as ex:
|
except TypeError as ex:
|
||||||
# NOTE: If passing non string value to patternProperties parameter,
|
# NOTE: If passing non string value to patternProperties parameter,
|
||||||
# TypeError happens. Here is for catching the TypeError.
|
# TypeError happens. Here is for catching the TypeError.
|
||||||
detail = six.text_type(ex)
|
raise exception.ValidationError(detail=str(ex))
|
||||||
raise exception.ValidationError(detail=detail)
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import requests
|
import requests
|
||||||
import six
|
|
||||||
import tacker.conf
|
import tacker.conf
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
|
@ -34,8 +33,8 @@ import json
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from six.moves import http_client
|
from http import client as http_client
|
||||||
from six.moves.urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.api.schemas import vnf_lcm
|
from tacker.api.schemas import vnf_lcm
|
||||||
|
@ -186,9 +185,8 @@ class VnfLcmController(wsgi.Controller):
|
||||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
msg = _("Encountered error while fetching vnf: %s") % id
|
msg = _("Encountered error while fetching vnf: %s") % id
|
||||||
LOG.debug("{}: {}".format(msg, six.text_type(exc)))
|
LOG.debug("{}: {}".format(msg, str(exc)))
|
||||||
raise webob.exc.HTTPInternalServerError(explanation=six.
|
raise webob.exc.HTTPInternalServerError(explanation=str(exc))
|
||||||
text_type(exc))
|
|
||||||
return vnf
|
return vnf
|
||||||
|
|
||||||
def _validate_flavour_and_inst_level(self, context, req_body,
|
def _validate_flavour_and_inst_level(self, context, req_body,
|
||||||
|
@ -463,11 +461,11 @@ class VnfLcmController(wsgi.Controller):
|
||||||
return wsgi.ResponseObject(result, headers=headers)
|
return wsgi.ResponseObject(result, headers=headers)
|
||||||
|
|
||||||
except nfvo.VimDefaultNotDefined as exc:
|
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)\
|
except(sqlexc.SQLAlchemyError, Exception)\
|
||||||
as exc:
|
as exc:
|
||||||
raise webob.exc.HTTPInternalServerError(
|
raise webob.exc.HTTPInternalServerError(
|
||||||
explanation=six.text_type(exc))
|
explanation=str(exc))
|
||||||
except webob.exc.HTTPNotFound as e:
|
except webob.exc.HTTPNotFound as e:
|
||||||
return self._make_problem_detail(str(e), 404,
|
return self._make_problem_detail(str(e), 404,
|
||||||
'Not Found')
|
'Not Found')
|
||||||
|
@ -566,7 +564,7 @@ class VnfLcmController(wsgi.Controller):
|
||||||
self._validate_flavour_and_inst_level(context, req_body,
|
self._validate_flavour_and_inst_level(context, req_body,
|
||||||
vnf_instance)
|
vnf_instance)
|
||||||
except exceptions.NotFound as ex:
|
except exceptions.NotFound as ex:
|
||||||
raise webob.exc.HTTPBadRequest(explanation=six.text_type(ex))
|
raise webob.exc.HTTPBadRequest(explanation=str(ex))
|
||||||
|
|
||||||
instantiate_vnf_request = \
|
instantiate_vnf_request = \
|
||||||
objects.InstantiateVnfRequest.obj_from_primitive(
|
objects.InstantiateVnfRequest.obj_from_primitive(
|
||||||
|
|
|
@ -13,10 +13,14 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import webob
|
||||||
|
import zipfile
|
||||||
|
from zipfile import ZipFile
|
||||||
|
|
||||||
from glance_store import exceptions as store_exceptions
|
from glance_store import exceptions as store_exceptions
|
||||||
from oslo_config import cfg
|
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 encodeutils
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import uuidutils
|
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._i18n import _
|
||||||
from tacker.api.schemas import vnf_packages
|
from tacker.api.schemas import vnf_packages
|
||||||
|
@ -256,7 +255,7 @@ class VnfPkgmController(wsgi.Controller):
|
||||||
zip_file_size)
|
zip_file_size)
|
||||||
else:
|
else:
|
||||||
chunk_size = zip_file_size
|
chunk_size = zip_file_size
|
||||||
response.headers['Content-Length'] = six.text_type(chunk_size)
|
response.headers['Content-Length'] = str(chunk_size)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def _get_csar_zip_data(self, uuid, location, offset=0, chunk_size=None):
|
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)
|
get_vnf_package_vnfd(context, vnf_package)
|
||||||
except exceptions.FailedToGetVnfdData as e:
|
except exceptions.FailedToGetVnfdData as e:
|
||||||
LOG.error(e.msg)
|
LOG.error(e.msg)
|
||||||
raise webob.exc.HTTPInternalServerError(
|
raise webob.exc.HTTPInternalServerError(explanation=str(e.msg))
|
||||||
explanation=six.text_type(e.msg))
|
|
||||||
|
|
||||||
if 'text/plain' in accept_headers:
|
if 'text/plain' in accept_headers:
|
||||||
# Checking for yaml files only. This is required when there is
|
# Checking for yaml files only. This is required when there is
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from cryptography import fernet
|
from cryptography import fernet
|
||||||
|
@ -140,10 +139,7 @@ class KubernetesHTTPAPI(object):
|
||||||
ca_cert = re.sub(r'END\nCERT', r'END CERT', ca_cert)
|
ca_cert = re.sub(r'END\nCERT', r'END CERT', ca_cert)
|
||||||
try:
|
try:
|
||||||
with open(file_path, 'w') as f:
|
with open(file_path, 'w') as f:
|
||||||
if six.PY2:
|
f.write(ca_cert)
|
||||||
f.write(ca_cert.decode('utf-8'))
|
|
||||||
else:
|
|
||||||
f.write(ca_cert)
|
|
||||||
LOG.debug('ca cert temp file successfully stored in %s',
|
LOG.debug('ca cert temp file successfully stored in %s',
|
||||||
file_path)
|
file_path)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|
|
@ -12,26 +12,26 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
from urllib import request as urllib2
|
||||||
import yaml
|
import yaml
|
||||||
|
import zipfile
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from six.moves.urllib.parse import urlparse
|
|
||||||
from toscaparser.prereq.csar import CSAR
|
from toscaparser.prereq.csar import CSAR
|
||||||
from toscaparser.tosca_template import ToscaTemplate
|
from toscaparser.tosca_template import ToscaTemplate
|
||||||
import zipfile
|
|
||||||
|
|
||||||
from tacker.common import exceptions
|
from tacker.common import exceptions
|
||||||
import tacker.conf
|
import tacker.conf
|
||||||
from tacker.extensions import vnfm
|
from tacker.extensions import vnfm
|
||||||
import urllib.request as urllib2
|
|
||||||
|
|
||||||
|
|
||||||
HASH_DICT = {
|
HASH_DICT = {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import random
|
||||||
import re
|
import re
|
||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
|
from stevedore import driver
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -38,9 +39,8 @@ from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from six.moves import urllib
|
import urllib
|
||||||
from six.moves.urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
from stevedore import driver
|
|
||||||
try:
|
try:
|
||||||
from eventlet import sleep
|
from eventlet import sleep
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -17,7 +17,6 @@ from datetime import datetime
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
from sqlalchemy.orm import exc as orm_exc
|
from sqlalchemy.orm import exc as orm_exc
|
||||||
from sqlalchemy import sql
|
from sqlalchemy import sql
|
||||||
|
|
||||||
|
@ -94,13 +93,13 @@ class CommonDbMixin(object):
|
||||||
model_hooks = self._model_query_hooks.get(model, {})
|
model_hooks = self._model_query_hooks.get(model, {})
|
||||||
for _name, hooks in model_hooks.items():
|
for _name, hooks in model_hooks.items():
|
||||||
query_hook = hooks.get('query')
|
query_hook = hooks.get('query')
|
||||||
if isinstance(query_hook, six.string_types):
|
if isinstance(query_hook, str):
|
||||||
query_hook = getattr(self, query_hook, None)
|
query_hook = getattr(self, query_hook, None)
|
||||||
if query_hook:
|
if query_hook:
|
||||||
query = query_hook(context, model, query)
|
query = query_hook(context, model, query)
|
||||||
|
|
||||||
filter_hook = hooks.get('filter')
|
filter_hook = hooks.get('filter')
|
||||||
if isinstance(filter_hook, six.string_types):
|
if isinstance(filter_hook, str):
|
||||||
filter_hook = getattr(self, filter_hook, None)
|
filter_hook = getattr(self, filter_hook, None)
|
||||||
if filter_hook:
|
if filter_hook:
|
||||||
query_filter = filter_hook(context, model, query_filter)
|
query_filter = filter_hook(context, model, query_filter)
|
||||||
|
@ -146,7 +145,7 @@ class CommonDbMixin(object):
|
||||||
model_hooks = self._model_query_hooks.get(model, {})
|
model_hooks = self._model_query_hooks.get(model, {})
|
||||||
for _name, hooks in model_hooks.items():
|
for _name, hooks in model_hooks.items():
|
||||||
result_filter = hooks.get('result_filters', None)
|
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)
|
result_filter = getattr(self, result_filter, None)
|
||||||
|
|
||||||
if result_filter:
|
if result_filter:
|
||||||
|
@ -159,7 +158,7 @@ class CommonDbMixin(object):
|
||||||
for func in self._dict_extend_functions.get(
|
for func in self._dict_extend_functions.get(
|
||||||
resource_type, []):
|
resource_type, []):
|
||||||
args = (response, db_object)
|
args = (response, db_object)
|
||||||
if isinstance(func, six.string_types):
|
if isinstance(func, str):
|
||||||
func = getattr(self, func, None)
|
func = getattr(self, func, None)
|
||||||
else:
|
else:
|
||||||
# must call unbound method - use self as 1st argument
|
# must call unbound method - use self as 1st argument
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six import moves
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy.orm.properties import RelationshipProperty
|
from sqlalchemy.orm.properties import RelationshipProperty
|
||||||
|
|
||||||
|
@ -85,7 +84,7 @@ def paginate_query(query, model, limit, sorts, marker_obj=None):
|
||||||
criteria_list = []
|
criteria_list = []
|
||||||
for i, sort in enumerate(sorts):
|
for i, sort in enumerate(sorts):
|
||||||
crit_attrs = [(getattr(model, sorts[j][0]) == marker_values[j])
|
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])
|
model_attr = getattr(model, sort[0])
|
||||||
if sort[1]:
|
if sort[1]:
|
||||||
crit_attrs.append((model_attr > marker_values[i]))
|
crit_attrs.append((model_attr > marker_values[i]))
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
from tacker.api.v1 import attributes as attr
|
from tacker.api.v1 import attributes as attr
|
||||||
|
@ -137,8 +135,8 @@ class Common_services(extensions.ExtensionDescriptor):
|
||||||
return version_map.get(version, {})
|
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):
|
def get_plugin_name(self):
|
||||||
return constants.COMMONSERVICES
|
return constants.COMMONSERVICES
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
from tacker.api.v1 import attributes as attr
|
from tacker.api.v1 import attributes as attr
|
||||||
|
@ -870,8 +868,7 @@ class Nfvo(extensions.ExtensionDescriptor):
|
||||||
return version_map.get(version, {})
|
return version_map.get(version, {})
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class NFVOPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||||
class NFVOPluginBase(service_base.NFVPluginBase):
|
|
||||||
def get_plugin_name(self):
|
def get_plugin_name(self):
|
||||||
return constants.NFVO
|
return constants.NFVO
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,13 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.common import exceptions
|
from tacker.common import exceptions
|
||||||
from tacker.services import service_base
|
from tacker.services import service_base
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class NSPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||||
class NSPluginBase(service_base.NFVPluginBase):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def create_nsd(self, context, nsd):
|
def create_nsd(self, context, nsd):
|
||||||
|
|
|
@ -14,13 +14,11 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.services import service_base
|
from tacker.services import service_base
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VNFFGPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||||
class VNFFGPluginBase(service_base.NFVPluginBase):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def create_vnffgd(self, context, vnffgd):
|
def create_vnffgd(self, context, vnffgd):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
@ -607,8 +606,7 @@ class Vnfm(extensions.ExtensionDescriptor):
|
||||||
return version_map.get(version, {})
|
return version_map.get(version, {})
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VNFMPluginBase(service_base.NFVPluginBase, metaclass=abc.ABCMeta):
|
||||||
class VNFMPluginBase(service_base.NFVPluginBase):
|
|
||||||
def get_plugin_name(self):
|
def get_plugin_name(self):
|
||||||
return constants.VNFM
|
return constants.VNFM
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
import urllib
|
||||||
|
|
||||||
import glance_store
|
import glance_store
|
||||||
from glance_store import exceptions as store_exceptions
|
from glance_store import exceptions as store_exceptions
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from tacker.common import exceptions
|
from tacker.common import exceptions
|
||||||
from tacker.common import utils
|
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):
|
def _add_basic_auth(request, username, password):
|
||||||
"""A helper function to add basic authentication.
|
"""A helper function to add basic authentication.
|
||||||
|
|
||||||
This function adds basic authentication information to a six.moves.urllib
|
This function adds basic authentication information to a urllib request.
|
||||||
request.
|
|
||||||
"""
|
"""
|
||||||
auth_str = base64.encodestring(('%s:%s' % (
|
auth_str = base64.encodestring(('%s:%s' % (
|
||||||
username, password)).encode()).decode().strip()
|
username, password)).encode()).decode().strip()
|
||||||
|
|
|
@ -19,11 +19,8 @@ Key manager API
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
class KeyManager(object, metaclass=abc.ABCMeta):
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
|
||||||
class KeyManager(object):
|
|
||||||
"""Base Key Manager Interface
|
"""Base Key Manager Interface
|
||||||
|
|
||||||
A Key Manager is responsible for creating, reading, and deleting keys.
|
A Key Manager is responsible for creating, reading, and deleting keys.
|
||||||
|
|
|
@ -15,13 +15,10 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VimAbstractDriver(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||||
class VimAbstractDriver(extensions.PluginInterface):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from keystoneauth1 import exceptions
|
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)
|
key_file = os.path.join(CONF.vim_keys.openstack, vim_id)
|
||||||
try:
|
try:
|
||||||
with open(key_file, 'wb') as f:
|
with open(key_file, 'wb') as f:
|
||||||
if six.PY2:
|
f.write(fernet_key)
|
||||||
f.write(fernet_key.decode('utf-8'))
|
|
||||||
else:
|
|
||||||
f.write(fernet_key)
|
|
||||||
LOG.debug('VIM auth successfully stored for vim %s',
|
LOG.debug('VIM auth successfully stored for vim %s',
|
||||||
vim_id)
|
vim_id)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|
|
@ -12,13 +12,10 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VnffgAbstractDriver(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||||
class VnffgAbstractDriver(extensions.PluginInterface):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
|
|
@ -23,7 +23,6 @@ from oslo_log import log as logging
|
||||||
from oslo_policy import policy
|
from oslo_policy import policy
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.api.v1 import attributes
|
from tacker.api.v1 import attributes
|
||||||
|
@ -297,7 +296,7 @@ class OwnerCheck(policy.Check):
|
||||||
LOG.exception('Policy check error while calling %s!', f)
|
LOG.exception('Policy check error while calling %s!', f)
|
||||||
match = self.match % target
|
match = self.match % target
|
||||||
if self.kind in creds:
|
if self.kind in creds:
|
||||||
return match == six.text_type(creds[self.kind])
|
return match == str(creds[self.kind])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,10 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class NFVPluginBase(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||||
class NFVPluginBase(extensions.PluginInterface):
|
|
||||||
"""Define base interface for any Advanced Service plugin."""
|
"""Define base interface for any Advanced Service plugin."""
|
||||||
supported_extension_aliases = []
|
supported_extension_aliases = []
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import ddt
|
import ddt
|
||||||
import os
|
import os
|
||||||
from six.moves import urllib
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import urllib
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
import six
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
from tacker.api.v1 import base as v1_base
|
from tacker.api.v1 import base as v1_base
|
||||||
|
@ -126,7 +125,7 @@ class VIMCreateTestCase(base.TestCase):
|
||||||
exp = self.assertRaises(exc.HTTPBadRequest,
|
exp = self.assertRaises(exc.HTTPBadRequest,
|
||||||
self.controller.create,
|
self.controller.create,
|
||||||
request, vim_dict)
|
request, vim_dict)
|
||||||
self.assertEqual(msg, six.text_type(exp))
|
self.assertEqual(msg, str(exp))
|
||||||
|
|
||||||
@ddt.data("", " ", None, 123)
|
@ddt.data("", " ", None, 123)
|
||||||
def test_create_vim_with_invalid_type(self, value):
|
def test_create_vim_with_invalid_type(self, value):
|
||||||
|
@ -152,7 +151,7 @@ class VIMCreateTestCase(base.TestCase):
|
||||||
exp = self.assertRaises(exc.HTTPBadRequest,
|
exp = self.assertRaises(exc.HTTPBadRequest,
|
||||||
self.controller.create,
|
self.controller.create,
|
||||||
request, vim_dict)
|
request, vim_dict)
|
||||||
self.assertEqual(msg, six.text_type(exp))
|
self.assertEqual(msg, str(exp))
|
||||||
|
|
||||||
@ddt.data('', 'testing', {})
|
@ddt.data('', 'testing', {})
|
||||||
def test_create_vim_invalid_vim_project(self, value):
|
def test_create_vim_invalid_vim_project(self, value):
|
||||||
|
@ -167,4 +166,4 @@ class VIMCreateTestCase(base.TestCase):
|
||||||
exp = self.assertRaises(exc.HTTPBadRequest,
|
exp = self.assertRaises(exc.HTTPBadRequest,
|
||||||
self.controller.create,
|
self.controller.create,
|
||||||
request, vim_dict)
|
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_config import cfg
|
||||||
from oslo_policy import policy as common_policy
|
from oslo_policy import policy as common_policy
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
from urllib import parse as urlparse
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
import webtest
|
import webtest
|
||||||
|
@ -932,8 +931,7 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
|
||||||
return_value.update(initial_input['port'])
|
return_value.update(initial_input['port'])
|
||||||
|
|
||||||
instance = self.plugin.return_value
|
instance = self.plugin.return_value
|
||||||
instance.get_network.return_value = {'tenant_id':
|
instance.get_network.return_value = {'tenant_id': str(tenant_id)}
|
||||||
six.text_type(tenant_id)}
|
|
||||||
instance.get_ports_count.return_value = 1
|
instance.get_ports_count.return_value = 1
|
||||||
instance.create_port.return_value = return_value
|
instance.create_port.return_value = return_value
|
||||||
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
||||||
|
|
|
@ -21,15 +21,16 @@ import json
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
import shutil
|
import shutil
|
||||||
import six.moves.urllib.error as urlerr
|
|
||||||
import sys
|
import sys
|
||||||
import tacker.conf
|
import unittest
|
||||||
|
from unittest import mock
|
||||||
|
import urllib
|
||||||
|
from urllib import error as urlerr
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from glance_store import exceptions as store_exceptions
|
from glance_store import exceptions as store_exceptions
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from tacker import auth
|
from tacker import auth
|
||||||
from tacker.common import coordination
|
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 driver_manager
|
||||||
from tacker.common import exceptions
|
from tacker.common import exceptions
|
||||||
from tacker.conductor import conductor_server
|
from tacker.conductor import conductor_server
|
||||||
|
import tacker.conf
|
||||||
from tacker import context
|
from tacker import context
|
||||||
from tacker import context as t_context
|
from tacker import context as t_context
|
||||||
from tacker.db.db_sqlalchemy import models
|
from tacker.db.db_sqlalchemy import models
|
||||||
|
@ -59,8 +61,6 @@ from tacker.tests import utils
|
||||||
from tacker.tests import uuidsentinel
|
from tacker.tests import uuidsentinel
|
||||||
from tacker.vnfm import nfvo_client as test_nfvo_client
|
from tacker.vnfm import nfvo_client as test_nfvo_client
|
||||||
from tacker.vnfm import vim_client
|
from tacker.vnfm import vim_client
|
||||||
import unittest
|
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
|
|
||||||
CONF = tacker.conf.CONF
|
CONF = tacker.conf.CONF
|
||||||
|
|
|
@ -102,7 +102,7 @@ class TestCli(base.BaseTestCase):
|
||||||
with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
|
with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
|
||||||
fc.return_value.get_heads.return_value = heads
|
fc.return_value.get_heads.return_value = heads
|
||||||
fc.return_value.get_current_head.return_value = heads[0]
|
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.__enter__ = lambda s: s
|
||||||
mock_open.return_value.__exit__ = mock.Mock()
|
mock_open.return_value.__exit__ = mock.Mock()
|
||||||
mock_open.return_value.read.return_value = file_content
|
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:
|
with mock.patch('alembic.script.ScriptDirectory.from_config') as fc:
|
||||||
fc.return_value.get_heads.return_value = ['a']
|
fc.return_value.get_heads.return_value = ['a']
|
||||||
fc.return_value.get_current_head.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.__enter__ = lambda s: s
|
||||||
mock_open.return_value.__exit__ = mock.Mock()
|
mock_open.return_value.__exit__ = mock.Mock()
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import glance_store
|
import glance_store
|
||||||
from six.moves import urllib
|
import urllib
|
||||||
import six.moves.urllib.error as urlerr
|
from urllib import error as urlerr
|
||||||
|
|
||||||
from tacker.common import exceptions
|
from tacker.common import exceptions
|
||||||
import tacker.conf
|
import tacker.conf
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.objects import base
|
from tacker.objects import base
|
||||||
from tacker.objects import fields
|
from tacker.objects import fields
|
||||||
from tacker.tests.unit import base as test_base
|
from tacker.tests.unit import base as test_base
|
||||||
|
@ -24,8 +22,6 @@ class TestString(test_base.TestCase):
|
||||||
super(TestString, self).setUp()
|
super(TestString, self).setUp()
|
||||||
self.field = fields.StringField()
|
self.field = fields.StringField()
|
||||||
self.coerce_good_values = [('foo', 'foo'), (1, '1'), (True, 'True')]
|
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]
|
self.coerce_bad_values = [None]
|
||||||
|
|
||||||
def test_stringify(self):
|
def test_stringify(self):
|
||||||
|
|
|
@ -15,15 +15,14 @@
|
||||||
|
|
||||||
"""Test of Policy Engine For Tacker"""
|
"""Test of Policy Engine For Tacker"""
|
||||||
|
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
import fixtures
|
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_policy import policy as common_policy
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from six.moves.urllib import request as urlrequest
|
|
||||||
|
|
||||||
import tacker
|
import tacker
|
||||||
from tacker.api.v1 import attributes
|
from tacker.api.v1 import attributes
|
||||||
|
@ -127,7 +126,7 @@ class PolicyTestCase(base.BaseTestCase):
|
||||||
def test_enforce_http_true(self):
|
def test_enforce_http_true(self):
|
||||||
|
|
||||||
def fakeurlopen(url, post_data):
|
def fakeurlopen(url, post_data):
|
||||||
return six.StringIO("True")
|
return io.StringIO("True")
|
||||||
|
|
||||||
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
||||||
action = "example:get_http"
|
action = "example:get_http"
|
||||||
|
@ -138,7 +137,7 @@ class PolicyTestCase(base.BaseTestCase):
|
||||||
def test_enforce_http_false(self):
|
def test_enforce_http_false(self):
|
||||||
|
|
||||||
def fakeurlopen(url, post_data):
|
def fakeurlopen(url, post_data):
|
||||||
return six.StringIO("False")
|
return io.StringIO("False")
|
||||||
|
|
||||||
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
||||||
action = "example:get_http"
|
action = "example:get_http"
|
||||||
|
|
|
@ -14,20 +14,18 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
import oslo_i18n
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
import six.moves.urllib.request as urllibrequest
|
|
||||||
import testtools
|
import testtools
|
||||||
|
from unittest import mock
|
||||||
|
from urllib import request as urllibrequest
|
||||||
import webob
|
import webob
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
import oslo_i18n
|
||||||
|
|
||||||
from tacker.common import exceptions as exception
|
from tacker.common import exceptions as exception
|
||||||
from tacker.tests import base
|
from tacker.tests import base
|
||||||
from tacker.tests.common import helpers
|
|
||||||
from tacker import wsgi
|
from tacker import wsgi
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
@ -467,18 +465,6 @@ class JSONDictSerializerTest(base.BaseTestCase):
|
||||||
|
|
||||||
self.assertEqual(expected_json, result)
|
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):
|
def test_json_with_unicode(self):
|
||||||
input_dict = dict(servers=dict(a=(2, u'\u7f51\u7edc')))
|
input_dict = dict(servers=dict(a=(2, u'\u7f51\u7edc')))
|
||||||
expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}'
|
expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}'
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
import sys
|
import sys
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from six import moves
|
|
||||||
|
|
||||||
from tacker.tests import base
|
from tacker.tests import base
|
||||||
from tacker.tests import post_mortem_debug
|
from tacker.tests import post_mortem_debug
|
||||||
|
|
||||||
|
@ -64,7 +62,7 @@ class TestGetIgnoredTraceback(base.BaseTestCase):
|
||||||
|
|
||||||
tb = root_tb
|
tb = root_tb
|
||||||
tracebacks = [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_next = mock.Mock()
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
tracebacks.append(tb)
|
tracebacks.append(tb)
|
||||||
|
|
|
@ -12,19 +12,19 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
import os
|
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
|
from http import client as http_client
|
||||||
import json
|
import json
|
||||||
from oslo_serialization import jsonutils
|
import os
|
||||||
from six.moves import http_client
|
from unittest import mock
|
||||||
import urllib
|
import urllib
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from tacker.api.vnflcm.v1 import controller
|
from tacker.api.vnflcm.v1 import controller
|
||||||
from tacker.api.vnflcm.v1 import sync_resource
|
from tacker.api.vnflcm.v1 import sync_resource
|
||||||
from tacker.common import exceptions
|
from tacker.common import exceptions
|
||||||
|
|
|
@ -12,10 +12,9 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
import six.moves.urllib.error as urlerr
|
|
||||||
import testtools
|
import testtools
|
||||||
|
from unittest import mock
|
||||||
|
from urllib import error as urlerr
|
||||||
|
|
||||||
from tacker.vnfm.monitor_drivers.http_ping import http_ping
|
from tacker.vnfm.monitor_drivers.http_ping import http_ping
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ class TestVNFMonitorHTTPPing(testtools.TestCase):
|
||||||
super(TestVNFMonitorHTTPPing, self).setUp()
|
super(TestVNFMonitorHTTPPing, self).setUp()
|
||||||
self.monitor_http_ping = http_ping.VNFMonitorHTTPPing()
|
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):
|
def test_monitor_call_for_success(self, mock_urlopen):
|
||||||
test_vnf = {}
|
test_vnf = {}
|
||||||
test_kwargs = {
|
test_kwargs = {
|
||||||
|
@ -36,7 +35,7 @@ class TestVNFMonitorHTTPPing(testtools.TestCase):
|
||||||
test_kwargs)
|
test_kwargs)
|
||||||
mock_urlopen.assert_called_once_with('http://a.b.c.d:80', timeout=5)
|
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):
|
def test_monitor_call_for_failure(self, mock_urlopen):
|
||||||
mock_urlopen.side_effect = urlerr.URLError("MOCK Error")
|
mock_urlopen.side_effect = urlerr.URLError("MOCK Error")
|
||||||
test_vnf = {}
|
test_vnf = {}
|
||||||
|
|
|
@ -12,16 +12,18 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
|
from http import client as http_client
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from oslo_serialization import jsonutils
|
from unittest import mock
|
||||||
from six.moves import http_client
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from tacker.api.vnfpkgm.v1 import controller
|
from tacker.api.vnfpkgm.v1 import controller
|
||||||
from tacker.common import exceptions as tacker_exc
|
from tacker.common import exceptions as tacker_exc
|
||||||
from tacker.conductor.conductorrpc.vnf_pkgm_rpc import VNFPackageRPCAPI
|
from tacker.conductor.conductorrpc.vnf_pkgm_rpc import VNFPackageRPCAPI
|
||||||
|
|
|
@ -15,11 +15,8 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
class VnfInstanceAbstractDriver(object, metaclass=abc.ABCMeta):
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
|
||||||
class VnfInstanceAbstractDriver(object):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def instantiate_vnf(self, context, vnf_instance_id, instantiate_vnf_req):
|
def instantiate_vnf(self, context, vnf_instance_id, instantiate_vnf_req):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import copy
|
import copy
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -373,7 +372,7 @@ def _create_grant_request(vnfd_dict, package_uuid):
|
||||||
artifacts = value.get('artifacts', {})
|
artifacts = value.get('artifacts', {})
|
||||||
for artifact, sw_image in artifacts.items():
|
for artifact, sw_image in artifacts.items():
|
||||||
artifact_image_path = None
|
artifact_image_path = None
|
||||||
if isinstance(sw_image, six.string_types):
|
if isinstance(sw_image, str):
|
||||||
artifact_image_path = sw_image
|
artifact_image_path = sw_image
|
||||||
elif sw_image.get('type') == 'tosca.artifacts.nfv.SwImage':
|
elif sw_image.get('type') == 'tosca.artifacts.nfv.SwImage':
|
||||||
artifact_image_path = sw_image.get('file', {})
|
artifact_image_path = sw_image.get('file', {})
|
||||||
|
|
|
@ -18,7 +18,6 @@ from datetime import datetime
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import yaml
|
import yaml
|
||||||
|
@ -533,7 +532,7 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
|
||||||
"%(id)s before respawning. The vnf is in "
|
"%(id)s before respawning. The vnf is in "
|
||||||
"inconsistent state. Error: %(error)s")
|
"inconsistent state. Error: %(error)s")
|
||||||
LOG.error(err_msg % {"id": vnf_instance.id,
|
LOG.error(err_msg % {"id": vnf_instance.id,
|
||||||
"error": six.text_type(exc)})
|
"error": str(exc)})
|
||||||
raise exceptions.VnfHealFailed(id=vnf_instance.id,
|
raise exceptions.VnfHealFailed(id=vnf_instance.id,
|
||||||
error=encodeutils.exception_to_unicode(exc))
|
error=encodeutils.exception_to_unicode(exc))
|
||||||
|
|
||||||
|
@ -555,7 +554,7 @@ class VnfLcmDriver(abstract_driver.VnfInstanceAbstractDriver):
|
||||||
"%(id)s after termination. The vnf is in "
|
"%(id)s after termination. The vnf is in "
|
||||||
"inconsistent state. Error: %(error)s")
|
"inconsistent state. Error: %(error)s")
|
||||||
LOG.error(err_msg % {"id": vnf_instance.id,
|
LOG.error(err_msg % {"id": vnf_instance.id,
|
||||||
"error": six.text_type(exc)})
|
"error": str(exc)})
|
||||||
raise exceptions.VnfHealFailed(id=vnf_instance.id,
|
raise exceptions.VnfHealFailed(id=vnf_instance.id,
|
||||||
error=encodeutils.exception_to_unicode(exc))
|
error=encodeutils.exception_to_unicode(exc))
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,10 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VnfAbstractDriver(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||||
class VnfAbstractDriver(extensions.PluginInterface):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
|
|
@ -15,13 +15,11 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VnfScaleAbstractDriver(extensions.PluginInterface,
|
||||||
class VnfScaleAbstractDriver(extensions.PluginInterface):
|
metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def scale(self,
|
def scale(self,
|
||||||
|
|
|
@ -12,13 +12,11 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.extensions import vnfm
|
from tacker.extensions import vnfm
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class AbstractUserData(object, metaclass=abc.ABCMeta):
|
||||||
class AbstractUserData(object):
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
|
|
@ -16,13 +16,10 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VnfMGMTAbstractDriver(extensions.PluginInterface, metaclass=abc.ABCMeta):
|
||||||
class VnfMGMTAbstractDriver(extensions.PluginInterface):
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
|
|
@ -15,13 +15,11 @@
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from tacker.api import extensions
|
from tacker.api import extensions
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class VNFMonitorAbstractDriver(extensions.PluginInterface,
|
||||||
class VNFMonitorAbstractDriver(extensions.PluginInterface):
|
metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
from urllib import error as urlerr
|
||||||
|
from urllib import request as urlreq
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six.moves.urllib.error as urlerr
|
|
||||||
import six.moves.urllib.request as urlreq
|
|
||||||
|
|
||||||
from tacker._i18n import _
|
from tacker._i18n import _
|
||||||
from tacker.common import log
|
from tacker.common import log
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
@ -336,8 +335,7 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
LOG.error("VNF Create failed for vnf_id %s", vnf_id)
|
LOG.error("VNF Create failed for vnf_id %s", vnf_id)
|
||||||
create_failed = True
|
create_failed = True
|
||||||
vnf_dict['status'] = constants.ERROR
|
vnf_dict['status'] = constants.ERROR
|
||||||
self.set_vnf_error_status_reason(context, vnf_id,
|
self.set_vnf_error_status_reason(context, vnf_id, str(e))
|
||||||
six.text_type(e))
|
|
||||||
|
|
||||||
if instance_id is None or create_failed:
|
if instance_id is None or create_failed:
|
||||||
mgmt_ip_address = None
|
mgmt_ip_address = None
|
||||||
|
@ -489,14 +487,13 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
||||||
self._vnf_maintenance_plugin.post(context, vnf_dict)
|
self._vnf_maintenance_plugin.post(context, vnf_dict)
|
||||||
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
||||||
six.text_type(e))
|
str(e))
|
||||||
except exceptions.MgmtDriverException as e:
|
except exceptions.MgmtDriverException as e:
|
||||||
LOG.error('VNF configuration failed')
|
LOG.error('VNF configuration failed')
|
||||||
new_status = constants.ERROR
|
new_status = constants.ERROR
|
||||||
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
||||||
self._vnf_maintenance_plugin.post(context, vnf_dict)
|
self._vnf_maintenance_plugin.post(context, vnf_dict)
|
||||||
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
self.set_vnf_error_status_reason(context, vnf_dict['id'], str(e))
|
||||||
six.text_type(e))
|
|
||||||
|
|
||||||
del vnf_dict['heal_stack_id']
|
del vnf_dict['heal_stack_id']
|
||||||
vnf_dict['status'] = new_status
|
vnf_dict['status'] = new_status
|
||||||
|
@ -536,13 +533,12 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
new_status = constants.ERROR
|
new_status = constants.ERROR
|
||||||
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
||||||
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
||||||
six.text_type(e))
|
str(e))
|
||||||
except exceptions.MgmtDriverException as e:
|
except exceptions.MgmtDriverException as e:
|
||||||
LOG.error('VNF configuration failed')
|
LOG.error('VNF configuration failed')
|
||||||
new_status = constants.ERROR
|
new_status = constants.ERROR
|
||||||
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
self._vnf_monitor.delete_hosting_vnf(vnf_dict['id'])
|
||||||
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
self.set_vnf_error_status_reason(context, vnf_dict['id'], str(e))
|
||||||
six.text_type(e))
|
|
||||||
vnf_dict['status'] = new_status
|
vnf_dict['status'] = new_status
|
||||||
self.mgmt_update_post(context, vnf_dict)
|
self.mgmt_update_post(context, vnf_dict)
|
||||||
self._update_vnf_post(context, vnf_dict['id'], new_status,
|
self._update_vnf_post(context, vnf_dict['id'], new_status,
|
||||||
|
@ -595,9 +591,8 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
vnf_dict['status'] = constants.ERROR
|
vnf_dict['status'] = constants.ERROR
|
||||||
self._vnf_monitor.delete_hosting_vnf(vnf_id)
|
self._vnf_monitor.delete_hosting_vnf(vnf_id)
|
||||||
self.set_vnf_error_status_reason(context,
|
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
||||||
vnf_dict['id'],
|
str(e))
|
||||||
six.text_type(e))
|
|
||||||
self.mgmt_update_post(context, vnf_dict)
|
self.mgmt_update_post(context, vnf_dict)
|
||||||
self._update_vnf_post(context, vnf_id,
|
self._update_vnf_post(context, vnf_id,
|
||||||
constants.ERROR,
|
constants.ERROR,
|
||||||
|
@ -632,9 +627,8 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
vnf_dict['status'] = constants.ERROR
|
vnf_dict['status'] = constants.ERROR
|
||||||
self._vnf_monitor.delete_hosting_vnf(vnf_id)
|
self._vnf_monitor.delete_hosting_vnf(vnf_id)
|
||||||
self.set_vnf_error_status_reason(context,
|
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
||||||
vnf_dict['id'],
|
str(e))
|
||||||
six.text_type(e))
|
|
||||||
self.mgmt_update_post(context, vnf_dict)
|
self.mgmt_update_post(context, vnf_dict)
|
||||||
self._vnf_maintenance_plugin.post(context, vnf_dict)
|
self._vnf_maintenance_plugin.post(context, vnf_dict)
|
||||||
self._update_vnf_post(context, vnf_id,
|
self._update_vnf_post(context, vnf_id,
|
||||||
|
@ -665,7 +659,7 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
except Exception as e_:
|
except Exception as e_:
|
||||||
e = e_
|
e = e_
|
||||||
vnf_dict['status'] = constants.ERROR
|
vnf_dict['status'] = constants.ERROR
|
||||||
vnf_dict['error_reason'] = six.text_type(e)
|
vnf_dict['error_reason'] = str(e)
|
||||||
LOG.exception('_delete_vnf_wait')
|
LOG.exception('_delete_vnf_wait')
|
||||||
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
||||||
vnf_dict['error_reason'])
|
vnf_dict['error_reason'])
|
||||||
|
@ -708,7 +702,7 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
if not force_delete:
|
if not force_delete:
|
||||||
vnf_dict['status'] = constants.ERROR
|
vnf_dict['status'] = constants.ERROR
|
||||||
vnf_dict['error_reason'] = six.text_type(e)
|
vnf_dict['error_reason'] = str(e)
|
||||||
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
self.set_vnf_error_status_reason(context, vnf_dict['id'],
|
||||||
vnf_dict['error_reason'])
|
vnf_dict['error_reason'])
|
||||||
self.mgmt_delete_post(context, vnf_dict)
|
self.mgmt_delete_post(context, vnf_dict)
|
||||||
|
@ -816,9 +810,7 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
vnf['status'] = constants.ERROR
|
vnf['status'] = constants.ERROR
|
||||||
self.set_vnf_error_status_reason(
|
self.set_vnf_error_status_reason(
|
||||||
context,
|
context, policy['vnf']['id'], str(e))
|
||||||
policy['vnf']['id'],
|
|
||||||
six.text_type(e))
|
|
||||||
_handle_vnf_scaling_post(constants.ERROR)
|
_handle_vnf_scaling_post(constants.ERROR)
|
||||||
|
|
||||||
# wait
|
# wait
|
||||||
|
@ -845,9 +837,7 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||||
policy['name'])
|
policy['name'])
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
self.set_vnf_error_status_reason(
|
self.set_vnf_error_status_reason(
|
||||||
context,
|
context, policy['vnf']['id'], str(e))
|
||||||
policy['vnf']['id'],
|
|
||||||
six.text_type(e))
|
|
||||||
_handle_vnf_scaling_post(constants.ERROR)
|
_handle_vnf_scaling_post(constants.ERROR)
|
||||||
|
|
||||||
_validate_scaling_policy()
|
_validate_scaling_policy()
|
||||||
|
|
|
@ -13,11 +13,9 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class AbstractPolicyAction(object, metaclass=abc.ABCMeta):
|
||||||
class AbstractPolicyAction(object):
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
"""Return one of predefined type of the hosting vnf drivers."""
|
"""Return one of predefined type of the hosting vnf drivers."""
|
||||||
|
|
|
@ -38,7 +38,6 @@ from oslo_service import systemd
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
import routes.middleware
|
import routes.middleware
|
||||||
import six
|
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
|
@ -466,7 +465,7 @@ class JSONDictSerializer(DictSerializer):
|
||||||
|
|
||||||
def default(self, data):
|
def default(self, data):
|
||||||
def sanitizer(obj):
|
def sanitizer(obj):
|
||||||
return six.text_type(obj)
|
return str(obj)
|
||||||
return encode_body(jsonutils.dump_as_bytes(data, default=sanitizer))
|
return encode_body(jsonutils.dump_as_bytes(data, default=sanitizer))
|
||||||
|
|
||||||
|
|
||||||
|
@ -955,26 +954,17 @@ class ResponseObject(object):
|
||||||
response = webob.Response(body=body)
|
response = webob.Response(body=body)
|
||||||
response.status_int = self.code
|
response.status_int = self.code
|
||||||
for hdr, val in self._headers.items():
|
for hdr, val in self._headers.items():
|
||||||
if six.PY2:
|
# Headers must be a str that was first safely
|
||||||
# In Py2.X Headers must be a UTF-8 encode str.
|
# encoded to UTF-8 (to catch any bad encodings) and then
|
||||||
response.headers[hdr] = encodeutils.safe_encode(val)
|
# decoded back to a native str.
|
||||||
else:
|
response.headers[hdr] = encodeutils.safe_decode(
|
||||||
# In Py3.X Headers must be a str that was first safely
|
encodeutils.safe_encode(val))
|
||||||
# encoded to UTF-8 (to catch any bad encodings) and then
|
|
||||||
# decoded back to a native str.
|
|
||||||
response.headers[hdr] = encodeutils.safe_decode(
|
|
||||||
encodeutils.safe_encode(val))
|
|
||||||
# Deal with content_type
|
# Deal with content_type
|
||||||
if not isinstance(content_type, six.text_type):
|
if not isinstance(content_type, str):
|
||||||
content_type = six.text_type(content_type)
|
content_type = str(content_type)
|
||||||
if six.PY2:
|
|
||||||
# In Py2.X Headers must be a UTF-8 encode str.
|
response.headers['Content-Type'] = encodeutils.safe_decode(
|
||||||
response.headers['Content-Type'] = encodeutils.safe_encode(
|
encodeutils.safe_encode(content_type))
|
||||||
content_type)
|
|
||||||
else:
|
|
||||||
# In Py3.X Headers must be a str.
|
|
||||||
response.headers['Content-Type'] = encodeutils.safe_decode(
|
|
||||||
encodeutils.safe_encode(content_type))
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1140,7 +1130,7 @@ class Fault(webob.exc.HTTPException):
|
||||||
self.wrapped_exc.charset = 'UTF-8'
|
self.wrapped_exc.charset = 'UTF-8'
|
||||||
|
|
||||||
body = JSONDictSerializer().serialize(fault_data)
|
body = JSONDictSerializer().serialize(fault_data)
|
||||||
if isinstance(body, six.text_type):
|
if isinstance(body, str):
|
||||||
body = body.encode('utf-8')
|
body = body.encode('utf-8')
|
||||||
self.wrapped_exc.body = body
|
self.wrapped_exc.body = body
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue