1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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 <git@yvanwatchman.eu>
(cherry picked from commit 9ccce82113)

Co-authored-by: Yvan Watchman <ik@yvanwatchman.eu>
This commit is contained in:
patchback[bot] 2021-07-31 09:38:18 +02:00 committed by GitHub
parent bdafa31851
commit e16bd2d015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -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).

View file

@ -113,6 +113,15 @@ hw_uuid:
returned: always returned: always
type: str type: str
sample: 123456ABC78901D2 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 import re
@ -177,6 +186,7 @@ def main():
# TODO: Count number of CPUs, DIMMs and total memory # TODO: Count number of CPUs, DIMMs and total memory
try: try:
data = ilo.get_host_data() data = ilo.get_host_data()
power_state = ilo.get_host_power_status()
except hpilo.IloCommunicationError as e: except hpilo.IloCommunicationError as e:
module.fail_json(msg=to_native(e)) module.fail_json(msg=to_native(e))
@ -243,6 +253,9 @@ def main():
# reformat into a text friendly format # reformat into a text friendly format
info['hw_memory_total'] = "{0} GB".format(info['hw_memory_total']) 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) module.exit_json(**info)