Skip to content

Instantly share code, notes, and snippets.

@mwhahaha
Last active June 4, 2021 21:21
Show Gist options
  • Save mwhahaha/efd54f0e2d4ee3c926274f337b84b5d8 to your computer and use it in GitHub Desktop.
Save mwhahaha/efd54f0e2d4ee3c926274f337b84b5d8 to your computer and use it in GitHub Desktop.
import logging
import sushy
import json
SUSHY_PROTO = 'http'
SUSHY_HOST = 'localhost'
SUSHY_PORT = 8000
SUSHY_BASE = '/redfish/v1'
SUSHY_USER = ""
SUSHY_PASSWORD = ""
SUSHY_URL = f"{SUSHY_PROTO}://{SUSHY_HOST}:{SUSHY_PORT}{SUSHY_BASE}"
# Enable logging at DEBUG level
#LOG = logging.getLogger('sushy')
#LOG.setLevel(logging.DEBUG)
#LOG.addHandler(logging.StreamHandler())
sess = sushy.Sushy(SUSHY_URL)
systems = []
s_systems = sess.get_system_collection()
for inst in s_systems.members_identities:
s_inst = s_systems.get_member(inst)
data = {
'name': s_inst.name,
'mac': [i.mac_address for i in s_inst.ethernet_interfaces.get_members()],
'cpu': s_inst.processors.summary.count,
'memory': (s_inst.memory_summary.size_gib * 1024),
'disk': (s_inst.simple_storage.max_size_bytes // (10 ** 10)),
'pm_addr': f"{SUSHY_PROTO}://{SUSHY_HOST}:{SUSHY_PORT}",
'pm_type': "redfish",
'pm_user': SUSHY_USER,
'pm_password': SUSHY_PASSWORD,
'pm_system_id': s_inst.path
}
systems.append(data)
print(json.dumps(systems, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment