fix: update actions method

This commit is contained in:
Ting-Jun Wang 2024-05-30 17:58:27 +08:00
parent b378aa73ec
commit 4f035b6d53
Signed by: snsd0805
GPG Key ID: 48D331A3D6160354
2 changed files with 9 additions and 9 deletions

View File

@ -74,8 +74,9 @@ class ClusterCommunicationModule():
if not status:
print("Some Errors!")
# remove 'add node'
self.node_manager.actions = self.node_manager.actions[1:]
self.node_manager.actions = [
{'explanation': 'Exit', 'function': 'exit'},
]
self.node_manager.status = 'worker'
print(f'You are in {addr} cluster now.\nPlease type in Enter to continue')

View File

@ -56,12 +56,12 @@ class NodeManager():
choose = int(choose)-1
accept = self.cluster_communication_module.request(hosts[choose])
if accept:
exit_func = self.actions[-1]
self.actions = self.actions[:-1]
info_func = {'explanation': 'cluster info', 'function': 'cluster_info'}
if info_func not in self.actions:
self.actions.append(info_func)
self.actions.append(exit_func)
self.actions = [
{'explanation': 'Add another node into our cluster', 'function': 'add_node'},
{'explanation': 'Cluster info', 'function': 'cluster_info'},
{'explanation': 'Start working', 'function': 'start_work'},
{'explanation': 'Exit', 'function': 'exit'},
]
except:
print("=== FAIL ===")
else:
@ -79,4 +79,3 @@ class NodeManager():
self.cluster_communication_module.exit()
self.service_exploration_module.exit()