Changeset 9479343
- Timestamp:
- Jul 28, 2009 3:05:56 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 886307f
- Parents:
- 93d4442
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_control.py
r93d4442 r9479343 1836 1836 if req.has_key('experimentID') and \ 1837 1837 req['experimentID'].has_key('localname'): 1838 overwrite = False 1838 1839 eid = req['experimentID']['localname'] 1840 # If there's an old failed experiment here with the same local name 1841 # and accessible by this user, we'll overwrite it, otherwise we'll 1842 # fall through and do the collision avoidance. 1843 old_expid = self.get_experiment_fedid(eid) 1844 if old_expid and self.check_experiment_access(fid, old_expid): 1845 self.state_lock.acquire() 1846 status = self.state[eid].get('experimentStatus', None) 1847 if status and status == 'failed': 1848 # remove the old access attribute 1849 self.auth.unset_attribute(fid, old_expid) 1850 overwrite = True 1851 del self.state[eid] 1852 del self.state[old_expid] 1853 self.state_lock.release() 1839 1854 self.state_lock.acquire() 1840 while (self.state.has_key(eid) ):1855 while (self.state.has_key(eid) and not overwrite): 1841 1856 eid += random.choice(string.ascii_letters) 1842 1857 # Initial state … … 2068 2083 2069 2084 return rv 2085 2086 def get_experiment_fedid(self, key): 2087 """ 2088 find the fedid associated with the localname key in the state database. 2089 """ 2090 2091 rv = None 2092 self.state_lock.acquire() 2093 if self.state.has_key(key): 2094 if isinstance(self.state[key], dict): 2095 try: 2096 kl = [ f['fedid'] for f in \ 2097 self.state[key]['experimentID']\ 2098 if f.has_key('fedid') ] 2099 except KeyError: 2100 self.state_lock.release() 2101 raise service_error(service_error.internal, 2102 "No fedid for experiment %s when getting "+\ 2103 "fedid(!?)" % key) 2104 if len(kl) == 1: 2105 rv = kl[0] 2106 else: 2107 self.state_lock.release() 2108 raise service_error(service_error.internal, 2109 "multiple fedids for experiment %s when " +\ 2110 "getting fedid(!?)" % key) 2111 else: 2112 self.state_lock.release() 2113 raise service_error(service_error.internal, 2114 "Unexpected state for %s" % key) 2115 self.state_lock.release() 2116 return rv 2070 2117 2071 2118 def check_experiment_access(self, fid, key): … … 2076 2123 """ 2077 2124 if not isinstance(key, fedid): 2078 self.state_lock.acquire() 2079 if self.state.has_key(key): 2080 if isinstance(self.state[key], dict): 2081 try: 2082 kl = [ f['fedid'] for f in \ 2083 self.state[key]['experimentID']\ 2084 if f.has_key('fedid') ] 2085 except KeyError: 2086 self.state_lock.release() 2087 raise service_error(service_error.internal, 2088 "No fedid for experiment %s when checking " +\ 2089 "access(!?)" % key) 2090 if len(kl) == 1: 2091 key = kl[0] 2092 else: 2093 self.state_lock.release() 2094 raise service_error(service_error.internal, 2095 "multiple fedids for experiment %s when " +\ 2096 "checking access(!?)" % key) 2097 elif isinstance(self.state[key], str): 2098 self.state_lock.release() 2099 raise service_error(service_error.internal, 2100 ("experiment %s is placeholder. " +\ 2101 "Creation in progress or aborted oddly") \ 2102 % key) 2103 else: 2104 self.state_lock.release() 2105 raise service_error(service_error.internal, 2106 "Unexpected state for %s" % key) 2107 2108 else: 2109 self.state_lock.release() 2110 raise service_error(service_error.access, "Access Denied") 2111 self.state_lock.release() 2125 key = self.get_experiment_fedid(key) 2112 2126 2113 2127 if self.auth.check_attribute(fid, key): … … 2389 2403 'aid': aid,\ 2390 2404 } 2391 print "%s %s" % (tb, tbparams[tb])2392 2405 fed_exp['experimentStatus'] = 'terminating' 2393 2406 if self.state_filename: self.write_state()
Note: See TracChangeset
for help on using the changeset viewer.