Last active
February 12, 2018 09:25
-
-
Save dtaniwaki/976b088f1579799847c6f1a379fccfa8 to your computer and use it in GitHub Desktop.
Resources page for UCRSpawner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = get_config() | |
from jupyterhub import handlers | |
handlers.default_handlers.extend([ | |
(r"/resources", ResourcesHandler), | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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