powervm: make start_lpar timeout
This patch makes the start_lpar method timeout like the stop_lpar method. Change-Id: I111ed7ee80f7a9e786d8cb8b02747b5187120858
This commit is contained in:
Matt Riedemann
committed by
Gerrit Code Review
parent
86c97ff020
commit
3fe738afc8
2 changed files with 30 additions and 3 deletions
@@ -1140,10 +1140,31 @@ class IVMOperatorTestCase(test.TestCase):
self.ivm_operator = powervm_operator.IVMOperator(ivm_connection)
def test_start_lpar(self):
instance_name = 'fake'
self.mox.StubOutWithMock(self.ivm_operator, 'run_vios_command')
self.ivm_operator.run_vios_command('chsysstate -r lpar -o on -n fake')
self.ivm_operator.run_vios_command('chsysstate -r lpar -o on -n %s' %
instance_name)
self.mox.StubOutWithMock(self.ivm_operator, 'get_lpar')
lpar1 = fake_lpar(instance_name)
self.ivm_operator.get_lpar(instance_name).AndReturn(lpar1)
self.mox.ReplayAll()
self.ivm_operator.start_lpar('fake')
self.ivm_operator.start_lpar(instance_name)
def test_start_lpar_timeout(self):
instance_name = 'fake'
# mock the remote command call
self.mox.StubOutWithMock(self.ivm_operator, 'run_vios_command')
self.ivm_operator.run_vios_command('chsysstate -r lpar -o on -n %s' %
instance_name)
self.mox.StubOutWithMock(self.ivm_operator, 'get_lpar')
# the lpar is stopped and the timeout is less than the looping call
# interval so we timeout
lpar1 = fake_lpar(instance_name, state=constants.POWERVM_SHUTDOWN)
self.ivm_operator.get_lpar(instance_name).AndReturn(lpar1)
self.mox.ReplayAll()
self.assertRaises(exception.PowerVMLPAROperationTimeout,
self.ivm_operator.start_lpar,
instance_name=instance_name, timeout=0.5)
def test_stop_lpar(self):
instance_name = 'fake'
@@ -553,13 +553,19 @@ class BaseOperator(object):
self.run_vios_command(self.command.mksyscfg('-r lpar -i "%s"' %
conf_data))
def start_lpar(self, instance_name):
def start_lpar(self, instance_name,
timeout=constants.POWERVM_LPAR_OPERATION_TIMEOUT):
"""Start a LPAR instance.
:param instance_name: LPAR instance name
:param timeout: value in seconds for specifying
how long to wait for the LPAR to start
"""
self.run_vios_command(self.command.chsysstate('-r lpar -o on -n %s'
% instance_name))
# poll instance until running or raise exception
self._poll_for_lpar_status(instance_name, constants.POWERVM_RUNNING,
'start_lpar', timeout)
def stop_lpar(self, instance_name,
timeout=constants.POWERVM_LPAR_OPERATION_TIMEOUT):
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.