Changeset c259a77 for fedd/fedd_create.py
- Timestamp:
- Jun 3, 2014 4:29:31 PM (10 years ago)
- Branches:
- master
- Children:
- 0b217d1
- Parents:
- ba07149
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_create.py
rba07149 rc259a77 17 17 from federation.client_lib import client_opts, exit_with_fault, RPCException, \ 18 18 wrangle_standard_options, do_rpc, get_experiment_names, save_certfile,\ 19 get_abac_certs, log_authentication 19 get_abac_certs, log_authentication, parse_service,\ 20 service_dict_to_line, ns_service_re, extract_services_from_xml 20 21 from federation.util import abac_split_cert, abac_context_to_creds 21 22 … … 58 59 self.set_defaults(delegate=True) 59 60 60 def parse_service(svc):61 """62 Pasre a service entry into a hash representing a service entry in a63 message. The format is:64 svc_name:exporter(s):importer(s):attr=val,attr=val65 The svc_name is teh service name, exporter is the exporting testbeds66 (comma-separated) importer is the importing testbeds (if any) and the rest67 are attr=val pairs that will become attributes of the service. These68 include parameters and other such stuff.69 """70 71 terms = svc.split(':')72 svcd = { }73 if len(terms) < 2 or len(terms[0]) == 0 or len(terms[1]) == 0:74 sys.exit("Bad service description '%s': Not enough terms" % svc)75 76 svcd['name'] = terms[0]77 svcd['export'] = terms[1].split(",")78 if len(terms) > 2 and len(terms[2]) > 0:79 svcd['import'] = terms[2].split(",")80 if len(terms) > 3 and len(terms[3]) > 0:81 svcd['fedAttr'] = [ ]82 for t in terms[3].split(";"):83 i = t.find("=")84 if i != -1 :85 svcd['fedAttr'].append(86 {'attribute': t[0:i], 'value': t[i+1:]})87 else:88 sys.exit("Bad service attribute '%s': no equals sign" % t)89 return svcd90 91 61 def project_export_service(master, project): 92 62 """ … … 156 126 157 127 # Main line 158 service_re = re.compile('^\\s*#\\s*SERVICE:\\s*([\\S]+)')159 128 parser = fedd_create_opts() 160 129 (opts, args) = parser.parse_args() … … 173 142 try: 174 143 top = topdl.topology_from_xml(filename=opts.file, top='experiment') 144 # Pull any service descriptions from the file as well 145 svcs = extract_services_from_xml(filename=opts.file) 175 146 except EnvironmentError: 176 147 # Can't read the file, fail now … … 186 157 # Parse all the strings that we can pull out of the file using the 187 158 # service_re. 188 svcs.extend([parse_service( service_re.match(l).group(1)) \189 for l in lines if service_re.match(l)])159 svcs.extend([parse_service(ns_service_re.match(l).group(1)) \ 160 for l in lines if ns_service_re.match(l)]) 190 161 except EnvironmentError: 191 162 sys.exit("Cannot read description file (%s)" %opts.file)
Note: See TracChangeset
for help on using the changeset viewer.