Skip to content

Commit 7f2eb99

Browse files
committed
improve logging of host_controller
1 parent d5f9e5d commit 7f2eb99

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -1389,10 +1389,9 @@ def start_host_managers(ip: str, emulation: str, ip_first_octet: int):
13891389
config = MetastoreFacade.get_config(id=1)
13901390
for node in config.cluster_config.cluster_nodes:
13911391
if node.ip == ip or ip == "":
1392-
started = ClusterController.start_host_managers(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
1392+
operation_outcome = ClusterController.start_host_managers(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
13931393
emulation=emulation, ip_first_octet=ip_first_octet)
1394-
1395-
if started:
1394+
if operation_outcome.outcome:
13961395
click.secho(f"Starting host managers on port:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}")
13971396
else:
13981397
click.secho(f"Host managers are not started:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}",
@@ -1413,14 +1412,14 @@ def start_host_manager(ip: str, container_ip:str, emulation: str, ip_first_octet
14131412
config = MetastoreFacade.get_config(id=1)
14141413
for node in config.cluster_config.cluster_nodes:
14151414
if node.ip == ip or ip == "":
1416-
started = ClusterController.start_host_manager(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
1415+
operation_outcome = ClusterController.start_host_manager(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
14171416
emulation=emulation, ip_first_octet=ip_first_octet,
14181417
container_ip=container_ip)
1419-
if started:
1420-
click.secho(f"Starting host with ip {container_ip} on "
1418+
if operation_outcome.outcome:
1419+
click.secho(f"Started host manager with ip {container_ip} on "
14211420
f"port:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}")
14221421
else:
1423-
click.secho(f"Host with ip {container_ip} is not "
1422+
click.secho(f"Host manager with ip {container_ip} is not "
14241423
f"started:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}",
14251424
bold=False)
14261425

simulation-system/libs/csle-cluster/src/csle_cluster/cluster_manager/cluster_manager.py

+2
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,8 @@ def startHostManager(
24252425
ip=container_config.docker_gw_bridge_ip, logger=logging.getLogger())
24262426
return csle_cluster.cluster_manager.cluster_manager_pb2.OperationOutcomeDTO(outcome=True)
24272427
else:
2428+
logging.info(f"Container with ip: {request.containerIp} not found in execution "
2429+
f"with id: {request.ipFirstOctet} of emulation {request.emulation}")
24282430
return csle_cluster.cluster_manager.cluster_manager_pb2.OperationOutcomeDTO(outcome=False)
24292431

24302432
def stopHostManagers(

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

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def start_host_manager(emulation_env_config: EmulationEnvConfig, ip: str, logger
8989
o, e, _ = EmulationUtil.execute_ssh_cmd(cmd=cmd,
9090
conn=emulation_env_config.get_connection(ip=ip))
9191
time.sleep(5)
92+
else:
93+
logger.info(f"Host manager is already running on: {ip}. Output of {cmd} was: {str(o)}, "
94+
f"err output was: {str(e)}")
9295

9396
@staticmethod
9497
def stop_host_managers(emulation_env_config: EmulationEnvConfig, physical_host_ip: str) -> None:

0 commit comments

Comments
 (0)