Remove wait_for_provision_state, a unused utility function
Change-Id: I7487d32305be36971e5f79e587f8c5c212b0feb8
This commit is contained in:
parent
48ed65c205
commit
90be7d7a9b
@ -565,46 +565,6 @@ class TestWaitForStackUtil(TestCase):
|
||||
result = utils.wait_for_stack_ready(self.mock_orchestration, 'stack')
|
||||
self.assertEqual(False, result)
|
||||
|
||||
def test_wait_for_provision_state(self):
|
||||
|
||||
baremetal_client = mock.Mock()
|
||||
|
||||
baremetal_client.node.get.return_value = mock.Mock(
|
||||
provision_state="available", last_error=None)
|
||||
|
||||
utils.wait_for_provision_state(baremetal_client, 'UUID', "available")
|
||||
|
||||
def test_wait_for_provision_state_not_found(self):
|
||||
|
||||
baremetal_client = mock.Mock()
|
||||
|
||||
baremetal_client.node.get.return_value = None
|
||||
|
||||
utils.wait_for_provision_state(baremetal_client, 'UUID', "available")
|
||||
|
||||
def test_wait_for_provision_state_timeout(self):
|
||||
|
||||
baremetal_client = mock.Mock()
|
||||
|
||||
baremetal_client.node.get.return_value = mock.Mock(
|
||||
provision_state="not what we want", last_error=None)
|
||||
|
||||
with self.assertRaises(exceptions.Timeout):
|
||||
utils.wait_for_provision_state(baremetal_client, 'UUID',
|
||||
"available", loops=1, sleep=0.01)
|
||||
|
||||
def test_wait_for_provision_state_fail(self):
|
||||
|
||||
baremetal_client = mock.Mock()
|
||||
|
||||
baremetal_client.node.get.return_value = mock.Mock(
|
||||
provision_state="enroll",
|
||||
last_error="node on fire; returning to previous state.")
|
||||
|
||||
with self.assertRaises(exceptions.StateTransitionFailed):
|
||||
utils.wait_for_provision_state(baremetal_client, 'UUID',
|
||||
"available", loops=1, sleep=0.01)
|
||||
|
||||
def test_check_stack_network_matches_env_files(self):
|
||||
stack_reg = {
|
||||
'OS::TripleO::Hosts::SoftwareConfig': 'val',
|
||||
|
@ -1238,13 +1238,11 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertRaises(exceptions.StackInProgress,
|
||||
self.cmd.take_action, parsed_args)
|
||||
|
||||
@mock.patch('tripleoclient.utils.wait_for_provision_state')
|
||||
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates_tmpdir', autospec=True)
|
||||
def test_deployed_server(self, mock_deploy_tmpdir, mock_overcloudrc,
|
||||
mock_provision):
|
||||
def test_deployed_server(self, mock_deploy_tmpdir, mock_overcloudrc):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
self.useFixture(fixture)
|
||||
utils_fixture = deployment.UtilsOvercloudFixture()
|
||||
@ -1264,7 +1262,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.assertTrue(mock_deploy_tmpdir.called)
|
||||
self.assertNotCalled(mock_provision)
|
||||
self.assertNotCalled(clients.baremetal)
|
||||
self.assertNotCalled(clients.compute)
|
||||
self.assertTrue(utils_fixture.mock_deploy_tht.called)
|
||||
|
@ -552,66 +552,6 @@ def wait_for_stack_ready(orchestration_client, stack_name, marker=None,
|
||||
"wait_for_stack_ready: Max retries {} reached".format(max_retries))
|
||||
|
||||
|
||||
def wait_for_provision_state(baremetal_client, node_uuid, provision_state,
|
||||
loops=10, sleep=1):
|
||||
"""Wait for a given Provisioning state in Ironic
|
||||
|
||||
Updating the provisioning state is an async operation, we
|
||||
need to wait for it to be completed.
|
||||
|
||||
:param baremetal_client: Instance of Ironic client
|
||||
:type baremetal_client: ironicclient.v1.client.Client
|
||||
|
||||
:param node_uuid: The Ironic node UUID
|
||||
:type node_uuid: str
|
||||
|
||||
:param provision_state: The provisioning state name to wait for
|
||||
:type provision_state: str
|
||||
|
||||
:param loops: How many times to loop
|
||||
:type loops: int
|
||||
|
||||
:param sleep: How long to sleep between loops
|
||||
:type sleep: int
|
||||
|
||||
:raises exceptions.StateTransitionFailed: if node.last_error is set
|
||||
"""
|
||||
|
||||
for _l in range(0, loops):
|
||||
|
||||
node = baremetal_client.node.get(node_uuid)
|
||||
|
||||
if node is None:
|
||||
# The node can't be found in ironic, so we don't need to wait for
|
||||
# the provision state
|
||||
return
|
||||
if node.provision_state == provision_state:
|
||||
return
|
||||
|
||||
# node.last_error should be None after any successful operation
|
||||
if node.last_error:
|
||||
raise exceptions.StateTransitionFailed(_(
|
||||
"Error transitioning node %(uuid)s to provision state "
|
||||
"%(state)s: %(error)s. Now in state %(actual)s.") % {
|
||||
'uuid': node_uuid,
|
||||
'state': provision_state,
|
||||
'error': node.last_error,
|
||||
'actual': node.provision_state
|
||||
}
|
||||
)
|
||||
|
||||
time.sleep(sleep)
|
||||
|
||||
raise exceptions.Timeout(_(
|
||||
"Node %(uuid)s did not reach provision state %(state)s. "
|
||||
"Now in state %(actual)s.") % {
|
||||
'uuid': node_uuid,
|
||||
'state': provision_state,
|
||||
'actual': node.provision_state
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def get_stack_output_item(stack, item):
|
||||
if not stack:
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user