Commit 9b402980 by Őry Máté

dashboard: show hostname on vm list

parent 99a67989
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
<div id="dashboard-vm-list"> <div id="dashboard-vm-list">
{% for i in instances %} {% for i in instances %}
<a href="{{ i.get_absolute_url }}" class="list-group-item"> <a href="{{ i.get_absolute_url }}" class="list-group-item">
<i class="icon-{% if i.state == "RUNNING" %}play-sign{% else %}pause{% endif %}"></i> {{ i.name }} <i class="{{ i.get_status_icon }}" title="{{ i.get_status_display }}"></i> {{ i.name }}
<small class="text-muted">{{ i.primary_host.hostname }}</small>
<div class="pull-right dashboard-vm-favourite" data-vm="{{ i.pk }}"> <div class="pull-right dashboard-vm-favourite" data-vm="{{ i.pk }}">
{% if i.fav %} {% if i.fav %}
<i class="icon-star text-primary title-favourite" title="Unfavourite"></i> <i class="icon-star text-primary title-favourite" title="Unfavourite"></i>
...@@ -51,7 +52,9 @@ ...@@ -51,7 +52,9 @@
<p><span class="bigbig"><big>{{ running_vm_num }}</big> running </span> <p><span class="bigbig"><big>{{ running_vm_num }}</big> running </span>
<ul class="list-inline"> <ul class="list-inline">
{% for vm in running_vms %} {% for vm in running_vms %}
<li class="label label-success"><i class="icon-play-sign"></i> {{ vm.name}}</li> <li class="label label-success">
<a href="vm.get_absolute_url" title="{{vm.primary_host.get_fqdn}}"><i class="icon-play-sign"></i> {{ vm.name}}</a>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
</p> </p>
......
...@@ -1177,3 +1177,14 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, ...@@ -1177,3 +1177,14 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
**kwargs): **kwargs):
self.shutdown(user, task_uuid) self.shutdown(user, task_uuid)
self.save_as_template(name, **kwargs) self.save_as_template(name, **kwargs)
def get_status_icon(self):
return {
'NOSTATE': 'icon-rocket',
'RUNNING': 'icon-play',
'STOPPED': 'icon-stop',
'SUSPENDED': 'icon-pause',
'ERROR': 'icon-warning_sign',
'PENDING': 'icon-rocket',
'DESTROYED': 'icon-trash',
'MIGRATING': 'icon-truck'}.get(self.status, 'icon-question-sign')
...@@ -97,6 +97,13 @@ class InstanceTestCase(TestCase): ...@@ -97,6 +97,13 @@ class InstanceTestCase(TestCase):
self.assertNotIn(call().__enter__().sub_activity(u'scheduling'), self.assertNotIn(call().__enter__().sub_activity(u'scheduling'),
ia.mock_calls) ia.mock_calls)
def test_status_icon(self):
inst = MagicMock(spec=Instance)
inst.status = 'dummy-value'
self.assertEqual(Instance.get_status_icon(inst), 'icon-question-sign')
inst.status = 'RUNNING'
self.assertEqual(Instance.get_status_icon(inst), 'icon-play')
class InterfaceTestCase(TestCase): class InterfaceTestCase(TestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment