Skip to content

Commit

Permalink
Fixed that partitions in paused status could not be stopped
Browse files Browse the repository at this point in the history
Details:

* Fixed issue that partitions in 'paused' status could not be stopped. As part
  of that, redesigned the start_partition(), stop_partition() and
  wait_for_transition_completion() methods to use a simple state machine. This
  will cause any bad statuses that happen on the way to be raised as
  exceptions (they were previously returned). (issue #642)

* Skipped function test cases that start or stop the partition, because
  the zhmcclient mock support does not support async partition start/stop.

* Added end2end testcases in test_zhmc_partition_state() for status
  'paused'.

* Changed type of mocked test partition in function testcases in
  test_func_partition.py from linux to ssc because that allows
  getting the partition into status 'active' instead of 'paused'.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Oct 5, 2023
1 parent b003f57 commit 4ca20ab
Show file tree
Hide file tree
Showing 8 changed files with 555 additions and 182 deletions.
6 changes: 6 additions & 0 deletions docs/source/release_notes.rst
Expand Up @@ -67,6 +67,12 @@ Availability: `AutomationHub`_, `Galaxy`_, `GitHub`_
and 'boot_storage_group_name' input properties to the name of the boot volume
and its storage group, respectively. (issue #640)

* zhmc_partition: Fixed issue that partitions in 'paused' status could not be
stopped. As part of that, redesigned the start_partition(), stop_partition()
and wait_for_transition_completion() methods to use a simple state machine.
This will cause any bad statuses that happen on the way to be raised as
exceptions (they were previously returned). (issue #642)

**Enhancements:**

* Increased minimum version of zhmcclient to 1.11.2 to pick up improved mock
Expand Down
431 changes: 286 additions & 145 deletions plugins/module_utils/common.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/modules/zhmc_hba.py
Expand Up @@ -503,7 +503,7 @@ def ensure_present(params, check_mode):
if stop:
raise AssertionError()

wait_for_transition_completion(partition)
wait_for_transition_completion(LOGGER, partition)
hba.update_properties(update_props)
# We refresh the properties after the update, in case an
# input property value gets changed (for example, the
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zhmc_nic.py
Expand Up @@ -593,7 +593,7 @@ def ensure_present(params, check_mode):
# active, therefore:
if stop:
raise AssertionError()
wait_for_transition_completion(partition)
wait_for_transition_completion(LOGGER, partition)
nic.update_properties(update_props)
# We refresh the properties after the update, in case an
# input property value gets changed (for example, the
Expand Down
10 changes: 5 additions & 5 deletions plugins/modules/zhmc_partition.py
Expand Up @@ -1749,9 +1749,9 @@ def ensure_active(params, check_mode):
if update_props:
if not check_mode:
if stop:
stop_partition(partition, check_mode)
stop_partition(LOGGER, partition, check_mode)
else:
wait_for_transition_completion(partition)
wait_for_transition_completion(LOGGER, partition)
partition.update_properties(update_props)
# Properties are refreshed further down
else:
Expand All @@ -1765,7 +1765,7 @@ def ensure_active(params, check_mode):
if not partition:
raise AssertionError()

changed |= start_partition(partition, check_mode)
changed |= start_partition(LOGGER, partition, check_mode)

if not check_mode:

Expand Down Expand Up @@ -1848,7 +1848,7 @@ def ensure_stopped(params, check_mode):
process_properties(cpc, partition, params)
# Note: create_props in this case only contains 'name' and can be
# ignored.
changed |= stop_partition(partition, check_mode)
changed |= stop_partition(LOGGER, partition, check_mode)
if update_props:
if not check_mode:
partition.update_properties(update_props)
Expand Down Expand Up @@ -1914,7 +1914,7 @@ def ensure_absent(params, check_mode):
return changed, result

if not check_mode:
stop_partition(partition, check_mode)
stop_partition(LOGGER, partition, check_mode)
partition.delete()
changed = True

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zhmc_virtual_function.py
Expand Up @@ -480,7 +480,7 @@ def ensure_present(params, check_mode):
# partition is active, therefore:
if stop:
raise AssertionError()
wait_for_transition_completion(partition)
wait_for_transition_completion(LOGGER, partition)
vfunction.update_properties(update_props)
# We refresh the properties after the update, in case an
# input property value gets changed (for example, the
Expand Down

0 comments on commit 4ca20ab

Please sign in to comment.