Commit 52026bc1 by Kálmán Viktor

Merge branch 'issue-426' into 'master'

vmdriver queue alive check

Closes #426

See merge request !371
parents 2c4472cf 2192dc4f
......@@ -56,6 +56,11 @@
<span class="label label-warning">{% trans "Offline" %}</span>
{% endif %}
</div>
<div>
{% for k, v in queues.iteritems %}
<span class="label label-{% if v %}success{% else %}danger{% endif %}">{{ k }}</span>
{% endfor %}
</div>
</div>
<div class="col-md-10" id="node-detail-pane">
<div class="panel panel-default" id="node-detail-panel">
......
......@@ -588,6 +588,12 @@ class NodeDetailTest(LoginMixin, MockCeleryMixin, TestCase):
node = Node.objects.get(pk=1)
trait, created = Trait.objects.get_or_create(name='testtrait')
node.traits.add(trait)
self.patcher = patch("vm.tasks.vm_tasks.get_queues", return_value={
'x': [{'name': "devenv.vm.fast"}],
'y': [{'name': "devenv.vm.slow"}],
'z': [{'name': "devenv.net.fast"}],
})
self.patcher.start()
def tearDown(self):
super(NodeDetailTest, self).tearDown()
......@@ -595,6 +601,7 @@ class NodeDetailTest(LoginMixin, MockCeleryMixin, TestCase):
self.u2.delete()
self.us.delete()
self.g1.delete()
self.patcher.stop()
def test_404_superuser_node_page(self):
c = Client()
......@@ -602,6 +609,12 @@ class NodeDetailTest(LoginMixin, MockCeleryMixin, TestCase):
response = c.get('/dashboard/node/25555/')
self.assertEqual(response.status_code, 404)
def test_200_superuser_node_page(self):
c = Client()
self.login(c, 'superuser')
response = c.get('/dashboard/node/1/')
self.assertEqual(response.status_code, 200)
def test_302_user_node_page(self):
c = Client()
self.login(c, 'user1')
......
......@@ -37,6 +37,7 @@ from django_tables2 import SingleTableView
from firewall.models import Host
from vm.models import Node, NodeActivity, Trait
from vm.tasks.vm_tasks import check_queue
from ..forms import TraitForm, HostForm, NodeForm
from ..tables import NodeListTable
......@@ -107,6 +108,13 @@ class NodeDetailView(LoginRequiredMixin,
context['trait_form'] = form
context['graphite_enabled'] = (
settings.GRAPHITE_URL is not None)
node_hostname = self.object.host.hostname
context['queues'] = {
'vmcelery.fast': check_queue(node_hostname, "vm", "fast"),
'vmcelery.slow': check_queue(node_hostname, "vm", "slow"),
'netcelery.fast': check_queue(node_hostname, "net", "fast"),
}
return context
def post(self, request, *args, **kwargs):
......
......@@ -160,6 +160,8 @@ class Node(OperatedMixin, TimeStampedModel):
"""
try:
self.get_remote_queue_name("vm", "fast")
self.get_remote_queue_name("vm", "slow")
self.get_remote_queue_name("net", "fast")
except:
return False
else:
......
......@@ -57,7 +57,7 @@ def get_queues():
inspect = celery.control.inspect()
inspect.timeout = 0.5
result = inspect.active_queues()
logger.debug('Queue list of length %d cached.', len(result))
logger.debug('Queue list of length %d cached.', result and len(result))
cache.set(key, result, 10)
return result
......
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