From e16bd2d0150795230c239985c9f80cf073e70f01 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 31 Jul 2021 09:38:18 +0200 Subject: [PATCH] Feature: implement hpilo_info system power info (#3079) (#3121) * report power state of host * Modify sample information * add changelog fragment * apply feedback from github community * apply feedback Co-authored-by: Yvan E. Watchman (cherry picked from commit 9ccce821136789d4786038a57c565d97a7e21e22) Co-authored-by: Yvan Watchman --- .../fragments/3079-report-power-state-hpilo.yaml | 3 +++ .../modules/remote_management/hpilo/hpilo_info.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 changelogs/fragments/3079-report-power-state-hpilo.yaml diff --git a/changelogs/fragments/3079-report-power-state-hpilo.yaml b/changelogs/fragments/3079-report-power-state-hpilo.yaml new file mode 100644 index 0000000000..e057e3395f --- /dev/null +++ b/changelogs/fragments/3079-report-power-state-hpilo.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - hpilo_info - added ``host_power_status`` return value to report power state of machine with ``OFF``, ``ON`` or ``UNKNOWN`` (https://github.com/ansible-collections/community.general/pull/3079). diff --git a/plugins/modules/remote_management/hpilo/hpilo_info.py b/plugins/modules/remote_management/hpilo/hpilo_info.py index f373b58639..2b6c30abd6 100644 --- a/plugins/modules/remote_management/hpilo/hpilo_info.py +++ b/plugins/modules/remote_management/hpilo/hpilo_info.py @@ -113,6 +113,15 @@ hw_uuid: returned: always type: str sample: 123456ABC78901D2 + +host_power_status: + description: + - Power status of host. + - Will be one of C(ON), C(OFF) and C(UNKNOWN). + returned: always + type: str + sample: ON + version_added: 3.5.0 ''' import re @@ -177,6 +186,7 @@ def main(): # TODO: Count number of CPUs, DIMMs and total memory try: data = ilo.get_host_data() + power_state = ilo.get_host_power_status() except hpilo.IloCommunicationError as e: module.fail_json(msg=to_native(e)) @@ -243,6 +253,9 @@ def main(): # reformat into a text friendly format info['hw_memory_total'] = "{0} GB".format(info['hw_memory_total']) + # Report host state + info['host_power_status'] = power_state or 'UNKNOWN' + module.exit_json(**info)