server: show interfaces as custom property

Change-Id: I129be1228b8a04386db5fe370ebdc2ec6ce8050a
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/34838
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
This commit is contained in:
Alexander Zaft
2024-10-18 12:52:31 +02:00
committed by Markus Zolliker
parent c7143a6dc7
commit b889a86461
2 changed files with 7 additions and 2 deletions

View File

@ -36,6 +36,7 @@ class SecNode:
- get_module(modulename) returns the requested module or None if there is - get_module(modulename) returns the requested module or None if there is
no suitable configuration on the server no suitable configuration on the server
""" """
def __init__(self, name, logger, options, srv): def __init__(self, name, logger, options, srv):
self.equipment_id = options.pop('equipment_id', name) self.equipment_id = options.pop('equipment_id', name)
self.nodeprops = {} self.nodeprops = {}
@ -54,6 +55,9 @@ class SecNode:
self.traceback_counter = 0 self.traceback_counter = 0
self.name = name self.name = name
def add_secnode_property(self, prop, value):
self.nodeprops[prop] = value
def get_module(self, modulename): def get_module(self, modulename):
""" Returns a fully initialized module. Or None, if something went """ Returns a fully initialized module. Or None, if something went
wrong during instatiating/initializing the module.""" wrong during instatiating/initializing the module."""
@ -219,9 +223,9 @@ class SecNode:
result['equipment_id'] = self.equipment_id result['equipment_id'] = self.equipment_id
result['firmware'] = 'FRAPPY ' + get_version() result['firmware'] = 'FRAPPY ' + get_version()
result['description'] = self.nodeprops['description'] result['description'] = self.nodeprops['description']
for prop in self.nodeprops: for prop, propvalue in self.nodeprops.items():
if prop.startswith('_'): if prop.startswith('_'):
result[prop] = self.nodeprops[prop] result[prop] = propvalue
else: else:
raise NoSuchModuleError(f'Module {modname!r} does not exist') raise NoSuchModuleError(f'Module {modname!r} does not exist')
return result return result

View File

@ -192,6 +192,7 @@ class Server:
if not self.interfaces: if not self.interfaces:
self.log.error('no interface started') self.log.error('no interface started')
return return
self.secnode.add_secnode_property('_interfaces', list(self.interfaces.keys()))
self.log.info('startup done with interface(s) %s' % ', '.join(self.interfaces)) self.log.info('startup done with interface(s) %s' % ', '.join(self.interfaces))
if systemd: if systemd:
systemd.daemon.notify("READY=1\nSTATUS=accepting requests") systemd.daemon.notify("READY=1\nSTATUS=accepting requests")