def biomaj_remove(options): ''' Remove a bank ''' if not options.bank: return (False, "Bank name is missing") if options.remove and not options.release: return (False, "Bank release is missing") bmaj = Bank(options.bank, options=options, no_log=True) if bmaj.is_locked(): return (False, 'Bank is locked due to an other action') res = True if options.removeall: if not options.proxy: res = bmaj.removeAll(options.force) return (res, '') res = biomaj_remove_request(options) else: if not options.proxy: res = bmaj.remove(options.release) return (res, '') res = biomaj_remove_request(options) if not res: return (False, 'Failed to send removal request') return (True, 'Bank removal request sent')
def biomaj_bank_update(options): ''' Update a bank ''' if not options.bank: return (False, "Bank name is missing") banks = options.bank.split(',') gres = True msg = '' for bank in banks: options.bank = bank bmaj = Bank(bank, options=options, no_log=True) if bmaj.is_locked(): return (False, 'Bank is locked due to an other action') check_status = bmaj.check() if not check_status: msg += 'Skip bank ' + options.bank + ': wrong config\n' gres = False continue else: msg += 'Bank update request sent for ' + options.bank + '\n' if not options.proxy: res = bmaj.update(depends=True) return (res, '') res = biomaj_bank_update_request(options) if not res: msg += 'Failed to send update request for ' + options.bank + '\n' if not gres: return (False, msg) return (True, msg)
def biomaj_remove(options, config): ''' Remove a bank ''' if not options.bank: return (False, "Bank name is missing") if options.remove and not options.release: return (False, "Bank release is missing") no_log = True if not options.proxy: no_log = False # If removeall, do not set logs as log dir will be deleted if options.removeall: no_log = True bmaj = Bank(options.bank, options=options, no_log=no_log) if bmaj.is_locked(): return (False, 'Bank is locked due to an other action') res = True if options.removeall: if not options.proxy: res = bmaj.removeAll(options.force) return (res, '') res = biomaj_remove_request(options, config) else: if not options.proxy: res = bmaj.remove(options.release) Notify.notifyBankAction(bmaj) return (res, '') res = biomaj_remove_request(options, config) if not res: return (False, 'Failed to send removal request') return (True, 'Bank removal request sent')
def bank_locked(request): bank = Bank(request.matchdict['id'], no_log=True) if not can_read_bank(request, bank.bank): return HTTPForbidden('Not authorized to access this resource') if bank.is_locked(): return {'status': 1} else: return {'status': 0}
def biomaj_remove_pending(options): ''' Remove pending releases ''' if not options.bank: return (False, "Bank name is missing") bmaj = Bank(options.bank, options=options, no_log=True) if bmaj.is_locked(): return (False, 'Bank is locked due to an other action') if not options.proxy: res = bmaj.remove_pending(options.release) return (res, '') res = biomaj_remove_pending_request(options) if not res: return (False, 'Failed to send removal request') return (True, 'Request sent')
def biomaj_bank_update(options, config): ''' Update a bank ''' if not options.bank: return (False, "Bank name is missing") banks = options.bank.split(',') gres = True msg = '' for bank in banks: options.bank = bank no_log = True if not options.proxy: no_log = False # logging.debug('Options: '+str(options.__dict__)) bmaj = Bank(bank, options=options, no_log=no_log) if bmaj.is_locked(): return (False, 'Bank is locked due to an other action') check_status = bmaj.check() if not check_status: msg += 'Skip bank ' + options.bank + ': wrong config\n' gres = False continue else: msg += 'Bank update request sent for ' + options.bank + '\n' if not options.proxy: res = bmaj.update(depends=True) Notify.notifyBankAction(bmaj) else: res = biomaj_bank_update_request(options, config) if not res: msg += 'Failed to send update request for ' + options.bank + '\n' gres = False if not gres: return (False, msg) return (True, msg)