Skip to content

Commit aa2e065

Browse files
authored
Merge pull request #419 from Limmen/cli_command
help command for CLI
2 parents 9457a16 + 75199e3 commit aa2e065

File tree

1 file changed

+166
-6
lines changed
  • simulation-system/libs/csle-cli/src/csle_cli

1 file changed

+166
-6
lines changed

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

+166-6
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,13 @@ def stop_shell_complete(ctx, param, incomplete) -> List[str]:
675675
running_containers = ContainerController.list_all_running_containers()
676676
containers: List[Tuple[str, str, str]] = running_containers
677677
container_names: List[str] = list(map(lambda x: x[0], containers))
678-
return ["prometheus", "node_exporter", "cadvisor", "pgadmin", "grafana", "flask",
679-
"statsmanager", "all", "emulation_executions"] + emulations + container_names
678+
return (["prometheus", "node_exporter", "cadvisor", "pgadmin", "grafana", "flask",
679+
"statsmanager", "all", "statsmanager", "nginx", "postgresql", "docker",
680+
"clustermanager", "hostmanagers", "hostmanager", "clientmanager", "snortmanagers", "snortmanager",
681+
"elkmanager", "trafficmanagers", "trafficmanager", "kafkamanager", "ossecmanagers", "ossecmanager",
682+
"ryumanager", "filebeats", "filebeat", "metricbeats", "metricbeat", "heartbeat", "heartbeats",
683+
"packetbeat", "packetbeats", "emulation_executions", "--ip", "--container_ip"]
684+
+ emulations + container_names)
680685

681686

682687
@click.option('--ip', default="", type=str)
@@ -689,7 +694,79 @@ def stop_shell_complete(ctx, param, incomplete) -> List[str]:
689694
"| docker | clustermanager | hostmanagers | hostmanager | clientmanager | snortmanagers "
690695
"| snortmanager | elkmanager | trafficmanagers | trafficmanager | kafkamanager "
691696
"| ossecmanagers | ossecmanager | ryumanager | filebeats | filebeat | metricbeat "
692-
"| metricbeats | heartbeats | heartbeat | packetbeat | packetbeats")
697+
"| metricbeats | heartbeats | heartbeat | packetbeat | packetbeats \n\n"
698+
"\b\n"
699+
"- \033[95mprometheus\033[0m: stops prometheus for a node with ip address specified with"
700+
" --ip option.\n"
701+
"- \033[95mnode_exporter\033[0m: stops node exporter for a node with ip address specified "
702+
"with --ip option.\n"
703+
"- \033[95mcadvisor\033[0m: stops cadvisor for a node with ip address specified "
704+
"with --ip option.\n"
705+
"- \033[95mgrafana\033[0m: stops grafana for a node with ip address specified "
706+
"with --ip option.\n"
707+
"- \033[95mflask\033[0m: stops flask for a node with ip address specified "
708+
"with --ip option.\n"
709+
"- \033[95mstatsmanager\033[0m: stops docker statsmanager for a node with ip address "
710+
"specified with --ip option.\n"
711+
"- \033[95memulation_executions\033[0m: stops all emulation executions.\n"
712+
"- \033[95mpgadmin\033[0m: stops pgadmin for a node with ip address "
713+
"specified with --ip option.\n"
714+
"- \033[95mall\033[0m: stops all running emulations and containers on all the nodes.\n"
715+
"- \033[95mnginx\033[0m: stops nginx for a node with ip address "
716+
"specified with --ip option.\n"
717+
"- \033[95mpostgresql\033[0m: stops PostgreSQL for a node with ip address "
718+
"specified with --ip option.\n"
719+
"- \033[95mdocker\033[0m: stops docker engine for a node with ip address "
720+
"specified with --ip option.\n"
721+
"- \033[95mclustermanager\033[0m: stops cluster manager.\n"
722+
"- \033[95mhostmanagers\033[0m: stops all host managers on the node specified by --ip,"
723+
" for the emulation identified by --name and --id.\n"
724+
"- \033[95mhostmanager\033[0m: stops the host manager on the node specified by --ip, "
725+
"targeting the container with the IP from --container_ip, for the emulation identified "
726+
"by --name and --id.\n"
727+
"- \033[95mclientmanager\033[0m: stops client manager on the node specified by --ip,"
728+
" for the emulation identified by --name and --id.\n"
729+
"- \033[95msnortmanagers\033[0m: stops all snort managers on the node specified by --ip,"
730+
" for the emulation identified by --name and --id.\n"
731+
"- \033[95msnortmanager\033[0m: stops the snort manager on the node specified by --ip, "
732+
"targeting the container with the IP from --container_ip, for the emulation identified "
733+
"by --name and --id.\n"
734+
"- \033[95melkmanager\033[0m: stops the elk manager on the node specified by --ip,"
735+
" for the emulation identified by --name and --id.\n"
736+
"- \033[95mtrafficmanagers\033[0m: stops all traffic managers on the node specified by"
737+
" --ip, for the emulation identified by --name and --id.\n"
738+
"- \033[95mtrafficmanager\033[0m: stops the traffic manager on the node specified by --ip, "
739+
"targeting the container with the IP from --container_ip, for the emulation identified "
740+
"by --name and --id.\n"
741+
"- \033[95mkafkamanager\033[0m: stops the ossec manager on the node specified by --ip,"
742+
" for the emulation identified by --name and --id.\n"
743+
"- \033[95mossecmanagers\033[0m: stops all traffic managers on the node specified by --ip,"
744+
" for the emulation identified by --name and --id.\n"
745+
"- \033[95mossecmanager\033[0m: stops the ossec manager on the node specified by --ip, "
746+
"targeting the container with the IP from --container_ip, for the emulation identified "
747+
"by --name and --id.\n"
748+
"- \033[95mtyumanager\033[0m: stops the ryu manager on the node specified by --ip,"
749+
" for the emulation identified by --name and --id. To stop the ryu manager the emulation"
750+
" should include the SDN network.\n"
751+
"- \033[95mfilebeats\033[0m: stops all filebeats for a node with the specified --ip option"
752+
" and the emulation identified by the specified --name and --id.\n"
753+
"- \033[95mfilebeat\033[0m: stops filebeat for a container with the IP address "
754+
"--container_ip, node specified by --ip, and emulation identified by --name and --id.\n"
755+
"- \033[95mmetricbeats\033[0m: stops all metricbeats for a node with the specified --ip "
756+
"option and the emulation identified by the specified --name and --id.\n"
757+
"- \033[95mmetricbeat\033[0m: stops metricbeat for a container with the IP address "
758+
"--container_ip, node specified by --ip, and emulation identified by --name and --id.\n"
759+
"- \033[95mheartbeats\033[0m: stops all heartbeats for a node with the specified --ip"
760+
" option and the emulation identified by the specified --name and --id.\n"
761+
"- \033[95mheartbeat\033[0m: stops heartbeat for a container with the IP address "
762+
"--container_ip, node specified by --ip, and emulation identified by --name and --id.\n"
763+
"- \033[95mpacketbeats\033[0m: stops all packetbeats for a node with the specified --ip"
764+
" option and the emulation identified by the specified --name and --id.\n"
765+
"- \033[95mpacketbeat\033[0m: stops packetbeat for a container with the IP address "
766+
"--container_ip, node specified by --ip, and emulation identified by --name and --id.\n\n"
767+
"\b\n"
768+
"* \033[93mExample: csle stop filebeat csle-level4-060 15 --ip X.X.X.X "
769+
"--container_ip Y.Y.Y.Y \033[0m")
693770
def stop(entity: str, name: str, id: int = -1, ip: str = "", container_ip: str = "") -> None:
694771
"""
695772
Stops an entity
@@ -1856,7 +1933,12 @@ def start_shell_complete(ctx, param, incomplete) -> List[str]:
18561933
images: List[Tuple[str, str, str, str, str]] = ContainerController.list_all_images()
18571934
image_names: List[str] = list(map(lambda x: x[0], images))
18581935
return (["prometheus", "node_exporter", "grafana", "cadvisor", "pgadmin", "flask", "all",
1859-
"statsmanager", "training_job", "system_id_job", "--id", "--no_traffic"]
1936+
"statsmanager", "training_job", "system_id_job", "nginx", "postgresql", "docker", "clustermanager",
1937+
"hostmanagers", "hostmanager", "clientmanager", "snortmanagers", "snortmanager", "elkmanager",
1938+
"trafficmanagers", "trafficmanager", "kafkamanager", "ossecmanagers", "ossecmanager", "ryumanager",
1939+
"filebeats", "filebeat", "metricbeats", "metricbeat", "heartbeat", "heartbeats", "packetbeat",
1940+
"packetbeats", "--container_ip", "--initial_start", "--no_clients", "--no_network", "--no_beats",
1941+
"--id", "--no_traffic"]
18601942
+ emulations + container_names + image_names)
18611943

18621944

@@ -1876,7 +1958,83 @@ def start_shell_complete(ctx, param, incomplete) -> List[str]:
18761958
"| hostmanager | clientmanager | snortmanagers | snortmanager | elkmanager "
18771959
"| trafficmanagers | trafficmanager | kafkamanager | ossecmanagers | ossecmanager "
18781960
"| ryumanager | filebeats | filebeat | metricbeats | metricbeat | heartbeat | heartbeats"
1879-
"| packetbeat | packetbeats")
1961+
"| packetbeat | packetbeats\n\n"
1962+
"\b\n"
1963+
"- \033[95mprometheus\033[0m: starts prometheus for a node with ip address specified with"
1964+
" --ip option.\n"
1965+
"- \033[95mnode_exporter\033[0m: starts node exporter for a node with ip address "
1966+
"specified with --ip option.\n"
1967+
"- \033[95mcadvisor\033[0m: starts cadvisor for a node with ip address specified "
1968+
"with --ip option.\n"
1969+
"- \033[95mgrafana\033[0m: starts grafana for a node with ip address specified "
1970+
"with --ip option.\n"
1971+
"- \033[95mflask\033[0m: starts flask for a node with ip address specified "
1972+
"with --ip option.\n"
1973+
"- \033[95mstatsmanager\033[0m: starts docker statsmanager for a node with ip address "
1974+
"specified with --ip option.\n"
1975+
"- \033[95memulation_executions\033[0m: starts all emulation executions.\n"
1976+
"- \033[95mpgadmin\033[0m: starts pgadmin for a node with ip address "
1977+
"specified with --ip option.\n"
1978+
"- \033[95mall\033[0m: starts all running emulations and containers on all the nodes.\n"
1979+
"- \033[95mnginx\033[0m: starts nginx for a node with ip address "
1980+
"specified with --ip option.\n"
1981+
"- \033[95mpostgresql\033[0m: starts PostgreSQL for a node with ip address "
1982+
"specified with --ip option.\n"
1983+
"- \033[95mdocker\033[0m: starts docker engine for a node with ip address "
1984+
"specified with --ip option.\n"
1985+
"- \033[95mclustermanager\033[0m: starts cluster manager.\n"
1986+
"- \033[95mhostmanagers\033[0m: starts all host managers on the node specified by --ip,"
1987+
" for the emulation identified by --name and --id.\n"
1988+
"- \033[95mhostmanager\033[0m: starts the host manager on the node specified by --ip, "
1989+
"targeting the container with the IP from --container_ip, for the emulation identified "
1990+
"by --name and --id.\n"
1991+
"- \033[95mclientmanager\033[0m: starts client manager on the node specified by --ip,"
1992+
" for the emulation identified by --name and --id.\n"
1993+
"- \033[95msnortmanagers\033[0m: starts all snort managers on the node specified by --ip,"
1994+
" for the emulation identified by --name and --id.\n"
1995+
"- \033[95msnortmanager\033[0m: starts the snort manager on the node specified by --ip, "
1996+
"targeting the container with the IP from --container_ip, for the emulation identified "
1997+
"by --name and --id.\n"
1998+
"- \033[95melkmanager\033[0m: starts the elk manager on the node specified by --ip,"
1999+
" for the emulation identified by --name and --id.\n"
2000+
"- \033[95mtrafficmanagers\033[0m: starts all traffic managers on the node specified by "
2001+
"--ip, for the emulation identified by --name and --id.\n"
2002+
"- \033[95mtrafficmanager\033[0m: starts the traffic manager on the node specified by "
2003+
"--ip, targeting the container with the IP from --container_ip, for the emulation"
2004+
" identified by --name and --id.\n"
2005+
"- \033[95mkafkamanager\033[0m: starts the ossec manager on the node specified by --ip,"
2006+
" for the emulation identified by --name and --id.\n"
2007+
"- \033[95mossecmanagers\033[0m: starts all traffic managers on the node specified by "
2008+
"--ip, for the emulation identified by --name and --id.\n"
2009+
"- \033[95mossecmanager\033[0m: starts the ossec manager on the node specified by --ip, "
2010+
"targeting the container with the IP from --container_ip, for the emulation identified "
2011+
"by --name and --id.\n"
2012+
"- \033[95mtyumanager\033[0m: starts the ryu manager on the node specified by --ip,"
2013+
" for the emulation identified by --name and --id. To stop the ryu manager the emulation"
2014+
" should include the SDN network.\n"
2015+
"- \033[95mfilebeats\033[0m: starts all Filebeats for a node with --ip and emulation "
2016+
"identified by --name and --id. Use --initial_start for the first start.\n"
2017+
"- \033[95mfilebeat\033[0m: starts filebeat for a container with --container_ip, "
2018+
"node with --ip, and emulation with --name and --id. Use --initial_start for "
2019+
"the initial start.\n"
2020+
"- \033[95mmetricbeats\033[0m: starts all metricbeats for a node with --ip and emulation "
2021+
"identified by --name and --id. Use --initial_start for the first start.\n"
2022+
"- \033[95mmetricbeat\033[0m: starts hearttbeat for a container with --container_ip, "
2023+
"node with --ip, and emulation with --name and --id. Use --initial_start for the "
2024+
"initial start.\n"
2025+
"- \033[95mheartbeats\033[0m: starts all heartbeats for a node with --ip and emulation"
2026+
" identified by --name and --id. Use --initial_start for the first start.\n"
2027+
"- \033[95mheartbeat\033[0m: starts heartbeat for a container with --container_ip, "
2028+
"node with --ip, and emulation with --name and --id. Use --initial_start for the "
2029+
"initial start.\n"
2030+
"- \033[95mpacketbeats\033[0m: starts all packetbeats for a node with --ip and emulation"
2031+
" identified by --name and --id. Use --initial_start for the first start.\n"
2032+
"- \033[95mpacketbeat\033[0m: starts packetbeat for a container with --container_ip, "
2033+
"node with --ip, and emulation with --name and --id. Use --initial_start for the"
2034+
" initial start.\n\n"
2035+
"\b\n"
2036+
"* \033[93mExample: csle start filebeat csle-level4-060 --id 15 --ip X.X.X.X "
2037+
"--container_ip Y.Y.Y.Y \033[0m")
18802038
def start(entity: str, no_traffic: bool, name: str, id: int, no_clients: bool, no_network: bool, ip: str,
18812039
container_ip: str, no_beats: bool, initial_start: bool) -> None:
18822040
"""
@@ -3267,7 +3425,9 @@ def ls_shell_complete(ctx, param, incomplete) -> List[str]:
32673425
"- \033[95mlogfiles\033[0m: list all CSLE log files with their path for a node with "
32683426
"the specified --ip option.\n"
32693427
"- \033[95mlogfile\033[0m: show the logs in a file with the path specified with "
3270-
"--logfile_name option for a node with the specified --ip option.\n")
3428+
"--logfile_name option for a node with the specified --ip option.\n\n"
3429+
"\b\n"
3430+
"* \033[93mExample: csle ls filebeats --name csle-level4-060 --id 15 --ip X.X.X.X \033[0m")
32713431
@click.argument('entity', default='all', type=str, shell_complete=ls_shell_complete)
32723432
@click.option('--all', is_flag=True, help='list all')
32733433
@click.option('--running', is_flag=True, help='list running only (default)')

0 commit comments

Comments
 (0)