Commit c2b89065 by Bach Dániel

dashboard: display minion status in node list view

parent 38b6f781
......@@ -19,7 +19,8 @@ from __future__ import absolute_import
from django.contrib.auth.models import Group, User
from django_tables2 import Table, A
from django_tables2.columns import TemplateColumn, Column, LinkColumn
from django_tables2.columns import (TemplateColumn, Column, LinkColumn,
from vm.models import Node, InstanceTemplate, Lease
from django.utils.translation import ugettext_lazy as _
......@@ -67,12 +68,18 @@ class NodeListTable(Table):
minion_online = BooleanColumn(
verbose_name=_("Minion online"),
attrs={'th': {'class': 'node-list-table-thin'}},
class Meta:
model = Node
attrs = {'class': ('table table-bordered table-striped table-hover '
fields = ('pk', 'name', 'host', 'get_status_display', 'priority',
'overcommit', 'number_of_VMs', )
'minion_online', 'overcommit', 'number_of_VMs', )
class GroupListTable(Table):
......@@ -7,8 +7,9 @@
<dt>{% trans "RAM size" %}:</dt> <dd>{% widthratio 1048576 1 %} MiB</dd>
<dt>{% trans "Architecture" %}:</dt><dd>{{ }}</dd>
<dt>{% trans "Host IP" %}:</dt><dd>{{ }}</dd>
<dt>{% trans "Enabled" %}:</dt><dd>{{ node.enabled }}</dd>
<dt>{% trans "Host online" %}:</dt><dd> {{ }}</dd>
<dt>{% trans "Enabled" %}:</dt><dd>{{ node.enabled|yesno }}</dd>
<dt>{% trans "Host online" %}:</dt><dd> {{|yesno }}</dd>
<dt>{% trans "Minion online" %}:</dt><dd> {{ node.minion_online|yesno }}</dd>
<dt>{% trans "Priority" %}:</dt><dd>{{ node.priority }}</dd>
<dt>{% trans "Driver Version:" %}</dt>
......@@ -17,9 +17,14 @@
from __future__ import absolute_import, unicode_literals
from functools import update_wrapper
from glob import glob
from logging import getLogger
import os.path
from warnings import warn
import requests
from salt.client import LocalClient
import salt.utils
from time import time, sleep
from django.conf import settings
from django.db.models import (
......@@ -44,6 +49,56 @@ from .common import Trait
logger = getLogger(__name__)
class MyLocalClient(LocalClient):
def get_returns(self, jid, minions, timeout=None):
Get the returns for the command line interface via the event system
minions = set(minions)
if timeout is None:
timeout = self.opts['timeout']
jid_dir = salt.utils.jid_dir(jid,
start = time()
timeout_at = start + timeout
found = set()
ret = {}
wtag = os.path.join(jid_dir, 'wtag*')
# Check to see if the jid is real, if not return the empty dict
if not os.path.isdir(jid_dir):
logger.warning("jid_dir (%s) does not exist", jid_dir)
return ret
# Wait for the hosts to check in
while True:
time_left = timeout_at - time()
raw = self.event.get_event(time_left, jid)
if raw is not None and 'return' in raw:
ret[raw['id']] = raw['return']
if len(found.intersection(minions)) >= len(minions):
# All minions have returned, break out of the loop
logger.debug("jid %s found all minions", jid)
# Then event system timeout was reached and nothing was returned
if len(found.intersection(minions)) >= len(minions):
# All minions have returned, break out of the loop
logger.debug("jid %s found all minions", jid)
if glob(wtag) and time() <= timeout_at + 1:
# The timeout +1 has not been reached and there is still a
# write tag for the syndic
if time() > timeout_at:'jid %s minions %s did not return in time',
jid, (minions - found))
return ret
def node_available(function):
"""Decorate methods to ignore disabled Nodes.
......@@ -111,6 +166,18 @@ class Node(OperatedMixin, TimeStampedModel):
online = property(get_online)
def get_minion_online(self):
name =
client = MyLocalClient()
client.opts['timeout'] = 0.2
return bool(client.cmd(name, '')[name])
except KeyError:
return False
minion_online = property(get_minion_online)
def get_info(self):
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