Drop unused CLI options
We probably won't implement logs serving anyway. Change-Id: I98f7c971057466fbdf5db8f32a83588cb25c02c5 Implements: blueprint python-ramdisk-code
This commit is contained in:
parent
56fc0996a1
commit
b16c7b2223
@ -255,7 +255,3 @@ def setup_ipmi_credentials(resp):
|
||||
try_call('ipmitool', 'user', 'enable', '2')
|
||||
try_call('ipmitool', 'channel', 'setaccess', '1', '2',
|
||||
'link=on', 'ipmi=on', 'callin=on', 'privilege=4')
|
||||
|
||||
|
||||
def fork_and_serve_logs(args):
|
||||
pass # TODO(dtantsur): implement
|
||||
|
@ -25,16 +25,11 @@ LOG = logging.getLogger('ironic-discoverd-ramdisk')
|
||||
|
||||
def parse_args(args):
|
||||
parser = argparse.ArgumentParser(description='Detect present hardware.')
|
||||
parser.add_argument('-p', '--port', type=int, default=8080,
|
||||
help='Port to serve logs over HTTP')
|
||||
parser.add_argument('-L', '--system-log-file', action='append',
|
||||
help='System log file to be sent to discoverd, may be '
|
||||
'specified multiple times')
|
||||
parser.add_argument('-l', '--log-file', default='discovery-logs',
|
||||
help='Path to log file, defaults to ./discovery-logs')
|
||||
parser.add_argument('-d', '--daemonize-on-failure', action='store_true',
|
||||
help='In case of failure, fork off, continue running '
|
||||
'and serve logs via port set by --port')
|
||||
parser.add_argument('--bootif', help='PXE boot interface')
|
||||
# Support for edeploy plugin
|
||||
parser.add_argument('--use-hardware-detect', action='store_true',
|
||||
@ -95,6 +90,4 @@ def main():
|
||||
call_error = True
|
||||
|
||||
if failures or call_error:
|
||||
if args.daemonize_on_failure:
|
||||
discover.fork_and_serve_logs(args)
|
||||
sys.exit(1)
|
||||
|
@ -26,10 +26,9 @@ FAKE_ARGS = test_discover.get_fake_args()
|
||||
|
||||
class TestParseArgs(unittest.TestCase):
|
||||
def test(self):
|
||||
args = ['-d', 'http://url']
|
||||
args = ['http://url']
|
||||
parsed_args = main.parse_args(args)
|
||||
self.assertEqual('http://url', parsed_args.callback_url)
|
||||
self.assertTrue(parsed_args.daemonize_on_failure)
|
||||
|
||||
def test_log_files(self):
|
||||
args = ['-L', 'log1', '-L', 'log2', 'url']
|
||||
@ -41,7 +40,6 @@ class TestParseArgs(unittest.TestCase):
|
||||
@mock.patch.object(main, 'setup_logging', lambda args: None)
|
||||
@mock.patch.object(main, 'parse_args', return_value=FAKE_ARGS,
|
||||
autospec=True)
|
||||
@mock.patch.object(discover, 'fork_and_serve_logs', autospec=True)
|
||||
@mock.patch.object(discover, 'setup_ipmi_credentials', autospec=True)
|
||||
@mock.patch.object(discover, 'call_discoverd', autospec=True,
|
||||
return_value={})
|
||||
@ -49,7 +47,7 @@ class TestParseArgs(unittest.TestCase):
|
||||
@mock.patch.object(discover, 'discover_hardware', autospec=True)
|
||||
class TestMain(unittest.TestCase):
|
||||
def test_success(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.return_value = 'LOG'
|
||||
|
||||
main.main()
|
||||
@ -60,11 +58,10 @@ class TestMain(unittest.TestCase):
|
||||
mock_logs.assert_called_once_with(FAKE_ARGS)
|
||||
mock_callback.assert_called_once_with(FAKE_ARGS, {'logs': 'LOG'},
|
||||
mock.ANY)
|
||||
self.assertFalse(mock_fork_serve.called)
|
||||
self.assertFalse(mock_setup_ipmi.called)
|
||||
|
||||
def test_discover_fails(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.return_value = 'LOG'
|
||||
mock_discover.side_effect = RuntimeError('boom')
|
||||
|
||||
@ -76,10 +73,9 @@ class TestMain(unittest.TestCase):
|
||||
mock.ANY)
|
||||
failures = mock_callback.call_args[0][2]
|
||||
self.assertIn('boom', failures.get_error())
|
||||
mock_fork_serve.assert_called_once_with(FAKE_ARGS)
|
||||
|
||||
def test_collect_logs_fails(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.side_effect = RuntimeError('boom')
|
||||
|
||||
main.main()
|
||||
@ -87,10 +83,9 @@ class TestMain(unittest.TestCase):
|
||||
mock_discover.assert_called_once_with(FAKE_ARGS, mock.ANY, mock.ANY)
|
||||
mock_logs.assert_called_once_with(FAKE_ARGS)
|
||||
mock_callback.assert_called_once_with(FAKE_ARGS, {}, mock.ANY)
|
||||
self.assertFalse(mock_fork_serve.called)
|
||||
|
||||
def test_callback_fails(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.return_value = 'LOG'
|
||||
mock_callback.side_effect = requests.HTTPError('boom')
|
||||
|
||||
@ -100,10 +95,9 @@ class TestMain(unittest.TestCase):
|
||||
mock_logs.assert_called_once_with(FAKE_ARGS)
|
||||
mock_callback.assert_called_once_with(FAKE_ARGS, {'logs': 'LOG'},
|
||||
mock.ANY)
|
||||
mock_fork_serve.assert_called_once_with(FAKE_ARGS)
|
||||
|
||||
def test_callback_fails2(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.return_value = 'LOG'
|
||||
mock_callback.side_effect = RuntimeError('boom')
|
||||
|
||||
@ -113,27 +107,9 @@ class TestMain(unittest.TestCase):
|
||||
mock_logs.assert_called_once_with(FAKE_ARGS)
|
||||
mock_callback.assert_called_once_with(FAKE_ARGS, {'logs': 'LOG'},
|
||||
mock.ANY)
|
||||
mock_fork_serve.assert_called_once_with(FAKE_ARGS)
|
||||
|
||||
def test_no_daemonize(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
new_fake_args = test_discover.get_fake_args()
|
||||
new_fake_args.daemonize_on_failure = None
|
||||
mock_parse.return_value = new_fake_args
|
||||
mock_logs.return_value = 'LOG'
|
||||
mock_callback.side_effect = RuntimeError('boom')
|
||||
|
||||
self.assertRaisesRegexp(SystemExit, '1', main.main)
|
||||
|
||||
mock_discover.assert_called_once_with(new_fake_args, mock.ANY,
|
||||
mock.ANY)
|
||||
mock_logs.assert_called_once_with(new_fake_args)
|
||||
mock_callback.assert_called_once_with(new_fake_args, {'logs': 'LOG'},
|
||||
mock.ANY)
|
||||
self.assertFalse(mock_fork_serve.called)
|
||||
|
||||
def test_setup_ipmi(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.return_value = 'LOG'
|
||||
mock_callback.return_value = {'ipmi_setup_credentials': True}
|
||||
|
||||
@ -144,10 +120,9 @@ class TestMain(unittest.TestCase):
|
||||
mock_callback.assert_called_once_with(FAKE_ARGS, {'logs': 'LOG'},
|
||||
mock.ANY)
|
||||
mock_setup_ipmi.assert_called_once_with(mock_callback.return_value)
|
||||
self.assertFalse(mock_fork_serve.called)
|
||||
|
||||
def test_setup_ipmi_fails(self, mock_discover, mock_logs, mock_callback,
|
||||
mock_setup_ipmi, mock_fork_serve, mock_parse):
|
||||
mock_setup_ipmi, mock_parse):
|
||||
mock_logs.return_value = 'LOG'
|
||||
mock_callback.return_value = {'ipmi_setup_credentials': True}
|
||||
mock_setup_ipmi.side_effect = RuntimeError('boom')
|
||||
@ -159,4 +134,3 @@ class TestMain(unittest.TestCase):
|
||||
mock_callback.assert_called_once_with(FAKE_ARGS, {'logs': 'LOG'},
|
||||
mock.ANY)
|
||||
mock_setup_ipmi.assert_called_once_with(mock_callback.return_value)
|
||||
mock_fork_serve.assert_called_once_with(FAKE_ARGS)
|
||||
|
Loading…
Reference in New Issue
Block a user