Follow-up of rescue mode

This addresses the comments in PS29 of
change id Id865d7c9a40e8d85242befb2a0335abe0c52dac7

Change-Id: I7352bedfdf65f5af1bd239476a343104f87965dd
Partial-bug: 1526449
This commit is contained in:
Dao Cong Tien 2018-01-29 15:07:48 +07:00
parent d232bf56f7
commit 487ad98067
4 changed files with 17 additions and 18 deletions

View File

@ -74,7 +74,7 @@ class ProvisionStateBaremetalNode(command.Command):
parsed_args.provision_state,
configdrive=config_drive,
cleansteps=clean_steps,
rescuepassword=rescue_password)
rescue_password=rescue_password)
class ProvisionStateWithWait(ProvisionStateBaremetalNode):
@ -949,7 +949,7 @@ class RescueBaremetalNode(ProvisionStateWithWait):
required=True,
default=None,
help=("The password that will be used to login to the rescue "
"ramdisk. The value should be a string."))
"ramdisk. The value should be a non-empty string."))
return parser

View File

@ -56,7 +56,7 @@ class TestAdopt(TestBaremetal):
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
'node_uuid', 'adopt',
cleansteps=None, configdrive=None, rescuepassword=None)
cleansteps=None, configdrive=None, rescue_password=None)
def test_adopt_no_wait(self):
arglist = ['node_uuid']
@ -1207,7 +1207,7 @@ class TestDeployBaremetalProvisionState(TestBaremetal):
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
'node_uuid', 'active',
cleansteps=None, configdrive='path/to/drive', rescuepassword=None)
cleansteps=None, configdrive='path/to/drive', rescue_password=None)
def test_deploy_no_wait(self):
arglist = ['node_uuid']
@ -1409,7 +1409,7 @@ class TestRescueBaremetalProvisionState(TestBaremetal):
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
'node_uuid', 'rescue', cleansteps=None, configdrive=None,
rescuepassword='supersecret')
rescue_password='supersecret')
def test_rescue_baremetal_provision_state_rescue_and_wait(self):
arglist = ['node_uuid',
@ -1598,7 +1598,7 @@ class TestRebuildBaremetalProvisionState(TestBaremetal):
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
'node_uuid', 'rebuild',
cleansteps=None, configdrive='path/to/drive',
rescuepassword=None)
rescue_password=None)
def test_rebuild_no_wait(self):
arglist = ['node_uuid']
@ -1614,7 +1614,7 @@ class TestRebuildBaremetalProvisionState(TestBaremetal):
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
'node_uuid', 'rebuild',
cleansteps=None, configdrive=None,
rescuepassword=None)
rescue_password=None)
self.baremetal_mock.node.wait_for_provision_state.assert_not_called()
@ -1732,7 +1732,7 @@ class TestUnrescueBaremetalProvisionState(TestBaremetal):
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
'node_uuid', 'unrescue', cleansteps=None, configdrive=None,
rescuepassword=None)
rescue_password=None)
def test_unrescue_baremetal_provision_state_active_and_wait(self):
arglist = ['node_uuid',

View File

@ -1352,12 +1352,12 @@ class NodeManagerTest(testtools.TestCase):
]
self.assertEqual(expect, self.api.calls)
def test_node_set_provision_state_with_rescuepassword(self):
rescuepassword = 'supersecret'
def test_node_set_provision_state_with_rescue_password(self):
rescue_password = 'supersecret'
target_state = 'rescue'
self.mgr.set_provision_state(NODE1['uuid'], target_state,
rescuepassword=rescuepassword)
body = {'target': target_state, 'rescue_password': rescuepassword}
rescue_password=rescue_password)
body = {'target': target_state, 'rescue_password': rescue_password}
expect = [
('PUT', '/v1/nodes/%s/states/provision' % NODE1['uuid'], {}, body),
]

View File

@ -478,7 +478,7 @@ class NodeManager(base.CreateManager):
return self.get(path)
def set_provision_state(self, node_uuid, state, configdrive=None,
cleansteps=None, rescuepassword=None):
cleansteps=None, rescue_password=None):
"""Set the provision state for the node.
:param node_uuid: The UUID or name of the node.
@ -494,10 +494,9 @@ class NodeManager(base.CreateManager):
dictionaries; each dictionary should have keys 'interface' and
'step', and optional key 'args'. This must be specified (and is
only valid) when setting provision-state to 'clean'.
:param rescuepassword: A string to be used as the login password
:param rescue_password: A string to be used as the login password
inside the rescue ramdisk once a node is rescued. This must be
specified (and is only valid) when setting provision-state to
'rescue'.
specified (and is only valid) when setting 'state' to 'rescue'.
:raises: InvalidAttribute if there was an error with the clean steps
:returns: The status of the request
"""
@ -514,8 +513,8 @@ class NodeManager(base.CreateManager):
body['configdrive'] = configdrive
elif cleansteps:
body['clean_steps'] = cleansteps
elif rescuepassword:
body['rescue_password'] = rescuepassword
elif rescue_password:
body['rescue_password'] = rescue_password
return self.update(path, body, http_method='PUT')