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
|
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
|
||||||
from core.emulator.enumerations import ConfigDataTypes
|
|
||||||
|
|
||||||
GROUP_NAME = "Utility"
|
GROUP_NAME = "Utility"
|
||||||
|
|
||||||
|
@ -21,11 +19,7 @@ class DefaultRoute(ConfigService):
|
||||||
validate = []
|
validate = []
|
||||||
shutdown = []
|
shutdown = []
|
||||||
validation_mode = ConfigServiceMode.BLOCKING
|
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 data(self) -> Dict[str, Any]:
|
def data(self) -> Dict[str, Any]:
|
||||||
addresses = []
|
addresses = []
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
class SimpleService(ConfigService):
|
class SimpleService(ConfigService):
|
||||||
|
@ -12,18 +14,24 @@ class SimpleService(ConfigService):
|
||||||
validate = []
|
validate = []
|
||||||
shutdown = []
|
shutdown = []
|
||||||
validation_mode = ConfigServiceMode.BLOCKING
|
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:
|
def get_text(self, name: str) -> str:
|
||||||
if name == "test1.sh":
|
if name == "test1.sh":
|
||||||
return """
|
return """
|
||||||
# sample script 1
|
# sample script 1
|
||||||
# node id(${node.id}) name(${node.name})
|
# node id(${node.id}) name(${node.name})
|
||||||
|
# config: ${config}
|
||||||
echo hello
|
echo hello
|
||||||
"""
|
"""
|
||||||
elif name == "test2.sh":
|
elif name == "test2.sh":
|
||||||
return """
|
return """
|
||||||
# sample script 2
|
# sample script 2
|
||||||
# node id(${node.id}) name(${node.name})
|
# node id(${node.id}) name(${node.name})
|
||||||
|
# config: ${config}
|
||||||
echo hello2
|
echo hello2
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -879,11 +879,15 @@ class CoreClient:
|
||||||
config_service_protos = []
|
config_service_protos = []
|
||||||
for node_id, node_config in self.config_service_configs.items():
|
for node_id, node_config in self.config_service_configs.items():
|
||||||
for name, service_config in node_config.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(
|
config_proto = configservices_pb2.ConfigServiceConfig(
|
||||||
node_id=node_id,
|
node_id=node_id,
|
||||||
name=name,
|
name=name,
|
||||||
templates=service_config["templates"],
|
templates=service_config["templates"],
|
||||||
config=service_config.get("config"),
|
config=config_values,
|
||||||
)
|
)
|
||||||
config_service_protos.append(config_proto)
|
config_service_protos.append(config_proto)
|
||||||
return config_service_protos
|
return config_service_protos
|
||||||
|
|
Loading…
Add table
Reference in a new issue