Changeset 9294673
- Timestamp:
- Nov 21, 2011 5:33:41 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- f769cb3
- Parents:
- 80b1e82
- Location:
- fedd/federation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_control.py
r80b1e82 r9294673 960 960 tb_attrs = copy.copy(attrs) 961 961 tp.wait_for_slot() 962 uri = tbparams[tb]. get('uri', tbmap.get(testbed_base(tb), None))962 uri = tbparams[tb].uri or tbmap.get(testbed_base(tb), None) 963 963 base, suffix = split_testbed(tb) 964 964 if suffix: … … 971 971 "Unknown testbed %s !?" % tb) 972 972 973 if tbparams[tb].has_key('allocID') and \ 974 tbparams[tb]['allocID'].has_key('fedid'): 975 aid = tbparams[tb]['allocID']['fedid'] 976 else: 973 aid = tbparams[tb].allocID 974 if not aid: 977 975 raise service_error(service_error.internal, 978 976 "No alloc id for testbed %s !?" % tb) … … 1021 1019 # Create and start a thread to stop the segment 1022 1020 tp.wait_for_slot() 1023 uri = tbparams[tb] ['uri']1021 uri = tbparams[tb].uri 1024 1022 t = pooled_thread(\ 1025 1023 target=self.terminate_segment(log=log, … … 1029 1027 trusted_certs=self.trusted_certs, 1030 1028 caller=self.call_TerminateSegment), 1031 args=(uri, tbparams[tb] ['federant']['allocID']),1029 args=(uri, tbparams[tb].allocID), 1032 1030 name=tb, 1033 1031 pdata=tp, trace_file=self.trace_file) … … 1040 1038 for tb in tbparams.keys(): 1041 1039 try: 1042 self.release_access(tb, tbparams[tb] ['allocID'],1043 tbmap=tbmap, uri=tbparams[tb]. get('uri', None),1040 self.release_access(tb, tbparams[tb].allocID, 1041 tbmap=tbmap, uri=tbparams[tb].uri, 1044 1042 cert_file=cert, cert_pwd=pw) 1045 1043 except service_error, e: … … 1386 1384 "Bad access response (no access proof)") 1387 1385 1388 tbparam[tb] = { 1389 "allocID" : r['allocID'], 1390 "uri": uri, 1391 "proof": [ r['proof'] ], 1392 } 1386 tbparam[tb] = allocation_info(allocID=r['allocID'].get('fedid', None), 1387 tb=tb, uri=uri, proof=[r['proof']]) 1393 1388 1394 1389 # Collect the responses corresponding to the services this testbed … … 1405 1400 for a in r.get('fedAttr', []): 1406 1401 try: 1407 if a['attribute'] and \ 1408 isinstance(a['attribute'], basestring)\ 1409 and not tbparam[tb].has_key(a['attribute'].lower()): 1410 tbparam[tb][a['attribute'].lower()] = a['value'] 1402 if a['attribute']: 1403 tbparam[tb].set_attribute(a['attribute'], a['value']) 1411 1404 except KeyError: 1412 1405 self.log.error("Bad attribute in response: %s" % a) … … 1525 1518 # the loop. 1526 1519 auth_attrs.update([ 1527 (tbparams[tb] ['allocID']['fedid'], "/%s/%s" % ( path, dest)) \1520 (tbparams[tb].allocID, "/%s/%s" % ( path, dest)) \ 1528 1521 for tb in tbparams.keys()]) 1529 1522 … … 1829 1822 # allocation principal. Yeah, that's a long list comprehension. 1830 1823 self.append_experiment_authorization(expid, set([ 1831 (tbparams[tb] ['allocID']['fedid'], "%s/%s" % (configpath, f)) \1824 (tbparams[tb].allocID, "%s/%s" % (configpath, f)) \ 1832 1825 for tb in tbparams.keys() \ 1833 1826 for f in ("hosts", 'ca.pem', 'node.pem', … … 1982 1975 # save federant information 1983 1976 for k in allocated.keys(): 1984 exp.add_allocation( 1985 allocation_info( 1986 tb=k, 1987 allocID=tbparams[k]['allocID'].get('fedid', None), 1988 uri=tbparams[k]['uri'], 1989 proof=tbparams[k]['proof']) 1990 ) 1977 exp.add_allocation(tbparams[k]) 1991 1978 1992 1979 # Access proofs for the response message 1993 1980 proofs = [copy.deepcopy(p) for k in tbparams.keys()\ 1994 for p in tbparams[k] ['proof']]1981 for p in tbparams[k].proof] 1995 1982 if self.state_filename: 1996 1983 self.write_state() … … 2105 2092 if store_keys: 2106 2093 auth_attrs.update(set([ 2107 (tbparams[tb] ['allocID']['fedid'], sk) \2094 (tbparams[tb].allocID, sk) \ 2108 2095 for sk in store_keys.split(" ")])) 2109 2096 -
fedd/federation/experiment_info.py
r80b1e82 r9294673 14 14 self.uri = uri 15 15 self.proof = proof 16 self.attrs = { } 17 18 def set_attribute(self, a, v): 19 a = a.lower() 20 if a not in self.attrs: self.attrs[a] = v 21 22 def get_attribute(self, a, default=None): 23 a = a.lower() 24 return self.attrs.get(a, default) 16 25 17 26 class experiment_info: -
fedd/federation/experiment_partition.py
r80b1e82 r9294673 74 74 75 75 if seer_master: 76 mdomain = tbparams[seer_master].get('domain', '.example.com') 77 mproject = tbparams[seer_master].get('project', 'project') 78 muser = tbparams[seer_master].get('user', 'root') 79 smbshare = tbparams[seer_master].get('smbshare', 'USERS') 76 mdomain = tbparams[seer_master].get_attribute('domain', 77 '.example.com') 78 mproject = tbparams[seer_master].get_attribute('project', 79 'project') 80 muser = tbparams[seer_master].get_attribute('user', 'root') 81 smbshare = tbparams[seer_master].get_attribute('smbshare', 'USERS') 80 82 else: 81 83 mdomain = '.example.com' … … 84 86 smbshare = 'USERS' 85 87 86 dproject = tbparams[dt].get ('project', 'project')87 ddomain = tbparams[dt].get ('domain', '.example.com')88 dproject = tbparams[dt].get_attribute('project', 'project') 89 ddomain = tbparams[dt].get_attribute('domain', '.example.com') 88 90 89 91 if (st in masters and dt not in masters) or \ … … 108 110 if conn_type == "ssh": 109 111 try: 110 aid = tbparams[st] ['allocID']['fedid']112 aid = tbparams[st].allocID 111 113 except: 112 114 self.log.debug("[new_portal_node] Can't get alloc id for %s?" \ … … 178 180 179 181 def new_portal_substrate(self, st, dt, eid, tbparams, expid): 180 ddomain = tbparams[dt].get ('domain', ".example.com")181 dproject = tbparams[dt].get ('project', 'project')182 ddomain = tbparams[dt].get_attribute('domain', ".example.com") 183 dproject = tbparams[dt].get_attribute('project', 'project') 182 184 tsubstrate = \ 183 185 topdl.Substrate(name='%s-%s' % (st, dt), … … 189 191 ) 190 192 segment_element = topdl.Segment( 191 id= tbparams[dt]['allocID'],193 id= {'fedid': tbparams[dt].allocID }, 192 194 type='emulab', 193 195 uri = self.tbmap.get(testbed_base(dt), None), … … 222 224 for tb in tbs.keys(): 223 225 seg = topdl.Segment( 224 id = tbparams[tb]['allocID'],226 id = { 'fedid':tbparams[tb].allocID }, 225 227 type='emulab', 226 228 uri = self.tbmap.get(testbed_base(tb), None), … … 231 233 attribute=[ topdl.Attribute( 232 234 attribute='%s_endpoint' % tb_name, 233 value=tbparams[tb] [tb_name]),235 value=tbparams[tb].get_attribute(tb_name)), 234 236 ] 235 237 ) 236 238 vlan_key = "%s_vlans" % tb_name 237 if vlan_key in tbparams[tb]: 238 seg.set_attribute(vlan_key, tbparams[tb][vlan_key]) 239 if tbparams[tb].get_attribute(vlan_key) is not None: 240 seg.set_attribute(vlan_key, 241 tbparams[tb].get_attribute(vlan_key)) 239 242 segs.append(seg) 240 243 … … 242 245 # vlan_id 243 246 try: 244 aid = tbparams[tb] ['allocID']['fedid']247 aid = tbparams[tb].allocID 245 248 self.auth.set_attribute(aid, store_key) 246 249 except: … … 292 295 293 296 if seer_master: 294 mdomain = tbparams[seer_master].get('domain', '.example.com') 295 mproject = tbparams[seer_master].get('project', 'project') 297 mdomain = tbparams[seer_master].get_attribute('domain', 298 '.example.com') 299 mproject = tbparams[seer_master].get_attribute('project', 'project') 296 300 else: 297 301 mdomain = '.example.com' … … 311 315 312 316 try: 313 aid = tbparams[tb] ['allocID']['fedid']317 aid = tbparams[tb].allocID 314 318 except: 315 319 self.log.debug("[create_direct_substrate] " + … … 370 374 connInfo[st] = [ ] 371 375 for dt in [ t for t in tbs.keys() if t != st]: 372 sproject = tbparams[st].get ('project', 'project')373 dproject = tbparams[dt].get ('project', 'project')374 sdomain = tbparams[st].get ('domain', ".example.com")375 ddomain = tbparams[dt].get ('domain', ".example.com")376 aid = tbparams[dt] ['allocID']['fedid']376 sproject = tbparams[st].get_attribute('project', 'project') 377 dproject = tbparams[dt].get_attribute('project', 'project') 378 sdomain = tbparams[st].get_attribute('domain', ".example.com") 379 ddomain = tbparams[dt].get_attribute('domain', ".example.com") 380 aid = tbparams[dt].allocID 377 381 378 382 seer_master = None … … 386 390 387 391 if seer_master: 388 mdomain = tbparams[seer_master].get('domain', '.example.com') 389 mproject = tbparams[seer_master].get('project', 'project') 390 muser = tbparams[seer_master].get('user', 'root') 391 smbshare = tbparams[seer_master].get('smbshare', 'USERS') 392 mdomain = tbparams[seer_master].get_attribute('domain', 393 '.example.com') 394 mproject = tbparams[seer_master].get_attribute('project', 395 'project') 396 muser = tbparams[seer_master].get_attribute('user', 'root') 397 smbshare = tbparams[seer_master].get_attribute('smbshare', 398 'USERS') 392 399 else: 393 400 mdomain = '.example.com' … … 541 548 # transits is applicable, use the internet. 542 549 for d in self.direct_transit: 543 if all([tbparams[x]. has_key(d) for x in tbs]):550 if all([tbparams[x].get_attribute(d) for x in tbs]): 544 551 self.create_direct_substrate(s, topo, tbs, tbparams, 545 552 masters, eid, connInfo, expid, d) … … 574 581 for tb_name in self.direct_transit: 575 582 576 if tbparams[mtb]. has_key(tb_name) \577 and tbparams[tb]. has_key(tb_name):583 if tbparams[mtb].get_attribute(tb_name) \ 584 and tbparams[tb].get_attribute(tb_name): 578 585 579 586 idx = len([x for x in topo.keys() \ … … 593 600 ) 594 601 seg = topdl.Segment( 595 id= tbparams[mtb]['allocID'],602 id= {'fedid': tbparams[mtb].allocID}, 596 603 type='emulab', 597 604 uri = self.tbmap.get(testbed_base(mtb), … … 605 612 for n, v in (\ 606 613 ('domain', 607 tbparams[mtb].get('domain', 614 tbparams[mtb].getattribute( 615 'domain', 608 616 ".example.com")), 609 617 ('experiment', "%s/%s" % \ 610 (tbparams[mtb].get (618 (tbparams[mtb].get_attribute( 611 619 'project', 612 620 'project'), … … 623 631 mcsub = csub.clone() 624 632 seg = topdl.Segment( 625 id= tbparams[tb]['allocID'],633 id= { 'fedid': tbparams[tb].allocID}, 626 634 type='emulab', 627 635 uri = self.tbmap.get(testbed_base(tb), … … 635 643 for n, v in (\ 636 644 ('domain', 637 tbparams[tb].get('domain', 645 tbparams[tb].get_attribute( 646 'domain', 638 647 ".example.com")), 639 648 ('experiment', "%s/%s" % \ 640 (tbparams[tb].get('project', 649 (tbparams[tb].get_attribute( 650 'project', 641 651 'project'), 642 652 eid)),)
Note: See TracChangeset
for help on using the changeset viewer.