def _masher_request(self, method, **kwargs): """ Call a remote method on the masher with any other arguments. Returns whatever the remote method returned to us. """ log.debug('Calling remote method "%s" with %s' % (method, kwargs)) try: client = ProxyClient(config.get('masher')) cookie = SimpleCookie(cherrypy.request.headers.get('Cookie')) session, data = client.send_request(method, auth_params={'session_id': cookie.get('tg-visit').value}, req_params=kwargs) log.debug("Remote method returned %s" % repr(data)) if data.get('tg_flash'): flash_log(data['tg_flash']) return data except Exception, e: flash_log("Error: %s" % str(e)) log.exception(e)
def mash(self, updates=None, resume=False, **kw): """ Mash a list of PackageUpdate objects. If this instance is deployed with a remote masher, then it simply proxies the request. If we are the masher, then send these updates to our Mash instance. This will then start a thread that takes care of handling all of the update requests, composing fresh repositories, generating and sending update notices, closing bugs, etc. """ if not updates: updates = [] if not isinstance(updates, list): if isinstance(updates, basestring): log.debug("Doing json hack") try: updates = json.loads( updates.replace("u'", "\"").replace("'", "\"")) except: log.debug("Didn't work, assuming it's a single update...") updates = [updates] else: updates = [updates] # If we're not The Masher, then proxy this request to it if config.get('masher'): data = self._masher_request( '/admin/mash', updates=updates, resume=resume) or {} flash_log('Push request %s' % (data.get('success') and 'succeeded' or 'failed')) raise redirect('/admin/masher') from bodhi.masher import masher masher.queue([PackageUpdate.byTitle(title) for title in updates], resume=resume) if request_format() == 'json': return dict(success=True) flash("Updates queued for mashing") raise redirect('/admin/masher')
def mash(self, updates=None, resume=False, **kw): """ Mash a list of PackageUpdate objects. If this instance is deployed with a remote masher, then it simply proxies the request. If we are the masher, then send these updates to our Mash instance. This will then start a thread that takes care of handling all of the update requests, composing fresh repositories, generating and sending update notices, closing bugs, etc. """ if not updates: updates = [] if not isinstance(updates, list): if isinstance(updates, basestring): log.debug("Doing json hack") try: updates = json.loads(updates.replace("u'", "\"").replace("'", "\"")) except: log.debug("Didn't work, assuming it's a single update...") updates = [updates] else: updates = [updates] # If we're not The Masher, then proxy this request to it if config.get('masher'): data = self._masher_request('/admin/mash', updates=updates, resume=resume) or {} flash_log('Push request %s' % (data.get('success') and 'succeeded' or 'failed')) raise redirect('/admin/masher') from bodhi.masher import masher masher.queue([PackageUpdate.byTitle(title) for title in updates], resume=resume) if request_format() == 'json': return dict(success=True) flash("Updates queued for mashing") raise redirect('/admin/masher')
def mash_tag(self, tag, **kw): """ Kick off a mash for a given tag """ log.debug("mash_tag(%s)" % locals()) if config.get('masher'): data = self._masher_request('/admin/mash_tag', tag=tag) if not data: flash_log("Mash request failed. There may be an " "existing mash that needs to be resumed first.") else: flash_log("Mash request %s" % data.get('success', 'failed')) else: from bodhi.masher import masher masher.mash_tags([tag]) flash_log("Mashing tag: %s" % tag) raise redirect('/admin/masher')
def push(self): """ List updates tagged with a push/unpush/move request """ updates = [] resume = False mash = self._current_mash() if not mash: flash_log("A masher exception has occured.") return dict(updates=[], resume=False) if mash['mashing']: flash_log('The masher is currently pushing updates') else: for update in mash.get('updates', []): try: updates.append(PackageUpdate.byTitle(update)) except SQLObjectNotFound: log.warning("Cannot find update %s in push queue" % update) if updates: flash_log('There is an updates push ready to be resumed') resume = True else: # Get a list of all updates with a request that aren't # unapproved security updates, or for a locked release requests = PackageUpdate.select( PackageUpdate.q.request != None) # Come F13+, bodhi will not have locked releases. It will # implement the 'No Frozen Rawhide' proposal, and treat 'locked' # releases as pending. #requests = filter(lambda update: not update.release.locked, # PackageUpdate.select( # PackageUpdate.q.request != None)) for update in requests: # Disable security approval requirement #if update.type == 'security' and not update.approved: # continue updates.append(update) return dict(updates=updates, resume=resume)
def push(self): """ List updates tagged with a push/unpush/move request """ updates = [] resume = False mash = self._current_mash() if not mash: flash_log("A masher exception has occured.") return dict(updates=[], resume=False) if mash['mashing']: flash_log('The masher is currently pushing updates') else: for update in mash.get('updates', []): try: updates.append(PackageUpdate.byTitle(update)) except SQLObjectNotFound: log.warning("Cannot find update %s in push queue" % update) if updates: flash_log('There is an updates push ready to be resumed') resume = True else: # Get a list of all updates with a request that aren't # unapproved security updates, or for a locked release requests = PackageUpdate.select(PackageUpdate.q.request != None) # Come F13+, bodhi will not have locked releases. It will # implement the 'No Frozen Rawhide' proposal, and treat 'locked' # releases as pending. #requests = filter(lambda update: not update.release.locked, # PackageUpdate.select( # PackageUpdate.q.request != None)) for update in requests: # Disable security approval requirement #if update.type == 'security' and not update.approved: # continue updates.append(update) return dict(updates=updates, resume=resume)