def rm_container(): cid = request.form['id'] name = eru.get_container(cid)['appname'] if name == APPNAME_ERU_LB: raise ValueError('Unable to remove eru-lb, do it on load balance page') p = Project.get_by_name(name) if not p.is_accessible(g.user): return {'reason': '你没有操作这个项目的权限'}, 403 eru.remove_containers([cid]) log = OPLog.create(g.user.id, OPLOG_ACTION.delete_container) log.container_id = cid
def delete_balancer(balancer_id): balancer = Balancer.get(balancer_id) if not balancer: abort(404) if g.user.id != balancer.user_id: return {'msg': 'forbidden'}, 403 eru.remove_containers([balancer.container_id]) balancer.delete() log = OPLog.create(g.user.id, OPLOG_ACTION.delete_balancer) log.balancer_id = balancer_id log.container_id = balancer.container_id