daemon: updating core.configservice and core.configservices to avoid deprecated type hinting

This commit is contained in:
Blake Harnden 2023-04-13 11:58:58 -07:00
parent e770bcd47c
commit 3d722a7721
8 changed files with 345 additions and 346 deletions

View file

@ -5,7 +5,7 @@ import logging
import time import time
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional from typing import Any, Optional
from mako import exceptions from mako import exceptions
from mako.lookup import TemplateLookup from mako.lookup import TemplateLookup
@ -67,7 +67,7 @@ class ConfigService(abc.ABC):
validation_timer: int = 5 validation_timer: int = 5
# directories to shadow and copy files from # directories to shadow and copy files from
shadow_directories: List[ShadowDir] = [] shadow_directories: list[ShadowDir] = []
def __init__(self, node: CoreNode) -> None: def __init__(self, node: CoreNode) -> None:
""" """
@ -79,9 +79,9 @@ class ConfigService(abc.ABC):
class_file = inspect.getfile(self.__class__) class_file = inspect.getfile(self.__class__)
templates_path = Path(class_file).parent.joinpath(TEMPLATES_DIR) templates_path = Path(class_file).parent.joinpath(TEMPLATES_DIR)
self.templates: TemplateLookup = TemplateLookup(directories=templates_path) self.templates: TemplateLookup = TemplateLookup(directories=templates_path)
self.config: Dict[str, Configuration] = {} self.config: dict[str, Configuration] = {}
self.custom_templates: Dict[str, str] = {} self.custom_templates: dict[str, str] = {}
self.custom_config: Dict[str, str] = {} self.custom_config: dict[str, str] = {}
configs = self.default_configs[:] configs = self.default_configs[:]
self._define_config(configs) self._define_config(configs)
@ -108,47 +108,47 @@ class ConfigService(abc.ABC):
@property @property
@abc.abstractmethod @abc.abstractmethod
def directories(self) -> List[str]: def directories(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def files(self) -> List[str]: def files(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def default_configs(self) -> List[Configuration]: def default_configs(self) -> list[Configuration]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def modes(self) -> Dict[str, Dict[str, str]]: def modes(self) -> dict[str, dict[str, str]]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def executables(self) -> List[str]: def executables(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def dependencies(self) -> List[str]: def dependencies(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def startup(self) -> List[str]: def startup(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def validate(self) -> List[str]: def validate(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@abc.abstractmethod @abc.abstractmethod
def shutdown(self) -> List[str]: def shutdown(self) -> list[str]:
raise NotImplementedError raise NotImplementedError
@property @property
@ -276,7 +276,7 @@ class ConfigService(abc.ABC):
f"failure to create service directory: {directory}" f"failure to create service directory: {directory}"
) )
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
""" """
Returns key/value data, used when rendering file templates. Returns key/value data, used when rendering file templates.
@ -303,7 +303,7 @@ class ConfigService(abc.ABC):
""" """
raise CoreError(f"service({self.name}) unknown template({name})") raise CoreError(f"service({self.name}) unknown template({name})")
def get_templates(self) -> Dict[str, str]: def get_templates(self) -> dict[str, str]:
""" """
Retrieves mapping of file names to templates for all cases, which Retrieves mapping of file names to templates for all cases, which
includes custom templates, file templates, and text templates. includes custom templates, file templates, and text templates.
@ -331,7 +331,7 @@ class ConfigService(abc.ABC):
templates[file] = template templates[file] = template
return templates return templates
def get_rendered_templates(self) -> Dict[str, str]: def get_rendered_templates(self) -> dict[str, str]:
templates = {} templates = {}
data = self.data() data = self.data()
for file in sorted(self.files): for file in sorted(self.files):
@ -339,7 +339,7 @@ class ConfigService(abc.ABC):
templates[file] = rendered templates[file] = rendered
return templates return templates
def _get_rendered_template(self, file: str, data: Dict[str, Any]) -> str: def _get_rendered_template(self, file: str, data: dict[str, Any]) -> str:
file_path = Path(file) file_path = Path(file)
template_path = get_template_path(file_path) template_path = get_template_path(file_path)
if file in self.custom_templates: if file in self.custom_templates:
@ -426,7 +426,7 @@ class ConfigService(abc.ABC):
f"node({self.node.name}) service({self.name}) failed to validate" f"node({self.node.name}) service({self.name}) failed to validate"
) )
def _render(self, template: Template, data: Dict[str, Any] = None) -> str: def _render(self, template: Template, data: dict[str, Any] = None) -> str:
""" """
Renders template providing all associated data to template. Renders template providing all associated data to template.
@ -440,7 +440,7 @@ class ConfigService(abc.ABC):
node=self.node, config=self.render_config(), **data node=self.node, config=self.render_config(), **data
) )
def render_text(self, text: str, data: Dict[str, Any] = None) -> str: def render_text(self, text: str, data: dict[str, Any] = None) -> str:
""" """
Renders text based template providing all associated data to template. Renders text based template providing all associated data to template.
@ -458,7 +458,7 @@ class ConfigService(abc.ABC):
f"{exceptions.text_error_template().render_unicode()}" f"{exceptions.text_error_template().render_unicode()}"
) )
def render_template(self, template_path: str, data: Dict[str, Any] = None) -> str: def render_template(self, template_path: str, data: dict[str, Any] = None) -> str:
""" """
Renders file based template providing all associated data to template. Renders file based template providing all associated data to template.
@ -475,7 +475,7 @@ class ConfigService(abc.ABC):
f"{exceptions.text_error_template().render_unicode()}" f"{exceptions.text_error_template().render_unicode()}"
) )
def _define_config(self, configs: List[Configuration]) -> None: def _define_config(self, configs: list[Configuration]) -> None:
""" """
Initializes default configuration data. Initializes default configuration data.
@ -485,7 +485,7 @@ class ConfigService(abc.ABC):
for config in configs: for config in configs:
self.config[config.id] = config self.config[config.id] = config
def render_config(self) -> Dict[str, str]: def render_config(self) -> dict[str, str]:
""" """
Returns configuration data key/value pairs for rendering a template. Returns configuration data key/value pairs for rendering a template.
@ -496,7 +496,7 @@ class ConfigService(abc.ABC):
else: else:
return {k: v.default for k, v in self.config.items()} return {k: v.default for k, v in self.config.items()}
def set_config(self, data: Dict[str, str]) -> None: def set_config(self, data: dict[str, str]) -> None:
""" """
Set configuration data from key/value pairs. Set configuration data from key/value pairs.

View file

@ -1,5 +1,5 @@
import logging import logging
from typing import TYPE_CHECKING, Dict, List, Set from typing import TYPE_CHECKING
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -12,16 +12,16 @@ class ConfigServiceDependencies:
Generates sets of services to start in order of their dependencies. Generates sets of services to start in order of their dependencies.
""" """
def __init__(self, services: Dict[str, "ConfigService"]) -> None: def __init__(self, services: dict[str, "ConfigService"]) -> None:
""" """
Create a ConfigServiceDependencies instance. Create a ConfigServiceDependencies instance.
:param services: services for determining dependency sets :param services: services for determining dependency sets
""" """
# helpers to check validity # helpers to check validity
self.dependents: Dict[str, Set[str]] = {} self.dependents: dict[str, set[str]] = {}
self.started: Set[str] = set() self.started: set[str] = set()
self.node_services: Dict[str, "ConfigService"] = {} self.node_services: dict[str, "ConfigService"] = {}
for service in services.values(): for service in services.values():
self.node_services[service.name] = service self.node_services[service.name] = service
for dependency in service.dependencies: for dependency in service.dependencies:
@ -29,11 +29,11 @@ class ConfigServiceDependencies:
dependents.add(service.name) dependents.add(service.name)
# used to find paths # used to find paths
self.path: List["ConfigService"] = [] self.path: list["ConfigService"] = []
self.visited: Set[str] = set() self.visited: set[str] = set()
self.visiting: Set[str] = set() self.visiting: set[str] = set()
def startup_paths(self) -> List[List["ConfigService"]]: def startup_paths(self) -> list[list["ConfigService"]]:
""" """
Find startup path sets based on service dependencies. Find startup path sets based on service dependencies.
@ -70,7 +70,7 @@ class ConfigServiceDependencies:
self.visited.clear() self.visited.clear()
self.visiting.clear() self.visiting.clear()
def _start(self, service: "ConfigService") -> List["ConfigService"]: def _start(self, service: "ConfigService") -> list["ConfigService"]:
""" """
Starts a oath for checking dependencies for a given service. Starts a oath for checking dependencies for a given service.
@ -81,7 +81,7 @@ class ConfigServiceDependencies:
self._reset() self._reset()
return self._visit(service) return self._visit(service)
def _visit(self, current_service: "ConfigService") -> List["ConfigService"]: def _visit(self, current_service: "ConfigService") -> list["ConfigService"]:
""" """
Visits a service when discovering dependency chains for service. Visits a service when discovering dependency chains for service.

View file

@ -2,7 +2,6 @@ import logging
import pathlib import pathlib
import pkgutil import pkgutil
from pathlib import Path from pathlib import Path
from typing import Dict, List, Type
from core import configservices, utils from core import configservices, utils
from core.configservice.base import ConfigService from core.configservice.base import ConfigService
@ -20,9 +19,9 @@ class ConfigServiceManager:
""" """
Create a ConfigServiceManager instance. Create a ConfigServiceManager instance.
""" """
self.services: Dict[str, Type[ConfigService]] = {} self.services: dict[str, type[ConfigService]] = {}
def get_service(self, name: str) -> Type[ConfigService]: def get_service(self, name: str) -> type[ConfigService]:
""" """
Retrieve a service by name. Retrieve a service by name.
@ -35,7 +34,7 @@ class ConfigServiceManager:
raise CoreError(f"service does not exist {name}") raise CoreError(f"service does not exist {name}")
return service_class return service_class
def add(self, service: Type[ConfigService]) -> None: def add(self, service: type[ConfigService]) -> None:
""" """
Add service to manager, checking service requirements have been met. Add service to manager, checking service requirements have been met.
@ -62,7 +61,7 @@ class ConfigServiceManager:
# make service available # make service available
self.services[name] = service self.services[name] = service
def load_locals(self) -> List[str]: def load_locals(self) -> list[str]:
""" """
Search and add config service from local core module. Search and add config service from local core module.
@ -81,7 +80,7 @@ class ConfigServiceManager:
logger.debug("not loading config service(%s): %s", service.name, e) logger.debug("not loading config service(%s): %s", service.name, e)
return errors return errors
def load(self, path: Path) -> List[str]: def load(self, path: Path) -> list[str]:
""" """
Search path provided for config services and add them for being managed. Search path provided for config services and add them for being managed.

View file

@ -1,5 +1,5 @@
import abc import abc
from typing import Any, Dict, List from typing import Any
from core.config import Configuration from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
@ -82,23 +82,23 @@ def rj45_check(iface: CoreInterface) -> bool:
class FRRZebra(ConfigService): class FRRZebra(ConfigService):
name: str = "FRRzebra" name: str = "FRRzebra"
group: str = GROUP group: str = GROUP
directories: List[str] = ["/usr/local/etc/frr", "/var/run/frr", "/var/log/frr"] directories: list[str] = ["/usr/local/etc/frr", "/var/run/frr", "/var/log/frr"]
files: List[str] = [ files: list[str] = [
"/usr/local/etc/frr/frr.conf", "/usr/local/etc/frr/frr.conf",
"frrboot.sh", "frrboot.sh",
"/usr/local/etc/frr/vtysh.conf", "/usr/local/etc/frr/vtysh.conf",
"/usr/local/etc/frr/daemons", "/usr/local/etc/frr/daemons",
] ]
executables: List[str] = ["zebra"] executables: list[str] = ["zebra"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash frrboot.sh zebra"] startup: list[str] = ["bash frrboot.sh zebra"]
validate: List[str] = ["pidof zebra"] validate: list[str] = ["pidof zebra"]
shutdown: List[str] = ["killall zebra"] shutdown: list[str] = ["killall zebra"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
frr_conf = self.files[0] frr_conf = self.files[0]
frr_bin_search = self.node.session.options.get( frr_bin_search = self.node.session.options.get(
"frr_bin_search", default="/usr/local/bin /usr/bin /usr/lib/frr" "frr_bin_search", default="/usr/local/bin /usr/bin /usr/lib/frr"
@ -145,16 +145,16 @@ class FRRZebra(ConfigService):
class FrrService(abc.ABC): class FrrService(abc.ABC):
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = [] files: list[str] = []
executables: List[str] = [] executables: list[str] = []
dependencies: List[str] = ["FRRzebra"] dependencies: list[str] = ["FRRzebra"]
startup: List[str] = [] startup: list[str] = []
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
ipv4_routing: bool = False ipv4_routing: bool = False
ipv6_routing: bool = False ipv6_routing: bool = False
@ -175,8 +175,8 @@ class FRROspfv2(FrrService, ConfigService):
""" """
name: str = "FRROSPFv2" name: str = "FRROSPFv2"
shutdown: List[str] = ["killall ospfd"] shutdown: list[str] = ["killall ospfd"]
validate: List[str] = ["pidof ospfd"] validate: list[str] = ["pidof ospfd"]
ipv4_routing: bool = True ipv4_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
@ -227,8 +227,8 @@ class FRROspfv3(FrrService, ConfigService):
""" """
name: str = "FRROSPFv3" name: str = "FRROSPFv3"
shutdown: List[str] = ["killall ospf6d"] shutdown: list[str] = ["killall ospf6d"]
validate: List[str] = ["pidof ospf6d"] validate: list[str] = ["pidof ospf6d"]
ipv4_routing: bool = True ipv4_routing: bool = True
ipv6_routing: bool = True ipv6_routing: bool = True
@ -264,8 +264,8 @@ class FRRBgp(FrrService, ConfigService):
""" """
name: str = "FRRBGP" name: str = "FRRBGP"
shutdown: List[str] = ["killall bgpd"] shutdown: list[str] = ["killall bgpd"]
validate: List[str] = ["pidof bgpd"] validate: list[str] = ["pidof bgpd"]
custom_needed: bool = True custom_needed: bool = True
ipv4_routing: bool = True ipv4_routing: bool = True
ipv6_routing: bool = True ipv6_routing: bool = True
@ -294,8 +294,8 @@ class FRRRip(FrrService, ConfigService):
""" """
name: str = "FRRRIP" name: str = "FRRRIP"
shutdown: List[str] = ["killall ripd"] shutdown: list[str] = ["killall ripd"]
validate: List[str] = ["pidof ripd"] validate: list[str] = ["pidof ripd"]
ipv4_routing: bool = True ipv4_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
@ -319,8 +319,8 @@ class FRRRipng(FrrService, ConfigService):
""" """
name: str = "FRRRIPNG" name: str = "FRRRIPNG"
shutdown: List[str] = ["killall ripngd"] shutdown: list[str] = ["killall ripngd"]
validate: List[str] = ["pidof ripngd"] validate: list[str] = ["pidof ripngd"]
ipv6_routing: bool = True ipv6_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
@ -345,8 +345,8 @@ class FRRBabel(FrrService, ConfigService):
""" """
name: str = "FRRBabel" name: str = "FRRBabel"
shutdown: List[str] = ["killall babeld"] shutdown: list[str] = ["killall babeld"]
validate: List[str] = ["pidof babeld"] validate: list[str] = ["pidof babeld"]
ipv6_routing: bool = True ipv6_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
@ -385,8 +385,8 @@ class FRRpimd(FrrService, ConfigService):
""" """
name: str = "FRRpimd" name: str = "FRRpimd"
shutdown: List[str] = ["killall pimd"] shutdown: list[str] = ["killall pimd"]
validate: List[str] = ["pidof pimd"] validate: list[str] = ["pidof pimd"]
ipv4_routing: bool = True ipv4_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:

View file

@ -1,4 +1,4 @@
from typing import Any, Dict, List from typing import Any
from core import utils from core import utils
from core.config import Configuration from core.config import Configuration
@ -10,18 +10,18 @@ GROUP: str = "ProtoSvc"
class MgenSinkService(ConfigService): class MgenSinkService(ConfigService):
name: str = "MGEN_Sink" name: str = "MGEN_Sink"
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["mgensink.sh", "sink.mgen"] files: list[str] = ["mgensink.sh", "sink.mgen"]
executables: List[str] = ["mgen"] executables: list[str] = ["mgen"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash mgensink.sh"] startup: list[str] = ["bash mgensink.sh"]
validate: List[str] = ["pidof mgen"] validate: list[str] = ["pidof mgen"]
shutdown: List[str] = ["killall mgen"] shutdown: list[str] = ["killall mgen"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(): for iface in self.node.get_ifaces():
name = utils.sysctl_devname(iface.name) name = utils.sysctl_devname(iface.name)
@ -32,18 +32,18 @@ class MgenSinkService(ConfigService):
class NrlNhdp(ConfigService): class NrlNhdp(ConfigService):
name: str = "NHDP" name: str = "NHDP"
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["nrlnhdp.sh"] files: list[str] = ["nrlnhdp.sh"]
executables: List[str] = ["nrlnhdp"] executables: list[str] = ["nrlnhdp"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash nrlnhdp.sh"] startup: list[str] = ["bash nrlnhdp.sh"]
validate: List[str] = ["pidof nrlnhdp"] validate: list[str] = ["pidof nrlnhdp"]
shutdown: List[str] = ["killall nrlnhdp"] shutdown: list[str] = ["killall nrlnhdp"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
has_smf = "SMF" in self.node.config_services has_smf = "SMF" in self.node.config_services
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
@ -54,18 +54,18 @@ class NrlNhdp(ConfigService):
class NrlSmf(ConfigService): class NrlSmf(ConfigService):
name: str = "SMF" name: str = "SMF"
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["startsmf.sh"] files: list[str] = ["startsmf.sh"]
executables: List[str] = ["nrlsmf", "killall"] executables: list[str] = ["nrlsmf", "killall"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash startsmf.sh"] startup: list[str] = ["bash startsmf.sh"]
validate: List[str] = ["pidof nrlsmf"] validate: list[str] = ["pidof nrlsmf"]
shutdown: List[str] = ["killall nrlsmf"] shutdown: list[str] = ["killall nrlsmf"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
has_nhdp = "NHDP" in self.node.config_services has_nhdp = "NHDP" in self.node.config_services
has_olsr = "OLSR" in self.node.config_services has_olsr = "OLSR" in self.node.config_services
ifnames = [] ifnames = []
@ -84,18 +84,18 @@ class NrlSmf(ConfigService):
class NrlOlsr(ConfigService): class NrlOlsr(ConfigService):
name: str = "OLSR" name: str = "OLSR"
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["nrlolsrd.sh"] files: list[str] = ["nrlolsrd.sh"]
executables: List[str] = ["nrlolsrd"] executables: list[str] = ["nrlolsrd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash nrlolsrd.sh"] startup: list[str] = ["bash nrlolsrd.sh"]
validate: List[str] = ["pidof nrlolsrd"] validate: list[str] = ["pidof nrlolsrd"]
shutdown: List[str] = ["killall nrlolsrd"] shutdown: list[str] = ["killall nrlolsrd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
has_smf = "SMF" in self.node.config_services has_smf = "SMF" in self.node.config_services
has_zebra = "zebra" in self.node.config_services has_zebra = "zebra" in self.node.config_services
ifname = None ifname = None
@ -108,18 +108,18 @@ class NrlOlsr(ConfigService):
class NrlOlsrv2(ConfigService): class NrlOlsrv2(ConfigService):
name: str = "OLSRv2" name: str = "OLSRv2"
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["nrlolsrv2.sh"] files: list[str] = ["nrlolsrv2.sh"]
executables: List[str] = ["nrlolsrv2"] executables: list[str] = ["nrlolsrv2"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash nrlolsrv2.sh"] startup: list[str] = ["bash nrlolsrv2.sh"]
validate: List[str] = ["pidof nrlolsrv2"] validate: list[str] = ["pidof nrlolsrv2"]
shutdown: List[str] = ["killall nrlolsrv2"] shutdown: list[str] = ["killall nrlolsrv2"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
has_smf = "SMF" in self.node.config_services has_smf = "SMF" in self.node.config_services
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
@ -130,18 +130,18 @@ class NrlOlsrv2(ConfigService):
class OlsrOrg(ConfigService): class OlsrOrg(ConfigService):
name: str = "OLSRORG" name: str = "OLSRORG"
group: str = GROUP group: str = GROUP
directories: List[str] = ["/etc/olsrd"] directories: list[str] = ["/etc/olsrd"]
files: List[str] = ["olsrd.sh", "/etc/olsrd/olsrd.conf"] files: list[str] = ["olsrd.sh", "/etc/olsrd/olsrd.conf"]
executables: List[str] = ["olsrd"] executables: list[str] = ["olsrd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash olsrd.sh"] startup: list[str] = ["bash olsrd.sh"]
validate: List[str] = ["pidof olsrd"] validate: list[str] = ["pidof olsrd"]
shutdown: List[str] = ["killall olsrd"] shutdown: list[str] = ["killall olsrd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
has_smf = "SMF" in self.node.config_services has_smf = "SMF" in self.node.config_services
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
@ -152,13 +152,13 @@ class OlsrOrg(ConfigService):
class MgenActor(ConfigService): class MgenActor(ConfigService):
name: str = "MgenActor" name: str = "MgenActor"
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["start_mgen_actor.sh"] files: list[str] = ["start_mgen_actor.sh"]
executables: List[str] = ["mgen"] executables: list[str] = ["mgen"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash start_mgen_actor.sh"] startup: list[str] = ["bash start_mgen_actor.sh"]
validate: List[str] = ["pidof mgen"] validate: list[str] = ["pidof mgen"]
shutdown: List[str] = ["killall mgen"] shutdown: list[str] = ["killall mgen"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}

View file

@ -1,6 +1,6 @@
import abc import abc
import logging import logging
from typing import Any, Dict, List from typing import Any
from core.config import Configuration from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
@ -84,22 +84,22 @@ def rj45_check(iface: CoreInterface) -> bool:
class Zebra(ConfigService): class Zebra(ConfigService):
name: str = "zebra" name: str = "zebra"
group: str = GROUP group: str = GROUP
directories: List[str] = ["/usr/local/etc/quagga", "/var/run/quagga"] directories: list[str] = ["/usr/local/etc/quagga", "/var/run/quagga"]
files: List[str] = [ files: list[str] = [
"/usr/local/etc/quagga/Quagga.conf", "/usr/local/etc/quagga/Quagga.conf",
"quaggaboot.sh", "quaggaboot.sh",
"/usr/local/etc/quagga/vtysh.conf", "/usr/local/etc/quagga/vtysh.conf",
] ]
executables: List[str] = ["zebra"] executables: list[str] = ["zebra"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash quaggaboot.sh zebra"] startup: list[str] = ["bash quaggaboot.sh zebra"]
validate: List[str] = ["pidof zebra"] validate: list[str] = ["pidof zebra"]
shutdown: List[str] = ["killall zebra"] shutdown: list[str] = ["killall zebra"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
quagga_bin_search = self.node.session.options.get( quagga_bin_search = self.node.session.options.get(
"quagga_bin_search", default="/usr/local/bin /usr/bin /usr/lib/quagga" "quagga_bin_search", default="/usr/local/bin /usr/bin /usr/lib/quagga"
).strip('"') ).strip('"')
@ -153,16 +153,16 @@ class Zebra(ConfigService):
class QuaggaService(abc.ABC): class QuaggaService(abc.ABC):
group: str = GROUP group: str = GROUP
directories: List[str] = [] directories: list[str] = []
files: List[str] = [] files: list[str] = []
executables: List[str] = [] executables: list[str] = []
dependencies: List[str] = ["zebra"] dependencies: list[str] = ["zebra"]
startup: List[str] = [] startup: list[str] = []
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
ipv4_routing: bool = False ipv4_routing: bool = False
ipv6_routing: bool = False ipv6_routing: bool = False
@ -183,8 +183,8 @@ class Ospfv2(QuaggaService, ConfigService):
""" """
name: str = "OSPFv2" name: str = "OSPFv2"
validate: List[str] = ["pidof ospfd"] validate: list[str] = ["pidof ospfd"]
shutdown: List[str] = ["killall ospfd"] shutdown: list[str] = ["killall ospfd"]
ipv4_routing: bool = True ipv4_routing: bool = True
def quagga_iface_config(self, iface: CoreInterface) -> str: def quagga_iface_config(self, iface: CoreInterface) -> str:
@ -234,8 +234,8 @@ class Ospfv3(QuaggaService, ConfigService):
""" """
name: str = "OSPFv3" name: str = "OSPFv3"
shutdown: List[str] = ["killall ospf6d"] shutdown: list[str] = ["killall ospf6d"]
validate: List[str] = ["pidof ospf6d"] validate: list[str] = ["pidof ospf6d"]
ipv4_routing: bool = True ipv4_routing: bool = True
ipv6_routing: bool = True ipv6_routing: bool = True
@ -300,8 +300,8 @@ class Bgp(QuaggaService, ConfigService):
""" """
name: str = "BGP" name: str = "BGP"
shutdown: List[str] = ["killall bgpd"] shutdown: list[str] = ["killall bgpd"]
validate: List[str] = ["pidof bgpd"] validate: list[str] = ["pidof bgpd"]
ipv4_routing: bool = True ipv4_routing: bool = True
ipv6_routing: bool = True ipv6_routing: bool = True
@ -329,8 +329,8 @@ class Rip(QuaggaService, ConfigService):
""" """
name: str = "RIP" name: str = "RIP"
shutdown: List[str] = ["killall ripd"] shutdown: list[str] = ["killall ripd"]
validate: List[str] = ["pidof ripd"] validate: list[str] = ["pidof ripd"]
ipv4_routing: bool = True ipv4_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
@ -354,8 +354,8 @@ class Ripng(QuaggaService, ConfigService):
""" """
name: str = "RIPNG" name: str = "RIPNG"
shutdown: List[str] = ["killall ripngd"] shutdown: list[str] = ["killall ripngd"]
validate: List[str] = ["pidof ripngd"] validate: list[str] = ["pidof ripngd"]
ipv6_routing: bool = True ipv6_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
@ -380,8 +380,8 @@ class Babel(QuaggaService, ConfigService):
""" """
name: str = "Babel" name: str = "Babel"
shutdown: List[str] = ["killall babeld"] shutdown: list[str] = ["killall babeld"]
validate: List[str] = ["pidof babeld"] validate: list[str] = ["pidof babeld"]
ipv6_routing: bool = True ipv6_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
@ -420,8 +420,8 @@ class Xpimd(QuaggaService, ConfigService):
""" """
name: str = "Xpimd" name: str = "Xpimd"
shutdown: List[str] = ["killall xpimd"] shutdown: list[str] = ["killall xpimd"]
validate: List[str] = ["pidof xpimd"] validate: list[str] = ["pidof xpimd"]
ipv4_routing: bool = True ipv4_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:

View file

@ -1,4 +1,4 @@
from typing import Any, Dict, List from typing import Any
from core.config import ConfigString, Configuration from core.config import ConfigString, Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
@ -9,41 +9,41 @@ GROUP_NAME: str = "Security"
class VpnClient(ConfigService): class VpnClient(ConfigService):
name: str = "VPNClient" name: str = "VPNClient"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["vpnclient.sh"] files: list[str] = ["vpnclient.sh"]
executables: List[str] = ["openvpn", "ip", "killall"] executables: list[str] = ["openvpn", "ip", "killall"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash vpnclient.sh"] startup: list[str] = ["bash vpnclient.sh"]
validate: List[str] = ["pidof openvpn"] validate: list[str] = ["pidof openvpn"]
shutdown: List[str] = ["killall openvpn"] shutdown: list[str] = ["killall openvpn"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [ default_configs: list[Configuration] = [
ConfigString(id="keydir", label="Key Dir", default="/etc/core/keys"), ConfigString(id="keydir", label="Key Dir", default="/etc/core/keys"),
ConfigString(id="keyname", label="Key Name", default="client1"), ConfigString(id="keyname", label="Key Name", default="client1"),
ConfigString(id="server", label="Server", default="10.0.2.10"), ConfigString(id="server", label="Server", default="10.0.2.10"),
] ]
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
class VpnServer(ConfigService): class VpnServer(ConfigService):
name: str = "VPNServer" name: str = "VPNServer"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["vpnserver.sh"] files: list[str] = ["vpnserver.sh"]
executables: List[str] = ["openvpn", "ip", "killall"] executables: list[str] = ["openvpn", "ip", "killall"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash vpnserver.sh"] startup: list[str] = ["bash vpnserver.sh"]
validate: List[str] = ["pidof openvpn"] validate: list[str] = ["pidof openvpn"]
shutdown: List[str] = ["killall openvpn"] shutdown: list[str] = ["killall openvpn"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [ default_configs: list[Configuration] = [
ConfigString(id="keydir", label="Key Dir", default="/etc/core/keys"), ConfigString(id="keydir", label="Key Dir", default="/etc/core/keys"),
ConfigString(id="keyname", label="Key Name", default="server"), ConfigString(id="keyname", label="Key Name", default="server"),
ConfigString(id="subnet", label="Subnet", default="10.0.200.0"), ConfigString(id="subnet", label="Subnet", default="10.0.200.0"),
] ]
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
address = None address = None
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
ip4 = iface.get_ip4() ip4 = iface.get_ip4()
@ -56,48 +56,48 @@ class VpnServer(ConfigService):
class IPsec(ConfigService): class IPsec(ConfigService):
name: str = "IPsec" name: str = "IPsec"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["ipsec.sh"] files: list[str] = ["ipsec.sh"]
executables: List[str] = ["racoon", "ip", "setkey", "killall"] executables: list[str] = ["racoon", "ip", "setkey", "killall"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash ipsec.sh"] startup: list[str] = ["bash ipsec.sh"]
validate: List[str] = ["pidof racoon"] validate: list[str] = ["pidof racoon"]
shutdown: List[str] = ["killall racoon"] shutdown: list[str] = ["killall racoon"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
class Firewall(ConfigService): class Firewall(ConfigService):
name: str = "Firewall" name: str = "Firewall"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["firewall.sh"] files: list[str] = ["firewall.sh"]
executables: List[str] = ["iptables"] executables: list[str] = ["iptables"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash firewall.sh"] startup: list[str] = ["bash firewall.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
class Nat(ConfigService): class Nat(ConfigService):
name: str = "NAT" name: str = "NAT"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["nat.sh"] files: list[str] = ["nat.sh"]
executables: List[str] = ["iptables"] executables: list[str] = ["iptables"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash nat.sh"] startup: list[str] = ["bash nat.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
ifnames.append(iface.name) ifnames.append(iface.name)

View file

@ -1,4 +1,4 @@
from typing import Any, Dict, List from typing import Any
import netaddr import netaddr
@ -12,18 +12,18 @@ GROUP_NAME = "Utility"
class DefaultRouteService(ConfigService): class DefaultRouteService(ConfigService):
name: str = "DefaultRoute" name: str = "DefaultRoute"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["defaultroute.sh"] files: list[str] = ["defaultroute.sh"]
executables: List[str] = ["ip"] executables: list[str] = ["ip"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash defaultroute.sh"] startup: list[str] = ["bash defaultroute.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
# only add default routes for linked routing nodes # only add default routes for linked routing nodes
routes = [] routes = []
ifaces = self.node.get_ifaces() ifaces = self.node.get_ifaces()
@ -40,18 +40,18 @@ class DefaultRouteService(ConfigService):
class DefaultMulticastRouteService(ConfigService): class DefaultMulticastRouteService(ConfigService):
name: str = "DefaultMulticastRoute" name: str = "DefaultMulticastRoute"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["defaultmroute.sh"] files: list[str] = ["defaultmroute.sh"]
executables: List[str] = [] executables: list[str] = []
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash defaultmroute.sh"] startup: list[str] = ["bash defaultmroute.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifname = None ifname = None
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
ifname = iface.name ifname = iface.name
@ -62,18 +62,18 @@ class DefaultMulticastRouteService(ConfigService):
class StaticRouteService(ConfigService): class StaticRouteService(ConfigService):
name: str = "StaticRoute" name: str = "StaticRoute"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["staticroute.sh"] files: list[str] = ["staticroute.sh"]
executables: List[str] = [] executables: list[str] = []
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash staticroute.sh"] startup: list[str] = ["bash staticroute.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
routes = [] routes = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
for ip in iface.ips(): for ip in iface.ips():
@ -90,18 +90,18 @@ class StaticRouteService(ConfigService):
class IpForwardService(ConfigService): class IpForwardService(ConfigService):
name: str = "IPForward" name: str = "IPForward"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["ipforward.sh"] files: list[str] = ["ipforward.sh"]
executables: List[str] = ["sysctl"] executables: list[str] = ["sysctl"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash ipforward.sh"] startup: list[str] = ["bash ipforward.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = [] shutdown: list[str] = []
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
devnames = [] devnames = []
for iface in self.node.get_ifaces(): for iface in self.node.get_ifaces():
devname = utils.sysctl_devname(iface.name) devname = utils.sysctl_devname(iface.name)
@ -112,18 +112,18 @@ class IpForwardService(ConfigService):
class SshService(ConfigService): class SshService(ConfigService):
name: str = "SSH" name: str = "SSH"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = ["/etc/ssh", "/var/run/sshd"] directories: list[str] = ["/etc/ssh", "/var/run/sshd"]
files: List[str] = ["startsshd.sh", "/etc/ssh/sshd_config"] files: list[str] = ["startsshd.sh", "/etc/ssh/sshd_config"]
executables: List[str] = ["sshd"] executables: list[str] = ["sshd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash startsshd.sh"] startup: list[str] = ["bash startsshd.sh"]
validate: List[str] = [] validate: list[str] = []
shutdown: List[str] = ["killall sshd"] shutdown: list[str] = ["killall sshd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
return dict( return dict(
sshcfgdir=self.directories[0], sshcfgdir=self.directories[0],
sshstatedir=self.directories[1], sshstatedir=self.directories[1],
@ -134,18 +134,18 @@ class SshService(ConfigService):
class DhcpService(ConfigService): class DhcpService(ConfigService):
name: str = "DHCP" name: str = "DHCP"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = ["/etc/dhcp", "/var/lib/dhcp"] directories: list[str] = ["/etc/dhcp", "/var/lib/dhcp"]
files: List[str] = ["/etc/dhcp/dhcpd.conf"] files: list[str] = ["/etc/dhcp/dhcpd.conf"]
executables: List[str] = ["dhcpd"] executables: list[str] = ["dhcpd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["touch /var/lib/dhcp/dhcpd.leases", "dhcpd"] startup: list[str] = ["touch /var/lib/dhcp/dhcpd.leases", "dhcpd"]
validate: List[str] = ["pidof dhcpd"] validate: list[str] = ["pidof dhcpd"]
shutdown: List[str] = ["killall dhcpd"] shutdown: list[str] = ["killall dhcpd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
subnets = [] subnets = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
for ip4 in iface.ip4s: for ip4 in iface.ip4s:
@ -162,18 +162,18 @@ class DhcpService(ConfigService):
class DhcpClientService(ConfigService): class DhcpClientService(ConfigService):
name: str = "DHCPClient" name: str = "DHCPClient"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["startdhcpclient.sh"] files: list[str] = ["startdhcpclient.sh"]
executables: List[str] = ["dhclient"] executables: list[str] = ["dhclient"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash startdhcpclient.sh"] startup: list[str] = ["bash startdhcpclient.sh"]
validate: List[str] = ["pidof dhclient"] validate: list[str] = ["pidof dhclient"]
shutdown: List[str] = ["killall dhclient"] shutdown: list[str] = ["killall dhclient"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
ifnames.append(iface.name) ifnames.append(iface.name)
@ -183,33 +183,33 @@ class DhcpClientService(ConfigService):
class FtpService(ConfigService): class FtpService(ConfigService):
name: str = "FTP" name: str = "FTP"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = ["/var/run/vsftpd/empty", "/var/ftp"] directories: list[str] = ["/var/run/vsftpd/empty", "/var/ftp"]
files: List[str] = ["vsftpd.conf"] files: list[str] = ["vsftpd.conf"]
executables: List[str] = ["vsftpd"] executables: list[str] = ["vsftpd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["vsftpd ./vsftpd.conf"] startup: list[str] = ["vsftpd ./vsftpd.conf"]
validate: List[str] = ["pidof vsftpd"] validate: list[str] = ["pidof vsftpd"]
shutdown: List[str] = ["killall vsftpd"] shutdown: list[str] = ["killall vsftpd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
class PcapService(ConfigService): class PcapService(ConfigService):
name: str = "pcap" name: str = "pcap"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [] directories: list[str] = []
files: List[str] = ["pcap.sh"] files: list[str] = ["pcap.sh"]
executables: List[str] = ["tcpdump"] executables: list[str] = ["tcpdump"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash pcap.sh start"] startup: list[str] = ["bash pcap.sh start"]
validate: List[str] = ["pidof tcpdump"] validate: list[str] = ["pidof tcpdump"]
shutdown: List[str] = ["bash pcap.sh stop"] shutdown: list[str] = ["bash pcap.sh stop"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifnames = [] ifnames = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
ifnames.append(iface.name) ifnames.append(iface.name)
@ -219,20 +219,20 @@ class PcapService(ConfigService):
class RadvdService(ConfigService): class RadvdService(ConfigService):
name: str = "radvd" name: str = "radvd"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = ["/etc/radvd", "/var/run/radvd"] directories: list[str] = ["/etc/radvd", "/var/run/radvd"]
files: List[str] = ["/etc/radvd/radvd.conf"] files: list[str] = ["/etc/radvd/radvd.conf"]
executables: List[str] = ["radvd"] executables: list[str] = ["radvd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = [ startup: list[str] = [
"radvd -C /etc/radvd/radvd.conf -m logfile -l /var/log/radvd.log" "radvd -C /etc/radvd/radvd.conf -m logfile -l /var/log/radvd.log"
] ]
validate: List[str] = ["pidof radvd"] validate: list[str] = ["pidof radvd"]
shutdown: List[str] = ["pkill radvd"] shutdown: list[str] = ["pkill radvd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifaces = [] ifaces = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
prefixes = [] prefixes = []
@ -247,22 +247,22 @@ class RadvdService(ConfigService):
class AtdService(ConfigService): class AtdService(ConfigService):
name: str = "atd" name: str = "atd"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = ["/var/spool/cron/atjobs", "/var/spool/cron/atspool"] directories: list[str] = ["/var/spool/cron/atjobs", "/var/spool/cron/atspool"]
files: List[str] = ["startatd.sh"] files: list[str] = ["startatd.sh"]
executables: List[str] = ["atd"] executables: list[str] = ["atd"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["bash startatd.sh"] startup: list[str] = ["bash startatd.sh"]
validate: List[str] = ["pidof atd"] validate: list[str] = ["pidof atd"]
shutdown: List[str] = ["pkill atd"] shutdown: list[str] = ["pkill atd"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
class HttpService(ConfigService): class HttpService(ConfigService):
name: str = "HTTP" name: str = "HTTP"
group: str = GROUP_NAME group: str = GROUP_NAME
directories: List[str] = [ directories: list[str] = [
"/etc/apache2", "/etc/apache2",
"/var/run/apache2", "/var/run/apache2",
"/var/log/apache2", "/var/log/apache2",
@ -270,21 +270,21 @@ class HttpService(ConfigService):
"/var/lock/apache2", "/var/lock/apache2",
"/var/www", "/var/www",
] ]
files: List[str] = [ files: list[str] = [
"/etc/apache2/apache2.conf", "/etc/apache2/apache2.conf",
"/etc/apache2/envvars", "/etc/apache2/envvars",
"/var/www/index.html", "/var/www/index.html",
] ]
executables: List[str] = ["apache2ctl"] executables: list[str] = ["apache2ctl"]
dependencies: List[str] = [] dependencies: list[str] = []
startup: List[str] = ["chown www-data /var/lock/apache2", "apache2ctl start"] startup: list[str] = ["chown www-data /var/lock/apache2", "apache2ctl start"]
validate: List[str] = ["pidof apache2"] validate: list[str] = ["pidof apache2"]
shutdown: List[str] = ["apache2ctl stop"] shutdown: list[str] = ["apache2ctl stop"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = [] default_configs: list[Configuration] = []
modes: Dict[str, Dict[str, str]] = {} modes: dict[str, dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> dict[str, Any]:
ifaces = [] ifaces = []
for iface in self.node.get_ifaces(control=False): for iface in self.node.get_ifaces(control=False):
ifaces.append(iface) ifaces.append(iface)