Skip to content

Commit

Permalink
improve logging of host_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Limmen committed Jul 27, 2024
1 parent d5f9e5d commit 7f2eb99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
13 changes: 6 additions & 7 deletions simulation-system/libs/csle-cli/src/csle_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,10 +1389,9 @@ def start_host_managers(ip: str, emulation: str, ip_first_octet: int):
config = MetastoreFacade.get_config(id=1)
for node in config.cluster_config.cluster_nodes:
if node.ip == ip or ip == "":
started = ClusterController.start_host_managers(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
operation_outcome = ClusterController.start_host_managers(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
emulation=emulation, ip_first_octet=ip_first_octet)

if started:
if operation_outcome.outcome:
click.secho(f"Starting host managers on port:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}")
else:
click.secho(f"Host managers are not started:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}",
Expand All @@ -1413,14 +1412,14 @@ def start_host_manager(ip: str, container_ip:str, emulation: str, ip_first_octet
config = MetastoreFacade.get_config(id=1)
for node in config.cluster_config.cluster_nodes:
if node.ip == ip or ip == "":
started = ClusterController.start_host_manager(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
operation_outcome = ClusterController.start_host_manager(ip=ip, port=constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT,
emulation=emulation, ip_first_octet=ip_first_octet,
container_ip=container_ip)
if started:
click.secho(f"Starting host with ip {container_ip} on "
if operation_outcome.outcome:
click.secho(f"Started host manager with ip {container_ip} on "
f"port:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}")
else:
click.secho(f"Host with ip {container_ip} is not "
click.secho(f"Host manager with ip {container_ip} is not "
f"started:{constants.GRPC_SERVERS.CLUSTER_MANAGER_PORT}",
bold=False)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,8 @@ def startHostManager(
ip=container_config.docker_gw_bridge_ip, logger=logging.getLogger())
return csle_cluster.cluster_manager.cluster_manager_pb2.OperationOutcomeDTO(outcome=True)
else:
logging.info(f"Container with ip: {request.containerIp} not found in execution "
f"with id: {request.ipFirstOctet} of emulation {request.emulation}")
return csle_cluster.cluster_manager.cluster_manager_pb2.OperationOutcomeDTO(outcome=False)

def stopHostManagers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def start_host_manager(emulation_env_config: EmulationEnvConfig, ip: str, logger
o, e, _ = EmulationUtil.execute_ssh_cmd(cmd=cmd,
conn=emulation_env_config.get_connection(ip=ip))
time.sleep(5)
else:
logger.info(f"Host manager is already running on: {ip}. Output of {cmd} was: {str(o)}, "
f"err output was: {str(e)}")

@staticmethod
def stop_host_managers(emulation_env_config: EmulationEnvConfig, physical_host_ip: str) -> None:
Expand Down

0 comments on commit 7f2eb99

Please sign in to comment.