#2561 - Ran pre-commit hook
This commit is contained in:
@@ -163,7 +163,7 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "venv",
|
"display_name": "Python 3 (ipykernel)",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
@@ -177,9 +177,9 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.11"
|
"version": "3.8.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 2
|
"nbformat_minor": 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,16 @@ class DatabaseService(Service):
|
|||||||
self._create_db_file()
|
self._create_db_file()
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
|
"""
|
||||||
|
Perform first-time setup of the DatabaseService.
|
||||||
|
|
||||||
|
Installs an instance of FTPClient on the Node to enable database backup if it isn't installed already.
|
||||||
|
"""
|
||||||
super().install()
|
super().install()
|
||||||
if not self.software_manager.software.get("FTPClient"):
|
if not self.software_manager.software.get("FTPClient"):
|
||||||
self.sys_log.info(f"{self.name}: Installing FTPClient to enable database backups")
|
self.sys_log.info(f"{self.name}: Installing FTPClient to enable database backups")
|
||||||
self.software_manager.install(FTPClient)
|
self.software_manager.install(FTPClient)
|
||||||
|
|
||||||
def configure_backup(self, backup_server: IPv4Address):
|
def configure_backup(self, backup_server: IPv4Address):
|
||||||
"""
|
"""
|
||||||
Set up the database backup.
|
Set up the database backup.
|
||||||
@@ -77,9 +83,7 @@ class DatabaseService(Service):
|
|||||||
|
|
||||||
# send backup copy of database file to FTP server
|
# send backup copy of database file to FTP server
|
||||||
if not self.db_file:
|
if not self.db_file:
|
||||||
self.sys_log.error(
|
self.sys_log.error(f"{self.name}: Attempted to backup database file but it doesn't exist.")
|
||||||
f"{self.name}: Attempted to backup database file but it doesn't exist."
|
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
response = ftp_client_service.send_file(
|
response = ftp_client_service.send_file(
|
||||||
@@ -170,11 +174,11 @@ class DatabaseService(Service):
|
|||||||
return str(uuid4())
|
return str(uuid4())
|
||||||
|
|
||||||
def _process_connect(
|
def _process_connect(
|
||||||
self,
|
self,
|
||||||
src_ip: IPv4Address,
|
src_ip: IPv4Address,
|
||||||
connection_request_id: str,
|
connection_request_id: str,
|
||||||
password: Optional[str] = None,
|
password: Optional[str] = None,
|
||||||
session_id: Optional[str] = None,
|
session_id: Optional[str] = None,
|
||||||
) -> Dict[str, Union[int, Dict[str, bool]]]:
|
) -> Dict[str, Union[int, Dict[str, bool]]]:
|
||||||
"""Process an incoming connection request.
|
"""Process an incoming connection request.
|
||||||
|
|
||||||
@@ -215,10 +219,10 @@ class DatabaseService(Service):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _process_sql(
|
def _process_sql(
|
||||||
self,
|
self,
|
||||||
query: Literal["SELECT", "DELETE", "INSERT", "ENCRYPT"],
|
query: Literal["SELECT", "DELETE", "INSERT", "ENCRYPT"],
|
||||||
query_id: str,
|
query_id: str,
|
||||||
connection_id: Optional[str] = None,
|
connection_id: Optional[str] = None,
|
||||||
) -> Dict[str, Union[int, List[Any]]]:
|
) -> Dict[str, Union[int, List[Any]]]:
|
||||||
"""
|
"""
|
||||||
Executes the given SQL query and returns the result.
|
Executes the given SQL query and returns the result.
|
||||||
|
|||||||
@@ -357,6 +357,7 @@ def test_client_connection_terminate_does_not_terminate_another_clients_connecti
|
|||||||
assert db_connection_b.query("SELECT")
|
assert db_connection_b.query("SELECT")
|
||||||
assert len(db_service.connections) == 1
|
assert len(db_service.connections) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_database_server_install_ftp_client():
|
def test_database_server_install_ftp_client():
|
||||||
server = Server(hostname="db_server", ip_address="192.168.1.2", subnet_mask="255.255.255.0", start_up_duration=0)
|
server = Server(hostname="db_server", ip_address="192.168.1.2", subnet_mask="255.255.255.0", start_up_duration=0)
|
||||||
server.software_manager.install(DatabaseService)
|
server.software_manager.install(DatabaseService)
|
||||||
|
|||||||
Reference in New Issue
Block a user