moved config values to simple service from default route, fixed coretk issue with config service config data
This commit is contained in:
parent
80a4955bd4
commit
1ca3b0e3f4
3 changed files with 15 additions and 9 deletions
|
@ -3,9 +3,7 @@ from typing import Any, Dict
|
|||
import netaddr
|
||||
|
||||
from core import utils
|
||||
from core.config import Configuration
|
||||
from core.configservice.base import ConfigService, ConfigServiceMode
|
||||
from core.emulator.enumerations import ConfigDataTypes
|
||||
|
||||
GROUP_NAME = "Utility"
|
||||
|
||||
|
@ -21,11 +19,7 @@ class DefaultRoute(ConfigService):
|
|||
validate = []
|
||||
shutdown = []
|
||||
validation_mode = ConfigServiceMode.BLOCKING
|
||||
default_configs = [
|
||||
Configuration(_id="value1", _type=ConfigDataTypes.STRING, label="Value 1"),
|
||||
Configuration(_id="value2", _type=ConfigDataTypes.STRING, label="Value 2"),
|
||||
Configuration(_id="value3", _type=ConfigDataTypes.STRING, label="Value 3"),
|
||||
]
|
||||
default_configs = []
|
||||
|
||||
def data(self) -> Dict[str, Any]:
|
||||
addresses = []
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from core.config import Configuration
|
||||
from core.configservice.base import ConfigService, ConfigServiceMode
|
||||
from core.emulator.enumerations import ConfigDataTypes
|
||||
|
||||
|
||||
class SimpleService(ConfigService):
|
||||
|
@ -12,18 +14,24 @@ class SimpleService(ConfigService):
|
|||
validate = []
|
||||
shutdown = []
|
||||
validation_mode = ConfigServiceMode.BLOCKING
|
||||
default_configs = []
|
||||
default_configs = [
|
||||
Configuration(_id="value1", _type=ConfigDataTypes.STRING, label="Value 1"),
|
||||
Configuration(_id="value2", _type=ConfigDataTypes.STRING, label="Value 2"),
|
||||
Configuration(_id="value3", _type=ConfigDataTypes.STRING, label="Value 3"),
|
||||
]
|
||||
|
||||
def get_text(self, name: str) -> str:
|
||||
if name == "test1.sh":
|
||||
return """
|
||||
# sample script 1
|
||||
# node id(${node.id}) name(${node.name})
|
||||
# config: ${config}
|
||||
echo hello
|
||||
"""
|
||||
elif name == "test2.sh":
|
||||
return """
|
||||
# sample script 2
|
||||
# node id(${node.id}) name(${node.name})
|
||||
# config: ${config}
|
||||
echo hello2
|
||||
"""
|
||||
|
|
|
@ -879,11 +879,15 @@ class CoreClient:
|
|||
config_service_protos = []
|
||||
for node_id, node_config in self.config_service_configs.items():
|
||||
for name, service_config in node_config.items():
|
||||
config = service_config.get("config", {})
|
||||
config_values = {}
|
||||
for key, option in config.items():
|
||||
config_values[key] = option.value
|
||||
config_proto = configservices_pb2.ConfigServiceConfig(
|
||||
node_id=node_id,
|
||||
name=name,
|
||||
templates=service_config["templates"],
|
||||
config=service_config.get("config"),
|
||||
config=config_values,
|
||||
)
|
||||
config_service_protos.append(config_proto)
|
||||
return config_service_protos
|
||||
|
|
Loading…
Add table
Reference in a new issue