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)
* 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>
This commit is contained in:
parent
43fe26d83c
commit
9ccce82113
2 changed files with 16 additions and 0 deletions
3
changelogs/fragments/3079-report-power-state-hpilo.yaml
Normal file
3
changelogs/fragments/3079-report-power-state-hpilo.yaml
Normal 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).
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue