Merge "Multiprocessing pickling error in vbmcd"
This commit is contained in:
+34
-34
@@ -35,6 +35,40 @@ DEFAULT_SECTION = 'VirtualBMC'
|
||||
CONF = vbmc_config.get_config()
|
||||
|
||||
|
||||
def vbmc_runner(bmc_config):
|
||||
# The manager process installs a signal handler for SIGTERM to
|
||||
# propagate it to children. Return to the default handler.
|
||||
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
||||
|
||||
show_passwords = CONF['default']['show_passwords']
|
||||
|
||||
if show_passwords:
|
||||
show_options = bmc_config
|
||||
else:
|
||||
show_options = utils.mask_dict_password(bmc_config)
|
||||
|
||||
try:
|
||||
vbmc = VirtualBMC(**bmc_config)
|
||||
|
||||
except Exception as ex:
|
||||
LOG.exception(
|
||||
'Error running vBMC with configuration '
|
||||
'%(opts)s: %(error)s', {'opts': show_options,
|
||||
'error': ex}
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
vbmc.listen(timeout=CONF['ipmi']['session_timeout'])
|
||||
|
||||
except Exception as ex:
|
||||
LOG.exception(
|
||||
'Shutdown vBMC for domain %(domain)s, cause '
|
||||
'%(error)s', {'domain': show_options['domain_name'], 'error': ex}
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
class VirtualBMCManager(object):
|
||||
|
||||
VBMC_OPTIONS = ['username', 'password', 'address', 'port',
|
||||
@@ -113,40 +147,6 @@ class VirtualBMCManager(object):
|
||||
but alive ones.
|
||||
"""
|
||||
|
||||
def vbmc_runner(bmc_config):
|
||||
# The manager process installs a signal handler for SIGTERM to
|
||||
# propagate it to children. Return to the default handler.
|
||||
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
||||
|
||||
show_passwords = CONF['default']['show_passwords']
|
||||
|
||||
if show_passwords:
|
||||
show_options = bmc_config
|
||||
else:
|
||||
show_options = utils.mask_dict_password(bmc_config)
|
||||
|
||||
try:
|
||||
vbmc = VirtualBMC(**bmc_config)
|
||||
|
||||
except Exception as ex:
|
||||
LOG.exception(
|
||||
'Error running vBMC with configuration '
|
||||
'%(opts)s: %(error)s', {'opts': show_options,
|
||||
'error': ex}
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
vbmc.listen(timeout=CONF['ipmi']['session_timeout'])
|
||||
|
||||
except Exception as ex:
|
||||
LOG.exception(
|
||||
'Shutdown vBMC for domain %(domain)s, cause '
|
||||
'%(error)s', {'domain': show_options['domain_name'],
|
||||
'error': ex}
|
||||
)
|
||||
return
|
||||
|
||||
for domain_name in os.listdir(self.config_dir):
|
||||
if not os.path.isdir(
|
||||
os.path.join(self.config_dir, domain_name)
|
||||
|
||||
@@ -284,3 +284,9 @@ class VirtualBMCManagerTestCase(base.TestCase):
|
||||
def test_show(self, mock__show):
|
||||
self.manager.show(self.domain0)
|
||||
mock__show.assert_called_once_with(self.domain0)
|
||||
|
||||
def test_vbmc_runner_is_picklable(self):
|
||||
import pickle
|
||||
payload = pickle.dumps(manager.vbmc_runner)
|
||||
loaded = pickle.loads(payload)
|
||||
self.assertIs(manager.vbmc_runner, loaded)
|
||||
|
||||
Reference in New Issue
Block a user