mirror of
https://opendev.org/x/pyghmi
synced 2025-02-05 13:32:48 +00:00
Add DNS configuration of TSMA
This exposes DNS configuration as 'bmc configuration', which is in line with how they manifest in XCC. Change-Id: If8cc3ffd76dd1f245c177032ceb1483892952873
This commit is contained in:
parent
d99e29cd57
commit
e44f309d93
@ -995,6 +995,8 @@ class OEMHandler(generic.OEMHandler):
|
||||
return self.immhandler.get_bmc_configuration()
|
||||
if self.is_fpc:
|
||||
return self.smmhandler.get_bmc_configuration()
|
||||
if self.has_tsma:
|
||||
return self.tsmahandler.get_bmc_configuration()
|
||||
return super(OEMHandler, self).get_bmc_configuration()
|
||||
|
||||
def set_bmc_configuration(self, changeset):
|
||||
@ -1003,6 +1005,9 @@ class OEMHandler(generic.OEMHandler):
|
||||
if self.is_fpc:
|
||||
return self.smmhandler.set_bmc_configuration(
|
||||
changeset, self._fpc_variant)
|
||||
if self.has_tsma:
|
||||
return self.tsmahandler.set_bmc_configuration(
|
||||
changeset)
|
||||
return super(OEMHandler, self).set_bmc_configuration(changeset)
|
||||
|
||||
def get_system_configuration(self, hideadvanced):
|
||||
|
@ -19,6 +19,8 @@ try:
|
||||
except ImportError:
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import six
|
||||
|
||||
import pyghmi.exceptions as exc
|
||||
import pyghmi.media as media
|
||||
import pyghmi.redfish.oem.generic as generic
|
||||
@ -90,6 +92,64 @@ class TsmHandler(generic.OEMHandler):
|
||||
self.tsm = webclient.thehost
|
||||
self._certverify = webclient._certverify
|
||||
|
||||
def get_bmc_configuration(self):
|
||||
wc = self.wc
|
||||
rsp, status = wc.grab_json_response_with_status(
|
||||
'/api/settings/dns-info')
|
||||
if status != 200:
|
||||
raise Exception(repr(rsp))
|
||||
settings = {}
|
||||
settings['dns_domain'] = {
|
||||
'value': rsp['domain_name']
|
||||
}
|
||||
dnssrvs = []
|
||||
for idx in range(3):
|
||||
currsrv = rsp.get('dns_server{0}'.format(idx + 1), '::')
|
||||
if currsrv and currsrv != '::':
|
||||
dnssrvs.append(currsrv)
|
||||
settings['dns_servers'] = {'value': ','.join(dnssrvs)}
|
||||
return settings
|
||||
|
||||
def set_bmc_configuration(self, changeset):
|
||||
dnschgs = {}
|
||||
for key in changeset:
|
||||
if isinstance(changeset[key], six.string_types):
|
||||
changeset[key] = {'value': changeset[key]}
|
||||
currval = changeset[key].get('value', None)
|
||||
if 'dns_servers'.startswith(key.lower()):
|
||||
srvs = currval.split(',')
|
||||
for idx in range(3):
|
||||
if idx < len(srvs):
|
||||
dnschgs['dns_server{0}'.format(idx + 1)] = srvs[idx]
|
||||
else:
|
||||
dnschgs['dns_server{0}'.format(idx + 1)] = ''
|
||||
if 'dns_domain'.startswith(key.lower()):
|
||||
dnschgs['domain_name'] = currval
|
||||
if dnschgs:
|
||||
self._set_dns_config(dnschgs)
|
||||
|
||||
def _set_dns_config(self, dnschgs):
|
||||
wc = self.wc
|
||||
rsp, status = wc.grab_json_response_with_status(
|
||||
'/api/settings/dns-info')
|
||||
if status != 200:
|
||||
raise Exception(repr(rsp))
|
||||
rsp['domain_manual'] = 1
|
||||
for i in range(3):
|
||||
keyn = 'dns_server{0}'.format(i + 1)
|
||||
if rsp[keyn] == '::':
|
||||
rsp[keyn] = ''
|
||||
for chg in dnschgs:
|
||||
rsp[chg] = dnschgs[chg]
|
||||
rsp, status = wc.grab_json_response_with_status(
|
||||
'/api/settings/dns-info', rsp, method='PUT')
|
||||
if status != 200:
|
||||
raise Exception(repr(rsp))
|
||||
rsp, status = wc.grab_json_response_with_status(
|
||||
'/api/settings/dns/restart', {'dns_status': 1}, method='PUT')
|
||||
if status != 200:
|
||||
raise Exception(repr(rsp))
|
||||
|
||||
def clear_uefi_configuration(self):
|
||||
if not self.fishclient:
|
||||
self.init_redfish()
|
||||
|
Loading…
x
Reference in New Issue
Block a user