Fix async keyword for Python 3.7
In Python 3.7, async becomes a keyword, and therefore we need to change variable async. The passthru() previously had async and async_call, we just remove the old parameter. scciclient moved from async to do_async as parameter, so we use that. Change-Id: I35cb34d9ba78186de88ff7b56ab89ee6e24db6e6
This commit is contained in:
parent
0a10eb7794
commit
3749cd618b
driver-requirements.txt
ironic
@ -8,7 +8,7 @@ proliantutils>=2.6.0
|
|||||||
pysnmp>=4.3.0,<5.0.0
|
pysnmp>=4.3.0,<5.0.0
|
||||||
python-ironic-inspector-client>=1.5.0
|
python-ironic-inspector-client>=1.5.0
|
||||||
python-oneviewclient<3.0.0,>=2.5.2
|
python-oneviewclient<3.0.0,>=2.5.2
|
||||||
python-scciclient>=0.7.2
|
python-scciclient>=0.8.0
|
||||||
python-ilorest-library>=2.1.0
|
python-ilorest-library>=2.1.0
|
||||||
hpOneView>=4.4.0
|
hpOneView>=4.4.0
|
||||||
UcsSdk==0.8.2.2
|
UcsSdk==0.8.2.2
|
||||||
|
@ -646,7 +646,7 @@ VendorMetadata = collections.namedtuple('VendorMetadata', ['method',
|
|||||||
'metadata'])
|
'metadata'])
|
||||||
|
|
||||||
|
|
||||||
def _passthru(http_methods, method=None, async=None, async_call=None,
|
def _passthru(http_methods, method=None, async_call=True,
|
||||||
driver_passthru=False, description=None,
|
driver_passthru=False, description=None,
|
||||||
attach=False, require_exclusive_lock=True):
|
attach=False, require_exclusive_lock=True):
|
||||||
"""A decorator for registering a function as a passthru function.
|
"""A decorator for registering a function as a passthru function.
|
||||||
@ -662,7 +662,6 @@ def _passthru(http_methods, method=None, async=None, async_call=None,
|
|||||||
:param http_methods: A list of supported HTTP methods by the vendor
|
:param http_methods: A list of supported HTTP methods by the vendor
|
||||||
function.
|
function.
|
||||||
:param method: an arbitrary string describing the action to be taken.
|
:param method: an arbitrary string describing the action to be taken.
|
||||||
:param async: Deprecated, please use async_call instead.
|
|
||||||
:param async_call: Boolean value. If True invoke the passthru function
|
:param async_call: Boolean value. If True invoke the passthru function
|
||||||
asynchronously; if False, synchronously. If a passthru
|
asynchronously; if False, synchronously. If a passthru
|
||||||
function touches the BMC we strongly recommend it to
|
function touches the BMC we strongly recommend it to
|
||||||
@ -682,26 +681,6 @@ def _passthru(http_methods, method=None, async=None, async_call=None,
|
|||||||
for a synchronous passthru method. If False,
|
for a synchronous passthru method. If False,
|
||||||
don't lock the node. Defaults to True.
|
don't lock the node. Defaults to True.
|
||||||
"""
|
"""
|
||||||
# TODO(rloo): In Stein cycle, remove support for 'async' parameter.
|
|
||||||
# The default value for 'async_call' should then be changed
|
|
||||||
# to True.
|
|
||||||
if async_call is None:
|
|
||||||
if async is not None:
|
|
||||||
LOG.warning(
|
|
||||||
'The "async" parameter is deprecated, please use "async_call" '
|
|
||||||
'instead. The "async" parameter will be removed in the Stein '
|
|
||||||
'cycle.'
|
|
||||||
)
|
|
||||||
async_call = async
|
|
||||||
else:
|
|
||||||
async_call = True
|
|
||||||
else:
|
|
||||||
if async is not None:
|
|
||||||
raise TypeError(
|
|
||||||
"'async_call' and 'async' parameters cannot be used together. "
|
|
||||||
"Use 'async_call' instead of 'async' since 'async' is "
|
|
||||||
"deprecated and will be removed in the Stein cycle."
|
|
||||||
)
|
|
||||||
|
|
||||||
def handle_passthru(func):
|
def handle_passthru(func):
|
||||||
api_method = method
|
api_method = method
|
||||||
@ -737,17 +716,17 @@ def _passthru(http_methods, method=None, async=None, async_call=None,
|
|||||||
return handle_passthru
|
return handle_passthru
|
||||||
|
|
||||||
|
|
||||||
def passthru(http_methods, method=None, async=None, description=None,
|
def passthru(http_methods, method=None, async_call=True, description=None,
|
||||||
attach=False, require_exclusive_lock=True, async_call=None):
|
attach=False, require_exclusive_lock=True):
|
||||||
return _passthru(http_methods, method, async, async_call,
|
return _passthru(http_methods, method, async_call,
|
||||||
driver_passthru=False,
|
driver_passthru=False,
|
||||||
description=description, attach=attach,
|
description=description, attach=attach,
|
||||||
require_exclusive_lock=require_exclusive_lock)
|
require_exclusive_lock=require_exclusive_lock)
|
||||||
|
|
||||||
|
|
||||||
def driver_passthru(http_methods, method=None, async=None, description=None,
|
def driver_passthru(http_methods, method=None, async_call=True,
|
||||||
attach=False, async_call=None):
|
description=None, attach=False):
|
||||||
return _passthru(http_methods, method, async, async_call,
|
return _passthru(http_methods, method, async_call,
|
||||||
driver_passthru=True, description=description,
|
driver_passthru=True, description=description,
|
||||||
attach=attach)
|
attach=attach)
|
||||||
|
|
||||||
|
@ -447,8 +447,8 @@ def _attach_virtual_cd(node, bootable_iso_filename):
|
|||||||
CONF.irmc.remote_image_user_name,
|
CONF.irmc.remote_image_user_name,
|
||||||
CONF.irmc.remote_image_user_password)
|
CONF.irmc.remote_image_user_password)
|
||||||
|
|
||||||
irmc_client(cd_set_params, async=False)
|
irmc_client(cd_set_params, do_async=False)
|
||||||
irmc_client(scci.MOUNT_CD, async=False)
|
irmc_client(scci.MOUNT_CD, do_async=False)
|
||||||
|
|
||||||
except scci.SCCIClientError as irmc_exception:
|
except scci.SCCIClientError as irmc_exception:
|
||||||
LOG.exception("Error while inserting virtual cdrom "
|
LOG.exception("Error while inserting virtual cdrom "
|
||||||
@ -503,8 +503,8 @@ def _attach_virtual_fd(node, floppy_image_filename):
|
|||||||
CONF.irmc.remote_image_user_name,
|
CONF.irmc.remote_image_user_name,
|
||||||
CONF.irmc.remote_image_user_password)
|
CONF.irmc.remote_image_user_password)
|
||||||
|
|
||||||
irmc_client(fd_set_params, async=False)
|
irmc_client(fd_set_params, do_async=False)
|
||||||
irmc_client(scci.MOUNT_FD, async=False)
|
irmc_client(scci.MOUNT_FD, do_async=False)
|
||||||
|
|
||||||
except scci.SCCIClientError as irmc_exception:
|
except scci.SCCIClientError as irmc_exception:
|
||||||
LOG.exception("Error while inserting virtual floppy "
|
LOG.exception("Error while inserting virtual floppy "
|
||||||
|
@ -726,8 +726,8 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
|
|||||||
'admin',
|
'admin',
|
||||||
'admin0')
|
'admin0')
|
||||||
irmc_client.assert_has_calls(
|
irmc_client.assert_has_calls(
|
||||||
[mock.call(cd_set_params, async=False),
|
[mock.call(cd_set_params, do_async=False),
|
||||||
mock.call(irmc_boot.scci.MOUNT_CD, async=False)])
|
mock.call(irmc_boot.scci.MOUNT_CD, do_async=False)])
|
||||||
|
|
||||||
@mock.patch.object(irmc_common, 'get_irmc_client', spec_set=True,
|
@mock.patch.object(irmc_common, 'get_irmc_client', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@ -805,8 +805,8 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
|
|||||||
'admin',
|
'admin',
|
||||||
'admin0')
|
'admin0')
|
||||||
irmc_client.assert_has_calls(
|
irmc_client.assert_has_calls(
|
||||||
[mock.call(fd_set_params, async=False),
|
[mock.call(fd_set_params, do_async=False),
|
||||||
mock.call(irmc_boot.scci.MOUNT_FD, async=False)])
|
mock.call(irmc_boot.scci.MOUNT_FD, do_async=False)])
|
||||||
|
|
||||||
@mock.patch.object(irmc_common, 'get_irmc_client', spec_set=True,
|
@mock.patch.object(irmc_common, 'get_irmc_client', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
|
@ -100,16 +100,6 @@ class PassthruDecoratorTestCase(base.TestCase):
|
|||||||
self.assertNotEqual(inst1.driver_routes['driver_noexception']['func'],
|
self.assertNotEqual(inst1.driver_routes['driver_noexception']['func'],
|
||||||
inst2.driver_routes['driver_noexception']['func'])
|
inst2.driver_routes['driver_noexception']['func'])
|
||||||
|
|
||||||
@mock.patch.object(driver_base.LOG, 'warning')
|
|
||||||
def test_old_async_warning(self, mock_log_warning):
|
|
||||||
driver_base.passthru(['POST'], async=True)
|
|
||||||
mock_log_warning.assert_called_once()
|
|
||||||
|
|
||||||
@mock.patch.object(driver_base.LOG, 'warning')
|
|
||||||
def test_new_async_call_without_warning(self, mock_log_warning):
|
|
||||||
driver_base.passthru(['POST'], async_call=True)
|
|
||||||
mock_log_warning.assert_not_called()
|
|
||||||
|
|
||||||
|
|
||||||
class CleanStepDecoratorTestCase(base.TestCase):
|
class CleanStepDecoratorTestCase(base.TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user