def servers_runner(**kwargs): with db_session() as db: servers = get_servers(db) init_md5 = get_md5_for_file("ansible/project/server.yml") for server in servers: if "init" not in server.config or server.config["init"] != init_md5: server_runner.delay(server.id, **kwargs)
async def servers_list( response: Response, db=Depends(get_db), user=Depends(get_current_active_user), ): """ Get all servers """ return paginate(get_servers(db, user))
def traffic_runner(): servers = get_servers(SessionLocal()) for server in servers: priv_data_dir = prepare_priv_dir(server) ansible_runner.run_async( private_data_dir=priv_data_dir, project_dir="ansible/project", playbook="traffic.yml", extravars={"host": server.ansible_name}, finished_callback=iptables_finished_handler(server), )
async def servers_list( response: Response, offset: int = 0, limit: int = 100, db=Depends(get_db), user=Depends(get_current_active_user), ): """ Get all servers """ servers = get_servers(db, user) return servers
async def servers_list( response: Response, offset: int = 0, limit: int = 100, db=Depends(get_db), user=Depends(get_current_active_user), ): """ Get all servers """ servers = jsonable_encoder(get_servers(db, user, offset, limit)) # This is necessary for react-admin to work response.headers["Content-Range"] = f"0-9/{len(servers)}" if user.is_ops or user.is_superuser: return [ServerOpsOut(**server) for server in servers] return [ServerOut(**server) for server in servers]
def traffic_runner(): with db_session() as db: servers = get_servers(db) for server in servers: traffic_server_runner(server.id) clear_cache()
def traffic_runner(): with db_session() as db: servers = get_servers(db) for server in servers: traffic_server_runner.delay(server.id)