mirror of
https://opendev.org/x/pyghmi
synced 2025-01-28 11:57:34 +00:00
Add custom OEM domain name command for Lenovo ThinkServers
Change-Id: Ied2e330badfdb0168fc359685684316f25aacf2d
This commit is contained in:
parent
2b8aa23676
commit
494e6af9f2
@ -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)
|
||||
|
@ -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 ()
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user