def get_proxies(self,condorq_dict,condorq_dict_types, status_dict,status_dict_types): new_users_set=glideinFrontendLib.getCondorQUsers(condorq_dict) old_users_set=self.config_data['users_set'] if old_users_set==new_users_set: return self.get_proxies_from_data() # users changed removed_users=old_users_set-new_users_set added_users=new_users_set-old_users_set if len(removed_users)>0: self.shrink_proxies(len(removed_users)) if len(added_users)>0: self.expand_proxies(len(added_users)) self.config_data['users_set']=new_users_set self.save() return self.get_proxies_from_data()
def update_usermap(self, condorq_dict, condorq_dict_types, status_dict, status_dict_types): self.users_set = glideinFrontendLib.getCondorQUsers(condorq_dict) return
def get_credentials(self, condorq_dict, condorq_dict_types, status_dict, status_dict_types, credential_type=None, trust_domain=None): users = list(glideinFrontendLib.getCondorQUsers(condorq_dict)) out_proxies = [] # check if there are more users than proxies user_map = self.config_data['user_map'] if len(users) < len(user_map.keys()): # regular algorithm, find in cache for user in users: if not user_map.has_key(user): # user not in cache, get the oldest unused entry # not ordered, need to loop over the whole cache keys = user_map.keys() keys.sort() min_key = keys[0] # will compare all others to the first for k in keys[1:]: if user_map[k]['last_seen'] < user_map[min_key]['last_seen']: min_key = k # replace min_key with the current user user_map[user] = user_map[min_key] del user_map[min_key] # else the user is already in the cache... just use that cel = user_map[user] out_proxies.append(cel['proxy']) # save that you have indeed seen the user cel['last_seen'] = time.time() else: # more users than proxies, use all proxies keys = user_map.keys() keys.sort() uncovered_users = users[0:] uncovered_keys = [] # first get the covered keys for k in keys: if (k in users): # the user in the cache is still present, use it cel = user_map[k] out_proxies.append(cel['proxy']) # save that you have indeed seen the user cel['last_seen'] = time.time() uncovered_users.remove(k) else: # this cache entry need to be updated uncovered_keys.append(k) # now add uncovered keys for k in uncovered_keys: # change key value with an uncovered user user = uncovered_users.pop() user_map[user] = user_map[k] del user_map[k] cel = user_map[user] out_proxies.append(cel['proxy']) # save that you have indeed seen the user cel['last_seen'] = time.time() # save changes self.save() return list2ilist(out_proxies)
def get_credentials(self, condorq_dict, condorq_dict_types, status_dict, status_dict_types, credential_type=None, trust_domain=None): users_set = glideinFrontendLib.getCondorQUsers(condorq_dict) return self.get_proxies_from_cardinality(len(users_set),credential_type,trust_domain)
def get_proxies(self,condorq_dict,condorq_dict_types, status_dict,status_dict_types): users_set=glideinFrontendLib.getCondorQUsers(condorq_dict) return self.get_proxies_from_cardinality(len(users_set))