mirror of
https://opendev.org/x/pyghmi
synced 2025-02-13 17:19:02 +00:00
Add standard NTP handling to redfish
Map the IPMI API to redfish behavior for generic redfish manipulation. Also, have the SMM3 handler explicitly indicate that system config does not apply. Change-Id: I1bbb16507b6e76bb460217c63d326c8e45155d89
This commit is contained in:
parent
7482692cdd
commit
8666417d61
@ -1,5 +1,5 @@
|
||||
# coding: utf8
|
||||
# Copyright 2021 Lenovo
|
||||
# Copyright 2025 Lenovo
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -892,6 +892,54 @@ class Command(object):
|
||||
def set_system_configuration(self, changeset):
|
||||
return self.oem.set_system_configuration(changeset, self)
|
||||
|
||||
def get_ntp_enabled(self):
|
||||
bmcinfo = self._do_web_request(self._bmcurl)
|
||||
netprotocols = bmcinfo.get('NetworkProtocol', {}).get('@odata.id', None)
|
||||
if netprotocols:
|
||||
netprotoinfo = self._do_web_request(netprotocols)
|
||||
enabled = netprotoinfo.get('NTP', {}).get('ProtocolEnabled', False)
|
||||
return enabled
|
||||
return False
|
||||
|
||||
def set_ntp_enabled(self, enable):
|
||||
bmcinfo = self._do_web_request(self._bmcurl)
|
||||
netprotocols = bmcinfo.get('NetworkProtocol', {}).get('@odata.id', None)
|
||||
if netprotocols:
|
||||
request = {'NTP':{'ProtocolEnabled': enable}}
|
||||
self._do_web_request(netprotocols, request, method='PATCH')
|
||||
self._do_web_request(netprotocols, cache=0)
|
||||
|
||||
def get_ntp_servers(self):
|
||||
bmcinfo = self._do_web_request(self._bmcurl)
|
||||
netprotocols = bmcinfo.get('NetworkProtocol', {}).get('@odata.id', None)
|
||||
if not netprotocols:
|
||||
return []
|
||||
netprotoinfo = self._do_web_request(netprotocols)
|
||||
return netprotoinfo.get('NTP', {}).get('NTPServers', [])
|
||||
|
||||
def set_ntp_server(self, server, index=None):
|
||||
bmcinfo = self._do_web_request(self._bmcurl)
|
||||
netprotocols = bmcinfo.get('NetworkProtocol', {}).get('@odata.id', None)
|
||||
currntpservers = self.get_ntp_servers()
|
||||
if index is None:
|
||||
if server in currntpservers:
|
||||
return
|
||||
currntpservers = [server] + currntpservers
|
||||
else:
|
||||
if (index + 1) > len(currntpservers):
|
||||
if not server:
|
||||
return
|
||||
currntpservers.append(server)
|
||||
else:
|
||||
if not server:
|
||||
del currntpservers[index]
|
||||
else:
|
||||
currntpservers[index] = server
|
||||
request = {'NTP':{'NTPServers': currntpservers}}
|
||||
self._do_web_request(netprotocols, request, method='PATCH')
|
||||
self._do_web_request(netprotocols, cache=0)
|
||||
|
||||
|
||||
def clear_bmc_configuration(self):
|
||||
"""Reset BMC to factory default
|
||||
|
||||
|
@ -34,6 +34,7 @@ def _baytonumber(bay):
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def _baytolabel(bay):
|
||||
try:
|
||||
baynum = int(bay)
|
||||
@ -53,6 +54,9 @@ class OEMHandler(generic.OEMHandler):
|
||||
health = healthlookup.get(health, pygconst.Health.Critical)
|
||||
return {'health': health}
|
||||
|
||||
def get_system_configuration(self, hideadvanced=True, fishclient=None):
|
||||
return {}
|
||||
|
||||
def _get_node_info(self):
|
||||
nodeinfo = self._varsysinfo
|
||||
if not nodeinfo:
|
||||
|
Loading…
x
Reference in New Issue
Block a user