Changeset cb1a5ff22cea in nodewatcher


Ignore:
Timestamp:
09/08/2014 04:08:01 PM (5 years ago)
Author:
kostko
Branches:
Travis-warnings, Update-packages, development, feature/cidr
Children:
8bdb20e8bc86
Parents:
d7ff044ea22c
git-author:
Jernej Kos <jernej@…> (09/08/2014 04:08:01 PM)
git-committer:
Jernej Kos <jernej@…> (09/08/2014 04:08:01 PM)
Message:

Fully modularized topology storage attributes.

Location:
nodewatcher/modules
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • nodewatcher/modules/monitor/topology/processors.py

    rd7ff044ea22c rcb1a5ff22cea  
    77from nodewatcher.modules.monitor.datastream import base as ds_base, fields as ds_fields 
    88from nodewatcher.modules.monitor.datastream.pool import pool as ds_pool 
     9 
     10from . import base as tp_base 
     11from .pool import pool as tp_pool 
    912 
    1013 
     
    6669            edge = {'f': source_id, 't': destination_id} 
    6770            # Add any extra link attributes 
    68             if hasattr(link, 'get_link_attributes'): 
    69                 edge.update(link.get_link_attributes()) 
     71            for attribute in tp_pool.get_attributes(tp_base.LinkAttribute, link_class=link.__class__): 
     72                if callable(attribute.value): 
     73                    value = attribute.value(link) 
     74                else: 
     75                    value = attribute.value 
     76 
     77                edge[attribute.name] = value 
    7078 
    7179            edges.append(edge) 
    7280 
    7381        # Fetch per-node attributes 
    74         NODE_ATTRIBUTES = { 
    75             # Node name 
    76             'n': 'core.general#name', 
    77         } 
    78         # TODO: Make node topology storage fields extensible via the pool pattern 
     82        node_attributes = tp_pool.get_attributes(tp_base.NodeAttribute) 
    7983 
    8084        qs = core_models.Node.objects.filter(pk__in=vertices.keys()) 
    81         qs = qs.regpoint('config').registry_fields(**NODE_ATTRIBUTES) 
    82         qs = qs.values(*(['pk'] + NODE_ATTRIBUTES.keys())) 
     85        qs = qs.regpoint('config') 
     86        for attr in node_attributes: 
     87            try: 
     88                qs = qs.registry_fields(**{attr.name: attr.field}) 
     89            except (TypeError, ValueError): 
     90                pass 
     91 
     92        qs = qs.values(*(['pk'] + [a.name for a in node_attributes])) 
    8393        for node in qs: 
    8494            node_id = str(node['pk']) 
  • nodewatcher/modules/routing/olsr/models.py

    r1b181c6e2f58 rcb1a5ff22cea  
    102102    etx = models.FloatField(default=0.0) 
    103103 
    104     def get_link_attributes(self): 
    105         """ 
    106         Returns additional link attributes that should be included in the 
    107         topology link when it is transformed into a graph representation. 
    108         """ 
    109  
    110         return { 
    111             'proto': 'olsr', 
    112             'metrics': { 
    113                 'lq': self.lq, 
    114                 'ilq': self.ilq, 
    115                 'etx': self.etx, 
    116             }, 
    117         } 
    118  
    119104 
    120105def peer_name(text): 
  • nodewatcher/modules/routing/olsr/static/olsr/js/topology.js

    rd7ff044ea22c rcb1a5ff22cea  
    1313            } 
    1414        }).style("stroke", function(d) { 
    15             var etx = d.data.metrics.etx; 
     15            var etx = d.data.etx; 
    1616            if (etx >= 1.0 && etx <= 2.0) 
    1717                return "#00FF00"; 
Note: See TracChangeset for help on using the changeset viewer.