Skip to content

Instantly share code, notes, and snippets.

@dtaniwaki
Last active February 12, 2018 09:25
Show Gist options
  • Save dtaniwaki/976b088f1579799847c6f1a379fccfa8 to your computer and use it in GitHub Desktop.
Save dtaniwaki/976b088f1579799847c6f1a379fccfa8 to your computer and use it in GitHub Desktop.
Resources page for UCRSpawner
c = get_config()
from jupyterhub import handlers
handlers.default_handlers.extend([
(r"/resources", ResourcesHandler),
])
{% extends "page.html" %}
{% block main %}
<div class="container">
<table class="table table-striped">
<thead>
<tr>
{% block thead %}
<th class="col-sm-3">Hostname</td>
<th class="">CPU</td>
<th class="">MEM</td>
<th class="">Disk</td>
<th class="">GPU</td>
{% endblock thead %}
</tr>
</thead>
<tbody>
{% for s in slaves %}
<tr class="{% if s.is_available() %}success{% endif %}">
{% block resources_row scoped %}
<td class="">{{s.hostname}}</td>
<td class="">{{s.used_cpus}} / {{s.cpus}}</td>
<td class="">{{s.used_mem}} / {{s.mem}}</td>
<td class="">{{s.used_disk}} / {{s.disk}}</td>
<td class="">{{s.used_gpus}} / {{s.gpus}}</td>
{% endblock resources_row %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
from tornado import web, gen
from jupyterhub.handlers import BaseHandler
class ResourcesHandler(BaseHandler):
"""Render the resources page."""
@web.authenticated
@gen.coroutine
def get(self):
slaves = self.get_current_user().spawner.get_mesos_slaves()
html = self.render_template('resources.html', slaves=slaves)
self.finish(html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment