Merge "Set IPMI session timeout for the virtual BMCs"
This commit is contained in:
commit
212be0a759
@ -33,6 +33,10 @@ class VirtualBMCConfig(object):
|
||||
'logfile': None,
|
||||
'debug': 'false'
|
||||
},
|
||||
'ipmi': {
|
||||
# Maximum time (in seconds) to wait for the data to come across
|
||||
'session_timeout': 1
|
||||
},
|
||||
}
|
||||
|
||||
def initialize(self):
|
||||
@ -58,6 +62,9 @@ class VirtualBMCConfig(object):
|
||||
self._conf_dict['default']['show_passwords'] = utils.str2bool(
|
||||
self._conf_dict['default']['show_passwords'])
|
||||
|
||||
self._conf_dict['ipmi']['session_timeout'] = int(
|
||||
self._conf_dict['ipmi']['session_timeout'])
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._conf_dict[key]
|
||||
|
||||
|
@ -170,7 +170,7 @@ class VirtualBMCManager(object):
|
||||
f.write(str(pid_num))
|
||||
|
||||
LOG.info('Virtual BMC for domain %s started', domain_name)
|
||||
vbmc.listen()
|
||||
vbmc.listen(timeout=CONF['ipmi']['session_timeout'])
|
||||
|
||||
def stop(self, domain_name):
|
||||
LOG.debug('Stopping Virtual BMC for domain %s', domain_name)
|
||||
|
@ -29,7 +29,8 @@ class VirtualBMCConfigTestCase(base.TestCase):
|
||||
super(VirtualBMCConfigTestCase, self).setUp()
|
||||
self.vbmc_config = config.VirtualBMCConfig()
|
||||
self.config_dict = {'default': {'show_passwords': 'true'},
|
||||
'log': {'debug': 'true', 'logfile': '/foo/bar'}}
|
||||
'log': {'debug': 'true', 'logfile': '/foo/bar'},
|
||||
'ipmi': {'session_timeout': '30'}}
|
||||
|
||||
@mock.patch.object(config.VirtualBMCConfig, '_validate')
|
||||
@mock.patch.object(config.VirtualBMCConfig, '_as_dict')
|
||||
@ -45,10 +46,11 @@ class VirtualBMCConfigTestCase(base.TestCase):
|
||||
|
||||
def test__as_dict(self):
|
||||
config = mock.Mock()
|
||||
config.sections.side_effect = ['default', 'log'],
|
||||
config.sections.side_effect = ['default', 'log', 'ipmi'],
|
||||
config.items.side_effect = [[('show_passwords', 'true')],
|
||||
[('logfile', '/foo/bar'),
|
||||
('debug', 'true')]]
|
||||
('debug', 'true')],
|
||||
[('session_timeout', '30')]]
|
||||
ret = self.vbmc_config._as_dict(config)
|
||||
self.assertEqual(self.config_dict, ret)
|
||||
|
||||
@ -59,4 +61,5 @@ class VirtualBMCConfigTestCase(base.TestCase):
|
||||
expected = self.config_dict.copy()
|
||||
expected['default']['show_passwords'] = True
|
||||
expected['log']['debug'] = True
|
||||
expected['ipmi']['session_timeout'] = 30
|
||||
self.assertEqual(expected, self.vbmc_config._conf_dict)
|
||||
|
@ -186,22 +186,25 @@ class VirtualBMCManagerTestCase(base.TestCase):
|
||||
@mock.patch.object(os.path, 'exists')
|
||||
def test_start(self, mock_exists, mock__parse, mock_check_conn,
|
||||
mock_detach, mock_vbmc, mock_open):
|
||||
mock_exists.return_value = True
|
||||
mock__parse.return_value = self.domain0
|
||||
mock_detach.return_value.__enter__.return_value = 99999
|
||||
file_handler = mock_open.return_value.__enter__.return_value
|
||||
self.manager.start(self.domain_name0)
|
||||
conf = {'ipmi': {'session_timeout': 10},
|
||||
'default': {'show_passwords': False}}
|
||||
with mock.patch('virtualbmc.manager.CONF', conf):
|
||||
mock_exists.return_value = True
|
||||
mock__parse.return_value = self.domain0
|
||||
mock_detach.return_value.__enter__.return_value = 99999
|
||||
file_handler = mock_open.return_value.__enter__.return_value
|
||||
self.manager.start(self.domain_name0)
|
||||
|
||||
mock_exists.assert_called_once_with(self.domain_path0)
|
||||
mock__parse.assert_called_once_with(self.domain_name0)
|
||||
mock_check_conn.assert_called_once_with(
|
||||
self.domain0['libvirt_uri'], self.domain0['domain_name'],
|
||||
sasl_username=self.domain0['libvirt_sasl_username'],
|
||||
sasl_password=self.domain0['libvirt_sasl_password'])
|
||||
mock_detach.assert_called_once_with()
|
||||
mock_vbmc.assert_called_once_with(**self.domain0)
|
||||
mock_vbmc.return_value.listen.assert_called_once_with()
|
||||
file_handler.write.assert_called_once_with('99999')
|
||||
mock_exists.assert_called_once_with(self.domain_path0)
|
||||
mock__parse.assert_called_once_with(self.domain_name0)
|
||||
mock_check_conn.assert_called_once_with(
|
||||
self.domain0['libvirt_uri'], self.domain0['domain_name'],
|
||||
sasl_username=self.domain0['libvirt_sasl_username'],
|
||||
sasl_password=self.domain0['libvirt_sasl_password'])
|
||||
mock_detach.assert_called_once_with()
|
||||
mock_vbmc.assert_called_once_with(**self.domain0)
|
||||
mock_vbmc.return_value.listen.assert_called_once_with(timeout=10)
|
||||
file_handler.write.assert_called_once_with('99999')
|
||||
|
||||
@mock.patch.object(builtins, 'open')
|
||||
@mock.patch.object(os, 'kill')
|
||||
|
Loading…
x
Reference in New Issue
Block a user