diff --git a/computes/models.py b/computes/models.py index 2b74de2..cfe0317 100644 --- a/computes/models.py +++ b/computes/models.py @@ -1,6 +1,9 @@ -from django.db.models import Model, CharField, IntegerField +from django.db.models import CharField, IntegerField, Model +from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ +from vrtManager.connection import connection_manager + class Compute(Model): name = CharField(_('name'), max_length=64, unique=True) @@ -10,5 +13,9 @@ class Compute(Model): details = CharField(_('details'), max_length=64, null=True, blank=True) type = IntegerField() + @cached_property + def status(self): + return connection_manager.host_is_up(self.type, self.hostname) + def __str__(self): - return self.hostname + return self.name diff --git a/computes/templates/computes.html b/computes/templates/computes.html deleted file mode 100644 index 3e7f98b..0000000 --- a/computes/templates/computes.html +++ /dev/null @@ -1,246 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block title %}{% trans "Computes" %}{% endblock %} -{% block content %} - -
{% trans "Name" %} | +{% trans "Status" %} | +{% trans "Details" %} | +{% trans "Actions" %} | +
---|---|---|---|
+ {{ compute.name }} + | ++ {% if compute.status is True %}{% trans "Connected" %}{% else %}{% trans "Not Connected" %}{% endif %} + | ++ {{ compute.details|default:"" }} + | +
+
+ {% if compute.status is True %}
+ {% icon 'eye' %}
+ {% else %}
+ {% icon 'eye' %}
+ {% endif %}
+ {% icon 'pencil' %}
+ {% icon 'times' %}
+
+ |
+