def get_server(server_id): """Display all running SIP2 servers.""" try: server = Server.get_record_by_id(server_id) server['clients'] = Monitoring.get_clients_by_server_id(server_id) return jsonify({ 'id': server.id, 'metadata': server, }) except Exception as error: return jsonify({'ERROR': str(error)})
def test_redis_datastore(app, server_data): """Redis datastore tests""" with app.app_context(): datastore = Sip2RedisDatastore(app) # clear datastore datastore.flush() server = Server(server_data) datastore.add(server, 'key_1') data = datastore.get(server.id, 'server') assert data datastore.flush() assert not datastore.get(server.id)
def server(app, server_data): """Load server record.""" server = Server.create(server_data, id_='key_1') return server
def monitoring(): """Render a basic view.""" return render_template("invenio_sip2/monitoring.html", module_name=_('Invenio-SIP2'), servers=list(Server.get_all_records()))
def get_servers(cls): """Get list of servers.""" servers = Server.get_all_records() return servers
def get_number_client_by_server(cls, server_id): """Get total number of clients by server.""" server = Server.get_record_by_id(server_id) return server.number_of_clients
def get_servers(): """Display all running SIP2 servers.""" try: return jsonify({'servers': Server.get_all_records()}) except Exception as error: return jsonify({'ERROR': str(error)})
def get_clients_by_server_id(cls, server_id): """Get list of clients by server id.""" server = Server.get_record_by_id(server_id) if server: return server.get_clients()