Fix properties
This commit is contained in:
@@ -65,8 +65,9 @@ class AgentLog:
|
||||
The logger is set to the DEBUG level, and is equipped with a handler that writes to a file and filters out
|
||||
JSON-like messages.
|
||||
"""
|
||||
if not SIM_OUTPUT.save_agent_logs:
|
||||
return
|
||||
# TODO: uncomment this once we figure out why it's broken
|
||||
# if not SIM_OUTPUT.save_agent_logs:
|
||||
# return
|
||||
|
||||
log_path = self._get_log_path()
|
||||
file_handler = logging.FileHandler(filename=log_path)
|
||||
|
||||
@@ -406,32 +406,6 @@ class PrimaiteGame:
|
||||
if "service_install_duration" in defaults_config:
|
||||
new_service.install_duration = defaults_config["service_install_duration"]
|
||||
|
||||
# service-dependent options
|
||||
if service_type == "DNSClient":
|
||||
if "options" in service_cfg:
|
||||
opt = service_cfg["options"]
|
||||
if "dns_server" in opt:
|
||||
new_service.dns_server = IPv4Address(opt["dns_server"])
|
||||
if service_type == "DNSServer":
|
||||
if "options" in service_cfg:
|
||||
opt = service_cfg["options"]
|
||||
if "domain_mapping" in opt:
|
||||
for domain, ip in opt["domain_mapping"].items():
|
||||
new_service.dns_register(domain, IPv4Address(ip))
|
||||
if service_type == "DatabaseService":
|
||||
if "options" in service_cfg:
|
||||
opt = service_cfg["options"]
|
||||
new_service.password = opt.get("db_password", None)
|
||||
if "backup_server_ip" in opt:
|
||||
new_service.configure_backup(backup_server=IPv4Address(opt.get("backup_server_ip")))
|
||||
if service_type == "FTPServer":
|
||||
if "options" in service_cfg:
|
||||
opt = service_cfg["options"]
|
||||
new_service.server_password = opt.get("server_password")
|
||||
if service_type == "NTPClient":
|
||||
if "options" in service_cfg:
|
||||
opt = service_cfg["options"]
|
||||
new_service.ntp_server = IPv4Address(opt.get("ntp_server_ip"))
|
||||
if "applications" in node_cfg:
|
||||
for application_cfg in node_cfg["applications"]:
|
||||
new_application = None
|
||||
|
||||
@@ -35,9 +35,6 @@ class DatabaseService(Service, identifier="DatabaseService"):
|
||||
|
||||
config: "DatabaseService.ConfigSchema" = Field(default_factory=lambda: DatabaseService.ConfigSchema())
|
||||
|
||||
password: Optional[str] = None
|
||||
"""Password that needs to be provided by clients if they want to connect to the DatabaseService."""
|
||||
|
||||
backup_server_ip: IPv4Address = None
|
||||
"""IP address of the backup server."""
|
||||
|
||||
@@ -60,6 +57,10 @@ class DatabaseService(Service, identifier="DatabaseService"):
|
||||
"""Convenience property for accessing the password."""
|
||||
return self.config.db_password
|
||||
|
||||
@password.setter
|
||||
def password(self, val: str) -> None:
|
||||
self.config.db_password = val
|
||||
|
||||
def install(self):
|
||||
"""
|
||||
Perform first-time setup of the DatabaseService.
|
||||
|
||||
@@ -30,8 +30,6 @@ class DNSClient(Service, identifier="DNSClient"):
|
||||
config: "DNSClient.ConfigSchema" = Field(default_factory=lambda: DNSClient.ConfigSchema())
|
||||
dns_cache: Dict[str, IPv4Address] = {}
|
||||
"A dict of known mappings between domain/URLs names and IPv4 addresses."
|
||||
dns_server: Optional[IPv4Address] = None
|
||||
"The DNS Server the client sends requests to."
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
kwargs["name"] = "DNSClient"
|
||||
@@ -43,11 +41,6 @@ class DNSClient(Service, identifier="DNSClient"):
|
||||
super().__init__(**kwargs)
|
||||
self.start()
|
||||
|
||||
@property
|
||||
def dns_server(self) -> Optional[IPV4Address]:
|
||||
"""Convenience property for accessing the dns server configuration."""
|
||||
return self.config.dns_server
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
Describes the current state of the software.
|
||||
@@ -61,6 +54,15 @@ class DNSClient(Service, identifier="DNSClient"):
|
||||
state = super().describe_state()
|
||||
return state
|
||||
|
||||
@property
|
||||
def dns_server(self) -> Optional[IPV4Address]:
|
||||
"""Convenience property for accessing the dns server configuration."""
|
||||
return self.config.dns_server
|
||||
|
||||
@dns_server.setter
|
||||
def dns_server(self, val: IPV4Address) -> None:
|
||||
self.config.dns_server = val
|
||||
|
||||
def add_domain_to_cache(self, domain_name: str, ip_address: IPv4Address) -> bool:
|
||||
"""
|
||||
Adds a domain name to the DNS Client cache.
|
||||
|
||||
Reference in New Issue
Block a user