Fix error message when running genconfig

The Fujitsu eternus_dx_common code was configured to
try to import pywbem and immediately throw an error in
the case that the module wasn't available.  This would
cause the error to be reported during the genconfig process.

This patch changes the driver to just attempt to import
the module and record whether it was successful.  If not,
the error message isn't reported until __init__ is called.

This approach is consistent with what EMC does in their
drivers for importing pywbem.

Change-Id: I4f7d90bc2d05bde653f9d64fdb183ebf639fe3d4
Closes-bug: 1558644
This commit is contained in:
Jay S Bryant 2016-03-12 03:18:00 -06:00
parent 4e062bd664
commit 3c6b224719
1 changed files with 7 additions and 3 deletions

View File

@ -39,10 +39,9 @@ CONF = cfg.CONF
try:
import pywbem
pywbemAvailable = True
except ImportError:
msg = _LE('import pywbem failed!! '
'pywbem is necessary for this volume driver.')
LOG.error(msg)
pywbemAvailable = False
VOL_PREFIX = "FJosv_"
RAIDGROUP = 2
@ -154,6 +153,11 @@ class FJDXCommon(object):
}
def __init__(self, prtcl, configuration=None):
if not pywbemAvailable:
LOG.error(_LE('import pywbem failed!! '
'pywbem is necessary for this volume driver.'))
self.protocol = prtcl
self.configuration = configuration
self.configuration.append_config_values(FJ_ETERNUS_DX_OPT_opts)