From 494e6af9f2729021faaeb43c91e644d5197414a7 Mon Sep 17 00:00:00 2001 From: Juliana Motira Date: Wed, 9 Sep 2015 15:47:00 -0300 Subject: [PATCH] Add custom OEM domain name command for Lenovo ThinkServers Change-Id: Ied2e330badfdb0168fc359685684316f25aacf2d --- pyghmi/ipmi/command.py | 14 ++++++++++++++ pyghmi/ipmi/oem/generic.py | 12 ++++++++++++ pyghmi/ipmi/oem/lenovo/handler.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 32069e15..5991c441 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1636,3 +1636,17 @@ class Command(object): """ self.oem_init() return self._oem.get_oem_remote_kvm_available() + + def get_domain_name(self): + """Get Domain name + """ + self.oem_init() + return self._oem.get_oem_domain_name() + + def set_domain_name(self, name): + """Set Domain name + + :param name: domain name to be set + """ + self.oem_init() + self._oem.set_oem_domain_name(name) diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 9c6c2277..cb056ae5 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -177,3 +177,15 @@ class OEMHandler(object): """Get remote KVM availability """ return False + + def get_oem_domain_name(self): + """Get Domain name + """ + return () + + def set_oem_domain_name(self, name): + """Set Domain name + + :param name: domain name to be set + """ + return () diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index d7e0f3a1..1f305726 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -361,3 +361,33 @@ class OEMHandler(generic.OEMHandler): rsp = self.ipmicmd.raw_command(netfn=0x3a, command=0x13) return rsp['data'][0] == 0 return False + + def _restart_dns(self): + if self.has_tsm: + self.ipmicmd.xraw_command(netfn=0x32, command=0x6c, data=(7, 0)) + + def get_oem_domain_name(self): + if self.has_tsm: + name = '' + for i in range(1, 5): + rsp = self.ipmicmd.xraw_command(netfn=0x32, command=0x6b, + data=(4, i)) + name += rsp['data'][:] + return name.rstrip('\x00') + + def set_oem_domain_name(self, name): + if self.has_tsm: + # set the domain name length + data = [3, 0, 0, 0, 0, len(name)] + self.ipmicmd.xraw_command(netfn=0x32, command=0x6c, data=data) + + # set the domain name content + name = name.ljust(256, "\x00") + for i in range(0, 4): + data = [4, i+1] + offset = i*64 + data.extend([ord(x) for x in name[offset:offset+64]]) + self.ipmicmd.xraw_command(netfn=0x32, command=0x6c, data=data) + + self._restart_dns() + return