From 9f9d8bf059c1f693dc07bd6e4c8ddc6eb93debf3 Mon Sep 17 00:00:00 2001 From: Dobli <61doal1mst@hft-stuttgart.de> Date: Thu, 31 Jan 2019 15:55:01 +0100 Subject: [PATCH] Added user menu demo entries --- building_manager.py | 47 ++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/building_manager.py b/building_manager.py index 06acc1f..f8ae6ee 100755 --- a/building_manager.py +++ b/building_manager.py @@ -861,6 +861,8 @@ def main_menu(args): init_menu(args) elif 'Execute' in choice: exec_menu(args) + elif 'User' in choice: + user_menu(args) return choice @@ -878,13 +880,14 @@ def load_main_entires(base_dir): entries.append('Create initial structure') else: entries.append('Execute a command in a service container') + entries.append('Manage Users') entries.append('Exit') return entries -# *** Main Menu Entries *** +# *** Init Menu Entries *** def init_menu(args): """Menu entry for initial setup and file generation @@ -940,21 +943,6 @@ def init_menu(args): generate_swarm(hosts) -def exec_menu(args): - """Menu entry for executing commands in services - - :args: Passed commandline arguments - """ - machine = docker_client_prompt(" to execute command at") - service_name = qust.select( - 'Which service container shall execute the command?', - choices=get_container_list(machine), style=st).ask() - command = qust.text('What command should be executed?', style=st).ask() - - run_command_in_service(service_name, command, machine) - - -# *** Sub Menu Entries *** def init_machine_menu(base_dir, host, increment): """Prompts to select server services @@ -982,6 +970,33 @@ def init_machine_menu(base_dir, host, increment): print(building) +# *** Exec Menu Entries *** +def exec_menu(args): + """Menu entry for executing commands in services + + :args: Passed commandline arguments + """ + machine = docker_client_prompt(" to execute command at") + service_name = qust.select( + 'Which service container shall execute the command?', + choices=get_container_list(machine), style=st).ask() + command = qust.text('What command should be executed?', style=st).ask() + + run_command_in_service(service_name, command, machine) + + +# *** User Menu Entries *** +def user_menu(args): + """Menu entry for user managment + + :args: Passed commandline arguments + """ + choice = qust.select("What do you want to do?", choices=[ + 'Add a new user', 'Remove existing user'], + style=st).ask() + print(choice) + + # *** Menu Helper Functions *** def generate_cb_choices(list, checked=False): """Generates checkbox entries for lists of strings -- GitLab