ansible/stats.py: include vcpu and memory stats

This is achieved by extra node metadata added in:
- https://github.com/status-im/infra-role-bootstrap-linux/commit/63998e7c
- https://github.com/status-im/infra-role-bootstrap-macos/commit/f2dda03c
- https://github.com/status-im/infra-role-bootstrap-windows/commit/99df3934
- https://github.com/status-im/infra-hq/commit/898fa9f5

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-02-23 22:18:53 +01:00
parent e02875274d
commit 527eaed3d4
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
1 changed files with 17 additions and 5 deletions

View File

@ -45,14 +45,26 @@ def main():
dc = dcs.setdefault(node['Datacenter'], [])
fleet = fleets.setdefault(fleet_name, [])
dc.append(node['Node'])
fleet.append(node['Node'])
env.append(node['Node'])
dc.append(node)
fleet.append(node)
env.append(node)
out = {
'total': len(nodes),
'dcs': {dc: len(hosts) for dc, hosts in dcs.items()},
'envs': {env: len(hosts) for env, hosts in envs.items()},
'dcs': {
dc: {
"count": len(hosts),
"vcpus": sum(int(h['Meta'].get('hw_vcpu_count', 0)) for h in hosts),
"memory": sum(int(h['Meta'].get('hw_memory_mb', 0)) for h in hosts),
} for dc, hosts in dcs.items()
},
'envs': {
env: {
"count": len(hosts),
"vcpus": sum(int(h['Meta'].get('hw_vcpu_count', 0)) for h in hosts),
"memory": sum(int(h['Meta'].get('hw_memory_mb', 0)) for h in hosts),
} for env, hosts in envs.items()
},
#'fleets': {fleet: len(hosts) for fleet, hosts in fleets.items()},
}