From 07785a9cba12f446f72412343f49544aa0548ce0 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 27 Dec 2010 22:01:51 +0100 Subject: [PATCH] fireinfo: Support for network configurations. --- www/templates/stasy-profile-detail.html | 26 +++++++++++++++++ www/templates/stasy-stats-network.html | 12 ++++++++ www/templates/stasy-stats.html | 5 ++++ www/webapp/backend/stasy.py | 37 +++++++++++++++++++++++++ www/webapp/handlers_stasy.py | 6 ++++ 5 files changed, 86 insertions(+) create mode 100644 www/templates/stasy-stats-network.html diff --git a/www/templates/stasy-profile-detail.html b/www/templates/stasy-profile-detail.html index 522e706..a444095 100644 --- a/www/templates/stasy-profile-detail.html +++ b/www/templates/stasy-profile-detail.html @@ -52,6 +52,32 @@ + {% if profile.network %} +

{{ _("Network") }}

+ + + + + +
+ {{ _("Network configuration") }} + + + + {% for zone in ("GREEN", "RED", "BLUE", "ORANGE") %} + {% if profile.network.has_zone(zone.lower()) %} + +
+ {% else %} + + {% end %} + {{ _(zone) }} + + {% end %} +
+
+ {% end %} + {% if profile.hypervisor %}

{{ _("Hypervisor") }}

diff --git a/www/templates/stasy-stats-network.html b/www/templates/stasy-stats-network.html new file mode 100644 index 0000000..83aa46f --- /dev/null +++ b/www/templates/stasy-stats-network.html @@ -0,0 +1,12 @@ +{% extends "stasy-base-2.html" %} + +{% block title %}{% end block %} + +{% block content %} +

{{ _("Network configuration") }}

+

+ This chart shows us which is the most favourite network configuration. +

+ {{ modules.StasyTable(network_zones, sortby="percentage") }}´ +{% end block %} + diff --git a/www/templates/stasy-stats.html b/www/templates/stasy-stats.html index 14b1b82..2430c21 100644 --- a/www/templates/stasy-stats.html +++ b/www/templates/stasy-stats.html @@ -18,5 +18,10 @@ {{ _("Virtualization") }} {{ _("Geographical information") }} + + {{ _("Network") }} +   +   + {% end block %} diff --git a/www/webapp/backend/stasy.py b/www/webapp/backend/stasy.py index f2304be..d5e5aec 100644 --- a/www/webapp/backend/stasy.py +++ b/www/webapp/backend/stasy.py @@ -78,6 +78,27 @@ class ProfileHypervisor(ProfileDict): return self._data.get("type") +class ProfileNetwork(ProfileDict): + def has_zone(self, name): + return self._data.get(name) + + @property + def green(self): + return self._data.get("green") + + @property + def red(self): + return self._data.get("red") + + @property + def blue(self): + return self._data.get("blue") + + @property + def orange(self): + return self._data.get("orange") + + class ProfileDevice(ProfileDict): subsystem2class = { "pci" : hwdata.PCI, @@ -254,6 +275,12 @@ class Profile(ProfileDict): return "unknown" + @property + def network(self): + network = self._data.get("network", None) + if network: + return ProfileNetwork(network) + class Stasy(object): __metaclass__ = Singleton @@ -601,6 +628,16 @@ class Stasy(object): return devices + def get_network_zones_map(self): + zones = { "green" : 0, "blue" : 0, "orange" : 0, "red" : 0 } + + for zone in zones.keys(): + zones[zone] = self.query({ + "profile.network.%s" % zone : True, + }).count() + + return zones + if __name__ == "__main__": s = Stasy() diff --git a/www/webapp/handlers_stasy.py b/www/webapp/handlers_stasy.py index e561275..37b84de 100644 --- a/www/webapp/handlers_stasy.py +++ b/www/webapp/handlers_stasy.py @@ -123,6 +123,12 @@ class StasyStatsGeoHandler(StasyBaseHandler): geo_locations = self.stasy.get_geo_location_map()) +class StasyStatsNetworkHandler(StasyBaseHandler): + def get(self): + return self.render("stasy-stats-network.html", + network_zones=self.stasy.get_network_zones_map()) + + class StasyStatsVendorDetail(StasyBaseHandler): def get(self, bus, vendor_id): # XXX some way ugly -- 2.39.2