def remove_from_poller(self, gid): # remove from master set self.rc.zrem(S1.gid_set('all'), gid) # clear cache self.rc.delete(S1.cache_key(gid)) self.del_destination_param(gid, 'cache', gid, S1.updated_key()) self.del_destination_param(gid, 'cache', gid, S1.etag_key()) self.purge_temp_accounts(gid)
def forget_source(self, master_gid, gid): """ Removes source gid, unlinks all bindings associated with the source @param master_gid: master gid @param gid: source gid @return: """ self.logger.info('Removing source [{0}:{1}]...'.format( master_gid, gid)) destinations = self.get_destinations(gid) for destination in destinations: users = self.get_destination_users(gid, destination) for user in users: # source gid can be bound to destination that does not belong to this master gid # forget_destination will only remove bindings that belong to this master gid DataApi.forget_destination(self, self.logger, gid, destination, user) # remove the gid from the list of child accounts self.remove_linked_account(master_gid, gid) # clear gid data if no destinations left destinations = self.get_destinations(gid) if not destinations: self.logger.info( 'Source [{0}:{1}] is orphaned, cleaning...'.format( master_gid, gid)) # remove user keys self.rc.delete(S1.gid_key(gid)) self.rc.delete(S1.gid_log_key(gid)) self.rc.delete(S1.links_key(gid)) self.rc.delete(S1.cache_key(gid)) self.del_destination_param(gid, 'cache', '', S1.cache_shorten_urls()) # clear chache and remove gid from poller list self.remove_from_poller(gid) # remove tnc self.rc.hdel(S1.TERMS_OK_KEY, gid)