Merge "Skip warning when changing target_raid_config" into stable/pike

This commit is contained in:
Jenkins 2017-09-05 21:10:04 +00:00 committed by Gerrit Code Review
commit 92107cf50e
3 changed files with 19 additions and 2 deletions

View File

@ -1153,7 +1153,7 @@ class SetBaremetalNode(command.Command):
in parsed_args.instance_info]))
if properties:
baremetal_client.node.update(parsed_args.node, properties)
else:
elif not parsed_args.target_raid_config:
self.log.warning("Please specify what to set.")
@ -1444,7 +1444,7 @@ class UnsetBaremetalNode(command.Command):
['vendor_interface']))
if properties:
baremetal_client.node.update(parsed_args.node, properties)
else:
elif not parsed_args.target_raid_config:
self.log.warning("Please specify what to unset.")

View File

@ -1948,6 +1948,7 @@ class TestBaremetalSet(TestBaremetal):
@mock.patch.object(commonutils, 'get_from_stdin', autospec=True)
@mock.patch.object(commonutils, 'handle_json_or_file_arg', autospec=True)
def test_baremetal_set_target_raid_config(self, mock_handle, mock_stdin):
self.cmd.log = mock.Mock(autospec=True)
target_raid_config_string = '{"raid": "config"}'
expected_target_raid_config = {'raid': 'config'}
mock_handle.return_value = expected_target_raid_config.copy()
@ -1960,6 +1961,7 @@ class TestBaremetalSet(TestBaremetal):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.cmd.log.warning.assert_not_called()
self.assertFalse(mock_stdin.called)
mock_handle.assert_called_once_with(target_raid_config_string)
self.baremetal_mock.node.set_target_raid_config.\
@ -1970,6 +1972,7 @@ class TestBaremetalSet(TestBaremetal):
@mock.patch.object(commonutils, 'handle_json_or_file_arg', autospec=True)
def test_baremetal_set_target_raid_config_and_name(
self, mock_handle, mock_stdin):
self.cmd.log = mock.Mock(autospec=True)
target_raid_config_string = '{"raid": "config"}'
expected_target_raid_config = {'raid': 'config'}
mock_handle.return_value = expected_target_raid_config.copy()
@ -1984,6 +1987,7 @@ class TestBaremetalSet(TestBaremetal):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.cmd.log.warning.assert_not_called()
self.assertFalse(mock_stdin.called)
mock_handle.assert_called_once_with(target_raid_config_string)
self.baremetal_mock.node.set_target_raid_config.\
@ -1996,6 +2000,7 @@ class TestBaremetalSet(TestBaremetal):
@mock.patch.object(commonutils, 'handle_json_or_file_arg', autospec=True)
def test_baremetal_set_target_raid_config_stdin(self, mock_handle,
mock_stdin):
self.cmd.log = mock.Mock(autospec=True)
target_value = '-'
target_raid_config_string = '{"raid": "config"}'
expected_target_raid_config = {'raid': 'config'}
@ -2010,6 +2015,7 @@ class TestBaremetalSet(TestBaremetal):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.cmd.log.warning.assert_not_called()
mock_stdin.assert_called_once_with('target_raid_config')
mock_handle.assert_called_once_with(target_raid_config_string)
self.baremetal_mock.node.set_target_raid_config.\
@ -2020,6 +2026,7 @@ class TestBaremetalSet(TestBaremetal):
@mock.patch.object(commonutils, 'handle_json_or_file_arg', autospec=True)
def test_baremetal_set_target_raid_config_stdin_exception(
self, mock_handle, mock_stdin):
self.cmd.log = mock.Mock(autospec=True)
target_value = '-'
mock_stdin.side_effect = exc.InvalidAttribute('bad')
@ -2032,6 +2039,7 @@ class TestBaremetalSet(TestBaremetal):
self.assertRaises(exc.InvalidAttribute,
self.cmd.take_action, parsed_args)
self.cmd.log.warning.assert_not_called()
mock_stdin.assert_called_once_with('target_raid_config')
self.assertFalse(mock_handle.called)
self.assertFalse(
@ -2367,6 +2375,7 @@ class TestBaremetalUnset(TestBaremetal):
)
def test_baremetal_unset_target_raid_config(self):
self.cmd.log = mock.Mock(autospec=True)
arglist = [
'node_uuid',
'--target-raid-config',
@ -2380,11 +2389,13 @@ class TestBaremetalUnset(TestBaremetal):
self.cmd.take_action(parsed_args)
self.cmd.log.warning.assert_not_called()
self.assertFalse(self.baremetal_mock.node.update.called)
self.baremetal_mock.node.set_target_raid_config.\
assert_called_once_with('node_uuid', {})
def test_baremetal_unset_target_raid_config_and_name(self):
self.cmd.log = mock.Mock(autospec=True)
arglist = [
'node_uuid',
'--name',
@ -2400,6 +2411,7 @@ class TestBaremetalUnset(TestBaremetal):
self.cmd.take_action(parsed_args)
self.cmd.log.warning.assert_not_called()
self.baremetal_mock.node.set_target_raid_config.\
assert_called_once_with('node_uuid', {})
self.baremetal_mock.node.update.assert_called_once_with(

View File

@ -0,0 +1,5 @@
---
fixes:
- No longer emits the incorrect warning "Please specify what to set/unset"
when only the --target-raid-config is specified in the
``openstack baremetal node set/unset`` command.