Stop using six library
Since we've dropped support for Python 2.7, it's time to look at the bright future that Python 3.x will bring and stop forcing compatibility with older versions. This patch removes the six library from requirements, not looking back. Change-Id: Ib546f16965475c32b2f8caabd560e2c7d382ac5a
This commit is contained in:
parent
67f5a6bf5c
commit
78c121a5d7
@ -11,11 +11,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves import http_client
|
|
||||||
from webob import exc as webob_exc
|
from webob import exc as webob_exc
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
@ -19,7 +20,6 @@ from oslo_utils import strutils
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
from webob import exc as webob_exc
|
from webob import exc as webob_exc
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# 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 ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
# 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 ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic import api
|
from ironic import api
|
||||||
from ironic.api.controllers.v1 import collection
|
from ironic.api.controllers.v1 import collection
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
import jsonschema
|
import jsonschema
|
||||||
@ -22,7 +23,6 @@ from oslo_utils import strutils
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
# 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 oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from ironic import api
|
from ironic import api
|
||||||
|
@ -21,7 +21,6 @@ import json
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@ -121,7 +120,7 @@ class BooleanType(wtypes.UserType):
|
|||||||
return strutils.bool_from_string(value, strict=True)
|
return strutils.bool_from_string(value, strict=True)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
# raise Invalid to return 400 (BadRequest) in the API
|
# raise Invalid to return 400 (BadRequest) in the API
|
||||||
raise exception.Invalid(six.text_type(e))
|
raise exception.Invalid(str(e))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def frombasetype(value):
|
def frombasetype(value):
|
||||||
@ -138,7 +137,7 @@ class JsonType(wtypes.UserType):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# These are the json serializable native types
|
# These are the json serializable native types
|
||||||
return ' | '.join(map(str, (wtypes.text, six.integer_types, float,
|
return ' | '.join(map(str, (wtypes.text, int, float,
|
||||||
BooleanType, list, dict, None)))
|
BooleanType, list, dict, None)))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -170,7 +169,7 @@ class ListType(wtypes.UserType):
|
|||||||
same order
|
same order
|
||||||
"""
|
"""
|
||||||
items = []
|
items = []
|
||||||
for v in six.text_type(value).split(','):
|
for v in str(value).split(','):
|
||||||
v_norm = v.strip().lower()
|
v_norm = v.strip().lower()
|
||||||
if v_norm and v_norm not in items:
|
if v_norm and v_norm not in items:
|
||||||
items.append(v_norm)
|
items.append(v_norm)
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# 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
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -23,8 +24,6 @@ import os_traits
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from webob import static
|
from webob import static
|
||||||
import wsme
|
import wsme
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ def validate_trait(trait, error_prefix=_('Invalid trait')):
|
|||||||
'A custom trait must start with the prefix CUSTOM_ and use '
|
'A custom trait must start with the prefix CUSTOM_ and use '
|
||||||
'the following characters: A-Z, 0-9 and _') %
|
'the following characters: A-Z, 0-9 and _') %
|
||||||
{'error_prefix': error_prefix})
|
{'error_prefix': error_prefix})
|
||||||
if not isinstance(trait, six.string_types):
|
if not isinstance(trait, str):
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
if len(trait) > 255 or len(trait) < 1:
|
if len(trait) > 255 or len(trait) < 1:
|
||||||
@ -422,7 +421,7 @@ def vendor_passthru(ident, method, topic, data=None, driver_passthru=False):
|
|||||||
|
|
||||||
# Attach the return value to the response object
|
# Attach the return value to the response object
|
||||||
if response.get('attach'):
|
if response.get('attach'):
|
||||||
if isinstance(return_value, six.text_type):
|
if isinstance(return_value, str):
|
||||||
# If unicode, convert to bytes
|
# If unicode, convert to bytes
|
||||||
return_value = return_value.encode('utf-8')
|
return_value = return_value.encode('utf-8')
|
||||||
file_ = wsme.types.File(content=return_value)
|
file_ = wsme.types.File(content=return_value)
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
# 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
|
||||||
|
|
||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
|
|
||||||
from ironic import api
|
from ironic import api
|
||||||
|
@ -13,12 +13,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@ -417,7 +416,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
for value in values:
|
for value in values:
|
||||||
if not uuidutils.is_uuid_like(value):
|
if not uuidutils.is_uuid_like(value):
|
||||||
message = _("Expected a UUID for node_uuid, but received "
|
message = _("Expected a UUID for node_uuid, but received "
|
||||||
"%(uuid)s.") % {'uuid': six.text_type(value)}
|
"%(uuid)s.") % {'uuid': str(value)}
|
||||||
raise exception.InvalidUUID(message=message)
|
raise exception.InvalidUUID(message=message)
|
||||||
|
|
||||||
rpc_connector = objects.VolumeConnector.get_by_uuid(context,
|
rpc_connector = objects.VolumeConnector.get_by_uuid(context,
|
||||||
|
@ -13,12 +13,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@ -429,7 +428,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
for value in values:
|
for value in values:
|
||||||
if not uuidutils.is_uuid_like(value):
|
if not uuidutils.is_uuid_like(value):
|
||||||
message = _("Expected a UUID for node_uuid, but received "
|
message = _("Expected a UUID for node_uuid, but received "
|
||||||
"%(uuid)s.") % {'uuid': six.text_type(value)}
|
"%(uuid)s.") % {'uuid': str(value)}
|
||||||
raise exception.InvalidUUID(message=message)
|
raise exception.InvalidUUID(message=message)
|
||||||
|
|
||||||
rpc_target = objects.VolumeTarget.get_by_uuid(context, target_uuid)
|
rpc_target = objects.VolumeTarget.get_by_uuid(context, target_uuid)
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
# 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
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from pecan import hooks
|
from pecan import hooks
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.common import context
|
from ironic.common import context
|
||||||
from ironic.common import policy
|
from ironic.common import policy
|
||||||
@ -48,7 +47,7 @@ def policy_deprecation_check():
|
|||||||
}
|
}
|
||||||
policy_rules = enforcer.file_rules.values()
|
policy_rules = enforcer.file_rules.values()
|
||||||
for rule in policy_rules:
|
for rule in policy_rules:
|
||||||
str_rule = six.text_type(rule)
|
str_rule = str(rule)
|
||||||
for deprecated, replacement in substitution_dict.items():
|
for deprecated, replacement in substitution_dict.items():
|
||||||
if re.search(r'\b%s\b' % deprecated, str_rule):
|
if re.search(r'\b%s\b' % deprecated, str_rule):
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
|
@ -23,7 +23,6 @@ Based on pecan.middleware.errordocument
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
|
|
||||||
@ -69,11 +68,9 @@ class ParsableErrorMiddleware(object):
|
|||||||
|
|
||||||
app_iter = self.app(environ, replacement_start_response)
|
app_iter = self.app(environ, replacement_start_response)
|
||||||
if (state['status_code'] // 100) not in (2, 3):
|
if (state['status_code'] // 100) not in (2, 3):
|
||||||
if six.PY3:
|
app_iter = [i.decode('utf-8') for i in app_iter]
|
||||||
app_iter = [i.decode('utf-8') for i in app_iter]
|
|
||||||
body = [json.dumps({'error_message': '\n'.join(app_iter)})]
|
body = [json.dumps({'error_message': '\n'.join(app_iter)})]
|
||||||
if six.PY3:
|
body = [item.encode('utf-8') for item in body]
|
||||||
body = [item.encode('utf-8') for item in body]
|
|
||||||
state['headers'].append(('Content-Type', 'application/json'))
|
state['headers'].append(('Content-Type', 'application/json'))
|
||||||
state['headers'].append(('Content-Length', str(len(body[0]))))
|
state['headers'].append(('Content-Length', str(len(body[0]))))
|
||||||
else:
|
else:
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
"""Ironic specific exceptions list."""
|
"""Ironic specific exceptions list."""
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib.exception import IronicException
|
from ironic_lib.exception import IronicException
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
|
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
# 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 functools
|
||||||
|
|
||||||
from automaton import exceptions as automaton_exceptions
|
from automaton import exceptions as automaton_exceptions
|
||||||
from automaton import machines
|
from automaton import machines
|
||||||
import six
|
|
||||||
|
|
||||||
"""State machine modelling.
|
"""State machine modelling.
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ from ironic.common.i18n import _
|
|||||||
def _translate_excp(func):
|
def _translate_excp(func):
|
||||||
"""Decorator to translate automaton exceptions into ironic exceptions."""
|
"""Decorator to translate automaton exceptions into ironic exceptions."""
|
||||||
|
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
@ -39,9 +40,9 @@ def _translate_excp(func):
|
|||||||
automaton_exceptions.NotInitialized,
|
automaton_exceptions.NotInitialized,
|
||||||
automaton_exceptions.FrozenMachine,
|
automaton_exceptions.FrozenMachine,
|
||||||
automaton_exceptions.NotFound) as e:
|
automaton_exceptions.NotFound) as e:
|
||||||
raise excp.InvalidState(six.text_type(e))
|
raise excp.InvalidState(str(e))
|
||||||
except automaton_exceptions.Duplicate as e:
|
except automaton_exceptions.Duplicate as e:
|
||||||
raise excp.Duplicate(six.text_type(e))
|
raise excp.Duplicate(str(e))
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
@ -14,18 +14,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from glanceclient import client
|
from glanceclient import client
|
||||||
from glanceclient import exc as glance_exc
|
from glanceclient import exc as glance_exc
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import sendfile
|
import sendfile
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from swiftclient import utils as swift_utils
|
from swiftclient import utils as swift_utils
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -56,7 +56,7 @@ def _translate_image_exception(image_id, exc_value):
|
|||||||
|
|
||||||
def check_image_service(func):
|
def check_image_service(func):
|
||||||
"""Creates a glance client if doesn't exists and calls the function."""
|
"""Creates a glance client if doesn't exists and calls the function."""
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
"""Wrapper around methods calls.
|
"""Wrapper around methods calls.
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ class GlanceImageService(object):
|
|||||||
exc_type, exc_value, exc_trace = sys.exc_info()
|
exc_type, exc_value, exc_trace = sys.exc_info()
|
||||||
new_exc = _translate_image_exception(
|
new_exc = _translate_image_exception(
|
||||||
args[0], exc_value)
|
args[0], exc_value)
|
||||||
six.reraise(type(new_exc), new_exc, exc_trace)
|
raise type(new_exc)(new_exc).with_traceback(exc_trace)
|
||||||
|
|
||||||
@check_image_service
|
@check_image_service
|
||||||
def show(self, image_href):
|
def show(self, image_href):
|
||||||
|
@ -19,7 +19,6 @@ import copy
|
|||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ def _convert(metadata):
|
|||||||
for attr in _CONVERT_PROPS:
|
for attr in _CONVERT_PROPS:
|
||||||
if attr in properties:
|
if attr in properties:
|
||||||
prop = properties[attr]
|
prop = properties[attr]
|
||||||
if isinstance(prop, six.string_types):
|
if isinstance(prop, str):
|
||||||
properties[attr] = jsonutils.loads(prop)
|
properties[attr] = jsonutils.loads(prop)
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ def parse_image_id(image_href):
|
|||||||
|
|
||||||
:raises InvalidImageRef: when input image href is invalid
|
:raises InvalidImageRef: when input image href is invalid
|
||||||
"""
|
"""
|
||||||
image_href = six.text_type(image_href)
|
image_href = str(image_href)
|
||||||
if uuidutils.is_uuid_like(image_href):
|
if uuidutils.is_uuid_like(image_href):
|
||||||
image_id = image_href
|
image_id = image_href
|
||||||
elif image_href.startswith('glance://'):
|
elif image_href.startswith('glance://'):
|
||||||
@ -130,7 +129,7 @@ def is_image_active(image):
|
|||||||
|
|
||||||
|
|
||||||
def is_glance_image(image_href):
|
def is_glance_image(image_href):
|
||||||
if not isinstance(image_href, six.string_types):
|
if not isinstance(image_href, str):
|
||||||
return False
|
return False
|
||||||
return (image_href.startswith('glance://')
|
return (image_href.startswith('glance://')
|
||||||
or uuidutils.is_uuid_like(image_href))
|
or uuidutils.is_uuid_like(image_href))
|
||||||
|
@ -17,16 +17,15 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import requests
|
import requests
|
||||||
import sendfile
|
import sendfile
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.glance_service import image_service
|
from ironic.common.glance_service import image_service
|
||||||
@ -45,8 +44,7 @@ LOG = log.getLogger(__name__)
|
|||||||
GlanceImageService = image_service.GlanceImageService
|
GlanceImageService = image_service.GlanceImageService
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseImageService(object, metaclass=abc.ABCMeta):
|
||||||
class BaseImageService(object):
|
|
||||||
"""Provides retrieval of disk images."""
|
"""Provides retrieval of disk images."""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@ -103,7 +101,7 @@ class HttpImageService(BaseImageService):
|
|||||||
"HEAD request.") % response.status_code)
|
"HEAD request.") % response.status_code)
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
raise exception.ImageRefValidationFailed(image_href=output_url,
|
raise exception.ImageRefValidationFailed(image_href=output_url,
|
||||||
reason=six.text_type(e))
|
reason=str(e))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def download(self, image_href, image_file):
|
def download(self, image_href, image_file):
|
||||||
@ -128,7 +126,7 @@ class HttpImageService(BaseImageService):
|
|||||||
shutil.copyfileobj(input_img, image_file, IMAGE_CHUNK_SIZE)
|
shutil.copyfileobj(input_img, image_file, IMAGE_CHUNK_SIZE)
|
||||||
except (requests.RequestException, IOError) as e:
|
except (requests.RequestException, IOError) as e:
|
||||||
raise exception.ImageDownloadFailed(image_href=image_href,
|
raise exception.ImageDownloadFailed(image_href=image_href,
|
||||||
reason=six.text_type(e))
|
reason=str(e))
|
||||||
|
|
||||||
def show(self, image_href):
|
def show(self, image_href):
|
||||||
"""Get dictionary of image properties.
|
"""Get dictionary of image properties.
|
||||||
@ -228,7 +226,7 @@ class FileImageService(BaseImageService):
|
|||||||
offset += nbytes_out
|
offset += nbytes_out
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise exception.ImageDownloadFailed(image_href=image_href,
|
raise exception.ImageDownloadFailed(image_href=image_href,
|
||||||
reason=six.text_type(e))
|
reason=str(e))
|
||||||
|
|
||||||
def show(self, image_href):
|
def show(self, image_href):
|
||||||
"""Get dictionary of image properties.
|
"""Get dictionary of image properties.
|
||||||
@ -272,7 +270,7 @@ def get_image_service(image_href, client=None, context=None):
|
|||||||
scheme = urlparse.urlparse(image_href).scheme.lower()
|
scheme = urlparse.urlparse(image_href).scheme.lower()
|
||||||
|
|
||||||
if not scheme:
|
if not scheme:
|
||||||
if uuidutils.is_uuid_like(six.text_type(image_href)):
|
if uuidutils.is_uuid_like(str(image_href)):
|
||||||
cls = GlanceImageService
|
cls = GlanceImageService
|
||||||
else:
|
else:
|
||||||
raise exception.ImageRefValidationFailed(
|
raise exception.ImageRefValidationFailed(
|
||||||
|
@ -14,12 +14,13 @@
|
|||||||
|
|
||||||
"""Central place for handling Keystone authorization and service lookup."""
|
"""Central place for handling Keystone authorization and service lookup."""
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as kaexception
|
from keystoneauth1 import exceptions as kaexception
|
||||||
from keystoneauth1 import loading as kaloading
|
from keystoneauth1 import loading as kaloading
|
||||||
from keystoneauth1 import service_token
|
from keystoneauth1 import service_token
|
||||||
from keystoneauth1 import token_endpoint
|
from keystoneauth1 import token_endpoint
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.conf import CONF
|
from ironic.conf import CONF
|
||||||
@ -30,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def ks_exceptions(f):
|
def ks_exceptions(f):
|
||||||
"""Wraps keystoneclient functions and centralizes exception handling."""
|
"""Wraps keystoneclient functions and centralizes exception handling."""
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
@ -43,11 +44,11 @@ def ks_exceptions(f):
|
|||||||
raise exception.KeystoneUnauthorized()
|
raise exception.KeystoneUnauthorized()
|
||||||
except (kaexception.NoMatchingPlugin,
|
except (kaexception.NoMatchingPlugin,
|
||||||
kaexception.MissingRequiredOptions) as e:
|
kaexception.MissingRequiredOptions) as e:
|
||||||
raise exception.ConfigInvalid(six.text_type(e))
|
raise exception.ConfigInvalid(str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception('Keystone request failed: %(msg)s',
|
LOG.exception('Keystone request failed: %(msg)s',
|
||||||
{'msg': six.text_type(e)})
|
{'msg': str(e)})
|
||||||
raise exception.KeystoneFailure(six.text_type(e))
|
raise exception.KeystoneFailure(str(e))
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
# 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 http import client as http_client
|
||||||
from six.moves import http_client
|
from urllib import parse as urlparse
|
||||||
from six.moves.urllib import parse
|
|
||||||
from swiftclient import client as swift_client
|
from swiftclient import client as swift_client
|
||||||
from swiftclient import exceptions as swift_exceptions
|
from swiftclient import exceptions as swift_exceptions
|
||||||
from swiftclient import utils as swift_utils
|
from swiftclient import utils as swift_utils
|
||||||
@ -69,7 +69,7 @@ class SwiftAPI(object):
|
|||||||
params['timeout'] = session.timeout
|
params['timeout'] = session.timeout
|
||||||
if session.verify is False:
|
if session.verify is False:
|
||||||
params['insecure'] = True
|
params['insecure'] = True
|
||||||
elif isinstance(session.verify, six.string_types):
|
elif isinstance(session.verify, str):
|
||||||
params['cacert'] = session.verify
|
params['cacert'] = session.verify
|
||||||
if session.cert:
|
if session.cert:
|
||||||
# NOTE(pas-ha) although setting cert as path to single file
|
# NOTE(pas-ha) although setting cert as path to single file
|
||||||
@ -129,17 +129,14 @@ class SwiftAPI(object):
|
|||||||
raise exception.SwiftOperationError(operation=operation,
|
raise exception.SwiftOperationError(operation=operation,
|
||||||
error=e)
|
error=e)
|
||||||
|
|
||||||
parse_result = parse.urlparse(self.connection.url)
|
parse_result = urlparse.urlparse(self.connection.url)
|
||||||
swift_object_path = '/'.join((parse_result.path, container, obj))
|
swift_object_path = '/'.join((parse_result.path, container, obj))
|
||||||
temp_url_key = account_info['x-account-meta-temp-url-key']
|
temp_url_key = account_info['x-account-meta-temp-url-key']
|
||||||
url_path = swift_utils.generate_temp_url(swift_object_path, timeout,
|
url_path = swift_utils.generate_temp_url(swift_object_path, timeout,
|
||||||
temp_url_key, 'GET')
|
temp_url_key, 'GET')
|
||||||
return parse.urlunparse((parse_result.scheme,
|
return urlparse.urlunparse(
|
||||||
parse_result.netloc,
|
(parse_result.scheme, parse_result.netloc, url_path,
|
||||||
url_path,
|
None, None, None))
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None))
|
|
||||||
|
|
||||||
def delete_object(self, container, obj):
|
def delete_object(self, container, obj):
|
||||||
"""Deletes the given Swift object.
|
"""Deletes the given Swift object.
|
||||||
|
@ -35,7 +35,6 @@ from oslo_utils import fileutils
|
|||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import pytz
|
import pytz
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -92,7 +91,7 @@ def is_valid_datapath_id(datapath_id):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
m = "^[0-9a-f]{16}$"
|
m = "^[0-9a-f]{16}$"
|
||||||
return (isinstance(datapath_id, six.string_types)
|
return (isinstance(datapath_id, str)
|
||||||
and re.match(m, datapath_id.lower()))
|
and re.match(m, datapath_id.lower()))
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ def is_valid_logical_name(hostname):
|
|||||||
|
|
||||||
ALPHA / DIGIT / "-" / "." / "_" / "~"
|
ALPHA / DIGIT / "-" / "." / "_" / "~"
|
||||||
"""
|
"""
|
||||||
if not isinstance(hostname, six.string_types) or len(hostname) > 255:
|
if not isinstance(hostname, str) or len(hostname) > 255:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return _is_valid_logical_name_re.match(hostname) is not None
|
return _is_valid_logical_name_re.match(hostname) is not None
|
||||||
@ -136,7 +135,7 @@ def is_hostname_safe(hostname):
|
|||||||
:param hostname: The hostname to be validated.
|
:param hostname: The hostname to be validated.
|
||||||
:returns: True if valid. False if not.
|
:returns: True if valid. False if not.
|
||||||
"""
|
"""
|
||||||
if not isinstance(hostname, six.string_types) or len(hostname) > 255:
|
if not isinstance(hostname, str) or len(hostname) > 255:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return _is_hostname_safe_re.match(hostname) is not None
|
return _is_hostname_safe_re.match(hostname) is not None
|
||||||
@ -153,7 +152,7 @@ def is_valid_no_proxy(no_proxy):
|
|||||||
(with optional :port).
|
(with optional :port).
|
||||||
:returns: True if no_proxy is valid, False otherwise.
|
:returns: True if no_proxy is valid, False otherwise.
|
||||||
"""
|
"""
|
||||||
if not isinstance(no_proxy, six.string_types):
|
if not isinstance(no_proxy, str):
|
||||||
return False
|
return False
|
||||||
hostname_re = re.compile('(?!-)[A-Z\\d-]{1,63}(?<!-)$', re.IGNORECASE)
|
hostname_re = re.compile('(?!-)[A-Z\\d-]{1,63}(?<!-)$', re.IGNORECASE)
|
||||||
for hostname in no_proxy.split(','):
|
for hostname in no_proxy.split(','):
|
||||||
@ -219,8 +218,7 @@ def _get_hash_object(hash_algo_name):
|
|||||||
:raises: InvalidParameterValue, on unsupported or invalid input.
|
:raises: InvalidParameterValue, on unsupported or invalid input.
|
||||||
:returns: a hash object based on the given named algorithm.
|
:returns: a hash object based on the given named algorithm.
|
||||||
"""
|
"""
|
||||||
algorithms = (hashlib.algorithms_guaranteed if six.PY3
|
algorithms = hashlib.algorithms_guaranteed
|
||||||
else hashlib.algorithms)
|
|
||||||
if hash_algo_name not in algorithms:
|
if hash_algo_name not in algorithms:
|
||||||
msg = (_("Unsupported/Invalid hash name '%s' provided.")
|
msg = (_("Unsupported/Invalid hash name '%s' provided.")
|
||||||
% hash_algo_name)
|
% hash_algo_name)
|
||||||
@ -242,7 +240,7 @@ def file_has_content(path, content, hash_algo='md5'):
|
|||||||
file_hash_hex = fileutils.compute_file_checksum(path, algorithm=hash_algo)
|
file_hash_hex = fileutils.compute_file_checksum(path, algorithm=hash_algo)
|
||||||
ref_hash = _get_hash_object(hash_algo)
|
ref_hash = _get_hash_object(hash_algo)
|
||||||
encoded_content = (content.encode(encoding='utf-8')
|
encoded_content = (content.encode(encoding='utf-8')
|
||||||
if isinstance(content, six.string_types) else content)
|
if isinstance(content, str) else content)
|
||||||
ref_hash.update(encoded_content)
|
ref_hash.update(encoded_content)
|
||||||
return file_hash_hex == ref_hash.hexdigest()
|
return file_hash_hex == ref_hash.hexdigest()
|
||||||
|
|
||||||
@ -294,7 +292,7 @@ def safe_rstrip(value, chars=None):
|
|||||||
:return: Stripped value.
|
:return: Stripped value.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
LOG.warning("Failed to remove trailing character. Returning "
|
LOG.warning("Failed to remove trailing character. Returning "
|
||||||
"original object. Supplied object is not a string: "
|
"original object. Supplied object is not a string: "
|
||||||
"%s,", value)
|
"%s,", value)
|
||||||
@ -515,7 +513,7 @@ def parse_instance_info_capabilities(node):
|
|||||||
raise exception.InvalidParameterValue(error_msg)
|
raise exception.InvalidParameterValue(error_msg)
|
||||||
|
|
||||||
capabilities = node.instance_info.get('capabilities', {})
|
capabilities = node.instance_info.get('capabilities', {})
|
||||||
if isinstance(capabilities, six.string_types):
|
if isinstance(capabilities, str):
|
||||||
try:
|
try:
|
||||||
capabilities = jsonutils.loads(capabilities)
|
capabilities = jsonutils.loads(capabilities)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
@ -528,7 +526,7 @@ def parse_instance_info_capabilities(node):
|
|||||||
|
|
||||||
|
|
||||||
def validate_conductor_group(conductor_group):
|
def validate_conductor_group(conductor_group):
|
||||||
if not isinstance(conductor_group, six.string_types):
|
if not isinstance(conductor_group, str):
|
||||||
raise exception.InvalidConductorGroup(group=conductor_group)
|
raise exception.InvalidConductorGroup(group=conductor_group)
|
||||||
if not re.match(r'^[a-zA-Z0-9_\-\.]*$', conductor_group):
|
if not re.match(r'^[a-zA-Z0-9_\-\.]*$', conductor_group):
|
||||||
raise exception.InvalidConductorGroup(group=conductor_group)
|
raise exception.InvalidConductorGroup(group=conductor_group)
|
||||||
|
@ -24,7 +24,6 @@ from oslo_db import exception as db_exception
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import context as ironic_context
|
from ironic.common import context as ironic_context
|
||||||
from ironic.common import driver_factory
|
from ironic.common import driver_factory
|
||||||
@ -471,7 +470,7 @@ class BaseConductorManager(object):
|
|||||||
fsm.
|
fsm.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if isinstance(provision_state, six.string_types):
|
if isinstance(provision_state, str):
|
||||||
provision_state = {provision_state}
|
provision_state = {provision_state}
|
||||||
|
|
||||||
node_iter = self.iter_nodes(filters=filters,
|
node_iter = self.iter_nodes(filters=filters,
|
||||||
|
@ -42,6 +42,7 @@ notifying Neutron of a change, etc.
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
|
import queue
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@ -54,7 +55,6 @@ import oslo_messaging as messaging
|
|||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
from six.moves import queue
|
|
||||||
|
|
||||||
from ironic.common import driver_factory
|
from ironic.common import driver_factory
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
|
@ -101,6 +101,7 @@ raised in the background thread.):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import functools
|
||||||
|
|
||||||
import futurist
|
import futurist
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
@ -108,7 +109,6 @@ from oslo_log import log as logging
|
|||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import retrying
|
import retrying
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import driver_factory
|
from ironic.common import driver_factory
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -131,7 +131,7 @@ def require_exclusive_lock(f):
|
|||||||
as the first parameter after "self".
|
as the first parameter after "self".
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
# NOTE(dtantsur): this code could be written simpler, but then unit
|
# NOTE(dtantsur): this code could be written simpler, but then unit
|
||||||
# testing decorated functions is pretty hard, as we usually pass a Mock
|
# testing decorated functions is pretty hard, as we usually pass a Mock
|
||||||
@ -378,7 +378,7 @@ class TaskManager(object):
|
|||||||
if exc is not None:
|
if exc is not None:
|
||||||
msg = _("Async execution of %(method)s failed with error: "
|
msg = _("Async execution of %(method)s failed with error: "
|
||||||
"%(error)s") % {'method': method,
|
"%(error)s") % {'method': method,
|
||||||
'error': six.text_type(exc)}
|
'error': str(exc)}
|
||||||
node.last_error = msg
|
node.last_error = msg
|
||||||
try:
|
try:
|
||||||
node.save()
|
node.save()
|
||||||
|
@ -23,7 +23,6 @@ from oslo_serialization import jsonutils
|
|||||||
from oslo_service import loopingcall
|
from oslo_service import loopingcall
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -731,7 +730,7 @@ def validate_instance_info_traits(node):
|
|||||||
instance_traits = node.instance_info['traits']
|
instance_traits = node.instance_info['traits']
|
||||||
if not isinstance(instance_traits, list):
|
if not isinstance(instance_traits, list):
|
||||||
invalid()
|
invalid()
|
||||||
if not all(isinstance(t, six.string_types) for t in instance_traits):
|
if not all(isinstance(t, str) for t in instance_traits):
|
||||||
invalid()
|
invalid()
|
||||||
|
|
||||||
node_traits = node.traits.get_trait_names()
|
node_traits = node.traits.get_trait_names()
|
||||||
|
@ -21,7 +21,6 @@ import abc
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import api as db_api
|
from oslo_db import api as db_api
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
_BACKEND_MAPPING = {'sqlalchemy': 'ironic.db.sqlalchemy.api'}
|
_BACKEND_MAPPING = {'sqlalchemy': 'ironic.db.sqlalchemy.api'}
|
||||||
@ -34,8 +33,7 @@ def get_instance():
|
|||||||
return IMPL
|
return IMPL
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class Connection(object, metaclass=abc.ABCMeta):
|
||||||
class Connection(object):
|
|
||||||
"""Base class for storage system connections."""
|
"""Base class for storage system connections."""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -19,11 +19,11 @@ SQLAlchemy models for baremetal data.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from oslo_db import options as db_options
|
from oslo_db import options as db_options
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo_db.sqlalchemy import types as db_types
|
from oslo_db.sqlalchemy import types as db_types
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
from sqlalchemy import Boolean, Column, DateTime, false, Index
|
from sqlalchemy import Boolean, Column, DateTime, false, Index
|
||||||
from sqlalchemy import ForeignKey, Integer
|
from sqlalchemy import ForeignKey, Integer
|
||||||
from sqlalchemy import schema, String, Text
|
from sqlalchemy import schema, String, Text
|
||||||
|
@ -20,13 +20,11 @@ Abstract base class for dhcp providers.
|
|||||||
import abc
|
import abc
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseDHCP(object, metaclass=abc.ABCMeta):
|
||||||
class BaseDHCP(object):
|
|
||||||
"""Base class for DHCP provider APIs."""
|
"""Base class for DHCP provider APIs."""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@ -20,13 +20,13 @@ Abstract base classes for drivers.
|
|||||||
import abc
|
import abc
|
||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -189,8 +189,7 @@ ALL_INTERFACES = set(BareDriver().all_interfaces)
|
|||||||
"""Constant holding all known interfaces."""
|
"""Constant holding all known interfaces."""
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseInterface(object, metaclass=abc.ABCMeta):
|
||||||
class BaseInterface(object):
|
|
||||||
"""A base interface implementing common functions for Driver Interfaces."""
|
"""A base interface implementing common functions for Driver Interfaces."""
|
||||||
|
|
||||||
supported = True
|
supported = True
|
||||||
@ -747,7 +746,7 @@ def _passthru(http_methods, method=None, async_call=True,
|
|||||||
|
|
||||||
passthru_logmessage = 'vendor_passthru failed with method %s'
|
passthru_logmessage = 'vendor_passthru failed with method %s'
|
||||||
|
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def passthru_handler(*args, **kwargs):
|
def passthru_handler(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
@ -1138,7 +1137,7 @@ def cache_bios_settings(func):
|
|||||||
|
|
||||||
:param func: Function or method to wrap.
|
:param func: Function or method to wrap.
|
||||||
"""
|
"""
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapped(self, task, *args, **kwargs):
|
def wrapped(self, task, *args, **kwargs):
|
||||||
result = func(self, task, *args, **kwargs)
|
result = func(self, task, *args, **kwargs)
|
||||||
self.cache_bios_settings(task)
|
self.cache_bios_settings(task)
|
||||||
@ -1545,8 +1544,7 @@ class NetworkInterface(BaseInterface):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class StorageInterface(BaseInterface, metaclass=abc.ABCMeta):
|
||||||
class StorageInterface(BaseInterface):
|
|
||||||
"""Base class for storage interfaces."""
|
"""Base class for storage interfaces."""
|
||||||
|
|
||||||
interface_type = 'storage'
|
interface_type = 'storage'
|
||||||
@ -1609,7 +1607,7 @@ def _validate_argsinfo(argsinfo):
|
|||||||
has_description = False
|
has_description = False
|
||||||
for (key, value) in info.items():
|
for (key, value) in info.items():
|
||||||
if key == 'description':
|
if key == 'description':
|
||||||
if not isinstance(value, six.string_types):
|
if not isinstance(value, str):
|
||||||
raise exception.InvalidParameterValue(
|
raise exception.InvalidParameterValue(
|
||||||
_('For argument "%(arg)s", "description" must be a '
|
_('For argument "%(arg)s", "description" must be a '
|
||||||
'string value instead of "%(value)s".') %
|
'string value instead of "%(value)s".') %
|
||||||
|
@ -18,8 +18,6 @@ Abstract base class for all hardware types.
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.drivers import base as driver_base
|
from ironic.drivers import base as driver_base
|
||||||
from ironic.drivers.modules.network import noop as noop_net
|
from ironic.drivers.modules.network import noop as noop_net
|
||||||
@ -27,8 +25,7 @@ from ironic.drivers.modules import noop
|
|||||||
from ironic.drivers.modules.storage import noop as noop_storage
|
from ironic.drivers.modules.storage import noop as noop_storage
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class AbstractHardwareType(object, metaclass=abc.ABCMeta):
|
||||||
class AbstractHardwareType(object):
|
|
||||||
"""Abstract base class for all hardware types.
|
"""Abstract base class for all hardware types.
|
||||||
|
|
||||||
Hardware type is a family of hardware supporting the same set of interfaces
|
Hardware type is a family of hardware supporting the same set of interfaces
|
||||||
|
@ -12,12 +12,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from ironic_lib import utils as il_utils
|
from ironic_lib import utils as il_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import six.moves.urllib_parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import dhcp_factory
|
from ironic.common import dhcp_factory
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
|
@ -12,12 +12,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import requests
|
import requests
|
||||||
import retrying
|
import retrying
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
|
@ -18,6 +18,7 @@ Ansible deploy interface
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from ironic_lib import utils as irlib_utils
|
from ironic_lib import utils as irlib_utils
|
||||||
@ -26,8 +27,6 @@ from oslo_log import log
|
|||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import retrying
|
import retrying
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from ironic.common import dhcp_factory
|
from ironic.common import dhcp_factory
|
||||||
@ -242,7 +241,7 @@ def _parse_root_device_hints(node):
|
|||||||
root_device_hints = {}
|
root_device_hints = {}
|
||||||
advanced = {}
|
advanced = {}
|
||||||
for hint, value in parsed_hints.items():
|
for hint, value in parsed_hints.items():
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
if value.startswith('== '):
|
if value.startswith('== '):
|
||||||
root_device_hints[hint] = int(value[3:])
|
root_device_hints[hint] = int(value[3:])
|
||||||
elif value.startswith('s== '):
|
elif value.startswith('s== '):
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
# 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 configparser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
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_utils import strutils
|
from oslo_utils import strutils
|
||||||
import pbr.version
|
import pbr.version
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
@ -29,7 +29,6 @@ from oslo_utils import excutils
|
|||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import faults
|
from ironic.common import faults
|
||||||
@ -126,7 +125,7 @@ def get_ironic_api_url():
|
|||||||
raise exception.InvalidParameterValue(_(
|
raise exception.InvalidParameterValue(_(
|
||||||
"Couldn't get the URL of the Ironic API service from the "
|
"Couldn't get the URL of the Ironic API service from the "
|
||||||
"configuration file or keystone catalog. Keystone error: "
|
"configuration file or keystone catalog. Keystone error: "
|
||||||
"%s") % six.text_type(e))
|
"%s") % str(e))
|
||||||
# NOTE: we should strip '/' from the end because it might be used in
|
# NOTE: we should strip '/' from the end because it might be used in
|
||||||
# hardcoded ramdisk script
|
# hardcoded ramdisk script
|
||||||
ironic_api = ironic_api.rstrip('/')
|
ironic_api = ironic_api.rstrip('/')
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
iBMC Driver common utils
|
iBMC Driver common utils
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
@ -21,7 +22,6 @@ from oslo_utils import importutils
|
|||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import retrying
|
import retrying
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -90,7 +90,7 @@ def parse_driver_info(node):
|
|||||||
|
|
||||||
# Check if verify_ca is a Boolean or a file/directory in the file-system
|
# Check if verify_ca is a Boolean or a file/directory in the file-system
|
||||||
verify_ca = driver_info.get('ibmc_verify_ca', True)
|
verify_ca = driver_info.get('ibmc_verify_ca', True)
|
||||||
if isinstance(verify_ca, six.string_types):
|
if isinstance(verify_ca, str):
|
||||||
if not os.path.exists(verify_ca):
|
if not os.path.exists(verify_ca):
|
||||||
try:
|
try:
|
||||||
verify_ca = strutils.bool_from_string(verify_ca, strict=True)
|
verify_ca = strutils.bool_from_string(verify_ca, strict=True)
|
||||||
@ -138,7 +138,7 @@ def handle_ibmc_exception(action):
|
|||||||
retry_on_exception=should_retry,
|
retry_on_exception=should_retry,
|
||||||
stop_max_attempt_number=CONF.ibmc.connection_attempts,
|
stop_max_attempt_number=CONF.ibmc.connection_attempts,
|
||||||
wait_fixed=CONF.ibmc.connection_retry_interval * 1000)
|
wait_fixed=CONF.ibmc.connection_retry_interval * 1000)
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
# NOTE(dtantsur): this code could be written simpler, but then unit
|
# NOTE(dtantsur): this code could be written simpler, but then unit
|
||||||
# testing decorated functions is pretty hard, as we usually pass a
|
# testing decorated functions is pretty hard, as we usually pass a
|
||||||
|
@ -17,13 +17,13 @@ Boot Interface for iLO drivers and its supporting methods.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from ironic_lib import utils as ironic_utils
|
from ironic_lib import utils as ironic_utils
|
||||||
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_utils import excutils
|
from oslo_utils import excutils
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
|
@ -19,14 +19,12 @@ Common functionalities shared between different iLO modules.
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import utils as ironic_utils
|
from ironic_lib import utils as ironic_utils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
from six.moves.urllib.parse import urljoin
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -137,7 +135,7 @@ def copy_image_to_web_server(source_file_path, destination):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
image_url = urljoin(CONF.deploy.http_url, destination)
|
image_url = urlparse.urljoin(CONF.deploy.http_url, destination)
|
||||||
image_path = os.path.join(CONF.deploy.http_root, destination)
|
image_path = os.path.join(CONF.deploy.http_root, destination)
|
||||||
try:
|
try:
|
||||||
shutil.copyfile(source_file_path, image_path)
|
shutil.copyfile(source_file_path, image_path)
|
||||||
@ -313,7 +311,7 @@ def _parse_snmp_driver_info(info):
|
|||||||
for param in SNMP_OPTIONAL_PROPERTIES:
|
for param in SNMP_OPTIONAL_PROPERTIES:
|
||||||
value = None
|
value = None
|
||||||
try:
|
try:
|
||||||
value = six.text_type(info[param]).upper()
|
value = str(info[param]).upper()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if value:
|
if value:
|
||||||
@ -781,7 +779,7 @@ def remove_single_or_list_of_files(file_location):
|
|||||||
for location in file_location:
|
for location in file_location:
|
||||||
ironic_utils.unlink_without_raise(location)
|
ironic_utils.unlink_without_raise(location)
|
||||||
# file_location is a single file path
|
# file_location is a single file path
|
||||||
elif isinstance(file_location, six.string_types):
|
elif isinstance(file_location, str):
|
||||||
ironic_utils.unlink_without_raise(file_location)
|
ironic_utils.unlink_without_raise(file_location)
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,18 +15,18 @@
|
|||||||
Firmware file processor
|
Firmware file processor
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import types
|
import types
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
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_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -53,7 +53,7 @@ proliantutils_utils = importutils.try_import('proliantutils.utils')
|
|||||||
|
|
||||||
def verify_firmware_update_args(func):
|
def verify_firmware_update_args(func):
|
||||||
"""Verifies the firmware update arguments."""
|
"""Verifies the firmware update arguments."""
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(self, task, **kwargs):
|
def wrapper(self, task, **kwargs):
|
||||||
"""Wrapper around ``update_firmware`` call.
|
"""Wrapper around ``update_firmware`` call.
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
iLO Management Interface
|
iLO Management Interface
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_service import loopingcall
|
from oslo_service import loopingcall
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -418,7 +418,7 @@ class IloManagement(base.ManagementInterface):
|
|||||||
ilo_license_key = kwargs.get('ilo_license_key')
|
ilo_license_key = kwargs.get('ilo_license_key')
|
||||||
node = task.node
|
node = task.node
|
||||||
|
|
||||||
if not isinstance(ilo_license_key, six.string_types):
|
if not isinstance(ilo_license_key, str):
|
||||||
msg = (_("Value of 'ilo_license_key' must be a string instead of "
|
msg = (_("Value of 'ilo_license_key' must be a string instead of "
|
||||||
"'%(value)s'. Step 'activate_license' is not executed "
|
"'%(value)s'. Step 'activate_license' is not executed "
|
||||||
"for %(node)s.")
|
"for %(node)s.")
|
||||||
|
@ -26,7 +26,6 @@ import uuid
|
|||||||
from oslo_concurrency import lockutils
|
from oslo_concurrency import lockutils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.glance_service import service_utils
|
from ironic.common.glance_service import service_utils
|
||||||
@ -95,11 +94,7 @@ class ImageCache(object):
|
|||||||
if service_utils.is_glance_image(href):
|
if service_utils.is_glance_image(href):
|
||||||
master_file_name = service_utils.parse_image_id(href)
|
master_file_name = service_utils.parse_image_id(href)
|
||||||
else:
|
else:
|
||||||
# NOTE(vdrok): Doing conversion of href in case it's unicode
|
master_file_name = str(uuid.uuid5(uuid.NAMESPACE_URL, href))
|
||||||
# string, UUID cannot be generated for unicode strings on python 2.
|
|
||||||
href_encoded = href.encode('utf-8') if six.PY2 else href
|
|
||||||
master_file_name = str(uuid.uuid5(uuid.NAMESPACE_URL,
|
|
||||||
href_encoded))
|
|
||||||
# NOTE(kaifeng) The ".converted" suffix acts as an indicator that the
|
# NOTE(kaifeng) The ".converted" suffix acts as an indicator that the
|
||||||
# image cached has gone through the conversion logic.
|
# image cached has gone through the conversion logic.
|
||||||
if force_raw:
|
if force_raw:
|
||||||
|
@ -43,7 +43,6 @@ from oslo_concurrency import processutils
|
|||||||
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 strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -284,7 +283,7 @@ def _parse_driver_info(node):
|
|||||||
|
|
||||||
address = info.get('ipmi_address')
|
address = info.get('ipmi_address')
|
||||||
username = info.get('ipmi_username')
|
username = info.get('ipmi_username')
|
||||||
password = six.text_type(info.get('ipmi_password', ''))
|
password = str(info.get('ipmi_password', ''))
|
||||||
hex_kg_key = info.get('ipmi_hex_kg_key')
|
hex_kg_key = info.get('ipmi_hex_kg_key')
|
||||||
dest_port = info.get('ipmi_port')
|
dest_port = info.get('ipmi_port')
|
||||||
port = info.get('ipmi_terminal_port')
|
port = info.get('ipmi_terminal_port')
|
||||||
@ -528,7 +527,7 @@ def _exec_ipmitool(driver_info, command, check_exit_code=None,
|
|||||||
x for x in (
|
x for x in (
|
||||||
IPMITOOL_RETRYABLE_FAILURES +
|
IPMITOOL_RETRYABLE_FAILURES +
|
||||||
CONF.ipmi.additional_retryable_ipmi_errors)
|
CONF.ipmi.additional_retryable_ipmi_errors)
|
||||||
if x in six.text_type(e)]
|
if x in str(e)]
|
||||||
if ((time.time() > end_time)
|
if ((time.time() > end_time)
|
||||||
or (num_tries == 0)
|
or (num_tries == 0)
|
||||||
or not err_list):
|
or not err_list):
|
||||||
|
@ -19,12 +19,12 @@ iRMC Boot Driver
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from ironic_lib import utils as ironic_utils
|
from ironic_lib import utils as ironic_utils
|
||||||
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 six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
|
@ -17,7 +17,6 @@ Common functionalities shared between different iRMC modules.
|
|||||||
"""
|
"""
|
||||||
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 six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -113,13 +112,13 @@ def parse_driver_info(node):
|
|||||||
d_info['irmc_snmp_port'])
|
d_info['irmc_snmp_port'])
|
||||||
if (d_info['irmc_snmp_version'].lower() in ('v1', 'v2c')
|
if (d_info['irmc_snmp_version'].lower() in ('v1', 'v2c')
|
||||||
and d_info['irmc_snmp_community']
|
and d_info['irmc_snmp_community']
|
||||||
and not isinstance(d_info['irmc_snmp_community'], six.string_types)):
|
and not isinstance(d_info['irmc_snmp_community'], str)):
|
||||||
error_msgs.append(
|
error_msgs.append(
|
||||||
_("Value '%s' is not a string for 'irmc_snmp_community'") %
|
_("Value '%s' is not a string for 'irmc_snmp_community'") %
|
||||||
d_info['irmc_snmp_community'])
|
d_info['irmc_snmp_community'])
|
||||||
if d_info['irmc_snmp_version'].lower() == 'v3':
|
if d_info['irmc_snmp_version'].lower() == 'v3':
|
||||||
if d_info['irmc_snmp_security']:
|
if d_info['irmc_snmp_security']:
|
||||||
if not isinstance(d_info['irmc_snmp_security'], six.string_types):
|
if not isinstance(d_info['irmc_snmp_security'], str):
|
||||||
error_msgs.append(
|
error_msgs.append(
|
||||||
_("Value '%s' is not a string for "
|
_("Value '%s' is not a string for "
|
||||||
"'irmc_snmp_security'") % d_info['irmc_snmp_security'])
|
"'irmc_snmp_security'") % d_info['irmc_snmp_security'])
|
||||||
|
@ -19,7 +19,6 @@ from futurist import periodics
|
|||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
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 six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import raid as raid_common
|
from ironic.common import raid as raid_common
|
||||||
@ -392,7 +391,7 @@ class IRMCRAID(base.RAIDInterface):
|
|||||||
logical_disks = target_raid_config['logical_disks']
|
logical_disks = target_raid_config['logical_disks']
|
||||||
for log_disk in logical_disks:
|
for log_disk in logical_disks:
|
||||||
if log_disk.get('raid_level'):
|
if log_disk.get('raid_level'):
|
||||||
log_disk['raid_level'] = six.text_type(
|
log_disk['raid_level'] = str(
|
||||||
log_disk['raid_level']).replace('+', '')
|
log_disk['raid_level']).replace('+', '')
|
||||||
|
|
||||||
# Validate physical disks on Fujitsu BM Server
|
# Validate physical disks on Fujitsu BM Server
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
# 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 as urlparse
|
||||||
|
|
||||||
from ironic_lib import disk_utils
|
from ironic_lib import disk_utils
|
||||||
from ironic_lib import metrics_utils
|
from ironic_lib import metrics_utils
|
||||||
from ironic_lib import utils as il_utils
|
from ironic_lib import utils as il_utils
|
||||||
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 six.moves.urllib import parse
|
|
||||||
|
|
||||||
from ironic.common import dhcp_factory
|
from ironic.common import dhcp_factory
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -284,7 +285,7 @@ def do_agent_iscsi_deploy(task, agent_client):
|
|||||||
deploy_utils.set_failed_state(task, msg)
|
deploy_utils.set_failed_state(task, msg)
|
||||||
raise exception.InstanceDeployFailure(reason=msg)
|
raise exception.InstanceDeployFailure(reason=msg)
|
||||||
|
|
||||||
address = parse.urlparse(node.driver_internal_info['agent_url'])
|
address = urlparse.urlparse(node.driver_internal_info['agent_url'])
|
||||||
address = address.hostname
|
address = address.hostname
|
||||||
|
|
||||||
uuid_dict_returned = continue_deploy(task, iqn=iqn, address=address,
|
uuid_dict_returned = continue_deploy(task, iqn=iqn, address=address,
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic_lib import utils as ironic_utils
|
from ironic_lib import utils as ironic_utils
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import os
|
import os
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
@ -22,8 +23,6 @@ from oslo_utils import importutils
|
|||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import retrying
|
import retrying
|
||||||
import rfc3986
|
import rfc3986
|
||||||
import six
|
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -111,7 +110,7 @@ def parse_driver_info(node):
|
|||||||
{'address': address, 'node': node.uuid})
|
{'address': address, 'node': node.uuid})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
system_id = urllib.parse.quote(driver_info['redfish_system_id'])
|
system_id = urlparse.quote(driver_info['redfish_system_id'])
|
||||||
except (TypeError, AttributeError):
|
except (TypeError, AttributeError):
|
||||||
raise exception.InvalidParameterValue(
|
raise exception.InvalidParameterValue(
|
||||||
_('Invalid value "%(value)s" set in '
|
_('Invalid value "%(value)s" set in '
|
||||||
@ -123,7 +122,7 @@ def parse_driver_info(node):
|
|||||||
|
|
||||||
# Check if verify_ca is a Boolean or a file/directory in the file-system
|
# Check if verify_ca is a Boolean or a file/directory in the file-system
|
||||||
verify_ca = driver_info.get('redfish_verify_ca', True)
|
verify_ca = driver_info.get('redfish_verify_ca', True)
|
||||||
if isinstance(verify_ca, six.string_types):
|
if isinstance(verify_ca, str):
|
||||||
if os.path.isdir(verify_ca) or os.path.isfile(verify_ca):
|
if os.path.isdir(verify_ca) or os.path.isfile(verify_ca):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -29,7 +29,6 @@ import time
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_service import loopingcall
|
from oslo_service import loopingcall
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -430,8 +429,7 @@ def retry_on_outdated_cache(f):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class SNMPDriverBase(object, metaclass=abc.ABCMeta):
|
||||||
class SNMPDriverBase(object):
|
|
||||||
"""SNMP power driver base class.
|
"""SNMP power driver base class.
|
||||||
|
|
||||||
The SNMPDriver class hierarchy implements manufacturer-specific MIB actions
|
The SNMPDriver class hierarchy implements manufacturer-specific MIB actions
|
||||||
|
@ -20,7 +20,6 @@ from oslo_log import log as logging
|
|||||||
from oslo_serialization import base64
|
from oslo_serialization import base64
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -239,7 +238,7 @@ def capabilities_to_dict(capabilities):
|
|||||||
"""
|
"""
|
||||||
capabilities_dict = {}
|
capabilities_dict = {}
|
||||||
if capabilities:
|
if capabilities:
|
||||||
if not isinstance(capabilities, six.string_types):
|
if not isinstance(capabilities, str):
|
||||||
raise exception.InvalidParameterValue(
|
raise exception.InvalidParameterValue(
|
||||||
_("Value of 'capabilities' must be string. Got %s")
|
_("Value of 'capabilities' must be string. Got %s")
|
||||||
% type(capabilities))
|
% type(capabilities))
|
||||||
|
@ -18,7 +18,6 @@ import hashlib
|
|||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from oslo_versionedobjects import fields as object_fields
|
from oslo_versionedobjects import fields as object_fields
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import utils
|
from ironic.common import utils
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ class ListOfObjectsField(object_fields.ListOfObjectsField):
|
|||||||
class FlexibleDict(object_fields.FieldType):
|
class FlexibleDict(object_fields.FieldType):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def coerce(obj, attr, value):
|
def coerce(obj, attr, value):
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
value = ast.literal_eval(value)
|
value = ast.literal_eval(value)
|
||||||
return dict(value)
|
return dict(value)
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ from oslo_utils import strutils
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
from oslo_versionedobjects import base as object_base
|
from oslo_versionedobjects import base as object_base
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
@ -424,7 +423,7 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
|
|
||||||
for attr_name in ('last_error', 'maintenance_reason'):
|
for attr_name in ('last_error', 'maintenance_reason'):
|
||||||
attr_value = getattr(self, attr_name, '')
|
attr_value = getattr(self, attr_name, '')
|
||||||
if (attr_value and isinstance(attr_value, six.string_types) and
|
if (attr_value and isinstance(attr_value, str) and
|
||||||
len(attr_value) > CONF.log_in_db_max_size):
|
len(attr_value) > CONF.log_in_db_max_size):
|
||||||
LOG.info('Truncating too long %s to %s characters for node %s',
|
LOG.info('Truncating too long %s to %s characters for node %s',
|
||||||
attr_name, CONF.log_in_db_max_size, self.uuid)
|
attr_name, CONF.log_in_db_max_size, self.uuid)
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
# ceilometer/tests/api/__init__.py). This should be oslo'ified:
|
# ceilometer/tests/api/__init__.py). This should be oslo'ified:
|
||||||
# https://bugs.launchpad.net/ironic/+bug/1255115.
|
# https://bugs.launchpad.net/ironic/+bug/1255115.
|
||||||
|
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import pecan
|
import pecan
|
||||||
import pecan.testing
|
import pecan.testing
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from ironic.tests.unit.db import base as db_base
|
from ironic.tests.unit.db import base as db_base
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
# 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
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from six.moves import http_client
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
from ironic.api.controllers import base as cbase
|
from ironic.api.controllers import base as cbase
|
||||||
|
@ -14,15 +14,14 @@ Tests for the API /allocations/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
@ -175,7 +174,7 @@ class TestListAllocations(test_api_base.BaseApiTest):
|
|||||||
self.assertEqual(len(allocations), len(data['allocations']))
|
self.assertEqual(len(allocations), len(data['allocations']))
|
||||||
|
|
||||||
uuids = [n['uuid'] for n in data['allocations']]
|
uuids = [n['uuid'] for n in data['allocations']]
|
||||||
six.assertCountEqual(self, allocations, uuids)
|
self.assertCountEqual(allocations, uuids)
|
||||||
|
|
||||||
def test_links(self):
|
def test_links(self):
|
||||||
uuid = uuidutils.generate_uuid()
|
uuid = uuidutils.generate_uuid()
|
||||||
|
@ -16,14 +16,13 @@ Tests for the API /chassis/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
@ -181,7 +180,7 @@ class TestListChassis(test_api_base.BaseApiTest):
|
|||||||
data = self.get_json('/chassis')
|
data = self.get_json('/chassis')
|
||||||
self.assertEqual(len(ch_list), len(data['chassis']))
|
self.assertEqual(len(ch_list), len(data['chassis']))
|
||||||
uuids = [n['uuid'] for n in data['chassis']]
|
uuids = [n['uuid'] for n in data['chassis']]
|
||||||
six.assertCountEqual(self, ch_list, uuids)
|
self.assertCountEqual(ch_list, uuids)
|
||||||
|
|
||||||
def _test_links(self, public_url=None):
|
def _test_links(self, public_url=None):
|
||||||
cfg.CONF.set_override('public_endpoint', public_url, 'api')
|
cfg.CONF.set_override('public_endpoint', public_url, 'api')
|
||||||
|
@ -14,12 +14,12 @@ Tests for the API /conductors/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
from ironic.api.controllers import v1 as api_v1
|
from ironic.api.controllers import v1 as api_v1
|
||||||
|
@ -14,14 +14,13 @@ Tests for the API /deploy_templates/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
from ironic.api.controllers import v1 as api_v1
|
from ironic.api.controllers import v1 as api_v1
|
||||||
@ -207,7 +206,7 @@ class TestListDeployTemplates(BaseDeployTemplatesAPITest):
|
|||||||
self.assertEqual(len(templates), len(data['deploy_templates']))
|
self.assertEqual(len(templates), len(data['deploy_templates']))
|
||||||
|
|
||||||
uuids = [n['uuid'] for n in data['deploy_templates']]
|
uuids = [n['uuid'] for n in data['deploy_templates']]
|
||||||
six.assertCountEqual(self, templates, uuids)
|
self.assertCountEqual(templates, uuids)
|
||||||
|
|
||||||
def test_links(self):
|
def test_links(self):
|
||||||
uuid = uuidutils.generate_uuid()
|
uuid = uuidutils.generate_uuid()
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
# 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
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from six.moves import http_client
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
Tests for the API /events methods.
|
Tests for the API /events methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
from ironic.api.controllers.v1 import types
|
from ironic.api.controllers.v1 import types
|
||||||
|
@ -14,16 +14,15 @@ Tests for the API /nodes/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
import json
|
import json
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@ -3476,8 +3475,7 @@ class TestPost(test_api_base.BaseApiTest):
|
|||||||
is_async=True):
|
is_async=True):
|
||||||
expected_status = http_client.ACCEPTED if is_async else http_client.OK
|
expected_status = http_client.ACCEPTED if is_async else http_client.OK
|
||||||
expected_return_value = json.dumps(return_value)
|
expected_return_value = json.dumps(return_value)
|
||||||
if six.PY3:
|
expected_return_value = expected_return_value.encode('utf-8')
|
||||||
expected_return_value = expected_return_value.encode('utf-8')
|
|
||||||
|
|
||||||
node = obj_utils.create_test_node(self.context)
|
node = obj_utils.create_test_node(self.context)
|
||||||
info = {'foo': 'bar'}
|
info = {'foo': 'bar'}
|
||||||
@ -3495,8 +3493,7 @@ class TestPost(test_api_base.BaseApiTest):
|
|||||||
is_async=True):
|
is_async=True):
|
||||||
expected_status = http_client.ACCEPTED if is_async else http_client.OK
|
expected_status = http_client.ACCEPTED if is_async else http_client.OK
|
||||||
expected_return_value = json.dumps(return_value)
|
expected_return_value = json.dumps(return_value)
|
||||||
if six.PY3:
|
expected_return_value = expected_return_value.encode('utf-8')
|
||||||
expected_return_value = expected_return_value.encode('utf-8')
|
|
||||||
|
|
||||||
node = obj_utils.create_test_node(self.context, name='node-109')
|
node = obj_utils.create_test_node(self.context, name='node-109')
|
||||||
info = {'foo': 'bar'}
|
info = {'foo': 'bar'}
|
||||||
|
@ -14,15 +14,14 @@ Tests for the API /ports/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
import types
|
import types
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@ -580,7 +579,7 @@ class TestListPorts(test_api_base.BaseApiTest):
|
|||||||
self.assertEqual(len(ports), len(data['ports']))
|
self.assertEqual(len(ports), len(data['ports']))
|
||||||
|
|
||||||
uuids = [n['uuid'] for n in data['ports']]
|
uuids = [n['uuid'] for n in data['ports']]
|
||||||
six.assertCountEqual(self, ports, uuids)
|
self.assertCountEqual(ports, uuids)
|
||||||
|
|
||||||
def _test_links(self, public_url=None):
|
def _test_links(self, public_url=None):
|
||||||
cfg.CONF.set_override('public_endpoint', public_url, 'api')
|
cfg.CONF.set_override('public_endpoint', public_url, 'api')
|
||||||
|
@ -14,14 +14,13 @@ Tests for the API /portgroups/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from testtools.matchers import HasLength
|
from testtools.matchers import HasLength
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
@ -277,7 +276,7 @@ class TestListPortgroups(test_api_base.BaseApiTest):
|
|||||||
self.assertEqual(len(portgroups), len(data['portgroups']))
|
self.assertEqual(len(portgroups), len(data['portgroups']))
|
||||||
|
|
||||||
uuids = [n['uuid'] for n in data['portgroups']]
|
uuids = [n['uuid'] for n in data['portgroups']]
|
||||||
six.assertCountEqual(self, portgroups, uuids)
|
self.assertCountEqual(portgroups, uuids)
|
||||||
|
|
||||||
def test_links(self):
|
def test_links(self):
|
||||||
uuid = uuidutils.generate_uuid()
|
uuid = uuidutils.generate_uuid()
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
Tests for the API /lookup/ methods.
|
Tests for the API /lookup/ methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
from ironic.api.controllers import v1 as api_v1
|
from ironic.api.controllers import v1 as api_v1
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
# 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 http import client as http_client
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
import webtest
|
import webtest
|
||||||
import wsme
|
import wsme
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
@ -264,8 +264,7 @@ class TestJsonType(base.TestCase):
|
|||||||
def test_apimultitype_tostring(self):
|
def test_apimultitype_tostring(self):
|
||||||
vts = str(types.jsontype)
|
vts = str(types.jsontype)
|
||||||
self.assertIn(str(wtypes.text), vts)
|
self.assertIn(str(wtypes.text), vts)
|
||||||
for int_type in six.integer_types:
|
self.assertIn(str(int), vts)
|
||||||
self.assertIn(str(int_type), vts)
|
|
||||||
self.assertIn(str(float), vts)
|
self.assertIn(str(float), vts)
|
||||||
self.assertIn(str(types.BooleanType), vts)
|
self.assertIn(str(types.BooleanType), vts)
|
||||||
self.assertIn(str(list), vts)
|
self.assertIn(str(list), vts)
|
||||||
|
@ -14,11 +14,12 @@
|
|||||||
# 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
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import os_traits
|
import os_traits
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from six.moves import http_client
|
|
||||||
from webob import static
|
from webob import static
|
||||||
import wsme
|
import wsme
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
Tests for the API /volume/ methods.
|
Tests for the API /volume/ methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from six.moves import http_client
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
from ironic.api.controllers import v1 as api_v1
|
from ironic.api.controllers import v1 as api_v1
|
||||||
|
@ -16,14 +16,13 @@ Tests for the API /volume connectors/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
@ -222,7 +221,7 @@ class TestListVolumeConnectors(test_api_base.BaseApiTest):
|
|||||||
self.assertEqual(len(connectors), len(data['connectors']))
|
self.assertEqual(len(connectors), len(data['connectors']))
|
||||||
|
|
||||||
uuids = [n['uuid'] for n in data['connectors']]
|
uuids = [n['uuid'] for n in data['connectors']]
|
||||||
six.assertCountEqual(self, connectors, uuids)
|
self.assertCountEqual(connectors, uuids)
|
||||||
|
|
||||||
def test_links(self):
|
def test_links(self):
|
||||||
uuid = uuidutils.generate_uuid()
|
uuid = uuidutils.generate_uuid()
|
||||||
|
@ -16,14 +16,13 @@ Tests for the API /volume targets/ methods.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from ironic.api.controllers import base as api_base
|
from ironic.api.controllers import base as api_base
|
||||||
@ -212,7 +211,7 @@ class TestListVolumeTargets(test_api_base.BaseApiTest):
|
|||||||
self.assertEqual(len(targets), len(data['targets']))
|
self.assertEqual(len(targets), len(data['targets']))
|
||||||
|
|
||||||
uuids = [n['uuid'] for n in data['targets']]
|
uuids = [n['uuid'] for n in data['targets']]
|
||||||
six.assertCountEqual(self, targets, uuids)
|
self.assertCountEqual(targets, uuids)
|
||||||
|
|
||||||
def test_links(self):
|
def test_links(self):
|
||||||
uuid = uuidutils.generate_uuid()
|
uuid = uuidutils.generate_uuid()
|
||||||
|
@ -16,9 +16,10 @@ Tests for ACL. Checks whether certain kinds of requests
|
|||||||
are blocked or allowed to be processed.
|
are blocked or allowed to be processed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.tests.unit.api import base
|
from ironic.tests.unit.api import base
|
||||||
from ironic.tests.unit.api import utils
|
from ironic.tests.unit.api import utils
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
|
|
||||||
"""Tests for the Pecan API hooks."""
|
"""Tests for the Pecan API hooks."""
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.api.controllers import root
|
from ironic.api.controllers import root
|
||||||
from ironic.api import hooks
|
from ironic.api import hooks
|
||||||
@ -130,7 +129,7 @@ class TestNoExceptionTracebackHook(base.BaseApiTest):
|
|||||||
# we don't care about this garbage.
|
# we don't care about this garbage.
|
||||||
expected_msg = ("Remote error: %s %s"
|
expected_msg = ("Remote error: %s %s"
|
||||||
% (test_exc_type, self.MSG_WITHOUT_TRACE)
|
% (test_exc_type, self.MSG_WITHOUT_TRACE)
|
||||||
+ ("\n[u'" if six.PY2 else "\n['"))
|
+ "\n['")
|
||||||
actual_msg = json.loads(response.json['error_message'])['faultstring']
|
actual_msg = json.loads(response.json['error_message'])['faultstring']
|
||||||
self.assertEqual(expected_msg, actual_msg)
|
self.assertEqual(expected_msg, actual_msg)
|
||||||
|
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
Tests to assert that various incorporated middleware works as expected.
|
Tests to assert that various incorporated middleware works as expected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_middleware.cors as cors_middleware
|
import oslo_middleware.cors as cors_middleware
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.tests.unit.api import base
|
from ironic.tests.unit.api import base
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# 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.moves import http_client
|
from http import client as http_client
|
||||||
|
|
||||||
from ironic.api.controllers.v1 import versions
|
from ironic.api.controllers.v1 import versions
|
||||||
from ironic.tests.unit.api import base
|
from ironic.tests.unit.api import base
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from cinderclient import exceptions as cinder_exceptions
|
from cinderclient import exceptions as cinder_exceptions
|
||||||
import cinderclient.v3 as cinderclient
|
import cinderclient.v3 as cinderclient
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.common import cinder
|
from ironic.common import cinder
|
||||||
from ironic.common import context
|
from ironic.common import context
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
# 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 builtins
|
||||||
import datetime
|
import datetime
|
||||||
|
from http import client as http_client
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@ -18,19 +21,12 @@ import mock
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import requests
|
import requests
|
||||||
import sendfile
|
import sendfile
|
||||||
import six
|
|
||||||
import six.moves.builtins as __builtin__
|
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.glance_service import image_service as glance_v2_service
|
from ironic.common.glance_service import image_service as glance_v2_service
|
||||||
from ironic.common import image_service
|
from ironic.common import image_service
|
||||||
from ironic.tests import base
|
from ironic.tests import base
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
|
|
||||||
class HttpImageServiceTestCase(base.TestCase):
|
class HttpImageServiceTestCase(base.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -74,8 +70,8 @@ class HttpImageServiceTestCase(base.TestCase):
|
|||||||
self.service.validate_href,
|
self.service.validate_href,
|
||||||
self.href,
|
self.href,
|
||||||
True)
|
True)
|
||||||
self.assertIn('secreturl', six.text_type(e))
|
self.assertIn('secreturl', str(e))
|
||||||
self.assertNotIn(self.href, six.text_type(e))
|
self.assertNotIn(self.href, str(e))
|
||||||
head_mock.assert_called_once_with(self.href)
|
head_mock.assert_called_once_with(self.href)
|
||||||
|
|
||||||
@mock.patch.object(requests, 'head', autospec=True)
|
@mock.patch.object(requests, 'head', autospec=True)
|
||||||
@ -115,8 +111,8 @@ class HttpImageServiceTestCase(base.TestCase):
|
|||||||
def test_download_success(self, req_get_mock, shutil_mock):
|
def test_download_success(self, req_get_mock, shutil_mock):
|
||||||
response_mock = req_get_mock.return_value
|
response_mock = req_get_mock.return_value
|
||||||
response_mock.status_code = http_client.OK
|
response_mock.status_code = http_client.OK
|
||||||
response_mock.raw = mock.MagicMock(spec=file)
|
response_mock.raw = mock.MagicMock(spec=io.BytesIO)
|
||||||
file_mock = mock.Mock(spec=file)
|
file_mock = mock.Mock(spec=io.BytesIO)
|
||||||
self.service.download(self.href, file_mock)
|
self.service.download(self.href, file_mock)
|
||||||
shutil_mock.assert_called_once_with(
|
shutil_mock.assert_called_once_with(
|
||||||
response_mock.raw.__enter__(), file_mock,
|
response_mock.raw.__enter__(), file_mock,
|
||||||
@ -127,7 +123,7 @@ class HttpImageServiceTestCase(base.TestCase):
|
|||||||
@mock.patch.object(requests, 'get', autospec=True)
|
@mock.patch.object(requests, 'get', autospec=True)
|
||||||
def test_download_fail_connerror(self, req_get_mock):
|
def test_download_fail_connerror(self, req_get_mock):
|
||||||
req_get_mock.side_effect = requests.ConnectionError()
|
req_get_mock.side_effect = requests.ConnectionError()
|
||||||
file_mock = mock.Mock(spec=file)
|
file_mock = mock.Mock(spec=io.BytesIO)
|
||||||
self.assertRaises(exception.ImageDownloadFailed,
|
self.assertRaises(exception.ImageDownloadFailed,
|
||||||
self.service.download, self.href, file_mock)
|
self.service.download, self.href, file_mock)
|
||||||
|
|
||||||
@ -136,8 +132,8 @@ class HttpImageServiceTestCase(base.TestCase):
|
|||||||
def test_download_fail_ioerror(self, req_get_mock, shutil_mock):
|
def test_download_fail_ioerror(self, req_get_mock, shutil_mock):
|
||||||
response_mock = req_get_mock.return_value
|
response_mock = req_get_mock.return_value
|
||||||
response_mock.status_code = http_client.OK
|
response_mock.status_code = http_client.OK
|
||||||
response_mock.raw = mock.MagicMock(spec=file)
|
response_mock.raw = mock.MagicMock(spec=io.BytesIO)
|
||||||
file_mock = mock.Mock(spec=file)
|
file_mock = mock.Mock(spec=io.BytesIO)
|
||||||
shutil_mock.side_effect = IOError
|
shutil_mock.side_effect = IOError
|
||||||
self.assertRaises(exception.ImageDownloadFailed,
|
self.assertRaises(exception.ImageDownloadFailed,
|
||||||
self.service.download, self.href, file_mock)
|
self.service.download, self.href, file_mock)
|
||||||
@ -188,7 +184,7 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
remove_mock, link_mock):
|
remove_mock, link_mock):
|
||||||
_validate_mock.return_value = self.href_path
|
_validate_mock.return_value = self.href_path
|
||||||
stat_mock.return_value.st_dev = 'dev1'
|
stat_mock.return_value.st_dev = 'dev1'
|
||||||
file_mock = mock.Mock(spec=file)
|
file_mock = mock.Mock(spec=io.BytesIO)
|
||||||
file_mock.name = 'file'
|
file_mock.name = 'file'
|
||||||
self.service.download(self.href, file_mock)
|
self.service.download(self.href, file_mock)
|
||||||
_validate_mock.assert_called_once_with(mock.ANY, self.href)
|
_validate_mock.assert_called_once_with(mock.ANY, self.href)
|
||||||
@ -199,7 +195,7 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
|
|
||||||
@mock.patch.object(sendfile, 'sendfile', return_value=42, autospec=True)
|
@mock.patch.object(sendfile, 'sendfile', return_value=42, autospec=True)
|
||||||
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
|
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
@mock.patch.object(os, 'access', return_value=False, autospec=True)
|
@mock.patch.object(os, 'access', return_value=False, autospec=True)
|
||||||
@mock.patch.object(os, 'stat', autospec=True)
|
@mock.patch.object(os, 'stat', autospec=True)
|
||||||
@mock.patch.object(image_service.FileImageService, 'validate_href',
|
@mock.patch.object(image_service.FileImageService, 'validate_href',
|
||||||
@ -208,9 +204,9 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
open_mock, size_mock, copy_mock):
|
open_mock, size_mock, copy_mock):
|
||||||
_validate_mock.return_value = self.href_path
|
_validate_mock.return_value = self.href_path
|
||||||
stat_mock.return_value.st_dev = 'dev1'
|
stat_mock.return_value.st_dev = 'dev1'
|
||||||
file_mock = mock.MagicMock(spec=file)
|
file_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
file_mock.name = 'file'
|
file_mock.name = 'file'
|
||||||
input_mock = mock.MagicMock(spec=file)
|
input_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
open_mock.return_value = input_mock
|
open_mock.return_value = input_mock
|
||||||
self.service.download(self.href, file_mock)
|
self.service.download(self.href, file_mock)
|
||||||
_validate_mock.assert_called_once_with(mock.ANY, self.href)
|
_validate_mock.assert_called_once_with(mock.ANY, self.href)
|
||||||
@ -222,7 +218,7 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
|
|
||||||
@mock.patch.object(sendfile, 'sendfile', autospec=True)
|
@mock.patch.object(sendfile, 'sendfile', autospec=True)
|
||||||
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
|
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
@mock.patch.object(os, 'access', return_value=False, autospec=True)
|
@mock.patch.object(os, 'access', return_value=False, autospec=True)
|
||||||
@mock.patch.object(os, 'stat', autospec=True)
|
@mock.patch.object(os, 'stat', autospec=True)
|
||||||
@mock.patch.object(image_service.FileImageService, 'validate_href',
|
@mock.patch.object(image_service.FileImageService, 'validate_href',
|
||||||
@ -236,9 +232,9 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
fake_chunk_seq = [chunk_size, chunk_size, chunk_size, 1024]
|
fake_chunk_seq = [chunk_size, chunk_size, chunk_size, 1024]
|
||||||
_validate_mock.return_value = self.href_path
|
_validate_mock.return_value = self.href_path
|
||||||
stat_mock.return_value.st_dev = 'dev1'
|
stat_mock.return_value.st_dev = 'dev1'
|
||||||
file_mock = mock.MagicMock(spec=file)
|
file_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
file_mock.name = 'file'
|
file_mock.name = 'file'
|
||||||
input_mock = mock.MagicMock(spec=file)
|
input_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
open_mock.return_value = input_mock
|
open_mock.return_value = input_mock
|
||||||
size_mock.return_value = fake_image_size
|
size_mock.return_value = fake_image_size
|
||||||
copy_mock.side_effect = fake_chunk_seq
|
copy_mock.side_effect = fake_chunk_seq
|
||||||
@ -262,7 +258,7 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
access_mock, remove_mock):
|
access_mock, remove_mock):
|
||||||
_validate_mock.return_value = self.href_path
|
_validate_mock.return_value = self.href_path
|
||||||
stat_mock.return_value.st_dev = 'dev1'
|
stat_mock.return_value.st_dev = 'dev1'
|
||||||
file_mock = mock.MagicMock(spec=file)
|
file_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
file_mock.name = 'file'
|
file_mock.name = 'file'
|
||||||
self.assertRaises(exception.ImageDownloadFailed,
|
self.assertRaises(exception.ImageDownloadFailed,
|
||||||
self.service.download, self.href, file_mock)
|
self.service.download, self.href, file_mock)
|
||||||
@ -273,7 +269,7 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
@mock.patch.object(sendfile, 'sendfile', side_effect=OSError,
|
@mock.patch.object(sendfile, 'sendfile', side_effect=OSError,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
|
@mock.patch.object(os.path, 'getsize', return_value=42, autospec=True)
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
@mock.patch.object(os, 'access', return_value=False, autospec=True)
|
@mock.patch.object(os, 'access', return_value=False, autospec=True)
|
||||||
@mock.patch.object(os, 'stat', autospec=True)
|
@mock.patch.object(os, 'stat', autospec=True)
|
||||||
@mock.patch.object(image_service.FileImageService, 'validate_href',
|
@mock.patch.object(image_service.FileImageService, 'validate_href',
|
||||||
@ -282,9 +278,9 @@ class FileImageServiceTestCase(base.TestCase):
|
|||||||
open_mock, size_mock, copy_mock):
|
open_mock, size_mock, copy_mock):
|
||||||
_validate_mock.return_value = self.href_path
|
_validate_mock.return_value = self.href_path
|
||||||
stat_mock.return_value.st_dev = 'dev1'
|
stat_mock.return_value.st_dev = 'dev1'
|
||||||
file_mock = mock.MagicMock(spec=file)
|
file_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
file_mock.name = 'file'
|
file_mock.name = 'file'
|
||||||
input_mock = mock.MagicMock(spec=file)
|
input_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
open_mock.return_value = input_mock
|
open_mock.return_value = input_mock
|
||||||
self.assertRaises(exception.ImageDownloadFailed,
|
self.assertRaises(exception.ImageDownloadFailed,
|
||||||
self.service.download, self.href, file_mock)
|
self.service.download, self.href, file_mock)
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
# 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 builtins
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@ -23,8 +25,6 @@ from ironic_lib import utils as ironic_utils
|
|||||||
import mock
|
import mock
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
import six.moves.builtins as __builtin__
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.glance_service import service_utils as glance_utils
|
from ironic.common.glance_service import service_utils as glance_utils
|
||||||
@ -33,10 +33,6 @@ from ironic.common import images
|
|||||||
from ironic.common import utils
|
from ironic.common import utils
|
||||||
from ironic.tests import base
|
from ironic.tests import base
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
@ -46,9 +42,9 @@ class IronicImagesTestCase(base.TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@mock.patch.object(image_service, 'get_image_service', autospec=True)
|
@mock.patch.object(image_service, 'get_image_service', autospec=True)
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_fetch_image_service(self, open_mock, image_service_mock):
|
def test_fetch_image_service(self, open_mock, image_service_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'file'
|
mock_file_handle.__enter__.return_value = 'file'
|
||||||
open_mock.return_value = mock_file_handle
|
open_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -62,10 +58,10 @@ class IronicImagesTestCase(base.TestCase):
|
|||||||
|
|
||||||
@mock.patch.object(image_service, 'get_image_service', autospec=True)
|
@mock.patch.object(image_service, 'get_image_service', autospec=True)
|
||||||
@mock.patch.object(images, 'image_to_raw', autospec=True)
|
@mock.patch.object(images, 'image_to_raw', autospec=True)
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_fetch_image_service_force_raw(self, open_mock, image_to_raw_mock,
|
def test_fetch_image_service_force_raw(self, open_mock, image_to_raw_mock,
|
||||||
image_service_mock):
|
image_service_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'file'
|
mock_file_handle.__enter__.return_value = 'file'
|
||||||
open_mock.return_value = mock_file_handle
|
open_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -294,7 +290,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
self, mkfs_mock, mount_mock, umount_mock, dd_mock, write_mock,
|
self, mkfs_mock, mount_mock, umount_mock, dd_mock, write_mock,
|
||||||
tempdir_mock, create_root_fs_mock):
|
tempdir_mock, create_root_fs_mock):
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tempdir'
|
mock_file_handle.__enter__.return_value = 'tempdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -329,7 +325,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
self, mkfs_mock, mount_mock, umount_mock, dd_mock,
|
self, mkfs_mock, mount_mock, umount_mock, dd_mock,
|
||||||
tempdir_mock, create_root_fs_mock):
|
tempdir_mock, create_root_fs_mock):
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tempdir'
|
mock_file_handle.__enter__.return_value = 'tempdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
files_info = {'a': 'b'}
|
files_info = {'a': 'b'}
|
||||||
@ -353,7 +349,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
def test_create_vfat_image_mkfs_fails(self, mkfs_mock, dd_mock,
|
def test_create_vfat_image_mkfs_fails(self, mkfs_mock, dd_mock,
|
||||||
tempdir_mock):
|
tempdir_mock):
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tempdir'
|
mock_file_handle.__enter__.return_value = 'tempdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -371,7 +367,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
self, mkfs_mock, mount_mock, umount_mock, dd_mock,
|
self, mkfs_mock, mount_mock, umount_mock, dd_mock,
|
||||||
tempdir_mock, create_root_fs_mock):
|
tempdir_mock, create_root_fs_mock):
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tempdir'
|
mock_file_handle.__enter__.return_value = 'tempdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
umount_mock.side_effect = processutils.ProcessExecutionError
|
umount_mock.side_effect = processutils.ProcessExecutionError
|
||||||
@ -513,9 +509,9 @@ class FsImageTestCase(base.TestCase):
|
|||||||
'path/to/grub': 'relpath/to/grub.cfg'}
|
'path/to/grub': 'relpath/to/grub.cfg'}
|
||||||
grub_rel_path = 'relpath/to/grub.cfg'
|
grub_rel_path = 'relpath/to/grub.cfg'
|
||||||
e_img_rel_path = 'path/to/efiboot.img'
|
e_img_rel_path = 'path/to/efiboot.img'
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
mock_file_handle1 = mock.MagicMock(spec=file)
|
mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle1.__enter__.return_value = 'mountdir'
|
mock_file_handle1.__enter__.return_value = 'mountdir'
|
||||||
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
||||||
mount_mock.return_value = (uefi_path_info,
|
mount_mock.return_value = (uefi_path_info,
|
||||||
@ -561,9 +557,9 @@ class FsImageTestCase(base.TestCase):
|
|||||||
grub_options = {'linux': '/vmlinuz',
|
grub_options = {'linux': '/vmlinuz',
|
||||||
'initrd': '/initrd'}
|
'initrd': '/initrd'}
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
mock_file_handle1 = mock.MagicMock(spec=file)
|
mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle1.__enter__.return_value = 'mountdir'
|
mock_file_handle1.__enter__.return_value = 'mountdir'
|
||||||
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
||||||
mountdir_grub_cfg_path = 'tmpdir' + grub_cfg_file
|
mountdir_grub_cfg_path = 'tmpdir' + grub_cfg_file
|
||||||
@ -590,7 +586,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
self, gen_cfg_mock, execute_mock, tempdir_mock,
|
self, gen_cfg_mock, execute_mock, tempdir_mock,
|
||||||
write_to_file_mock, create_root_fs_mock, ldlinux_path=None):
|
write_to_file_mock, create_root_fs_mock, ldlinux_path=None):
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -653,9 +649,9 @@ class FsImageTestCase(base.TestCase):
|
|||||||
create_root_fs_mock,
|
create_root_fs_mock,
|
||||||
umount_mock):
|
umount_mock):
|
||||||
|
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
mock_file_handle1 = mock.MagicMock(spec=file)
|
mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle1.__enter__.return_value = 'mountdir'
|
mock_file_handle1.__enter__.return_value = 'mountdir'
|
||||||
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
||||||
create_root_fs_mock.side_effect = IOError
|
create_root_fs_mock.side_effect = IOError
|
||||||
@ -698,9 +694,9 @@ class FsImageTestCase(base.TestCase):
|
|||||||
write_to_file_mock,
|
write_to_file_mock,
|
||||||
create_root_fs_mock,
|
create_root_fs_mock,
|
||||||
umount_mock):
|
umount_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
mock_file_handle1 = mock.MagicMock(spec=file)
|
mock_file_handle1 = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle1.__enter__.return_value = 'mountdir'
|
mock_file_handle1.__enter__.return_value = 'mountdir'
|
||||||
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
tempdir_mock.side_effect = mock_file_handle, mock_file_handle1
|
||||||
mount_mock.return_value = ({'a': 'a'}, 'b', 'c')
|
mount_mock.return_value = ({'a': 'a'}, 'b', 'c')
|
||||||
@ -725,7 +721,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
tempdir_mock,
|
tempdir_mock,
|
||||||
write_to_file_mock,
|
write_to_file_mock,
|
||||||
create_root_fs_mock):
|
create_root_fs_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
utils_mock.side_effect = processutils.ProcessExecutionError
|
utils_mock.side_effect = processutils.ProcessExecutionError
|
||||||
@ -740,7 +736,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||||
def test_create_boot_iso_for_uefi_deploy_iso(
|
def test_create_boot_iso_for_uefi_deploy_iso(
|
||||||
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -768,7 +764,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||||
def test_create_boot_iso_for_uefi_esp_image(
|
def test_create_boot_iso_for_uefi_esp_image(
|
||||||
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -796,7 +792,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||||
def test_create_boot_iso_for_uefi_deploy_iso_for_hrefs(
|
def test_create_boot_iso_for_uefi_deploy_iso_for_hrefs(
|
||||||
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -824,7 +820,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||||
def test_create_boot_iso_for_uefi_esp_image_for_hrefs(
|
def test_create_boot_iso_for_uefi_esp_image_for_hrefs(
|
||||||
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -852,7 +848,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||||
def test_create_boot_iso_for_bios(
|
def test_create_boot_iso_for_bios(
|
||||||
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -884,7 +880,7 @@ class FsImageTestCase(base.TestCase):
|
|||||||
def test_create_boot_iso_for_bios_with_no_boot_mode(self, tempdir_mock,
|
def test_create_boot_iso_for_bios_with_no_boot_mode(self, tempdir_mock,
|
||||||
fetch_images_mock,
|
fetch_images_mock,
|
||||||
create_isolinux_mock):
|
create_isolinux_mock):
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||||
tempdir_mock.return_value = mock_file_handle
|
tempdir_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import mock
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.glance_service import image_service
|
from ironic.common.glance_service import image_service
|
||||||
@ -122,7 +121,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
with open('ironic/tests/unit/drivers/pxe_config.template') as f:
|
with open('ironic/tests/unit/drivers/pxe_config.template') as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
|
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
def test_default_ipxe_boot_script(self):
|
def test_default_ipxe_boot_script(self):
|
||||||
rendered_template = utils.render_template(
|
rendered_template = utils.render_template(
|
||||||
@ -132,7 +131,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
with open('ironic/tests/unit/drivers/boot.ipxe') as f:
|
with open('ironic/tests/unit/drivers/boot.ipxe') as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
|
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
def test_default_ipxe_config(self):
|
def test_default_ipxe_config(self):
|
||||||
# NOTE(lucasagomes): iPXE is just an extension of the PXE driver,
|
# NOTE(lucasagomes): iPXE is just an extension of the PXE driver,
|
||||||
@ -154,7 +153,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
with open(templ_file) as f:
|
with open(templ_file) as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
|
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
def test_default_ipxe_timeout_config(self):
|
def test_default_ipxe_timeout_config(self):
|
||||||
# NOTE(lucasagomes): iPXE is just an extension of the PXE driver,
|
# NOTE(lucasagomes): iPXE is just an extension of the PXE driver,
|
||||||
@ -176,7 +175,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
with open(templ_file) as f:
|
with open(templ_file) as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
|
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
def test_default_ipxe_boot_from_volume_config(self):
|
def test_default_ipxe_boot_from_volume_config(self):
|
||||||
self.config(
|
self.config(
|
||||||
@ -195,7 +194,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
with open(templ_file) as f:
|
with open(templ_file) as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
|
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
def test_default_ipxe_boot_from_volume_config_no_extra_volumes(self):
|
def test_default_ipxe_boot_from_volume_config_no_extra_volumes(self):
|
||||||
self.config(
|
self.config(
|
||||||
@ -217,7 +216,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
'ipxe_config_boot_from_volume_no_extra_volumes.template'
|
'ipxe_config_boot_from_volume_no_extra_volumes.template'
|
||||||
with open(templ_file) as f:
|
with open(templ_file) as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
def test_default_grub_config(self):
|
def test_default_grub_config(self):
|
||||||
pxe_opts = self.pxe_options
|
pxe_opts = self.pxe_options
|
||||||
@ -233,7 +232,7 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
with open(templ_file) as f:
|
with open(templ_file) as f:
|
||||||
expected_template = f.read().rstrip()
|
expected_template = f.read().rstrip()
|
||||||
|
|
||||||
self.assertEqual(six.text_type(expected_template), rendered_template)
|
self.assertEqual(str(expected_template), rendered_template)
|
||||||
|
|
||||||
@mock.patch('ironic.common.utils.create_link_without_raise', autospec=True)
|
@mock.patch('ironic.common.utils.create_link_without_raise', autospec=True)
|
||||||
@mock.patch('ironic_lib.utils.unlink_without_raise', autospec=True)
|
@mock.patch('ironic_lib.utils.unlink_without_raise', autospec=True)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.api.controllers.v1 import versions as api_versions
|
from ironic.api.controllers.v1 import versions as api_versions
|
||||||
from ironic.common import release_mappings
|
from ironic.common import release_mappings
|
||||||
@ -50,16 +49,16 @@ class ReleaseMappingsTestCase(base.TestCase):
|
|||||||
for value in release_mappings.RELEASE_MAPPING.values():
|
for value in release_mappings.RELEASE_MAPPING.values():
|
||||||
self.assertIsInstance(value, dict)
|
self.assertIsInstance(value, dict)
|
||||||
self.assertEqual({'api', 'rpc', 'objects'}, set(value))
|
self.assertEqual({'api', 'rpc', 'objects'}, set(value))
|
||||||
self.assertIsInstance(value['api'], six.string_types)
|
self.assertIsInstance(value['api'], str)
|
||||||
(major, minor) = value['api'].split('.')
|
(major, minor) = value['api'].split('.')
|
||||||
self.assertEqual(1, int(major))
|
self.assertEqual(1, int(major))
|
||||||
self.assertLessEqual(int(minor), api_versions.MINOR_MAX_VERSION)
|
self.assertLessEqual(int(minor), api_versions.MINOR_MAX_VERSION)
|
||||||
self.assertIsInstance(value['rpc'], six.string_types)
|
self.assertIsInstance(value['rpc'], str)
|
||||||
self.assertIsInstance(value['objects'], dict)
|
self.assertIsInstance(value['objects'], dict)
|
||||||
for obj_value in value['objects'].values():
|
for obj_value in value['objects'].values():
|
||||||
self.assertIsInstance(obj_value, list)
|
self.assertIsInstance(obj_value, list)
|
||||||
for ver in obj_value:
|
for ver in obj_value:
|
||||||
self.assertIsInstance(ver, six.string_types)
|
self.assertIsInstance(ver, str)
|
||||||
tuple_ver = versionutils.convert_version_to_tuple(ver)
|
tuple_ver = versionutils.convert_version_to_tuple(ver)
|
||||||
self.assertEqual(2, len(tuple_ver))
|
self.assertEqual(2, len(tuple_ver))
|
||||||
|
|
||||||
|
@ -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 ironic.common import states
|
from ironic.common import states
|
||||||
from ironic.tests import base
|
from ironic.tests import base
|
||||||
|
|
||||||
@ -31,7 +29,7 @@ class StatesTest(base.TestCase):
|
|||||||
for key, value in states.__dict__.items():
|
for key, value in states.__dict__.items():
|
||||||
# Assumption: A state variable name is all UPPERCASE and contents
|
# Assumption: A state variable name is all UPPERCASE and contents
|
||||||
# are a string.
|
# are a string.
|
||||||
if key.upper() == key and isinstance(value, six.string_types):
|
if key.upper() == key and isinstance(value, str):
|
||||||
self.assertLessEqual(
|
self.assertLessEqual(
|
||||||
len(value), 15,
|
len(value), 15,
|
||||||
"Value for state: {} is greater than 15 characters".format(
|
"Value for state: {} is greater than 15 characters".format(
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
# 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 builtins
|
||||||
|
from http import client as http_client
|
||||||
|
import io
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
from six.moves import builtins as __builtin__
|
|
||||||
from six.moves import http_client
|
|
||||||
from swiftclient import client as swift_client
|
from swiftclient import client as swift_client
|
||||||
from swiftclient import exceptions as swift_exception
|
from swiftclient import exceptions as swift_exception
|
||||||
from swiftclient import utils as swift_utils
|
from swiftclient import utils as swift_utils
|
||||||
@ -27,10 +28,6 @@ from ironic.tests import base
|
|||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(swift, 'get_swift_session', autospec=True,
|
@mock.patch.object(swift, 'get_swift_session', autospec=True,
|
||||||
return_value=mock.Mock(verify=False, cert=('spam', 'ham'),
|
return_value=mock.Mock(verify=False, cert=('spam', 'ham'),
|
||||||
@ -57,11 +54,11 @@ class SwiftTestCase(base.TestCase):
|
|||||||
os_options={'object_storage_url': 'http://example.com/objects'}
|
os_options={'object_storage_url': 'http://example.com/objects'}
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_create_object(self, open_mock, connection_mock, keystone_mock):
|
def test_create_object(self, open_mock, connection_mock, keystone_mock):
|
||||||
swiftapi = swift.SwiftAPI()
|
swiftapi = swift.SwiftAPI()
|
||||||
connection_obj_mock = connection_mock.return_value
|
connection_obj_mock = connection_mock.return_value
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'file-object'
|
mock_file_handle.__enter__.return_value = 'file-object'
|
||||||
open_mock.return_value = mock_file_handle
|
open_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -75,7 +72,7 @@ class SwiftTestCase(base.TestCase):
|
|||||||
'container', 'object', 'file-object', headers=None)
|
'container', 'object', 'file-object', headers=None)
|
||||||
self.assertEqual('object-uuid', object_uuid)
|
self.assertEqual('object-uuid', object_uuid)
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_create_object_create_container_fails(self, open_mock,
|
def test_create_object_create_container_fails(self, open_mock,
|
||||||
connection_mock,
|
connection_mock,
|
||||||
keystone_mock):
|
keystone_mock):
|
||||||
@ -88,11 +85,11 @@ class SwiftTestCase(base.TestCase):
|
|||||||
connection_obj_mock.put_container.assert_called_once_with('container')
|
connection_obj_mock.put_container.assert_called_once_with('container')
|
||||||
self.assertFalse(connection_obj_mock.put_object.called)
|
self.assertFalse(connection_obj_mock.put_object.called)
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_create_object_put_object_fails(self, open_mock, connection_mock,
|
def test_create_object_put_object_fails(self, open_mock, connection_mock,
|
||||||
keystone_mock):
|
keystone_mock):
|
||||||
swiftapi = swift.SwiftAPI()
|
swiftapi = swift.SwiftAPI()
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = 'file-object'
|
mock_file_handle.__enter__.return_value = 'file-object'
|
||||||
open_mock.return_value = mock_file_handle
|
open_mock.return_value = mock_file_handle
|
||||||
connection_obj_mock = connection_mock.return_value
|
connection_obj_mock = connection_mock.return_value
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import datetime
|
import datetime
|
||||||
|
import queue
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@ -31,8 +32,6 @@ import oslo_messaging as messaging
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from oslo_versionedobjects import base as ovo_base
|
from oslo_versionedobjects import base as ovo_base
|
||||||
from oslo_versionedobjects import fields
|
from oslo_versionedobjects import fields
|
||||||
import six
|
|
||||||
from six.moves import queue
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import driver_factory
|
from ironic.common import driver_factory
|
||||||
@ -5881,12 +5880,6 @@ class SensorsTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
|||||||
self.assertEqual(5, validate_mock.call_count)
|
self.assertEqual(5, validate_mock.call_count)
|
||||||
self.assertEqual(5, get_sensors_data_mock.call_count)
|
self.assertEqual(5, get_sensors_data_mock.call_count)
|
||||||
self.assertEqual(5, notifier_mock.call_count)
|
self.assertEqual(5, notifier_mock.call_count)
|
||||||
if six.PY2:
|
|
||||||
# bail out if python2 as matching fails to match the
|
|
||||||
# data structure becasue it requires the order to be consistent
|
|
||||||
# but the mock also records the call dictionary contents in
|
|
||||||
# random order changing with every invocation. :\
|
|
||||||
return
|
|
||||||
n_call = mock.call(mock.ANY, mock.ANY, 'hardware.fake.metrics',
|
n_call = mock.call(mock.ANY, mock.ANY, 'hardware.fake.metrics',
|
||||||
{'event_type': 'hardware.fake.metrics.update',
|
{'event_type': 'hardware.fake.metrics.update',
|
||||||
'node_name': 'fake_node', 'timestamp': mock.ANY,
|
'node_name': 'fake_node', 'timestamp': mock.ANY,
|
||||||
@ -6505,7 +6498,7 @@ class RaidHardwareTypeTestCases(RaidTestCases):
|
|||||||
self.node.refresh()
|
self.node.refresh()
|
||||||
self.assertEqual({}, self.node.target_raid_config)
|
self.assertEqual({}, self.node.target_raid_config)
|
||||||
self.assertEqual(exception.UnsupportedDriverExtension, exc.exc_info[0])
|
self.assertEqual(exception.UnsupportedDriverExtension, exc.exc_info[0])
|
||||||
self.assertIn('manual-management', six.text_type(exc.exc_info[1]))
|
self.assertIn('manual-management', str(exc.exc_info[1]))
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(conductor_utils, 'node_power_action')
|
@mock.patch.object(conductor_utils, 'node_power_action')
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""Tests for manipulating Chassis via the DB API"""
|
"""Tests for manipulating Chassis via the DB API"""
|
||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests.unit.db import base
|
from ironic.tests.unit.db import base
|
||||||
@ -33,10 +32,10 @@ class DbChassisTestCase(base.DbTestCase):
|
|||||||
uuids = [self.chassis.uuid]
|
uuids = [self.chassis.uuid]
|
||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
ch = utils.create_test_chassis(uuid=uuidutils.generate_uuid())
|
ch = utils.create_test_chassis(uuid=uuidutils.generate_uuid())
|
||||||
uuids.append(six.text_type(ch.uuid))
|
uuids.append(str(ch.uuid))
|
||||||
res = self.dbapi.get_chassis_list()
|
res = self.dbapi.get_chassis_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
|
|
||||||
def test_get_chassis_by_id(self):
|
def test_get_chassis_by_id(self):
|
||||||
chassis = self.dbapi.get_chassis_by_id(self.chassis.id)
|
chassis = self.dbapi.get_chassis_by_id(self.chassis.id)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
from oslo_db import exception as db_exc
|
from oslo_db import exception as db_exc
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests.unit.db import base
|
from ironic.tests.unit.db import base
|
||||||
@ -173,19 +172,19 @@ class DbDeployTemplateTestCase(base.DbTestCase):
|
|||||||
self.dbapi.get_deploy_template_by_name, 'bogus')
|
self.dbapi.get_deploy_template_by_name, 'bogus')
|
||||||
|
|
||||||
def _template_list_preparation(self):
|
def _template_list_preparation(self):
|
||||||
uuids = [six.text_type(self.template.uuid)]
|
uuids = [str(self.template.uuid)]
|
||||||
for i in range(1, 3):
|
for i in range(1, 3):
|
||||||
template = db_utils.create_test_deploy_template(
|
template = db_utils.create_test_deploy_template(
|
||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
name='CUSTOM_DT%d' % (i + 1))
|
name='CUSTOM_DT%d' % (i + 1))
|
||||||
uuids.append(six.text_type(template.uuid))
|
uuids.append(str(template.uuid))
|
||||||
return uuids
|
return uuids
|
||||||
|
|
||||||
def test_get_deploy_template_list(self):
|
def test_get_deploy_template_list(self):
|
||||||
uuids = self._template_list_preparation()
|
uuids = self._template_list_preparation()
|
||||||
res = self.dbapi.get_deploy_template_list()
|
res = self.dbapi.get_deploy_template_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
|
|
||||||
def test_get_deploy_template_list_sorted(self):
|
def test_get_deploy_template_list_sorted(self):
|
||||||
uuids = self._template_list_preparation()
|
uuids = self._template_list_preparation()
|
||||||
@ -201,7 +200,7 @@ class DbDeployTemplateTestCase(base.DbTestCase):
|
|||||||
names = ['CUSTOM_DT2', 'CUSTOM_DT3']
|
names = ['CUSTOM_DT2', 'CUSTOM_DT3']
|
||||||
res = self.dbapi.get_deploy_template_list_by_names(names=names)
|
res = self.dbapi.get_deploy_template_list_by_names(names=names)
|
||||||
res_names = [r.name for r in res]
|
res_names = [r.name for r in res]
|
||||||
six.assertCountEqual(self, names, res_names)
|
self.assertCountEqual(names, res_names)
|
||||||
|
|
||||||
def test_get_deploy_template_list_by_names_no_match(self):
|
def test_get_deploy_template_list_by_names_no_match(self):
|
||||||
self._template_list_preparation()
|
self._template_list_preparation()
|
||||||
|
@ -20,7 +20,6 @@ import datetime
|
|||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import states
|
from ironic.common import states
|
||||||
@ -295,10 +294,10 @@ class DbNodeTestCase(base.DbTestCase):
|
|||||||
uuids = []
|
uuids = []
|
||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
node = utils.create_test_node(uuid=uuidutils.generate_uuid())
|
node = utils.create_test_node(uuid=uuidutils.generate_uuid())
|
||||||
uuids.append(six.text_type(node['uuid']))
|
uuids.append(str(node['uuid']))
|
||||||
res = self.dbapi.get_node_list()
|
res = self.dbapi.get_node_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
for r in res:
|
for r in res:
|
||||||
self.assertEqual([], r.tags)
|
self.assertEqual([], r.tags)
|
||||||
self.assertEqual([], r.traits)
|
self.assertEqual([], r.traits)
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
"""Tests for manipulating portgroups via the DB API"""
|
"""Tests for manipulating portgroups via the DB API"""
|
||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests.unit.db import base
|
from ironic.tests.unit.db import base
|
||||||
@ -45,7 +44,7 @@ class DbportgroupTestCase(base.DbTestCase):
|
|||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
name='portgroup' + str(i),
|
name='portgroup' + str(i),
|
||||||
address='52:54:00:cf:2d:4%s' % i)
|
address='52:54:00:cf:2d:4%s' % i)
|
||||||
uuids.append(six.text_type(portgroup.uuid))
|
uuids.append(str(portgroup.uuid))
|
||||||
|
|
||||||
return uuids
|
return uuids
|
||||||
|
|
||||||
@ -87,16 +86,16 @@ class DbportgroupTestCase(base.DbTestCase):
|
|||||||
uuids = self._create_test_portgroup_range(6)
|
uuids = self._create_test_portgroup_range(6)
|
||||||
|
|
||||||
# Also add the uuid for the portgroup created in setUp()
|
# Also add the uuid for the portgroup created in setUp()
|
||||||
uuids.append(six.text_type(self.portgroup.uuid))
|
uuids.append(str(self.portgroup.uuid))
|
||||||
res = self.dbapi.get_portgroup_list()
|
res = self.dbapi.get_portgroup_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
|
|
||||||
def test_get_portgroup_list_sorted(self):
|
def test_get_portgroup_list_sorted(self):
|
||||||
uuids = self._create_test_portgroup_range(6)
|
uuids = self._create_test_portgroup_range(6)
|
||||||
|
|
||||||
# Also add the uuid for the portgroup created in setUp()
|
# Also add the uuid for the portgroup created in setUp()
|
||||||
uuids.append(six.text_type(self.portgroup.uuid))
|
uuids.append(str(self.portgroup.uuid))
|
||||||
res = self.dbapi.get_portgroup_list(sort_key='uuid')
|
res = self.dbapi.get_portgroup_list(sort_key='uuid')
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
self.assertEqual(sorted(uuids), res_uuids)
|
self.assertEqual(sorted(uuids), res_uuids)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""Tests for manipulating Ports via the DB API"""
|
"""Tests for manipulating Ports via the DB API"""
|
||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests.unit.db import base
|
from ironic.tests.unit.db import base
|
||||||
@ -51,21 +50,21 @@ class DbPortTestCase(base.DbTestCase):
|
|||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
|
port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
|
||||||
address='52:54:00:cf:2d:4%s' % i)
|
address='52:54:00:cf:2d:4%s' % i)
|
||||||
uuids.append(six.text_type(port.uuid))
|
uuids.append(str(port.uuid))
|
||||||
# Also add the uuid for the port created in setUp()
|
# Also add the uuid for the port created in setUp()
|
||||||
uuids.append(six.text_type(self.port.uuid))
|
uuids.append(str(self.port.uuid))
|
||||||
res = self.dbapi.get_port_list()
|
res = self.dbapi.get_port_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
|
|
||||||
def test_get_port_list_sorted(self):
|
def test_get_port_list_sorted(self):
|
||||||
uuids = []
|
uuids = []
|
||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
|
port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
|
||||||
address='52:54:00:cf:2d:4%s' % i)
|
address='52:54:00:cf:2d:4%s' % i)
|
||||||
uuids.append(six.text_type(port.uuid))
|
uuids.append(str(port.uuid))
|
||||||
# Also add the uuid for the port created in setUp()
|
# Also add the uuid for the port created in setUp()
|
||||||
uuids.append(six.text_type(self.port.uuid))
|
uuids.append(str(self.port.uuid))
|
||||||
res = self.dbapi.get_port_list(sort_key='uuid')
|
res = self.dbapi.get_port_list(sort_key='uuid')
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
self.assertEqual(sorted(uuids), res_uuids)
|
self.assertEqual(sorted(uuids), res_uuids)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"""Tests for manipulating VolumeConnectors via the DB API"""
|
"""Tests for manipulating VolumeConnectors via the DB API"""
|
||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests.unit.db import base
|
from ironic.tests.unit.db import base
|
||||||
@ -65,20 +64,20 @@ class DbVolumeConnectorTestCase(base.DbTestCase):
|
|||||||
-1)
|
-1)
|
||||||
|
|
||||||
def _connector_list_preparation(self):
|
def _connector_list_preparation(self):
|
||||||
uuids = [six.text_type(self.connector.uuid)]
|
uuids = [str(self.connector.uuid)]
|
||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
volume_connector = db_utils.create_test_volume_connector(
|
volume_connector = db_utils.create_test_volume_connector(
|
||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
type='iqn',
|
type='iqn',
|
||||||
connector_id='iqn.test-%s' % i)
|
connector_id='iqn.test-%s' % i)
|
||||||
uuids.append(six.text_type(volume_connector.uuid))
|
uuids.append(str(volume_connector.uuid))
|
||||||
return uuids
|
return uuids
|
||||||
|
|
||||||
def test_get_volume_connector_list(self):
|
def test_get_volume_connector_list(self):
|
||||||
uuids = self._connector_list_preparation()
|
uuids = self._connector_list_preparation()
|
||||||
res = self.dbapi.get_volume_connector_list()
|
res = self.dbapi.get_volume_connector_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
|
|
||||||
def test_get_volume_connector_list_sorted(self):
|
def test_get_volume_connector_list_sorted(self):
|
||||||
uuids = self._connector_list_preparation()
|
uuids = self._connector_list_preparation()
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"""Tests for manipulating VolumeTargets via the DB API"""
|
"""Tests for manipulating VolumeTargets via the DB API"""
|
||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.tests.unit.db import base
|
from ironic.tests.unit.db import base
|
||||||
@ -79,20 +78,20 @@ class DbVolumeTargetTestCase(base.DbTestCase):
|
|||||||
'11111111-2222-3333-4444-555555555555')
|
'11111111-2222-3333-4444-555555555555')
|
||||||
|
|
||||||
def _create_list_of_volume_targets(self, num):
|
def _create_list_of_volume_targets(self, num):
|
||||||
uuids = [six.text_type(self.target.uuid)]
|
uuids = [str(self.target.uuid)]
|
||||||
for i in range(1, num):
|
for i in range(1, num):
|
||||||
volume_target = db_utils.create_test_volume_target(
|
volume_target = db_utils.create_test_volume_target(
|
||||||
uuid=uuidutils.generate_uuid(),
|
uuid=uuidutils.generate_uuid(),
|
||||||
properties={"target_iqn": "iqn.test-%s" % i},
|
properties={"target_iqn": "iqn.test-%s" % i},
|
||||||
boot_index=i)
|
boot_index=i)
|
||||||
uuids.append(six.text_type(volume_target.uuid))
|
uuids.append(str(volume_target.uuid))
|
||||||
return uuids
|
return uuids
|
||||||
|
|
||||||
def test_get_volume_target_list(self):
|
def test_get_volume_target_list(self):
|
||||||
uuids = self._create_list_of_volume_targets(6)
|
uuids = self._create_list_of_volume_targets(6)
|
||||||
res = self.dbapi.get_volume_target_list()
|
res = self.dbapi.get_volume_target_list()
|
||||||
res_uuids = [r.uuid for r in res]
|
res_uuids = [r.uuid for r in res]
|
||||||
six.assertCountEqual(self, uuids, res_uuids)
|
self.assertCountEqual(uuids, res_uuids)
|
||||||
|
|
||||||
def test_get_volume_target_list_sorted(self):
|
def test_get_volume_target_list_sorted(self):
|
||||||
uuids = self._create_list_of_volume_targets(5)
|
uuids = self._create_list_of_volume_targets(5)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
from ironic.common import dhcp_factory
|
from ironic.common import dhcp_factory
|
||||||
@ -84,7 +83,7 @@ class TestDHCPFactory(base.TestCase):
|
|||||||
class CompareBasetoModules(base.TestCase):
|
class CompareBasetoModules(base.TestCase):
|
||||||
|
|
||||||
def test_drivers_match_dhcp_base(self):
|
def test_drivers_match_dhcp_base(self):
|
||||||
signature_method = inspect.getargspec if six.PY2 else inspect.signature
|
signature_method = inspect.signature
|
||||||
|
|
||||||
def _get_public_apis(inst):
|
def _get_public_apis(inst):
|
||||||
methods = {}
|
methods = {}
|
||||||
|
@ -15,7 +15,6 @@ import json
|
|||||||
from ironic_lib import utils as irlib_utils
|
from ironic_lib import utils as irlib_utils
|
||||||
import mock
|
import mock
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import states
|
from ironic.common import states
|
||||||
@ -235,7 +234,7 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
|
|||||||
ansible_deploy._run_playbook,
|
ansible_deploy._run_playbook,
|
||||||
self.node, 'deploy', extra_vars,
|
self.node, 'deploy', extra_vars,
|
||||||
'/path/to/key')
|
'/path/to/key')
|
||||||
self.assertIn('VIKINGS!', six.text_type(exc))
|
self.assertIn('VIKINGS!', str(exc))
|
||||||
execute_mock.assert_called_once_with(
|
execute_mock.assert_called_once_with(
|
||||||
'env', 'ANSIBLE_CONFIG=/path/to/config',
|
'env', 'ANSIBLE_CONFIG=/path/to/config',
|
||||||
'ansible-playbook', '/path/to/playbooks/deploy', '-i',
|
'ansible-playbook', '/path/to/playbooks/deploy', '-i',
|
||||||
@ -374,8 +373,8 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
|
|||||||
exception.InvalidParameterValue,
|
exception.InvalidParameterValue,
|
||||||
ansible_deploy._parse_root_device_hints, task.node)
|
ansible_deploy._parse_root_device_hints, task.node)
|
||||||
for key, value in expected.items():
|
for key, value in expected.items():
|
||||||
self.assertIn(six.text_type(key), six.text_type(exc))
|
self.assertIn(str(key), str(exc))
|
||||||
self.assertIn(six.text_type(value), six.text_type(exc))
|
self.assertIn(str(value), str(exc))
|
||||||
|
|
||||||
def test__prepare_variables(self):
|
def test__prepare_variables(self):
|
||||||
i_info = self.node.instance_info
|
i_info = self.node.instance_info
|
||||||
@ -486,9 +485,9 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
|
|||||||
exc = self.assertRaises(exception.NodeCleaningFailure,
|
exc = self.assertRaises(exception.NodeCleaningFailure,
|
||||||
ansible_deploy._validate_clean_steps,
|
ansible_deploy._validate_clean_steps,
|
||||||
steps, self.node.uuid)
|
steps, self.node.uuid)
|
||||||
self.assertIn("name foo, field ham.value", six.text_type(exc))
|
self.assertIn("name foo, field ham.value", str(exc))
|
||||||
self.assertIn("name bar, field interface", six.text_type(exc))
|
self.assertIn("name bar, field interface", str(exc))
|
||||||
self.assertIn("name undefined, field name", six.text_type(exc))
|
self.assertIn("name undefined, field name", str(exc))
|
||||||
|
|
||||||
def test__validate_clean_steps_names_not_unique(self):
|
def test__validate_clean_steps_names_not_unique(self):
|
||||||
steps = [{"name": "foo",
|
steps = [{"name": "foo",
|
||||||
@ -498,7 +497,7 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
|
|||||||
exc = self.assertRaises(exception.NodeCleaningFailure,
|
exc = self.assertRaises(exception.NodeCleaningFailure,
|
||||||
ansible_deploy._validate_clean_steps,
|
ansible_deploy._validate_clean_steps,
|
||||||
steps, self.node.uuid)
|
steps, self.node.uuid)
|
||||||
self.assertIn("unique names", six.text_type(exc))
|
self.assertIn("unique names", str(exc))
|
||||||
|
|
||||||
@mock.patch.object(ansible_deploy.yaml, 'safe_load', autospec=True)
|
@mock.patch.object(ansible_deploy.yaml, 'safe_load', autospec=True)
|
||||||
def test__get_clean_steps(self, load_mock):
|
def test__get_clean_steps(self, load_mock):
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
"""Test class for boot methods used by iLO modules."""
|
"""Test class for boot methods used by iLO modules."""
|
||||||
|
|
||||||
|
import io
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from ironic_lib import utils as ironic_utils
|
from ironic_lib import utils as ironic_utils
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -43,10 +43,6 @@ from ironic.drivers import utils as driver_utils
|
|||||||
from ironic.tests.unit.drivers.modules.ilo import test_common
|
from ironic.tests.unit.drivers.modules.ilo import test_common
|
||||||
|
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
@ -183,9 +179,9 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
|
|||||||
CONF.pxe.pxe_append_params = 'kernel-params'
|
CONF.pxe.pxe_append_params = 'kernel-params'
|
||||||
|
|
||||||
swift_obj_mock = swift_api_mock.return_value
|
swift_obj_mock = swift_api_mock.return_value
|
||||||
fileobj_mock = mock.MagicMock(spec=file)
|
fileobj_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
fileobj_mock.name = 'tmpfile'
|
fileobj_mock.name = 'tmpfile'
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = fileobj_mock
|
mock_file_handle.__enter__.return_value = fileobj_mock
|
||||||
tempfile_mock.return_value = mock_file_handle
|
tempfile_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -241,9 +237,9 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
|
|||||||
CONF.deploy.http_root = "/httpboot"
|
CONF.deploy.http_root = "/httpboot"
|
||||||
CONF.pxe.pxe_append_params = 'kernel-params'
|
CONF.pxe.pxe_append_params = 'kernel-params'
|
||||||
|
|
||||||
fileobj_mock = mock.MagicMock(spec=file)
|
fileobj_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
fileobj_mock.name = 'tmpfile'
|
fileobj_mock.name = 'tmpfile'
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = fileobj_mock
|
mock_file_handle.__enter__.return_value = fileobj_mock
|
||||||
tempfile_mock.return_value = mock_file_handle
|
tempfile_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
@ -307,9 +303,9 @@ class IloBootPrivateMethodsTestCase(test_common.BaseIloTest):
|
|||||||
CONF.deploy.http_root = "/httpboot"
|
CONF.deploy.http_root = "/httpboot"
|
||||||
CONF.pxe.pxe_append_params = 'kernel-params'
|
CONF.pxe.pxe_append_params = 'kernel-params'
|
||||||
|
|
||||||
fileobj_mock = mock.MagicMock(spec=file)
|
fileobj_mock = mock.MagicMock(spec=io.BytesIO)
|
||||||
fileobj_mock.name = 'tmpfile'
|
fileobj_mock.name = 'tmpfile'
|
||||||
mock_file_handle = mock.MagicMock(spec=file)
|
mock_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_file_handle.__enter__.return_value = fileobj_mock
|
mock_file_handle.__enter__.return_value = fileobj_mock
|
||||||
tempfile_mock.return_value = mock_file_handle
|
tempfile_mock.return_value = mock_file_handle
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
"""Test class for common methods used by iLO modules."""
|
"""Test class for common methods used by iLO modules."""
|
||||||
|
|
||||||
|
import builtins
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -25,8 +27,6 @@ import mock
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
import six.moves.builtins as __builtin__
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -45,11 +45,6 @@ INFO_DICT = db_utils.get_test_ilo_info()
|
|||||||
ilo_client = importutils.try_import('proliantutils.ilo.client')
|
ilo_client = importutils.try_import('proliantutils.ilo.client')
|
||||||
ilo_error = importutils.try_import('proliantutils.exception')
|
ilo_error = importutils.try_import('proliantutils.exception')
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
@ -315,8 +310,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
def test__prepare_floppy_image(self, tempfile_mock, fatimage_mock,
|
def test__prepare_floppy_image(self, tempfile_mock, fatimage_mock,
|
||||||
swift_api_mock):
|
swift_api_mock):
|
||||||
mock_image_file_handle = mock.MagicMock(spec=file)
|
mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_image_file_obj = mock.MagicMock(spec=file)
|
mock_image_file_obj = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_image_file_obj.name = 'image-tmp-file'
|
mock_image_file_obj.name = 'image-tmp-file'
|
||||||
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
||||||
|
|
||||||
@ -355,8 +350,8 @@ class IloCommonMethodsTestCase(BaseIloTest):
|
|||||||
def test__prepare_floppy_image_use_webserver(self, tempfile_mock,
|
def test__prepare_floppy_image_use_webserver(self, tempfile_mock,
|
||||||
fatimage_mock,
|
fatimage_mock,
|
||||||
copy_mock):
|
copy_mock):
|
||||||
mock_image_file_handle = mock.MagicMock(spec=file)
|
mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_image_file_obj = mock.MagicMock(spec=file)
|
mock_image_file_obj = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_image_file_obj.name = 'image-tmp-file'
|
mock_image_file_obj.name = 'image-tmp-file'
|
||||||
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
||||||
|
|
||||||
@ -1038,11 +1033,11 @@ class IloCommonMethodsTestCase(BaseIloTest):
|
|||||||
# | THEN |
|
# | THEN |
|
||||||
unlink_mock.assert_called_once_with('/any_path1/any_file')
|
unlink_mock.assert_called_once_with('/any_path1/any_file')
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_verify_image_checksum(self, open_mock):
|
def test_verify_image_checksum(self, open_mock):
|
||||||
# | GIVEN |
|
# | GIVEN |
|
||||||
data = b'Yankee Doodle went to town riding on a pony;'
|
data = b'Yankee Doodle went to town riding on a pony;'
|
||||||
file_like_object = six.BytesIO(data)
|
file_like_object = io.BytesIO(data)
|
||||||
open_mock().__enter__.return_value = file_like_object
|
open_mock().__enter__.return_value = file_like_object
|
||||||
actual_hash = hashlib.md5(data).hexdigest()
|
actual_hash = hashlib.md5(data).hexdigest()
|
||||||
# | WHEN |
|
# | WHEN |
|
||||||
@ -1058,12 +1053,12 @@ class IloCommonMethodsTestCase(BaseIloTest):
|
|||||||
ilo_common.verify_image_checksum,
|
ilo_common.verify_image_checksum,
|
||||||
invalid_file_path, 'hash_xxx')
|
invalid_file_path, 'hash_xxx')
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
def test_verify_image_checksum_throws_for_failed_validation(self,
|
def test_verify_image_checksum_throws_for_failed_validation(self,
|
||||||
open_mock):
|
open_mock):
|
||||||
# | GIVEN |
|
# | GIVEN |
|
||||||
data = b'Yankee Doodle went to town riding on a pony;'
|
data = b'Yankee Doodle went to town riding on a pony;'
|
||||||
file_like_object = six.BytesIO(data)
|
file_like_object = io.BytesIO(data)
|
||||||
open_mock().__enter__.return_value = file_like_object
|
open_mock().__enter__.return_value = file_like_object
|
||||||
invalid_hash = 'invalid_hash_value'
|
invalid_hash = 'invalid_hash_value'
|
||||||
# | WHEN | & | THEN |
|
# | WHEN | & | THEN |
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""Test class for common methods used by iLO modules."""
|
"""Test class for common methods used by iLO modules."""
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.conductor import task_manager
|
from ironic.conductor import task_manager
|
||||||
@ -25,11 +24,6 @@ from ironic.drivers.modules import ipmitool
|
|||||||
from ironic.tests.unit.drivers.modules.ilo import test_common
|
from ironic.tests.unit.drivers.modules.ilo import test_common
|
||||||
|
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
|
|
||||||
class IloConsoleInterfaceTestCase(test_common.BaseIloTest):
|
class IloConsoleInterfaceTestCase(test_common.BaseIloTest):
|
||||||
|
|
||||||
boot_interface = 'ilo-virtual-media'
|
boot_interface = 'ilo-virtual-media'
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""Test class for Firmware Processor used by iLO management interface."""
|
"""Test class for Firmware Processor used by iLO management interface."""
|
||||||
|
|
||||||
|
import builtins
|
||||||
import io
|
import io
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from six.moves import builtins as __builtin__
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.drivers.modules.ilo import common as ilo_common
|
from ironic.drivers.modules.ilo import common as ilo_common
|
||||||
@ -42,8 +43,8 @@ class FirmwareProcessorTestCase(base.TestCase):
|
|||||||
firmware_update_args = {'firmware_update_mode': 'invalid_mode',
|
firmware_update_args = {'firmware_update_mode': 'invalid_mode',
|
||||||
'firmware_images': None}
|
'firmware_images': None}
|
||||||
# Note(deray): Need to set __name__ attribute explicitly to keep
|
# Note(deray): Need to set __name__ attribute explicitly to keep
|
||||||
# ``six.wraps`` happy. Passing this to the `name` argument at the time
|
# ``functools.wraps`` happy. Passing this to the `name` argument at
|
||||||
# creation of Mock doesn't help.
|
# the time creation of Mock doesn't help.
|
||||||
update_firmware_mock.__name__ = 'update_firmware_mock'
|
update_firmware_mock.__name__ = 'update_firmware_mock'
|
||||||
wrapped_func = (ilo_fw_processor.
|
wrapped_func = (ilo_fw_processor.
|
||||||
verify_firmware_update_args(update_firmware_mock))
|
verify_firmware_update_args(update_firmware_mock))
|
||||||
@ -370,7 +371,7 @@ class FirmwareProcessorTestCase(base.TestCase):
|
|||||||
shutil_mock.rmtree.assert_called_once_with(
|
shutil_mock.rmtree.assert_called_once_with(
|
||||||
tempfile_mock.mkdtemp(), ignore_errors=True)
|
tempfile_mock.mkdtemp(), ignore_errors=True)
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
ilo_fw_processor.image_service, 'FileImageService', autospec=True)
|
ilo_fw_processor.image_service, 'FileImageService', autospec=True)
|
||||||
def test__download_file_based_fw_to_copies_file_to_target(
|
def test__download_file_based_fw_to_copies_file_to_target(
|
||||||
@ -390,7 +391,7 @@ class FirmwareProcessorTestCase(base.TestCase):
|
|||||||
file_image_service_mock.return_value.download.assert_called_once_with(
|
file_image_service_mock.return_value.download.assert_called_once_with(
|
||||||
firmware_file_path, fd_mock)
|
firmware_file_path, fd_mock)
|
||||||
|
|
||||||
@mock.patch.object(__builtin__, 'open', autospec=True)
|
@mock.patch.object(builtins, 'open', autospec=True)
|
||||||
@mock.patch.object(ilo_fw_processor, 'image_service', autospec=True)
|
@mock.patch.object(ilo_fw_processor, 'image_service', autospec=True)
|
||||||
def test__download_http_based_fw_to_downloads_the_fw_file(
|
def test__download_http_based_fw_to_downloads_the_fw_file(
|
||||||
self, image_service_mock, open_mock):
|
self, image_service_mock, open_mock):
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""Test class for Management Interface used by iLO modules."""
|
"""Test class for Management Interface used by iLO modules."""
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import states
|
from ironic.common import states
|
||||||
@ -365,7 +364,7 @@ class TestInspectPrivateMethods(test_common.BaseIloTest):
|
|||||||
self.node,
|
self.node,
|
||||||
ilo_mock)
|
ilo_mock)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
six.text_type(result),
|
str(result),
|
||||||
("Failed to inspect hardware. Reason: Server didn't return the "
|
("Failed to inspect hardware. Reason: Server didn't return the "
|
||||||
"key(s): cpu_arch"))
|
"key(s): cpu_arch"))
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
Test class for iRMC Boot Driver
|
Test class for iRMC Boot Driver
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -24,7 +25,6 @@ from ironic_lib import utils as ironic_utils
|
|||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import six
|
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -47,10 +47,6 @@ from ironic.tests.unit.drivers.modules import test_pxe
|
|||||||
from ironic.tests.unit.drivers import third_party_driver_mock_specs \
|
from ironic.tests.unit.drivers import third_party_driver_mock_specs \
|
||||||
as mock_specs
|
as mock_specs
|
||||||
from ironic.tests.unit.objects import utils as obj_utils
|
from ironic.tests.unit.objects import utils as obj_utils
|
||||||
if six.PY3:
|
|
||||||
import io
|
|
||||||
file = io.BytesIO
|
|
||||||
|
|
||||||
|
|
||||||
INFO_DICT = db_utils.get_test_irmc_info()
|
INFO_DICT = db_utils.get_test_irmc_info()
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
@ -519,7 +515,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
|
|||||||
tempfile_mock,
|
tempfile_mock,
|
||||||
create_vfat_image_mock,
|
create_vfat_image_mock,
|
||||||
copyfile_mock):
|
copyfile_mock):
|
||||||
mock_image_file_handle = mock.MagicMock(spec=file)
|
mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_image_file_obj = mock.MagicMock()
|
mock_image_file_obj = mock.MagicMock()
|
||||||
mock_image_file_obj.name = 'image-tmp-file'
|
mock_image_file_obj.name = 'image-tmp-file'
|
||||||
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
||||||
@ -546,7 +542,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
|
|||||||
tempfile_mock,
|
tempfile_mock,
|
||||||
create_vfat_image_mock,
|
create_vfat_image_mock,
|
||||||
copyfile_mock):
|
copyfile_mock):
|
||||||
mock_image_file_handle = mock.MagicMock(spec=file)
|
mock_image_file_handle = mock.MagicMock(spec=io.BytesIO)
|
||||||
mock_image_file_obj = mock.MagicMock()
|
mock_image_file_obj = mock.MagicMock()
|
||||||
mock_image_file_obj.name = 'image-tmp-file'
|
mock_image_file_obj.name = 'image-tmp-file'
|
||||||
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
mock_image_file_handle.__enter__.return_value = mock_image_file_obj
|
||||||
|
@ -12,13 +12,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import requests
|
import requests
|
||||||
import retrying
|
import retrying
|
||||||
import six
|
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic import conf
|
from ironic import conf
|
||||||
@ -31,7 +30,7 @@ CONF = conf.CONF
|
|||||||
|
|
||||||
class MockResponse(object):
|
class MockResponse(object):
|
||||||
def __init__(self, text, status_code=http_client.OK):
|
def __init__(self, text, status_code=http_client.OK):
|
||||||
assert isinstance(text, six.string_types)
|
assert isinstance(text, str)
|
||||||
self.text = text
|
self.text = text
|
||||||
self.status_code = status_code
|
self.status_code = status_code
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user