]> git.ipfire.org Git - people/shoehn/ipfire.org.git/commitdiff
fireinfo: Support for network configurations.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 27 Dec 2010 21:01:51 +0000 (22:01 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 27 Dec 2010 21:01:51 +0000 (22:01 +0100)
www/templates/stasy-profile-detail.html
www/templates/stasy-stats-network.html [new file with mode: 0644]
www/templates/stasy-stats.html
www/webapp/backend/stasy.py
www/webapp/handlers_stasy.py

index 522e7064e899d334d34488bbe2d913540287552b..a444095a291928e491e2acbd948e01827d148ec5 100644 (file)
                </tr>
        </table>
 
+       {% if profile.network %}
+               <h4>{{ _("Network") }}</h4>
+               <table class="fireinfo">
+                       <tr>
+                               <td class="key">
+                                       {{ _("Network configuration") }}
+                               </td>
+                               <td class="value">
+                                       <table class="cpufeatures">
+                                               <tr>
+                                                       {% for zone in ("GREEN", "RED", "BLUE", "ORANGE") %}
+                                                               {% if profile.network.has_zone(zone.lower()) %}
+                                                                       <td class="enabled">
+                                                               {% else %}
+                                                                       <td class="disabled">
+                                                               {% end %}
+                                                                       {{ _(zone)  }}
+                                                               <td>
+                                                       {% end %}
+                                               </tr>
+                                       </table>
+                               </td>
+                       </tr>
+               </table>
+       {% end %}
+
        {% if profile.hypervisor %}
                <h4>{{ _("Hypervisor") }}</h4>
                <p>
diff --git a/www/templates/stasy-stats-network.html b/www/templates/stasy-stats-network.html
new file mode 100644 (file)
index 0000000..83aa46f
--- /dev/null
@@ -0,0 +1,12 @@
+{% extends "stasy-base-2.html" %}
+
+{% block title %}{% end block %}
+
+{% block content %}
+       <h3>{{ _("Network configuration") }}</h3>
+       <p>
+               This chart shows us which is the most favourite network configuration.
+       </p>
+       {{ modules.StasyTable(network_zones, sortby="percentage") }}ยด
+{% end block %}
+
index 14b1b82b6a59480094e5b0dc884d98363b6339a1..2430c218350e1583a21c7de0fc25278b9e6b027a 100644 (file)
                        <td><a href="/stats/virtual">{{ _("Virtualization") }}</a></td>
                        <td><a href="/stats/geo">{{ _("Geographical information") }}</a></td>
                </tr>
+               <tr>
+                       <td><a href="/stats/network">{{ _("Network") }}</a></td>
+                       <td>&nbsp;</td>
+                       <td>&nbsp;</td>
+               </tr>
        </table>
 {% end block %}
index f2304be0a74f6c3471d1223ee5e8f9e11a954292..d5e5aec159cc49ac19eec81d62f934797e6b1e95 100644 (file)
@@ -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()
index e561275384650c49bdb14f5dd23e91244bb446e3..37b84de90217bd5fc1f10a5ea7ca6ac42140ce21 100644 (file)
@@ -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