Changeset a7c0bcb for fedd/fedd_create.py
- Timestamp:
- Dec 6, 2010 5:51:09 PM (13 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- ac15159, c179764, cd60510
- Parents:
- 35a5879
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_create.py
r35a5879 ra7c0bcb 15 15 get_abac_certs 16 16 from federation.util import abac_split_cert, abac_context_to_creds 17 from federation import topdl 18 19 from xml.parsers.expat import ExpatError 17 20 18 21 class fedd_create_opts(client_opts): … … 154 157 155 158 if opts.file: 159 160 top = None 161 # Try the file as a topdl description 156 162 try: 157 lines = [ line for line in open(opts.file, 'r')] 158 exp_desc = "".join(lines) 163 top = topdl.topology_from_xml(filename=opts.file, top='experiment') 159 164 except EnvironmentError: 165 # Can't read the file, fail now 160 166 sys.exit("Cannot read description file (%s)" %opts.file) 167 except ExpatError: 168 # The file is not topdl, fall and assume it's ns2 169 pass 170 171 if top is None: 172 try: 173 lines = [ line for line in open(opts.file, 'r')] 174 exp_desc = "".join(lines) 175 # Parse all the strings that we can pull out of the file using the 176 # service_re. 177 svcs.extend([parse_service(service_re.match(l).group(1)) \ 178 for l in lines if service_re.match(l)]) 179 except EnvironmentError: 180 sys.exit("Cannot read description file (%s)" %opts.file) 161 181 else: 162 182 sys.exit("Must specify an experiment description (--file)") … … 183 203 svcs.append(project_export_service(opts.master, opts.project)) 184 204 svcs.extend([ parse_service(s) for s in opts.service]) 185 186 # Parse all the strings that we can pull out of the file using the service_re.187 svcs.extend([parse_service(service_re.match(l).group(1)) \188 for l in lines if service_re.match(l)])189 205 190 206 # Create a testbed map if one is specified … … 253 269 254 270 # Construct the Create message 255 msg = { 'experimentdescription': { 'ns2description': exp_desc }, } 271 if top: 272 msg = { 'experimentdescription' : { 'topdldescription': top.to_dict() }, } 273 else: 274 msg = { 'experimentdescription': { 'ns2description': exp_desc }, } 256 275 257 276 if svcs:
Note: See TracChangeset
for help on using the changeset viewer.