diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-10-09 22:21:50 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-10-09 22:21:50 +0000 |
| commit | fcb5c1623164983e331a148903e23f45168d3e9a (patch) | |
| tree | e38aace030eed20d3274b1314a421d0a97cc04d8 | |
| parent | 7b618f2bf5e39c22dd60d3c3977f9b7137890493 (diff) | |
| parent | be6152f89b99a0edc4390a4d10f27575265a0d13 (diff) | |
| download | nova-fcb5c1623164983e331a148903e23f45168d3e9a.tar.gz nova-fcb5c1623164983e331a148903e23f45168d3e9a.tar.xz nova-fcb5c1623164983e331a148903e23f45168d3e9a.zip | |
Merge "powervm: add polling timeout for LPAR stop command"
| -rw-r--r-- | nova/virt/powervm/exception.py | 5 | ||||
| -rw-r--r-- | nova/virt/powervm/operator.py | 29 |
2 files changed, 28 insertions, 6 deletions
diff --git a/nova/virt/powervm/exception.py b/nova/virt/powervm/exception.py index be476109c..2a8cf4771 100644 --- a/nova/virt/powervm/exception.py +++ b/nova/virt/powervm/exception.py @@ -41,6 +41,11 @@ class PowerVMLPARAttributeNotFound(exception.NovaException): pass +class PowerVMLPAROperationTimeout(exception.NovaException): + message = _("Operation '%(operation)s' on " + "LPAR '%(instance_name)s' timed out") + + class PowerVMImageCreationFailed(exception.NovaException): message = _("Image creation failed on PowerVM") diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py index 7c7478b99..bc0986ca4 100644 --- a/nova/virt/powervm/operator.py +++ b/nova/virt/powervm/operator.py @@ -295,11 +295,11 @@ class PowerVMOperator(object): raise exception.PowerVMLPARInstanceCleanupFailed( instance_name=instance_name) - def power_off(self, instance_name): - self._operator.stop(instance_name) + def power_off(self, instance_name, timeout=30): + self._operator.stop_lpar(instance_name, timeout) def power_on(self, instance_name): - self._operator.start(instance_name) + self._operator.start_lpar(instance_name) class BaseOperator(object): @@ -360,15 +360,32 @@ class BaseOperator(object): self.run_command(self.command.chsysstate('-r lpar -o on -n %s' % instance_name)) - def stop_lpar(self, instance_name): + def stop_lpar(self, instance_name, timeout=30): """Stop a running LPAR. :param instance_name: LPAR instance name + :param timeout: value in seconds for specifying + how long to wait for the LPAR to stop """ - cmd = self.command.chsysstate('-r lpar -o shutdown --immed -n %s' - % instance_name) + cmd = self.command.chsysstate('-r lpar -o shutdown --immed -n %s' % + instance_name) self.run_command(cmd) + # poll instance until stopped or raise exception + lpar_obj = self.get_lpar(instance_name) + wait_inc = 1 # seconds to wait between status polling + start_time = time.time() + while lpar_obj['state'] != 'Not Activated': + curr_time = time.time() + # wait up to (timeout) seconds for shutdown + if (curr_time - start_time) > timeout: + raise exception.PowerVMLPAROperationTimeout( + operation='stop_lpar', + instance_name=instance_name) + + time.sleep(wait_inc) + lpar_obj = self.get_lpar(instance_name) + def remove_lpar(self, instance_name): """Removes a LPAR. |
