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: if not status:
print("Some Errors!") print("Some Errors!")
# remove 'add node' self.node_manager.actions = [
self.node_manager.actions = self.node_manager.actions[1:] {'explanation': 'Exit', 'function': 'exit'},
]
self.node_manager.status = 'worker' self.node_manager.status = 'worker'
print(f'You are in {addr} cluster now.\nPlease type in Enter to continue') 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 choose = int(choose)-1
accept = self.cluster_communication_module.request(hosts[choose]) accept = self.cluster_communication_module.request(hosts[choose])
if accept: if accept:
exit_func = self.actions[-1] self.actions = [
self.actions = self.actions[:-1] {'explanation': 'Add another node into our cluster', 'function': 'add_node'},
info_func = {'explanation': 'cluster info', 'function': 'cluster_info'} {'explanation': 'Cluster info', 'function': 'cluster_info'},
if info_func not in self.actions: {'explanation': 'Start working', 'function': 'start_work'},
self.actions.append(info_func) {'explanation': 'Exit', 'function': 'exit'},
self.actions.append(exit_func) ]
except: except:
print("=== FAIL ===") print("=== FAIL ===")
else: else:
@ -79,4 +79,3 @@ class NodeManager():
self.cluster_communication_module.exit() self.cluster_communication_module.exit()
self.service_exploration_module.exit() self.service_exploration_module.exit()