Evgeny Sorokin 275d138436 web_kbn upd
2024-06-25 22:43:09 +03:00

36 lines
1.1 KiB
Python

from ..config import ConfigUnit, Translation
from typing import Optional
from enum import Enum
class ModemType(Enum):
E3372 = 'e3372'
GPON = 'gpon'
class ModemsConfig(ConfigUnit):
NAME = 'modems'
_strings: Translation
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._strings = Translation('modems')
@classmethod
def schema(cls) -> Optional[dict]:
return {
'type': 'dict',
'schema': {
'ip': cls._addr_schema(required=True, only_ip=True),
'gateway_ip': cls._addr_schema(required=False, only_ip=True),
'legacy_auth': {'type': 'boolean', 'required': True},
'type': {'type': 'string', 'allowed': [t.value for t in ModemType], 'required': True}
}
}
def getshortname(self, modem: str, lang=Translation.DEFAULT_LANGUAGE):
return self._strings.get(lang)[modem]['short']
def getfullname(self, modem: str, lang=Translation.DEFAULT_LANGUAGE):
return self._strings.get(lang)[modem]['full']