File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- TODO: Error message if --client or --hub does not exist in configuration
2-
31TODO: Cleanup Shamir's Secret Sharing (SSS) code (no back-and-forth conversion to RawShare)
42
53TODO: Move code coverage data files to subdirectory
Original file line number Diff line number Diff line change 4141MAX_MIN_NR_SHARES = 128
4242
4343
44+ def fatal_error (message : str ):
45+ """
46+ Print a fatal error message and exit.
47+ """
48+ print (message , file = sys .stderr )
49+ sys .exit (1 )
50+
51+
4452class Configuration :
4553 """
4654 Configuration for the DSKE manager.
@@ -158,18 +166,15 @@ def parse_configuration_file(filename: str) -> Configuration:
158166 try :
159167 parsed_config = yaml .safe_load (file )
160168 except yaml .YAMLError as err :
161- print (
162- f"Could not load configuration file { filename } : { str (err )} " ,
163- file = sys .stderr ,
169+ fatal_error (
170+ f"Could not parse configuration file { filename } : { str (err )} "
164171 )
165- sys .exit (1 )
166172 except (OSError , IOError ) as err :
167- print (f"Could not open configuration file { filename } ({ err } )" , file = sys .stderr )
168- sys .exit (1 )
173+ fatal_error (f"Could not open configuration file { filename } : { err } " )
169174 validator = cerberus .Validator ()
170175 if not validator .validate (parsed_config , SCHEMA ):
171- print (f"Could not parse configuration file { filename } " , file = sys .stderr )
172- pretty_printer = pprint .PrettyPrinter ()
176+ print (f"Could not validate configuration file { filename } " , file = sys .stderr )
177+ pretty_printer = pprint .PrettyPrinter (stream = sys . stderr )
173178 pretty_printer .pprint (validator .errors )
174179 sys .exit (1 )
175180 parsed_config = validator .normalized (parsed_config )
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def main(self):
3939 self .parse_command_line_arguments ()
4040 self ._config = configuration .parse_configuration_file (self ._args .config )
4141 self ._nodes = self ._config .nodes
42+ self .check_clients_and_hubs_exist ()
4243 match self ._args .command :
4344 case "start" :
4445 self .start ()
@@ -261,6 +262,31 @@ def selected_nodes_description(self):
261262 description += f"hub { hub_name } "
262263 return description
263264
265+ def check_clients_and_hubs_exist (self ):
266+ """
267+ Check that all clients and hubs selected in the command-line arguments exist in the
268+ configuration.
269+ """
270+ print ("HEY" )
271+ if self ._args .client is not None :
272+ for client_name in self ._args .client :
273+ found = False
274+ for node in self ._nodes :
275+ if node .type == NodeType .CLIENT and node .name == client_name :
276+ found = True
277+ break
278+ if not found :
279+ self .fatal_error (f"There is no client with name { client_name } " )
280+ if self ._args .hub is not None :
281+ for hub_name in self ._args .hub :
282+ found = False
283+ for node in self ._nodes :
284+ if node .type == NodeType .HUB and node .name == hub_name :
285+ found = True
286+ break
287+ if not found :
288+ self .fatal_error (f"There is no hub with name { hub_name } " )
289+
264290 def wait_for_selected_nodes_condition (
265291 self , condition_func : typing .Callable [[Node ], bool ], condition_description : str
266292 ):
You can’t perform that action at this time.
0 commit comments