Assign the platform after declaration

This simple patch changes when the arch value is
assigned in the connector factory until after the
function defintion.  kwarg values assigned in
function declarations are assigned at file import
time and not at call time.

Change-Id: I08b6560a5f4dfd221c4211ab35a784c4605150dc
This commit is contained in:
Walter A. Boring IV 2015-05-08 10:12:23 -07:00 committed by Walter A. Boring IV (hemna)
parent 28f3d0950f
commit 49c2bdf641
1 changed files with 7 additions and 1 deletions

View File

@ -120,9 +120,15 @@ class InitiatorConnector(executor.Executor):
def factory(protocol, root_helper, driver=None,
execute=putils.execute, use_multipath=False,
device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT,
arch=platform.machine(),
arch=None,
*args, **kwargs):
"""Build a Connector object based upon protocol and architecture."""
# We do this instead of assigning it in the definition
# to help mocking for unit tests
if arch is None:
arch = platform.machine()
LOG.debug("Factory for %(protocol)s on %(arch)s",
{'protocol': protocol, 'arch': arch})
protocol = protocol.upper()