Skip to content

Commit d79cbf8

Browse files
committed
bugfix
1 parent 8d8bd9e commit d79cbf8

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

simulation-system/libs/csle-cli/src/csle_cli/cli.py

+22-21
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ def stop(entity: str, name: str, id: int = -1, ip: str = "") -> None:
727727
stop_statsmanager(ip=ip)
728728
elif entity == "emulation_executions":
729729
stop_emulation_executions()
730-
elif entity == "hostmanager":
730+
elif entity == "hostmanagers":
731731
stop_host_managers(ip=ip, emulation=name, ip_first_octet=id)
732732
else:
733733
container_stopped = False
@@ -914,16 +914,15 @@ def stop_host_managers(ip: str, emulation: str, ip_first_octet: int) -> None:
914914
config = MetastoreFacade.get_config(id=1)
915915
for node in config.cluster_config.cluster_nodes:
916916
if node.ip == ip or ip == "":
917-
stopped = ClusterController.stop_host_managers(ip=ip, port= constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
918-
emulation=emulation, ip_first_octet=ip_first_octet)
917+
stopped = ClusterController.stop_host_managers(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
918+
emulation=emulation, ip_first_octet=ip_first_octet)
919919
if stopped:
920920
click.secho(f"Stopping host managers on port:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}")
921921
else:
922922
click.secho(f"Host managers are not stopped:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}",
923923
bold=False)
924924

925925

926-
927926
@click.argument('max_workers', default=10, type=int)
928927
@click.argument('log_file', default="docker_statsmanager.log", type=str)
929928
@click.argument('log_dir', default="/var/log/csle", type=str)
@@ -1341,16 +1340,16 @@ def start_statsmanager(ip: str) -> None:
13411340
if node.ip == ip or ip == "":
13421341
ClusterController.start_docker_statsmanager(ip=node.ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT)
13431342

1343+
13441344
def start_host_manager(ip: str, emulation: str, ip_first_octet: int):
13451345
"""
1346-
Utility function for starting host manager
1346+
Utility function for starting host manager
13471347
1348-
:param ip: the ip of the node to start host manager
1349-
:param emulation: the emulation of the execution
1350-
:param ip_first_octet: the ID of the execution
1351-
1352-
:return: None
1353-
"""
1348+
:param ip: the ip of the node to start host manager
1349+
:param emulation: the emulation of the execution
1350+
:param ip_first_octet: the ID of the execution
1351+
:return: None
1352+
"""
13541353
import csle_common.constants.constants as constants
13551354
from csle_common.metastore.metastore_facade import MetastoreFacade
13561355
config = MetastoreFacade.get_config(id=1)
@@ -1746,24 +1745,26 @@ def ls(entity: str, all: bool, running: bool, stopped: bool, ip: str, name: str,
17461745
else:
17471746
click.secho(f"entity: {entity} is not recognized", fg="red", bold=True)
17481747

1749-
def list_host_managers(ip: str, emulation: str , ip_first_octet: int) -> None:
1748+
1749+
def list_host_managers(ip: str, emulation: str, ip_first_octet: int) -> None:
17501750
"""
1751-
Utility function for listing host managers
1751+
Utility function for listing host managers
17521752
1753-
:param ip: the ip of the node to start host manager
1754-
:param emulation: the emulation of the execution
1755-
:param ip_first_octet: the ID of the execution
1753+
:param ip: the ip of the node to start host manager
1754+
:param emulation: the emulation of the execution
1755+
:param ip_first_octet: the ID of the execution
17561756
1757-
:return: None
1758-
"""
1757+
:return: None
1758+
"""
17591759
import csle_common.constants.constants as constants
17601760
from csle_common.metastore.metastore_facade import MetastoreFacade
17611761
config = MetastoreFacade.get_config(id=1)
17621762
for node in config.cluster_config.cluster_nodes:
17631763
if node.ip == ip or ip == "":
1764-
host_manage_info = ClusterController.get_host_managers_info(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
1765-
emulation=emulation, ip_first_octet=ip_first_octet)
1766-
host_managers = host_manage_info.hostManagersStatuses
1764+
host_manager_info = ClusterController.get_host_managers_info(
1765+
ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT, emulation=emulation,
1766+
ip_first_octet=ip_first_octet)
1767+
host_managers = host_manager_info.hostManagersStatuses
17671768

17681769
click.secho('+' + '-' * 50 + '+', fg='white')
17691770
click.secho(f'|{"Host IP":^30}|{"Running Status":^19}|', fg='white')

simulation-system/libs/csle-common/src/csle_common/controllers/host_controller.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ def get_host_managers_info(emulation_env_config: EmulationEnvConfig, active_ips:
13081308
host_managers_statuses.append((status, ip))
13091309
else:
13101310
host_managers_statuses.append(
1311-
csle_collector.host_manager.host_manager_util.HostManagerUtil.host_monitor_dto_empty())
1311+
(csle_collector.host_manager.host_manager_util.HostManagerUtil.host_monitor_dto_empty(), ip))
13121312
host_managers_running.append(running)
13131313
execution_id = emulation_env_config.execution_id
13141314
emulation_name = emulation_env_config.name

simulation-system/libs/csle-common/tests/test_management_util.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from csle_common.util.management_util import ManagementUtil
33
from unittest.mock import patch
44

5+
56
class TestManagementUtilSuite:
67
"""
78
Test suite for management util
@@ -12,7 +13,7 @@ class TestManagementUtilSuite:
1213
@patch("bcrypt.hashpw")
1314
@patch("csle_common.metastore.metastore_facade.MetastoreFacade.save_management_user")
1415
def test_create_default_management_admin_account(
15-
self, mock_save_management_user, mock_hashpw, mock_gensalt, mock_list_management_users
16+
self, mock_save_management_user, mock_hashpw, mock_gensalt, mock_list_management_users
1617
) -> None:
1718
"""
1819
Test the method that creates the default management admin account
@@ -48,7 +49,7 @@ def test_create_default_management_admin_account(
4849
@patch("bcrypt.hashpw")
4950
@patch("csle_common.metastore.metastore_facade.MetastoreFacade.save_management_user")
5051
def test_create_default_management_guest_account(
51-
self, mock_save_management_user, mock_hashpw, mock_gensalt, mock_list_management_users
52+
self, mock_save_management_user, mock_hashpw, mock_gensalt, mock_list_management_users
5253
) -> None:
5354
"""
5455
Test the method that creates the default management guest account

0 commit comments

Comments
 (0)