From 5f42788179f4229073b8302a5b9c42f522710504 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 4 Sep 2015 15:30:48 -0400 Subject: [PATCH] Implement get/set of DCMI asset tag and MCI DCMI provides standard commands for accessing/setting asset tag and BMC identifier. Provide access to those facilities Change-Id: If3f99d308e5b37ff3e99f19fd804f00a74bbb561 --- pyghmi/ipmi/command.py | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index a2e217da..8402c467 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -945,6 +945,56 @@ class Command(object): if not ip == '0.0.0.0': self._assure_alert_policy(channel, destination) + def get_mci(self): + """Get the Management Controller Identifier, per DCMI specification + + :returns: The identifier as a string + """ + return self._chunkwise_dcmi_fetch(9) + + def set_mci(self, mci): + """Set the management controller identifier, per DCMI specification + + """ + return self._chunkwise_dcmi_set(0xa, mci + '\x00') + + def get_asset_tag(self): + """Get the system asset tag, per DCMI specification + + :returns: The asset tag + """ + return self._chunkwise_dcmi_fetch(6) + + def set_asset_tag(self, tag): + """Set the asset tag value + + """ + return self._chunkwise_dcmi_set(8, tag) + + def _chunkwise_dcmi_fetch(self, command): + szdata = self.xraw_command( + netfn=0x2c, command=command, data=(0xdc, 0, 0)) + totalsize = ord(szdata['data'][1]) + chksize = 0xf + offset = 0 + retstr = '' + while offset < totalsize: + if (offset + chksize) > totalsize: + chksize = totalsize - offset + chk = self.xraw_command( + netfn=0x2c, command=command, data=(0xdc, offset, chksize)) + retstr += chk['data'][2:] + offset += chksize + return retstr + + def _chunkwise_dcmi_set(self, command, data): + chunks = [data[i:i+15] for i in xrange(0, len(data), 15)] + offset = 0 + for chunk in chunks: + cmddata = bytearray((0xdc, offset, len(chunk))) + cmddata += chunk + self.xraw_command(netfn=0x2c, command=command, data=cmddata) + def set_channel_access(self, channel=None, access_update_mode='non_volatile', alerting=False, per_msg_auth=False,