Changeset 34bc05c
- Timestamp:
- Nov 24, 2008 11:11:52 AM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- d90f0fa
- Parents:
- bf0a80e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_experiment_control.py
rbf0a80e r34bc05c 181 181 self.exp_stem = "fed-stem" 182 182 self.log = logging.getLogger("fedd.experiment_control") 183 set_log_level(config, "experiment_control", self.log) 183 184 self.muxmax = 2 184 185 self.nthreads = 2 … … 190 191 self.ssh_keygen = "/usr/bin/ssh-keygen" 191 192 self.ssh_identity_file = None 193 192 194 193 195 self.debug = config.getboolean("experiment_control", "create_debug") … … 208 210 self.tclsh = "/usr/local/bin/otclsh" 209 211 self.tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl" 210 self.tbmap = { 211 'deter':'https://users.isi.deterlab.net:23235', 212 'emulab':'https://users.isi.deterlab.net:23236', 213 'ucb':'https://users.isi.deterlab.net:23237', 214 } 212 mapdb_file = config.get("experiment_control", "mapdb") 215 213 self.trace_file = sys.stderr 216 214 … … 229 227 self.def_gwtype = "pc"; 230 228 229 if auth: 230 self.auth = auth 231 else: 232 self.log.error(\ 233 "[access]: No authorizer initialized, creating local one.") 234 auth = authorizer() 235 231 236 232 237 if self.ssh_pubkey_file: … … 246 251 "No SSH public key file?") 247 252 248 set_log_level(config, "experiment_control", self.log) 249 250 if auth:251 self.auth = auth253 254 if mapdb_file: 255 self.read_mapdb(mapdb_file) 256 print self.tbmap 252 257 else: 253 self.log.error(\ 254 "[access]: No authorizer initialized, creating local one.") 255 auth = authorizer() 258 self.log.warn("[experiment_control] No testbed map, using defaults") 259 self.tbmap = { 260 'deter':'https://users.isi.deterlab.net:23235', 261 'emulab':'https://users.isi.deterlab.net:23236', 262 'ucb':'https://users.isi.deterlab.net:23237', 263 } 256 264 257 265 if accessdb_file: 258 try: 259 self.accessdb = self.read_accessdb(accessdb_file) 260 except IOError: 261 raise service_error(service_error.internal, 262 "Error opening %s as experiment control accessdb" % \ 263 accessdb_file) 264 for fid in self.accessdb.keys(): 265 self.auth.set_attribute(fid, 'create') 266 self.read_accessdb(accessdb_file) 266 267 else: 267 268 raise service_error(service_error.internal, … … 391 392 392 393 def read_accessdb(self, accessdb_file): 393 access = {} 394 """ 395 Read the mapping from fedids that can create experiments to their name 396 in the 3-level access namespace. All will be asserted from this 397 testbed and can include the local username and porject that will be 398 asserted on their behalf by this fedd. Each fedid is also added to the 399 authorization system with the "create" attribute. 400 """ 401 self.accessdb = {} 402 # These are the regexps for parsing the db 394 403 name_expr = "[" + string.ascii_letters + string.digits + "\.\-]+" 395 404 project_line = re.compile("^\s*fedid:([" + string.hexdigits + "]+)"+ \ … … 399 408 lineno = 0 400 409 401 f = open(accessdb_file, "r") 402 for line in f: 403 lineno += 1 404 line.strip() 405 if len(line) == 0 or line.startswith('#'): 406 continue 407 m = project_line.match(line) 408 if m: 409 fid = fedid(hexstr=m.group(1)) 410 project, user = m.group(2,3) 411 if not access.has_key(fid): 412 access[fid] = [] 413 access[fid].append((project, user)) 414 continue 415 416 m = user_line.match(line) 417 if m: 418 fid = fedid(hexstr=m.group(1)) 419 project = None 420 user = m.group(2) 421 if not access.has_key(fid): 422 access[fid] = [] 423 access[fid].append((project, user)) 424 continue 410 # Parse the mappings and store in self.authdb, a dict of 411 # fedid -> (proj, user) 412 try: 413 f = open(accessdb_file, "r") 414 for line in f: 415 lineno += 1 416 line = line.strip() 417 if len(line) == 0 or line.startswith('#'): 418 continue 419 m = project_line.match(line) 420 if m: 421 fid = fedid(hexstr=m.group(1)) 422 project, user = m.group(2,3) 423 if not self.accessdb.has_key(fid): 424 self.accessdb[fid] = [] 425 self.accessdb[fid].append((project, user)) 426 continue 427 428 m = user_line.match(line) 429 if m: 430 fid = fedid(hexstr=m.group(1)) 431 project = None 432 user = m.group(2) 433 if not self.accessdb.has_key(fid): 434 self.accessdb[fid] = [] 435 self.accessdb[fid].append((project, user)) 436 continue 437 self.log.warn("[experiment_control] Error parsing access " +\ 438 "db %s at line %d" % (accessdb_file, lineno)) 439 except IOError: 425 440 raise service_error(service_error.internal, 426 "Error parsing access db %s at line %d" %\427 (accessdb_file, lineno))441 "Error opening/reading %s as experiment " +\ 442 "control accessdb" % accessdb_file) 428 443 f.close() 429 return access 430 444 445 # Initialize the authorization attributes 446 for fid in self.accessdb.keys(): 447 self.auth.set_attribute(fid, 'create') 448 449 def read_mapdb(self, file): 450 """ 451 Read a simple colon separated list of mappings for the 452 label-to-testbed-URL mappings. Clears or creates self.tbmap. 453 """ 454 455 self.tbmap = { } 456 lineno =0 457 try: 458 f = open(file, "r") 459 for line in f: 460 lineno += 1 461 line = line.strip() 462 if line.startswith('#') or len(line) == 0: 463 continue 464 try: 465 label, url = line.split(':', 1) 466 self.tbmap[label] = url 467 except ValueError, e: 468 self.log.warn("[read_mapdb] Ignored bad line (%d) in " +\ 469 "map db: %s %s" % (lineno, line, e)) 470 except IOError, e: 471 self.log.warning("[read_mapdb]: No saved map database: Can't " +\ 472 "open %s: %s" % (file, e)) 473 f.close() 431 474 432 475 def scp_file(self, file, user, host, dest=""):
Note: See TracChangeset
for help on using the changeset viewer.