mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-22 08:59:08 -07:00
Fixes solaris (sunos) uptime in ansible facts module (#54626)
* correct uptime on solaris by using system boot_time instead of snaptime * add unit test
This commit is contained in:
parent
91a664a93e
commit
b28c73af62
3 changed files with 24 additions and 8 deletions
|
@ -0,0 +1,16 @@
|
|||
import time
|
||||
from ansible.module_utils.facts.hardware import sunos
|
||||
|
||||
|
||||
def test_sunos_get_uptime_facts(mocker):
|
||||
kstat_output = '\nunix:0:system_misc:boot_time\t1548249689\n'
|
||||
|
||||
module_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule')
|
||||
module = module_mock()
|
||||
module.run_command.return_value = (0, kstat_output, '')
|
||||
|
||||
inst = sunos.SunOSHardware(module)
|
||||
|
||||
expected = int(time.time()) - 1548249689
|
||||
result = inst.get_uptime_facts()
|
||||
assert expected == result['uptime_seconds']
|
Loading…
Add table
Add a link
Reference in a new issue