daemon: updates to provide config types for configurable values, without the need to specify the enumerated type
This commit is contained in:
parent
bd3e2f5d0e
commit
22e92111d0
10 changed files with 115 additions and 240 deletions
|
@ -36,7 +36,7 @@ class ConfigGroup:
|
||||||
@dataclass
|
@dataclass
|
||||||
class Configuration:
|
class Configuration:
|
||||||
"""
|
"""
|
||||||
Represents a configuration options.
|
Represents a configuration option.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
id: str
|
id: str
|
||||||
|
@ -71,6 +71,42 @@ class Configuration:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConfigBool(Configuration):
|
||||||
|
"""
|
||||||
|
Represents a boolean configuration option.
|
||||||
|
"""
|
||||||
|
|
||||||
|
type: ConfigDataTypes = ConfigDataTypes.BOOL
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConfigFloat(Configuration):
|
||||||
|
"""
|
||||||
|
Represents a float configuration option.
|
||||||
|
"""
|
||||||
|
|
||||||
|
type: ConfigDataTypes = ConfigDataTypes.FLOAT
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConfigInt(Configuration):
|
||||||
|
"""
|
||||||
|
Represents an integer configuration option.
|
||||||
|
"""
|
||||||
|
|
||||||
|
type: ConfigDataTypes = ConfigDataTypes.INT32
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ConfigString(Configuration):
|
||||||
|
"""
|
||||||
|
Represents a string configuration option.
|
||||||
|
"""
|
||||||
|
|
||||||
|
type: ConfigDataTypes = ConfigDataTypes.STRING
|
||||||
|
|
||||||
|
|
||||||
class ConfigurableOptions:
|
class ConfigurableOptions:
|
||||||
"""
|
"""
|
||||||
Provides a base for defining configuration options within CORE.
|
Provides a base for defining configuration options within CORE.
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from core.config import Configuration
|
from core.config import ConfigString, Configuration
|
||||||
from core.configservice.base import ConfigService, ConfigServiceMode
|
from core.configservice.base import ConfigService, ConfigServiceMode
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
|
|
||||||
GROUP_NAME: str = "Security"
|
GROUP_NAME: str = "Security"
|
||||||
|
|
||||||
|
@ -19,24 +18,9 @@ class VpnClient(ConfigService):
|
||||||
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] = [
|
||||||
Configuration(
|
ConfigString(id="keydir", label="Key Dir", default="/etc/core/keys"),
|
||||||
id="keydir",
|
ConfigString(id="keyname", label="Key Name", default="client1"),
|
||||||
type=ConfigDataTypes.STRING,
|
ConfigString(id="server", label="Server", default="10.0.2.10"),
|
||||||
label="Key Dir",
|
|
||||||
default="/etc/core/keys",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="keyname",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Key Name",
|
|
||||||
default="client1",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="server",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Server",
|
|
||||||
default="10.0.2.10",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
modes: Dict[str, Dict[str, str]] = {}
|
modes: Dict[str, Dict[str, str]] = {}
|
||||||
|
|
||||||
|
@ -53,24 +37,9 @@ class VpnServer(ConfigService):
|
||||||
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] = [
|
||||||
Configuration(
|
ConfigString(id="keydir", label="Key Dir", default="/etc/core/keys"),
|
||||||
id="keydir",
|
ConfigString(id="keyname", label="Key Name", default="server"),
|
||||||
type=ConfigDataTypes.STRING,
|
ConfigString(id="subnet", label="Subnet", default="10.0.200.0"),
|
||||||
label="Key Dir",
|
|
||||||
default="/etc/core/keys",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="keyname",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Key Name",
|
|
||||||
default="server",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="subnet",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Subnet",
|
|
||||||
default="10.0.200.0",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
modes: Dict[str, Dict[str, str]] = {}
|
modes: Dict[str, Dict[str, str]] = {}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@ import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional, Set
|
from typing import Dict, List, Optional, Set
|
||||||
|
|
||||||
from core.config import ConfigGroup, Configuration
|
from core.config import ConfigBool, ConfigGroup, ConfigString, Configuration
|
||||||
from core.emane import emanemanifest
|
from core.emane import emanemanifest
|
||||||
from core.emulator.data import LinkOptions
|
from core.emulator.data import LinkOptions
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
from core.errors import CoreError
|
from core.errors import CoreError
|
||||||
from core.location.mobility import WirelessModel
|
from core.location.mobility import WirelessModel
|
||||||
from core.nodes.interface import CoreInterface
|
from core.nodes.interface import CoreInterface
|
||||||
|
@ -55,13 +54,9 @@ class EmaneModel(WirelessModel):
|
||||||
|
|
||||||
# support for external configurations
|
# support for external configurations
|
||||||
external_config: List[Configuration] = [
|
external_config: List[Configuration] = [
|
||||||
Configuration("external", ConfigDataTypes.BOOL, default="0"),
|
ConfigBool(id="external", default="0"),
|
||||||
Configuration(
|
ConfigString(id="platformendpoint", default="127.0.0.1:40001"),
|
||||||
"platformendpoint", ConfigDataTypes.STRING, default="127.0.0.1:40001"
|
ConfigString(id="transportendpoint", default="127.0.0.1:50002"),
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
"transportendpoint", ConfigDataTypes.STRING, default="127.0.0.1:50002"
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
config_ignore: Set[str] = set()
|
config_ignore: Set[str] = set()
|
||||||
|
|
|
@ -4,9 +4,8 @@ EMANE Bypass model for CORE
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Set
|
from typing import List, Set
|
||||||
|
|
||||||
from core.config import Configuration
|
from core.config import ConfigBool, Configuration
|
||||||
from core.emane import emanemodel
|
from core.emane import emanemodel
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
|
|
||||||
|
|
||||||
class EmaneBypassModel(emanemodel.EmaneModel):
|
class EmaneBypassModel(emanemodel.EmaneModel):
|
||||||
|
@ -18,9 +17,8 @@ class EmaneBypassModel(emanemodel.EmaneModel):
|
||||||
# mac definitions
|
# mac definitions
|
||||||
mac_library: str = "bypassmaclayer"
|
mac_library: str = "bypassmaclayer"
|
||||||
mac_config: List[Configuration] = [
|
mac_config: List[Configuration] = [
|
||||||
Configuration(
|
ConfigBool(
|
||||||
id="none",
|
id="none",
|
||||||
type=ConfigDataTypes.BOOL,
|
|
||||||
default="0",
|
default="0",
|
||||||
label="There are no parameters for the bypass model.",
|
label="There are no parameters for the bypass model.",
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,10 +7,9 @@ from pathlib import Path
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
|
||||||
from core import constants, utils
|
from core import constants, utils
|
||||||
from core.config import Configuration
|
from core.config import ConfigString
|
||||||
from core.emane import emanemodel
|
from core.emane import emanemodel
|
||||||
from core.emane.nodes import EmaneNet
|
from core.emane.nodes import EmaneNet
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
from core.nodes.interface import CoreInterface
|
from core.nodes.interface import CoreInterface
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -38,9 +37,8 @@ class EmaneTdmaModel(emanemodel.EmaneModel):
|
||||||
/ "share/emane/xml/models/mac/tdmaeventscheduler/tdmabasemodelpcr.xml"
|
/ "share/emane/xml/models/mac/tdmaeventscheduler/tdmabasemodelpcr.xml"
|
||||||
)
|
)
|
||||||
super().load(emane_prefix)
|
super().load(emane_prefix)
|
||||||
config_item = Configuration(
|
config_item = ConfigString(
|
||||||
id=cls.schedule_name,
|
id=cls.schedule_name,
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
default=str(cls.default_schedule),
|
default=str(cls.default_schedule),
|
||||||
label="TDMA schedule file (core)",
|
label="TDMA schedule file (core)",
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
|
|
||||||
from core.config import ConfigurableManager, ConfigurableOptions, Configuration
|
from core.config import (
|
||||||
from core.emulator.enumerations import ConfigDataTypes, RegisterTlvs
|
ConfigBool,
|
||||||
|
ConfigInt,
|
||||||
|
ConfigString,
|
||||||
|
ConfigurableManager,
|
||||||
|
ConfigurableOptions,
|
||||||
|
Configuration,
|
||||||
|
)
|
||||||
|
from core.emulator.enumerations import RegisterTlvs
|
||||||
from core.plugins.sdt import Sdt
|
from core.plugins.sdt import Sdt
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,89 +19,27 @@ class SessionConfig(ConfigurableManager, ConfigurableOptions):
|
||||||
|
|
||||||
name: str = "session"
|
name: str = "session"
|
||||||
options: List[Configuration] = [
|
options: List[Configuration] = [
|
||||||
Configuration(
|
ConfigString(id="controlnet", label="Control Network"),
|
||||||
id="controlnet", type=ConfigDataTypes.STRING, label="Control Network"
|
ConfigString(id="controlnet0", label="Control Network 0"),
|
||||||
|
ConfigString(id="controlnet1", label="Control Network 1"),
|
||||||
|
ConfigString(id="controlnet2", label="Control Network 2"),
|
||||||
|
ConfigString(id="controlnet3", label="Control Network 3"),
|
||||||
|
ConfigString(id="controlnet_updown_script", label="Control Network Script"),
|
||||||
|
ConfigBool(id="enablerj45", default="1", label="Enable RJ45s"),
|
||||||
|
ConfigBool(id="preservedir", default="0", label="Preserve session dir"),
|
||||||
|
ConfigBool(id="enablesdt", default="0", label="Enable SDT3D output"),
|
||||||
|
ConfigString(id="sdturl", default=Sdt.DEFAULT_SDT_URL, label="SDT3D URL"),
|
||||||
|
ConfigBool(id="ovs", default="0", label="Enable OVS"),
|
||||||
|
ConfigInt(id="platform_id_start", default="1", label="EMANE Platform ID Start"),
|
||||||
|
ConfigInt(id="nem_id_start", default="1", label="EMANE NEM ID Start"),
|
||||||
|
ConfigBool(id="link_enabled", default="1", label="EMANE Links?"),
|
||||||
|
ConfigInt(
|
||||||
|
id="loss_threshold", default="30", label="EMANE Link Loss Threshold (%)"
|
||||||
),
|
),
|
||||||
Configuration(
|
ConfigInt(
|
||||||
id="controlnet0", type=ConfigDataTypes.STRING, label="Control Network 0"
|
id="link_interval", default="1", label="EMANE Link Check Interval (sec)"
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="controlnet1", type=ConfigDataTypes.STRING, label="Control Network 1"
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="controlnet2", type=ConfigDataTypes.STRING, label="Control Network 2"
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="controlnet3", type=ConfigDataTypes.STRING, label="Control Network 3"
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="controlnet_updown_script",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Control Network Script",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="enablerj45",
|
|
||||||
type=ConfigDataTypes.BOOL,
|
|
||||||
default="1",
|
|
||||||
label="Enable RJ45s",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="preservedir",
|
|
||||||
type=ConfigDataTypes.BOOL,
|
|
||||||
default="0",
|
|
||||||
label="Preserve session dir",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="enablesdt",
|
|
||||||
type=ConfigDataTypes.BOOL,
|
|
||||||
default="0",
|
|
||||||
label="Enable SDT3D output",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="sdturl",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
default=Sdt.DEFAULT_SDT_URL,
|
|
||||||
label="SDT3D URL",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="ovs", type=ConfigDataTypes.BOOL, default="0", label="Enable OVS"
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="platform_id_start",
|
|
||||||
type=ConfigDataTypes.INT32,
|
|
||||||
default="1",
|
|
||||||
label="EMANE Platform ID Start",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="nem_id_start",
|
|
||||||
type=ConfigDataTypes.INT32,
|
|
||||||
default="1",
|
|
||||||
label="EMANE NEM ID Start",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="link_enabled",
|
|
||||||
type=ConfigDataTypes.BOOL,
|
|
||||||
default="1",
|
|
||||||
label="EMANE Links?",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="loss_threshold",
|
|
||||||
type=ConfigDataTypes.INT32,
|
|
||||||
default="30",
|
|
||||||
label="EMANE Link Loss Threshold (%)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="link_interval",
|
|
||||||
type=ConfigDataTypes.INT32,
|
|
||||||
default="1",
|
|
||||||
label="EMANE Link Check Interval (sec)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="link_timeout",
|
|
||||||
type=ConfigDataTypes.INT32,
|
|
||||||
default="4",
|
|
||||||
label="EMANE Link Timeout (sec)",
|
|
||||||
),
|
),
|
||||||
|
ConfigInt(id="link_timeout", default="4", label="EMANE Link Timeout (sec)"),
|
||||||
]
|
]
|
||||||
config_type: RegisterTlvs = RegisterTlvs.UTILITY
|
config_type: RegisterTlvs = RegisterTlvs.UTILITY
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,18 @@ from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union
|
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from core import utils
|
from core import utils
|
||||||
from core.config import ConfigGroup, ConfigurableOptions, Configuration, ModelManager
|
from core.config import (
|
||||||
|
ConfigBool,
|
||||||
|
ConfigGroup,
|
||||||
|
ConfigInt,
|
||||||
|
ConfigString,
|
||||||
|
ConfigurableOptions,
|
||||||
|
Configuration,
|
||||||
|
ModelManager,
|
||||||
|
)
|
||||||
from core.emane.nodes import EmaneNet
|
from core.emane.nodes import EmaneNet
|
||||||
from core.emulator.data import EventData, LinkData, LinkOptions
|
from core.emulator.data import EventData, LinkData, LinkOptions
|
||||||
from core.emulator.enumerations import (
|
from core.emulator.enumerations import EventTypes, LinkTypes, MessageFlags, RegisterTlvs
|
||||||
ConfigDataTypes,
|
|
||||||
EventTypes,
|
|
||||||
LinkTypes,
|
|
||||||
MessageFlags,
|
|
||||||
RegisterTlvs,
|
|
||||||
)
|
|
||||||
from core.errors import CoreError
|
from core.errors import CoreError
|
||||||
from core.executables import BASH
|
from core.executables import BASH
|
||||||
from core.nodes.base import CoreNode
|
from core.nodes.base import CoreNode
|
||||||
|
@ -274,39 +276,12 @@ class BasicRangeModel(WirelessModel):
|
||||||
|
|
||||||
name: str = "basic_range"
|
name: str = "basic_range"
|
||||||
options: List[Configuration] = [
|
options: List[Configuration] = [
|
||||||
Configuration(
|
ConfigInt(id="range", default="275", label="wireless range (pixels)"),
|
||||||
id="range",
|
ConfigInt(id="bandwidth", default="54000000", label="bandwidth (bps)"),
|
||||||
type=ConfigDataTypes.UINT32,
|
ConfigInt(id="jitter", default="0", label="transmission jitter (usec)"),
|
||||||
default="275",
|
ConfigInt(id="delay", default="5000", label="transmission delay (usec)"),
|
||||||
label="wireless range (pixels)",
|
ConfigString(id="error", default="0", label="loss (%)"),
|
||||||
),
|
ConfigBool(id="promiscuous", default="0", label="promiscuous mode"),
|
||||||
Configuration(
|
|
||||||
id="bandwidth",
|
|
||||||
type=ConfigDataTypes.UINT64,
|
|
||||||
default="54000000",
|
|
||||||
label="bandwidth (bps)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="jitter",
|
|
||||||
type=ConfigDataTypes.UINT64,
|
|
||||||
default="0",
|
|
||||||
label="transmission jitter (usec)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="delay",
|
|
||||||
type=ConfigDataTypes.UINT64,
|
|
||||||
default="5000",
|
|
||||||
label="transmission delay (usec)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="error", type=ConfigDataTypes.STRING, default="0", label="loss (%)"
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="promiscuous",
|
|
||||||
type=ConfigDataTypes.BOOL,
|
|
||||||
default="0",
|
|
||||||
label="promiscuous mode",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -887,41 +862,14 @@ class Ns2ScriptedMobility(WayPointMobility):
|
||||||
|
|
||||||
name: str = "ns2script"
|
name: str = "ns2script"
|
||||||
options: List[Configuration] = [
|
options: List[Configuration] = [
|
||||||
Configuration(
|
ConfigString(id="file", label="mobility script file"),
|
||||||
id="file", type=ConfigDataTypes.STRING, label="mobility script file"
|
ConfigInt(id="refresh_ms", default="50", label="refresh time (ms)"),
|
||||||
),
|
ConfigBool(id="loop", default="1", label="loop"),
|
||||||
Configuration(
|
ConfigString(id="autostart", label="auto-start seconds (0.0 for runtime)"),
|
||||||
id="refresh_ms",
|
ConfigString(id="map", label="node mapping (optional, e.g. 0:1,1:2,2:3)"),
|
||||||
type=ConfigDataTypes.UINT32,
|
ConfigString(id="script_start", label="script file to run upon start"),
|
||||||
default="50",
|
ConfigString(id="script_pause", label="script file to run upon pause"),
|
||||||
label="refresh time (ms)",
|
ConfigString(id="script_stop", label="script file to run upon stop"),
|
||||||
),
|
|
||||||
Configuration(id="loop", type=ConfigDataTypes.BOOL, default="1", label="loop"),
|
|
||||||
Configuration(
|
|
||||||
id="autostart",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="auto-start seconds (0.0 for runtime)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="map",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="node mapping (optional, e.g. 0:1,1:2,2:3)",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="script_start",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="script file to run upon start",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="script_pause",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="script file to run upon pause",
|
|
||||||
),
|
|
||||||
Configuration(
|
|
||||||
id="script_stop",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="script file to run upon stop",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from core.config import (
|
from core.config import (
|
||||||
|
ConfigString,
|
||||||
ConfigurableManager,
|
ConfigurableManager,
|
||||||
ConfigurableOptions,
|
ConfigurableOptions,
|
||||||
Configuration,
|
|
||||||
ModelManager,
|
ModelManager,
|
||||||
)
|
)
|
||||||
from core.emane.models.ieee80211abg import EmaneIeee80211abgModel
|
from core.emane.models.ieee80211abg import EmaneIeee80211abgModel
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
from core.emulator.session import Session
|
from core.emulator.session import Session
|
||||||
from core.location.mobility import BasicRangeModel
|
from core.location.mobility import BasicRangeModel
|
||||||
from core.nodes.network import WlanNode
|
from core.nodes.network import WlanNode
|
||||||
|
@ -16,10 +15,7 @@ from core.nodes.network import WlanNode
|
||||||
class TestConfigurableOptions(ConfigurableOptions):
|
class TestConfigurableOptions(ConfigurableOptions):
|
||||||
name1 = "value1"
|
name1 = "value1"
|
||||||
name2 = "value2"
|
name2 = "value2"
|
||||||
options = [
|
options = [ConfigString(id=name1, label=name1), ConfigString(id=name2, label=name2)]
|
||||||
Configuration(id=name1, type=ConfigDataTypes.STRING, label=name1),
|
|
||||||
Configuration(id=name2, type=ConfigDataTypes.STRING, label=name2),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class TestConf:
|
class TestConf:
|
||||||
|
|
|
@ -3,13 +3,12 @@ from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from core.config import Configuration
|
from core.config import ConfigBool, ConfigString
|
||||||
from core.configservice.base import (
|
from core.configservice.base import (
|
||||||
ConfigService,
|
ConfigService,
|
||||||
ConfigServiceBootError,
|
ConfigServiceBootError,
|
||||||
ConfigServiceMode,
|
ConfigServiceMode,
|
||||||
)
|
)
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
from core.errors import CoreCommandError, CoreError
|
from core.errors import CoreCommandError, CoreError
|
||||||
|
|
||||||
TEMPLATE_TEXT = "echo hello"
|
TEMPLATE_TEXT = "echo hello"
|
||||||
|
@ -27,13 +26,10 @@ class MyService(ConfigService):
|
||||||
shutdown = [f"pkill {files[0]}"]
|
shutdown = [f"pkill {files[0]}"]
|
||||||
validation_mode = ConfigServiceMode.BLOCKING
|
validation_mode = ConfigServiceMode.BLOCKING
|
||||||
default_configs = [
|
default_configs = [
|
||||||
Configuration(id="value1", type=ConfigDataTypes.STRING, label="Text"),
|
ConfigString(id="value1", label="Text"),
|
||||||
Configuration(id="value2", type=ConfigDataTypes.BOOL, label="Boolean"),
|
ConfigBool(id="value2", label="Boolean"),
|
||||||
Configuration(
|
ConfigString(
|
||||||
id="value3",
|
id="value3", label="Multiple Choice", options=["value1", "value2", "value3"]
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Multiple Choice",
|
|
||||||
options=["value1", "value2", "value3"],
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
modes = {
|
modes = {
|
||||||
|
|
|
@ -118,9 +118,8 @@ running the shell files generated.
|
||||||
```python
|
```python
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
from core.config import Configuration
|
from core.config import ConfigString, ConfigBool, Configuration
|
||||||
from core.configservice.base import ConfigService, ConfigServiceMode, ShadowDir
|
from core.configservice.base import ConfigService, ConfigServiceMode, ShadowDir
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
|
|
||||||
# class that subclasses ConfigService
|
# class that subclasses ConfigService
|
||||||
class ExampleService(ConfigService):
|
class ExampleService(ConfigService):
|
||||||
|
@ -152,14 +151,9 @@ class ExampleService(ConfigService):
|
||||||
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
|
validation_mode: ConfigServiceMode = ConfigServiceMode.BLOCKING
|
||||||
# configurable values that this service can use, for file generation
|
# configurable values that this service can use, for file generation
|
||||||
default_configs: List[Configuration] = [
|
default_configs: List[Configuration] = [
|
||||||
Configuration(id="value1", type=ConfigDataTypes.STRING, label="Text"),
|
ConfigString(id="value1", label="Text"),
|
||||||
Configuration(id="value2", type=ConfigDataTypes.BOOL, label="Boolean"),
|
ConfigBool(id="value2", label="Boolean"),
|
||||||
Configuration(
|
ConfigString(id="value3", label="Multiple Choice", options=["value1", "value2", "value3"]),
|
||||||
id="value3",
|
|
||||||
type=ConfigDataTypes.STRING,
|
|
||||||
label="Multiple Choice",
|
|
||||||
options=["value1", "value2", "value3"],
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
# sets of values to set for the configuration defined above, can be used to
|
# sets of values to set for the configuration defined above, can be used to
|
||||||
# provide convenient sets of values to typically use
|
# provide convenient sets of values to typically use
|
||||||
|
|
Loading…
Reference in a new issue