daemon: added type hinting throughout config services

This commit is contained in:
Blake Harnden 2020-06-18 14:15:45 -07:00
parent a09910d0bc
commit b2ea8cbbf6
9 changed files with 471 additions and 455 deletions

View file

@ -14,7 +14,7 @@ from core.config import Configuration
from core.errors import CoreCommandError, CoreError from core.errors import CoreCommandError, CoreError
from core.nodes.base import CoreNode from core.nodes.base import CoreNode
TEMPLATES_DIR = "templates" TEMPLATES_DIR: str = "templates"
class ConfigServiceMode(enum.Enum): class ConfigServiceMode(enum.Enum):
@ -33,10 +33,10 @@ class ConfigService(abc.ABC):
""" """
# validation period in seconds, how frequent validation is attempted # validation period in seconds, how frequent validation is attempted
validation_period = 0.5 validation_period: float = 0.5
# time to wait in seconds for determining if service started successfully # time to wait in seconds for determining if service started successfully
validation_timer = 5 validation_timer: int = 5
def __init__(self, node: CoreNode) -> None: def __init__(self, node: CoreNode) -> None:
""" """
@ -44,13 +44,13 @@ class ConfigService(abc.ABC):
:param node: node this service is assigned to :param node: node this service is assigned to
""" """
self.node = node self.node: CoreNode = node
class_file = inspect.getfile(self.__class__) class_file = inspect.getfile(self.__class__)
templates_path = pathlib.Path(class_file).parent.joinpath(TEMPLATES_DIR) templates_path = pathlib.Path(class_file).parent.joinpath(TEMPLATES_DIR)
self.templates = TemplateLookup(directories=templates_path) self.templates: TemplateLookup = TemplateLookup(directories=templates_path)
self.config = {} self.config: Dict[str, Configuration] = {}
self.custom_templates = {} self.custom_templates: Dict[str, str] = {}
self.custom_config = {} self.custom_config: Dict[str, str] = {}
configs = self.default_configs[:] configs = self.default_configs[:]
self._define_config(configs) self._define_config(configs)

View file

@ -1,5 +1,5 @@
import logging import logging
from typing import TYPE_CHECKING, Dict, List from typing import TYPE_CHECKING, Dict, List, Set
if TYPE_CHECKING: if TYPE_CHECKING:
from core.configservice.base import ConfigService from core.configservice.base import ConfigService
@ -17,9 +17,9 @@ class ConfigServiceDependencies:
:param services: services for determining dependency sets :param services: services for determining dependency sets
""" """
# helpers to check validity # helpers to check validity
self.dependents = {} self.dependents: Dict[str, Set[str]] = {}
self.started = set() self.started: Set[str] = set()
self.node_services = {} 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:
@ -27,9 +27,9 @@ class ConfigServiceDependencies:
dependents.add(service.name) dependents.add(service.name)
# used to find paths # used to find paths
self.path = [] self.path: List["ConfigService"] = []
self.visited = set() self.visited: Set[str] = set()
self.visiting = set() self.visiting: Set[str] = set()
def startup_paths(self) -> List[List["ConfigService"]]: def startup_paths(self) -> List[List["ConfigService"]]:
""" """

View file

@ -1,6 +1,6 @@
import logging import logging
import pathlib import pathlib
from typing import List, Type from typing import Dict, List, Type
from core import utils from core import utils
from core.configservice.base import ConfigService from core.configservice.base import ConfigService
@ -16,7 +16,7 @@ class ConfigServiceManager:
""" """
Create a ConfigServiceManager instance. Create a ConfigServiceManager instance.
""" """
self.services = {} self.services: Dict[str, Type[ConfigService]] = {}
def get_service(self, name: str) -> Type[ConfigService]: def get_service(self, name: str) -> Type[ConfigService]:
""" """
@ -31,7 +31,7 @@ class ConfigServiceManager:
raise CoreError(f"service does not exit {name}") raise CoreError(f"service does not exit {name}")
return service_class return service_class
def add(self, service: 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.
@ -40,7 +40,9 @@ class ConfigServiceManager:
:raises CoreError: when service is a duplicate or has unmet executables :raises CoreError: when service is a duplicate or has unmet executables
""" """
name = service.name name = service.name
logging.debug("loading service: class(%s) name(%s)", service.__class__, name) logging.debug(
"loading service: class(%s) name(%s)", service.__class__.__name__, name
)
# avoid duplicate services # avoid duplicate services
if name in self.services: if name in self.services:
@ -73,7 +75,6 @@ class ConfigServiceManager:
logging.debug("loading config services from: %s", subdir) logging.debug("loading config services from: %s", subdir)
services = utils.load_classes(str(subdir), ConfigService) services = utils.load_classes(str(subdir), ConfigService)
for service in services: for service in services:
logging.debug("found service: %s", service)
try: try:
self.add(service) self.add(service)
except CoreError as e: except CoreError as e:

View file

@ -1,16 +1,17 @@
import abc import abc
from typing import Any, Dict from typing import Any, Dict, List
import netaddr import netaddr
from core import constants from core import constants
from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
from core.emane.nodes import EmaneNet from core.emane.nodes import EmaneNet
from core.nodes.base import CoreNodeBase from core.nodes.base import CoreNodeBase
from core.nodes.interface import CoreInterface from core.nodes.interface import CoreInterface
from core.nodes.network import WlanNode from core.nodes.network import WlanNode
GROUP = "FRR" GROUP: str = "FRR"
def has_mtu_mismatch(iface: CoreInterface) -> bool: def has_mtu_mismatch(iface: CoreInterface) -> bool:
@ -29,7 +30,7 @@ def has_mtu_mismatch(iface: CoreInterface) -> bool:
return False return False
def get_min_mtu(iface): def get_min_mtu(iface: CoreInterface) -> int:
""" """
Helper to discover the minimum MTU of interfaces linked with the Helper to discover the minimum MTU of interfaces linked with the
given interface. given interface.
@ -56,23 +57,23 @@ def get_router_id(node: CoreNodeBase) -> str:
class FRRZebra(ConfigService): class FRRZebra(ConfigService):
name = "FRRzebra" name: str = "FRRzebra"
group = GROUP group: str = GROUP
directories = ["/usr/local/etc/frr", "/var/run/frr", "/var/log/frr"] directories: List[str] = ["/usr/local/etc/frr", "/var/run/frr", "/var/log/frr"]
files = [ 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 = ["zebra"] executables: List[str] = ["zebra"]
dependencies = [] dependencies: List[str] = []
startup = ["sh frrboot.sh zebra"] startup: List[str] = ["sh frrboot.sh zebra"]
validate = ["pidof zebra"] validate: List[str] = ["pidof zebra"]
shutdown = ["killall zebra"] shutdown: List[str] = ["killall zebra"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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]
@ -89,6 +90,8 @@ class FRRZebra(ConfigService):
for service in self.node.config_services.values(): for service in self.node.config_services.values():
if self.name not in service.dependencies: if self.name not in service.dependencies:
continue continue
if not isinstance(service, FrrService):
continue
if service.ipv4_routing: if service.ipv4_routing:
want_ip4 = True want_ip4 = True
if service.ipv6_routing: if service.ipv6_routing:
@ -121,19 +124,19 @@ class FRRZebra(ConfigService):
class FrrService(abc.ABC): class FrrService(abc.ABC):
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = [] files: List[str] = []
executables = [] executables: List[str] = []
dependencies = ["FRRzebra"] dependencies: List[str] = ["FRRzebra"]
startup = [] startup: List[str] = []
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
ipv4_routing = False ipv4_routing: bool = False
ipv6_routing = False ipv6_routing: bool = False
@abc.abstractmethod @abc.abstractmethod
def frr_iface_config(self, iface: CoreInterface) -> str: def frr_iface_config(self, iface: CoreInterface) -> str:
@ -151,11 +154,10 @@ class FRROspfv2(FrrService, ConfigService):
unified frr.conf file. unified frr.conf file.
""" """
name = "FRROSPFv2" name: str = "FRROSPFv2"
startup = () shutdown: List[str] = ["killall ospfd"]
shutdown = ["killall ospfd"] validate: List[str] = ["pidof ospfd"]
validate = ["pidof ospfd"] ipv4_routing: bool = True
ipv4_routing = True
def frr_config(self) -> str: def frr_config(self) -> str:
router_id = get_router_id(self.node) router_id = get_router_id(self.node)
@ -190,11 +192,11 @@ class FRROspfv3(FrrService, ConfigService):
unified frr.conf file. unified frr.conf file.
""" """
name = "FRROSPFv3" name: str = "FRROSPFv3"
shutdown = ["killall ospf6d"] shutdown: List[str] = ["killall ospf6d"]
validate = ["pidof ospf6d"] validate: List[str] = ["pidof ospf6d"]
ipv4_routing = True ipv4_routing: bool = True
ipv6_routing = True ipv6_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
router_id = get_router_id(self.node) router_id = get_router_id(self.node)
@ -227,12 +229,12 @@ class FRRBgp(FrrService, ConfigService):
having the same AS number. having the same AS number.
""" """
name = "FRRBGP" name: str = "FRRBGP"
shutdown = ["killall bgpd"] shutdown: List[str] = ["killall bgpd"]
validate = ["pidof bgpd"] validate: List[str] = ["pidof bgpd"]
custom_needed = True custom_needed: bool = True
ipv4_routing = True ipv4_routing: bool = True
ipv6_routing = True ipv6_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
router_id = get_router_id(self.node) router_id = get_router_id(self.node)
@ -257,10 +259,10 @@ class FRRRip(FrrService, ConfigService):
The RIP service provides IPv4 routing for wired networks. The RIP service provides IPv4 routing for wired networks.
""" """
name = "FRRRIP" name: str = "FRRRIP"
shutdown = ["killall ripd"] shutdown: List[str] = ["killall ripd"]
validate = ["pidof ripd"] validate: List[str] = ["pidof ripd"]
ipv4_routing = True ipv4_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
text = """ text = """
@ -282,10 +284,10 @@ class FRRRipng(FrrService, ConfigService):
The RIP NG service provides IPv6 routing for wired networks. The RIP NG service provides IPv6 routing for wired networks.
""" """
name = "FRRRIPNG" name: str = "FRRRIPNG"
shutdown = ["killall ripngd"] shutdown: List[str] = ["killall ripngd"]
validate = ["pidof ripngd"] validate: List[str] = ["pidof ripngd"]
ipv6_routing = True ipv6_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
text = """ text = """
@ -308,10 +310,10 @@ class FRRBabel(FrrService, ConfigService):
protocol for IPv6 and IPv4 with fast convergence properties. protocol for IPv6 and IPv4 with fast convergence properties.
""" """
name = "FRRBabel" name: str = "FRRBabel"
shutdown = ["killall babeld"] shutdown: List[str] = ["killall babeld"]
validate = ["pidof babeld"] validate: List[str] = ["pidof babeld"]
ipv6_routing = True ipv6_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
ifnames = [] ifnames = []
@ -348,10 +350,10 @@ class FRRpimd(FrrService, ConfigService):
PIM multicast routing based on XORP. PIM multicast routing based on XORP.
""" """
name = "FRRpimd" name: str = "FRRpimd"
shutdown = ["killall pimd"] shutdown: List[str] = ["killall pimd"]
validate = ["pidof pimd"] validate: List[str] = ["pidof pimd"]
ipv4_routing = True ipv4_routing: bool = True
def frr_config(self) -> str: def frr_config(self) -> str:
ifname = "eth0" ifname = "eth0"

View file

@ -1,26 +1,27 @@
from typing import Any, Dict from typing import Any, Dict, List
import netaddr import netaddr
from core import utils from core import utils
from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
GROUP = "ProtoSvc" GROUP: str = "ProtoSvc"
class MgenSinkService(ConfigService): class MgenSinkService(ConfigService):
name = "MGEN_Sink" name: str = "MGEN_Sink"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["mgensink.sh", "sink.mgen"] files: List[str] = ["mgensink.sh", "sink.mgen"]
executables = ["mgen"] executables: List[str] = ["mgen"]
dependencies = [] dependencies: List[str] = []
startup = ["sh mgensink.sh"] startup: List[str] = ["sh mgensink.sh"]
validate = ["pidof mgen"] validate: List[str] = ["pidof mgen"]
shutdown = ["killall mgen"] shutdown: List[str] = ["killall mgen"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifnames = [] ifnames = []
@ -31,18 +32,18 @@ class MgenSinkService(ConfigService):
class NrlNhdp(ConfigService): class NrlNhdp(ConfigService):
name = "NHDP" name: str = "NHDP"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["nrlnhdp.sh"] files: List[str] = ["nrlnhdp.sh"]
executables = ["nrlnhdp"] executables: List[str] = ["nrlnhdp"]
dependencies = [] dependencies: List[str] = []
startup = ["sh nrlnhdp.sh"] startup: List[str] = ["sh nrlnhdp.sh"]
validate = ["pidof nrlnhdp"] validate: List[str] = ["pidof nrlnhdp"]
shutdown = ["killall nrlnhdp"] shutdown: List[str] = ["killall nrlnhdp"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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
@ -53,18 +54,18 @@ class NrlNhdp(ConfigService):
class NrlSmf(ConfigService): class NrlSmf(ConfigService):
name = "SMF" name: str = "SMF"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["startsmf.sh"] files: List[str] = ["startsmf.sh"]
executables = ["nrlsmf", "killall"] executables: List[str] = ["nrlsmf", "killall"]
dependencies = [] dependencies: List[str] = []
startup = ["sh startsmf.sh"] startup: List[str] = ["sh startsmf.sh"]
validate = ["pidof nrlsmf"] validate: List[str] = ["pidof nrlsmf"]
shutdown = ["killall nrlsmf"] shutdown: List[str] = ["killall nrlsmf"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
has_arouted = "arouted" in self.node.config_services has_arouted = "arouted" in self.node.config_services
@ -91,18 +92,18 @@ class NrlSmf(ConfigService):
class NrlOlsr(ConfigService): class NrlOlsr(ConfigService):
name = "OLSR" name: str = "OLSR"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["nrlolsrd.sh"] files: List[str] = ["nrlolsrd.sh"]
executables = ["nrlolsrd"] executables: List[str] = ["nrlolsrd"]
dependencies = [] dependencies: List[str] = []
startup = ["sh nrlolsrd.sh"] startup: List[str] = ["sh nrlolsrd.sh"]
validate = ["pidof nrlolsrd"] validate: List[str] = ["pidof nrlolsrd"]
shutdown = ["killall nrlolsrd"] shutdown: List[str] = ["killall nrlolsrd"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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
@ -115,18 +116,18 @@ class NrlOlsr(ConfigService):
class NrlOlsrv2(ConfigService): class NrlOlsrv2(ConfigService):
name = "OLSRv2" name: str = "OLSRv2"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["nrlolsrv2.sh"] files: List[str] = ["nrlolsrv2.sh"]
executables = ["nrlolsrv2"] executables: List[str] = ["nrlolsrv2"]
dependencies = [] dependencies: List[str] = []
startup = ["sh nrlolsrv2.sh"] startup: List[str] = ["sh nrlolsrv2.sh"]
validate = ["pidof nrlolsrv2"] validate: List[str] = ["pidof nrlolsrv2"]
shutdown = ["killall nrlolsrv2"] shutdown: List[str] = ["killall nrlolsrv2"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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
@ -137,18 +138,18 @@ class NrlOlsrv2(ConfigService):
class OlsrOrg(ConfigService): class OlsrOrg(ConfigService):
name = "OLSRORG" name: str = "OLSRORG"
group = GROUP group: str = GROUP
directories = ["/etc/olsrd"] directories: List[str] = ["/etc/olsrd"]
files = ["olsrd.sh", "/etc/olsrd/olsrd.conf"] files: List[str] = ["olsrd.sh", "/etc/olsrd/olsrd.conf"]
executables = ["olsrd"] executables: List[str] = ["olsrd"]
dependencies = [] dependencies: List[str] = []
startup = ["sh olsrd.sh"] startup: List[str] = ["sh olsrd.sh"]
validate = ["pidof olsrd"] validate: List[str] = ["pidof olsrd"]
shutdown = ["killall olsrd"] shutdown: List[str] = ["killall olsrd"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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
@ -159,33 +160,33 @@ class OlsrOrg(ConfigService):
class MgenActor(ConfigService): class MgenActor(ConfigService):
name = "MgenActor" name: str = "MgenActor"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["start_mgen_actor.sh"] files: List[str] = ["start_mgen_actor.sh"]
executables = ["mgen"] executables: List[str] = ["mgen"]
dependencies = [] dependencies: List[str] = []
startup = ["sh start_mgen_actor.sh"] startup: List[str] = ["sh start_mgen_actor.sh"]
validate = ["pidof mgen"] validate: List[str] = ["pidof mgen"]
shutdown = ["killall mgen"] shutdown: List[str] = ["killall mgen"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
class Arouted(ConfigService): class Arouted(ConfigService):
name = "arouted" name: str = "arouted"
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = ["startarouted.sh"] files: List[str] = ["startarouted.sh"]
executables = ["arouted"] executables: List[str] = ["arouted"]
dependencies = [] dependencies: List[str] = []
startup = ["sh startarouted.sh"] startup: List[str] = ["sh startarouted.sh"]
validate = ["pidof arouted"] validate: List[str] = ["pidof arouted"]
shutdown = ["pkill arouted"] shutdown: List[str] = ["pkill arouted"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ip4_prefix = None ip4_prefix = None

View file

@ -1,17 +1,18 @@
import abc import abc
import logging import logging
from typing import Any, Dict from typing import Any, Dict, List
import netaddr import netaddr
from core import constants from core import constants
from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
from core.emane.nodes import EmaneNet from core.emane.nodes import EmaneNet
from core.nodes.base import CoreNodeBase from core.nodes.base import CoreNodeBase
from core.nodes.interface import CoreInterface from core.nodes.interface import CoreInterface
from core.nodes.network import WlanNode from core.nodes.network import WlanNode
GROUP = "Quagga" GROUP: str = "Quagga"
def has_mtu_mismatch(iface: CoreInterface) -> bool: def has_mtu_mismatch(iface: CoreInterface) -> bool:
@ -57,22 +58,22 @@ def get_router_id(node: CoreNodeBase) -> str:
class Zebra(ConfigService): class Zebra(ConfigService):
name = "zebra" name: str = "zebra"
group = GROUP group: str = GROUP
directories = ["/usr/local/etc/quagga", "/var/run/quagga"] directories: List[str] = ["/usr/local/etc/quagga", "/var/run/quagga"]
files = [ 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 = ["zebra"] executables: List[str] = ["zebra"]
dependencies = [] dependencies: List[str] = []
startup = ["sh quaggaboot.sh zebra"] startup: List[str] = ["sh quaggaboot.sh zebra"]
validate = ["pidof zebra"] validate: List[str] = ["pidof zebra"]
shutdown = ["killall zebra"] shutdown: List[str] = ["killall zebra"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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_config( quagga_bin_search = self.node.session.options.get_config(
@ -90,6 +91,8 @@ class Zebra(ConfigService):
for service in self.node.config_services.values(): for service in self.node.config_services.values():
if self.name not in service.dependencies: if self.name not in service.dependencies:
continue continue
if not isinstance(service, QuaggaService):
continue
if service.ipv4_routing: if service.ipv4_routing:
want_ip4 = True want_ip4 = True
if service.ipv6_routing: if service.ipv6_routing:
@ -122,19 +125,19 @@ class Zebra(ConfigService):
class QuaggaService(abc.ABC): class QuaggaService(abc.ABC):
group = GROUP group: str = GROUP
directories = [] directories: List[str] = []
files = [] files: List[str] = []
executables = [] executables: List[str] = []
dependencies = ["zebra"] dependencies: List[str] = ["zebra"]
startup = [] startup: List[str] = []
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
ipv4_routing = False ipv4_routing: bool = False
ipv6_routing = False ipv6_routing: bool = False
@abc.abstractmethod @abc.abstractmethod
def quagga_iface_config(self, iface: CoreInterface) -> str: def quagga_iface_config(self, iface: CoreInterface) -> str:
@ -152,10 +155,10 @@ class Ospfv2(QuaggaService, ConfigService):
unified Quagga.conf file. unified Quagga.conf file.
""" """
name = "OSPFv2" name: str = "OSPFv2"
validate = ["pidof ospfd"] validate: List[str] = ["pidof ospfd"]
shutdown = ["killall ospfd"] shutdown: List[str] = ["killall ospfd"]
ipv4_routing = True ipv4_routing: bool = True
def quagga_iface_config(self, iface: CoreInterface) -> str: def quagga_iface_config(self, iface: CoreInterface) -> str:
if has_mtu_mismatch(iface): if has_mtu_mismatch(iface):
@ -190,11 +193,11 @@ class Ospfv3(QuaggaService, ConfigService):
unified Quagga.conf file. unified Quagga.conf file.
""" """
name = "OSPFv3" name: str = "OSPFv3"
shutdown = ("killall ospf6d",) shutdown: List[str] = ["killall ospf6d"]
validate = ("pidof ospf6d",) validate: List[str] = ["pidof ospf6d"]
ipv4_routing = True ipv4_routing: bool = True
ipv6_routing = True ipv6_routing: bool = True
def quagga_iface_config(self, iface: CoreInterface) -> str: def quagga_iface_config(self, iface: CoreInterface) -> str:
mtu = get_min_mtu(iface) mtu = get_min_mtu(iface)
@ -229,7 +232,7 @@ class Ospfv3mdr(Ospfv3):
unified Quagga.conf file. unified Quagga.conf file.
""" """
name = "OSPFv3MDR" name: str = "OSPFv3MDR"
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
for iface in self.node.get_ifaces(): for iface in self.node.get_ifaces():
@ -262,11 +265,11 @@ class Bgp(QuaggaService, ConfigService):
having the same AS number. having the same AS number.
""" """
name = "BGP" name: str = "BGP"
shutdown = ["killall bgpd"] shutdown: List[str] = ["killall bgpd"]
validate = ["pidof bgpd"] validate: List[str] = ["pidof bgpd"]
ipv4_routing = True ipv4_routing: bool = True
ipv6_routing = True ipv6_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
return "" return ""
@ -291,10 +294,10 @@ class Rip(QuaggaService, ConfigService):
The RIP service provides IPv4 routing for wired networks. The RIP service provides IPv4 routing for wired networks.
""" """
name = "RIP" name: str = "RIP"
shutdown = ["killall ripd"] shutdown: List[str] = ["killall ripd"]
validate = ["pidof ripd"] validate: List[str] = ["pidof ripd"]
ipv4_routing = True ipv4_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
text = """ text = """
@ -316,10 +319,10 @@ class Ripng(QuaggaService, ConfigService):
The RIP NG service provides IPv6 routing for wired networks. The RIP NG service provides IPv6 routing for wired networks.
""" """
name = "RIPNG" name: str = "RIPNG"
shutdown = ["killall ripngd"] shutdown: List[str] = ["killall ripngd"]
validate = ["pidof ripngd"] validate: List[str] = ["pidof ripngd"]
ipv6_routing = True ipv6_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
text = """ text = """
@ -342,10 +345,10 @@ class Babel(QuaggaService, ConfigService):
protocol for IPv6 and IPv4 with fast convergence properties. protocol for IPv6 and IPv4 with fast convergence properties.
""" """
name = "Babel" name: str = "Babel"
shutdown = ["killall babeld"] shutdown: List[str] = ["killall babeld"]
validate = ["pidof babeld"] validate: List[str] = ["pidof babeld"]
ipv6_routing = True ipv6_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
ifnames = [] ifnames = []
@ -382,10 +385,10 @@ class Xpimd(QuaggaService, ConfigService):
PIM multicast routing based on XORP. PIM multicast routing based on XORP.
""" """
name = "Xpimd" name: str = "Xpimd"
shutdown = ["killall xpimd"] shutdown: List[str] = ["killall xpimd"]
validate = ["pidof xpimd"] validate: List[str] = ["pidof xpimd"]
ipv4_routing = True ipv4_routing: bool = True
def quagga_config(self) -> str: def quagga_config(self) -> str:
ifname = "eth0" ifname = "eth0"

View file

@ -1,4 +1,4 @@
from typing import Any, Dict from typing import Any, Dict, List
import netaddr import netaddr
@ -6,21 +6,21 @@ from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
from core.emulator.enumerations import ConfigDataTypes from core.emulator.enumerations import ConfigDataTypes
GROUP_NAME = "Security" GROUP_NAME: str = "Security"
class VpnClient(ConfigService): class VpnClient(ConfigService):
name = "VPNClient" name: str = "VPNClient"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["vpnclient.sh"] files: List[str] = ["vpnclient.sh"]
executables = ["openvpn", "ip", "killall"] executables: List[str] = ["openvpn", "ip", "killall"]
dependencies = [] dependencies: List[str] = []
startup = ["sh vpnclient.sh"] startup: List[str] = ["sh vpnclient.sh"]
validate = ["pidof openvpn"] validate: List[str] = ["pidof openvpn"]
shutdown = ["killall openvpn"] shutdown: List[str] = ["killall openvpn"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [ default_configs: List[Configuration] = [
Configuration( Configuration(
_id="keydir", _id="keydir",
_type=ConfigDataTypes.STRING, _type=ConfigDataTypes.STRING,
@ -40,21 +40,21 @@ class VpnClient(ConfigService):
default="10.0.2.10", default="10.0.2.10",
), ),
] ]
modes = {} modes: Dict[str, Dict[str, str]] = {}
class VpnServer(ConfigService): class VpnServer(ConfigService):
name = "VPNServer" name: str = "VPNServer"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["vpnserver.sh"] files: List[str] = ["vpnserver.sh"]
executables = ["openvpn", "ip", "killall"] executables: List[str] = ["openvpn", "ip", "killall"]
dependencies = [] dependencies: List[str] = []
startup = ["sh vpnserver.sh"] startup: List[str] = ["sh vpnserver.sh"]
validate = ["pidof openvpn"] validate: List[str] = ["pidof openvpn"]
shutdown = ["killall openvpn"] shutdown: List[str] = ["killall openvpn"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [ default_configs: List[Configuration] = [
Configuration( Configuration(
_id="keydir", _id="keydir",
_type=ConfigDataTypes.STRING, _type=ConfigDataTypes.STRING,
@ -74,7 +74,7 @@ class VpnServer(ConfigService):
default="10.0.200.0", default="10.0.200.0",
), ),
] ]
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
address = None address = None
@ -87,48 +87,48 @@ class VpnServer(ConfigService):
class IPsec(ConfigService): class IPsec(ConfigService):
name = "IPsec" name: str = "IPsec"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["ipsec.sh"] files: List[str] = ["ipsec.sh"]
executables = ["racoon", "ip", "setkey", "killall"] executables: List[str] = ["racoon", "ip", "setkey", "killall"]
dependencies = [] dependencies: List[str] = []
startup = ["sh ipsec.sh"] startup: List[str] = ["sh ipsec.sh"]
validate = ["pidof racoon"] validate: List[str] = ["pidof racoon"]
shutdown = ["killall racoon"] shutdown: List[str] = ["killall racoon"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
class Firewall(ConfigService): class Firewall(ConfigService):
name = "Firewall" name: str = "Firewall"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["firewall.sh"] files: List[str] = ["firewall.sh"]
executables = ["iptables"] executables: List[str] = ["iptables"]
dependencies = [] dependencies: List[str] = []
startup = ["sh firewall.sh"] startup: List[str] = ["sh firewall.sh"]
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
class Nat(ConfigService): class Nat(ConfigService):
name = "NAT" name: str = "NAT"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["nat.sh"] files: List[str] = ["nat.sh"]
executables = ["iptables"] executables: List[str] = ["iptables"]
dependencies = [] dependencies: List[str] = []
startup = ["sh nat.sh"] startup: List[str] = ["sh nat.sh"]
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifnames = [] ifnames = []

View file

@ -1,20 +1,22 @@
from typing import Dict, List
from core.config import Configuration from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
from core.emulator.enumerations import ConfigDataTypes from core.emulator.enumerations import ConfigDataTypes
class SimpleService(ConfigService): class SimpleService(ConfigService):
name = "Simple" name: str = "Simple"
group = "SimpleGroup" group: str = "SimpleGroup"
directories = ["/etc/quagga", "/usr/local/lib"] directories: List[str] = ["/etc/quagga", "/usr/local/lib"]
files = ["test1.sh", "test2.sh"] files: List[str] = ["test1.sh", "test2.sh"]
executables = [] executables: List[str] = []
dependencies = [] dependencies: List[str] = []
startup = [] startup: List[str] = []
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [ default_configs: List[Configuration] = [
Configuration(_id="value1", _type=ConfigDataTypes.STRING, label="Text"), Configuration(_id="value1", _type=ConfigDataTypes.STRING, label="Text"),
Configuration(_id="value2", _type=ConfigDataTypes.BOOL, label="Boolean"), Configuration(_id="value2", _type=ConfigDataTypes.BOOL, label="Boolean"),
Configuration( Configuration(
@ -24,7 +26,7 @@ class SimpleService(ConfigService):
options=["value1", "value2", "value3"], options=["value1", "value2", "value3"],
), ),
] ]
modes = { modes: Dict[str, Dict[str, str]] = {
"mode1": {"value1": "value1", "value2": "0", "value3": "value2"}, "mode1": {"value1": "value1", "value2": "0", "value3": "value2"},
"mode2": {"value1": "value2", "value2": "1", "value3": "value3"}, "mode2": {"value1": "value2", "value2": "1", "value3": "value3"},
"mode3": {"value1": "value3", "value2": "0", "value3": "value1"}, "mode3": {"value1": "value3", "value2": "0", "value3": "value1"},

View file

@ -1,26 +1,27 @@
from typing import Any, Dict from typing import Any, Dict, List
import netaddr import netaddr
from core import utils from core import utils
from core.config import Configuration
from core.configservice.base import ConfigService, ConfigServiceMode from core.configservice.base import ConfigService, ConfigServiceMode
GROUP_NAME = "Utility" GROUP_NAME = "Utility"
class DefaultRouteService(ConfigService): class DefaultRouteService(ConfigService):
name = "DefaultRoute" name: str = "DefaultRoute"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["defaultroute.sh"] files: List[str] = ["defaultroute.sh"]
executables = ["ip"] executables: List[str] = ["ip"]
dependencies = [] dependencies: List[str] = []
startup = ["sh defaultroute.sh"] startup: List[str] = ["sh defaultroute.sh"]
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} 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
@ -37,18 +38,18 @@ class DefaultRouteService(ConfigService):
class DefaultMulticastRouteService(ConfigService): class DefaultMulticastRouteService(ConfigService):
name = "DefaultMulticastRoute" name: str = "DefaultMulticastRoute"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["defaultmroute.sh"] files: List[str] = ["defaultmroute.sh"]
executables = [] executables: List[str] = []
dependencies = [] dependencies: List[str] = []
startup = ["sh defaultmroute.sh"] startup: List[str] = ["sh defaultmroute.sh"]
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifname = None ifname = None
@ -59,18 +60,18 @@ class DefaultMulticastRouteService(ConfigService):
class StaticRouteService(ConfigService): class StaticRouteService(ConfigService):
name = "StaticRoute" name: str = "StaticRoute"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["staticroute.sh"] files: List[str] = ["staticroute.sh"]
executables = [] executables: List[str] = []
dependencies = [] dependencies: List[str] = []
startup = ["sh staticroute.sh"] startup: List[str] = ["sh staticroute.sh"]
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
routes = [] routes = []
@ -88,18 +89,18 @@ class StaticRouteService(ConfigService):
class IpForwardService(ConfigService): class IpForwardService(ConfigService):
name = "IPForward" name: str = "IPForward"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["ipforward.sh"] files: List[str] = ["ipforward.sh"]
executables = ["sysctl"] executables: List[str] = ["sysctl"]
dependencies = [] dependencies: List[str] = []
startup = ["sh ipforward.sh"] startup: List[str] = ["sh ipforward.sh"]
validate = [] validate: List[str] = []
shutdown = [] shutdown: List[str] = []
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
devnames = [] devnames = []
@ -110,18 +111,18 @@ class IpForwardService(ConfigService):
class SshService(ConfigService): class SshService(ConfigService):
name = "SSH" name: str = "SSH"
group = GROUP_NAME group: str = GROUP_NAME
directories = ["/etc/ssh", "/var/run/sshd"] directories: List[str] = ["/etc/ssh", "/var/run/sshd"]
files = ["startsshd.sh", "/etc/ssh/sshd_config"] files: List[str] = ["startsshd.sh", "/etc/ssh/sshd_config"]
executables = ["sshd"] executables: List[str] = ["sshd"]
dependencies = [] dependencies: List[str] = []
startup = ["sh startsshd.sh"] startup: List[str] = ["sh startsshd.sh"]
validate = [] validate: List[str] = []
shutdown = ["killall sshd"] shutdown: List[str] = ["killall sshd"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
return dict( return dict(
@ -132,18 +133,18 @@ class SshService(ConfigService):
class DhcpService(ConfigService): class DhcpService(ConfigService):
name = "DHCP" name: str = "DHCP"
group = GROUP_NAME group: str = GROUP_NAME
directories = ["/etc/dhcp", "/var/lib/dhcp"] directories: List[str] = ["/etc/dhcp", "/var/lib/dhcp"]
files = ["/etc/dhcp/dhcpd.conf"] files: List[str] = ["/etc/dhcp/dhcpd.conf"]
executables = ["dhcpd"] executables: List[str] = ["dhcpd"]
dependencies = [] dependencies: List[str] = []
startup = ["touch /var/lib/dhcp/dhcpd.leases", "dhcpd"] startup: List[str] = ["touch /var/lib/dhcp/dhcpd.leases", "dhcpd"]
validate = ["pidof dhcpd"] validate: List[str] = ["pidof dhcpd"]
shutdown = ["killall dhcpd"] shutdown: List[str] = ["killall dhcpd"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
subnets = [] subnets = []
@ -161,18 +162,18 @@ class DhcpService(ConfigService):
class DhcpClientService(ConfigService): class DhcpClientService(ConfigService):
name = "DHCPClient" name: str = "DHCPClient"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["startdhcpclient.sh"] files: List[str] = ["startdhcpclient.sh"]
executables = ["dhclient"] executables: List[str] = ["dhclient"]
dependencies = [] dependencies: List[str] = []
startup = ["sh startdhcpclient.sh"] startup: List[str] = ["sh startdhcpclient.sh"]
validate = ["pidof dhclient"] validate: List[str] = ["pidof dhclient"]
shutdown = ["killall dhclient"] shutdown: List[str] = ["killall dhclient"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifnames = [] ifnames = []
@ -182,33 +183,33 @@ class DhcpClientService(ConfigService):
class FtpService(ConfigService): class FtpService(ConfigService):
name = "FTP" name: str = "FTP"
group = GROUP_NAME group: str = GROUP_NAME
directories = ["/var/run/vsftpd/empty", "/var/ftp"] directories: List[str] = ["/var/run/vsftpd/empty", "/var/ftp"]
files = ["vsftpd.conf"] files: List[str] = ["vsftpd.conf"]
executables = ["vsftpd"] executables: List[str] = ["vsftpd"]
dependencies = [] dependencies: List[str] = []
startup = ["vsftpd ./vsftpd.conf"] startup: List[str] = ["vsftpd ./vsftpd.conf"]
validate = ["pidof vsftpd"] validate: List[str] = ["pidof vsftpd"]
shutdown = ["killall vsftpd"] shutdown: List[str] = ["killall vsftpd"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
class PcapService(ConfigService): class PcapService(ConfigService):
name = "pcap" name: str = "pcap"
group = GROUP_NAME group: str = GROUP_NAME
directories = [] directories: List[str] = []
files = ["pcap.sh"] files: List[str] = ["pcap.sh"]
executables = ["tcpdump"] executables: List[str] = ["tcpdump"]
dependencies = [] dependencies: List[str] = []
startup = ["sh pcap.sh start"] startup: List[str] = ["sh pcap.sh start"]
validate = ["pidof tcpdump"] validate: List[str] = ["pidof tcpdump"]
shutdown = ["sh pcap.sh stop"] shutdown: List[str] = ["sh pcap.sh stop"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifnames = [] ifnames = []
@ -218,18 +219,20 @@ class PcapService(ConfigService):
class RadvdService(ConfigService): class RadvdService(ConfigService):
name = "radvd" name: str = "radvd"
group = GROUP_NAME group: str = GROUP_NAME
directories = ["/etc/radvd"] directories: List[str] = ["/etc/radvd"]
files = ["/etc/radvd/radvd.conf"] files: List[str] = ["/etc/radvd/radvd.conf"]
executables = ["radvd"] executables: List[str] = ["radvd"]
dependencies = [] dependencies: List[str] = []
startup = ["radvd -C /etc/radvd/radvd.conf -m logfile -l /var/log/radvd.log"] startup: List[str] = [
validate = ["pidof radvd"] "radvd -C /etc/radvd/radvd.conf -m logfile -l /var/log/radvd.log"
shutdown = ["pkill radvd"] ]
validation_mode = ConfigServiceMode.BLOCKING validate: List[str] = ["pidof radvd"]
default_configs = [] shutdown: List[str] = ["pkill radvd"]
modes = {} validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = []
modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifaces = [] ifaces = []
@ -246,24 +249,24 @@ class RadvdService(ConfigService):
class AtdService(ConfigService): class AtdService(ConfigService):
name = "atd" name: str = "atd"
group = GROUP_NAME group: str = GROUP_NAME
directories = ["/var/spool/cron/atjobs", "/var/spool/cron/atspool"] directories: List[str] = ["/var/spool/cron/atjobs", "/var/spool/cron/atspool"]
files = ["startatd.sh"] files: List[str] = ["startatd.sh"]
executables = ["atd"] executables: List[str] = ["atd"]
dependencies = [] dependencies: List[str] = []
startup = ["sh startatd.sh"] startup: List[str] = ["sh startatd.sh"]
validate = ["pidof atd"] validate: List[str] = ["pidof atd"]
shutdown = ["pkill atd"] shutdown: List[str] = ["pkill atd"]
validation_mode = ConfigServiceMode.BLOCKING validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs = [] default_configs: List[Configuration] = []
modes = {} modes: Dict[str, Dict[str, str]] = {}
class HttpService(ConfigService): class HttpService(ConfigService):
name = "HTTP" name: str = "HTTP"
group = GROUP_NAME group: str = GROUP_NAME
directories = [ directories: List[str] = [
"/etc/apache2", "/etc/apache2",
"/var/run/apache2", "/var/run/apache2",
"/var/log/apache2", "/var/log/apache2",
@ -271,15 +274,19 @@ class HttpService(ConfigService):
"/var/lock/apache2", "/var/lock/apache2",
"/var/www", "/var/www",
] ]
files = ["/etc/apache2/apache2.conf", "/etc/apache2/envvars", "/var/www/index.html"] files: List[str] = [
executables = ["apache2ctl"] "/etc/apache2/apache2.conf",
dependencies = [] "/etc/apache2/envvars",
startup = ["chown www-data /var/lock/apache2", "apache2ctl start"] "/var/www/index.html",
validate = ["pidof apache2"] ]
shutdown = ["apache2ctl stop"] executables: List[str] = ["apache2ctl"]
validation_mode = ConfigServiceMode.BLOCKING dependencies: List[str] = []
default_configs = [] startup: List[str] = ["chown www-data /var/lock/apache2", "apache2ctl start"]
modes = {} validate: List[str] = ["pidof apache2"]
shutdown: List[str] = ["apache2ctl stop"]
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
default_configs: List[Configuration] = []
modes: Dict[str, Dict[str, str]] = {}
def data(self) -> Dict[str, Any]: def data(self) -> Dict[str, Any]:
ifaces = [] ifaces = []