Skip to content

Commit

Permalink
Merge pull request #36 from ceph/wip-node-detail
Browse files Browse the repository at this point in the history
Individual node detail pages
  • Loading branch information
andrewschoen committed Sep 24, 2015
2 parents 610cc30 + 5d92fd9 commit d06666c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 29 deletions.
34 changes: 33 additions & 1 deletion pulpito/controllers/nodes.py
Expand Up @@ -27,7 +27,8 @@ def index(self, machine_type=None):
for node in nodes:
set_node_status_class(node)
# keep only the node name, not the fqdn
node['name'] = node['name'].split(".")[0]
node['fqdn'] = node['name']
node['name'] = node['fqdn'].split(".")[0]
desc = node['description']
if not desc or desc.lower() == "none":
node['description'] = ""
Expand All @@ -44,3 +45,34 @@ def index(self, machine_type=None):
title=title,
nodes=nodes,
)

@expose()
def _lookup(self, name, *remainder):
return NodeController(name), remainder


class NodeController(object):
def __init__(self, name):
self.name = name
self.node = None

def get_node(self):
resp = requests.get(
'{base}/nodes/{name}'.format(base=base_url,
name=self.name))
if resp.status_code == 404:
error('/errors/not_found/',
'requested node does not exist')
else:
node = resp.json()

set_node_status_class(node)
self.node = node
return self.node

@expose('nodes.html')
def index(self):
node = self.node or self.get_node()
return dict(
nodes=[node]
)
16 changes: 16 additions & 0 deletions pulpito/templates/node_table_body.html
@@ -0,0 +1,16 @@
<tr class="{{ node.status_class }}">
{% if node.fqdn %}
<td><a href="./{{ node.fqdn }}">{{ node.name }}</a></td>
{% else %}
<td>{{ node.name }}</td>
{% endif %}
<td>{{ node.machine_type }}</td>
<td>{{ node.up }}</td>
<td>{{ node.locked }}</td>
<td>{{ node.locked_since|brief }}</td>
<td>{{ node.locked_by|brief }}</td>
<td>{{ node.os_type|brief }}</td>
<td>{{ node.os_version|brief }}</td>
<td>{{ node.arch|brief }}</td>
<td>{{ node.description }}</td>
</tr>
14 changes: 14 additions & 0 deletions pulpito/templates/node_table_head.html
@@ -0,0 +1,14 @@
<thead>
<tr>
<th>Name</th>
<th>Machine Type</th>
<th>Up</th>
<th>Locked</th>
<th>Locked Since</th>
<th>Locked By</th>
<th>OS Type</th>
<th>OS Version</th>
<th>Arch</th>
<th>Description</th>
</tr>
</thead>
32 changes: 4 additions & 28 deletions pulpito/templates/nodes.html
Expand Up @@ -11,41 +11,17 @@ <h1>{{ title }}</h1>

<div class="bs-example">
<table data-sortlist="[[1,0]]" class="table table-condensed table-striped table-bordered table-hover" style="border-collapse:collapse;">
<thead>
<tr>
<th>Name</th>
<th>Machine Type</th>
<th>Up</th>
<th>Locked</th>
<th>Locked Since</th>
<th>Locked By</th>
<th>OS Type</th>
<th>OS Version</th>
<th>Arch</th>
<th>Description</th>
</tr>
</thead>
{% include "node_table_head.html" %}
<tbody>
{% if not nodes|length %}
<tr>
<td colspan=8>No nodes!</td>
</tr>
{% else %}
{% for node in nodes %}
<tr class="{{ node.status_class }}">
<td>{{ node.name }}</td>
<td>{{ node.machine_type }}</td>
<td>{{ node.up }}</td>
<td>{{ node.locked }}</td>
<td>{{ node.locked_since|brief }}</td>
<td>{{ node.locked_by|brief }}</td>
<td>{{ node.os_type|brief }}</td>
<td>{{ node.os_version|brief }}</td>
<td>{{ node.arch|brief }}</td>
<td>{{ node.description }}</td>
</tr>
{% endfor %}
{% endif %}
{% include "node_table_body.html" %}
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
Expand Down

0 comments on commit d06666c

Please sign in to comment.