mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
Included ansible_devices for AIX facts/hardware (#31546)
* Included ansible_devices for AIX
This commit is contained in:
parent
87e82be09f
commit
bcd883ce5e
1 changed files with 33 additions and 0 deletions
|
@ -42,12 +42,14 @@ class AIXHardware(Hardware):
|
||||||
dmi_facts = self.get_dmi_facts()
|
dmi_facts = self.get_dmi_facts()
|
||||||
vgs_facts = self.get_vgs_facts()
|
vgs_facts = self.get_vgs_facts()
|
||||||
mount_facts = self.get_mount_facts()
|
mount_facts = self.get_mount_facts()
|
||||||
|
devices_facts = self.get_device_facts()
|
||||||
|
|
||||||
hardware_facts.update(cpu_facts)
|
hardware_facts.update(cpu_facts)
|
||||||
hardware_facts.update(memory_facts)
|
hardware_facts.update(memory_facts)
|
||||||
hardware_facts.update(dmi_facts)
|
hardware_facts.update(dmi_facts)
|
||||||
hardware_facts.update(vgs_facts)
|
hardware_facts.update(vgs_facts)
|
||||||
hardware_facts.update(mount_facts)
|
hardware_facts.update(mount_facts)
|
||||||
|
hardware_facts.update(devices_facts)
|
||||||
|
|
||||||
return hardware_facts
|
return hardware_facts
|
||||||
|
|
||||||
|
@ -202,6 +204,37 @@ class AIXHardware(Hardware):
|
||||||
'time': '%s %s %s' % (fields[4], fields[5], fields[6])})
|
'time': '%s %s %s' % (fields[4], fields[5], fields[6])})
|
||||||
return mount_facts
|
return mount_facts
|
||||||
|
|
||||||
|
def get_device_facts(self):
|
||||||
|
device_facts = {}
|
||||||
|
device_facts['devices'] = {}
|
||||||
|
|
||||||
|
lsdev_cmd = self.module.get_bin_path('lsdev', True)
|
||||||
|
lsattr_cmd = self.module.get_bin_path('lsattr', True)
|
||||||
|
rc, out_lsdev, err = self.module.run_command(lsdev_cmd)
|
||||||
|
|
||||||
|
for line in out_lsdev.splitlines():
|
||||||
|
field = line.split()
|
||||||
|
|
||||||
|
device_attrs = {}
|
||||||
|
device_name = field[0]
|
||||||
|
device_state = field[1]
|
||||||
|
device_type = field[2:]
|
||||||
|
lsattr_cmd_args = [lsattr_cmd, '-E', '-l', device_name]
|
||||||
|
rc, out_lsattr, err = self.module.run_command(lsattr_cmd_args)
|
||||||
|
for attr in out_lsattr.splitlines():
|
||||||
|
attr_fields = attr.split()
|
||||||
|
attr_name = attr_fields[0]
|
||||||
|
attr_parameter = attr_fields[1]
|
||||||
|
device_attrs[attr_name] = attr_parameter
|
||||||
|
|
||||||
|
device_facts['devices'][device_name] = {
|
||||||
|
'state': device_state,
|
||||||
|
'type': ' '.join(device_type),
|
||||||
|
'attributes': device_attrs
|
||||||
|
}
|
||||||
|
|
||||||
|
return device_facts
|
||||||
|
|
||||||
|
|
||||||
class AIXHardwareCollector(HardwareCollector):
|
class AIXHardwareCollector(HardwareCollector):
|
||||||
_platform = 'AIX'
|
_platform = 'AIX'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue