X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fsfi.py;h=25f81f2222e31a004dc424e739afbd2638a95707;hb=0943c9135dade2921b6d0ca0f9266bb81182438f;hp=31b8a0530ac144da14d88d080842323ca65769f6;hpb=a56ecfce798a6e9da4357116134458111a98f508;p=sfa.git diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index 31b8a053..25f81f22 100644 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -184,8 +184,22 @@ def check_ssh_key (key): return re.match(good_ssh_key, key, re.IGNORECASE) # load methods +def normalize_type (type): + if type.startswith('au'): + return 'authority' + elif type.startswith('us'): + return 'user' + elif type.startswith('sl'): + return 'slice' + elif type.startswith('no'): + return 'node' + else: + return None + def load_record_from_opts(options): record_dict = {} + if hasattr(options, 'type'): + options.type = normalize_type(options.type) if hasattr(options, 'xrn') and options.xrn: if hasattr(options, 'type') and options.type: xrn = Xrn(options.xrn, options.type) @@ -1060,7 +1074,7 @@ use this if you mean an authority instead""") if options: record_dict.update(load_record_from_opts(options).todict()) # at the very least we need 'type' here - if 'type' not in record_dict: + if 'type' not in record_dict or record_dict['type'] is None: self.print_help() sys.exit(1) @@ -1086,7 +1100,7 @@ use this if you mean an authority instead""") elif record_dict['type'] in ['node']: cred = self.my_authority_credential_string() else: - raise "unknown record type" + record_dict['type'] + raise Exception("unknown record type {}".format(record_dict['type'])) if options.show_credential: show_credentials(cred) update = self.registry().Update(record_dict, cred)