Changeset 10379 in genesis for tools/make_network_kml.py


Ignore:
Timestamp:
Apr 7, 2012, 1:09:20 PM (13 years ago)
Author:
rick
Message:

Link status colour by status.

Reported-by: henk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/make_network_kml.py

    r10378 r10379  
    2323<kml xmlns="http://www.opengis.net/kml/2.2">
    2424<Document>
     25  <Style id="linkDown">
     26    <LineStyle>
     27      <color>990000ff</color>
     28      <width>2</width>
     29    </LineStyle>
     30  </Style>
     31  <Style id="linkUp">
     32    <LineStyle>
     33      <color>9900ff00</color>
     34      <width>3</width>
     35    </LineStyle>
     36  </Style>
     37  <Style id="linkPlanned">
     38    <LineStyle>
     39      <color>99ff0000</color>
     40      <width>1</width>
     41    </LineStyle>
     42  </Style>
     43
    2544'''
    2645
     
    3756LINE = '''
    3857   <Placemark>
     58      <styleUrl>#%(styleId)s</styleUrl>
    3959      <LineString>
    4060        <coordinates>
     
    5070</kml>
    5171'''
     72
    5273def make_graph(debug=False):
    5374  poel = {}
    5475  link_type = {}
    5576  link_data = {}
     77  link_status = {}
    5678  hosts = {}
    5779
     
    6385      hosts[nodename] = datadump
    6486
    65       iface_keys = [elem for elem in datadump.keys() if (elem.startswith('iface_') and not "lo0" in elem)]
    66       for iface_key in iface_keys:
     87      for iface_key in datadump['autogen_iface_keys']:
    6788        l = datadump[iface_key]['ip']
    6889        addr, mask = l.split('/')
     
    7798        if poel.has_key(addr):
    7899          poel[addr] += [nodename]
     100          if link_status[addr] == 'linkUp':
     101            if datadump['status'] == 'planned':
     102              link_status[addr] = 'linkPlanned'
     103            elif datadump[iface_key]['status'] == 'planned':
     104              link_status[addr] = 'linkPlanned'
     105            elif datadump[iface_key]['status'] == 'down':
     106              link_status[addr] = 'linkDown'
    79107        else:
    80108          poel[addr] = [nodename]
     
    84112          else:
    85113            link_type[addr] = datadump[iface_key]['type']
     114
     115          if datadump['status'] == 'planned':
     116            link_status[addr] = 'linkPlanned'
     117          elif datadump[iface_key]['status'] == 'planned':
     118            link_status[addr] = 'linkPlanned'
     119          elif datadump[iface_key]['status'] == 'down':
     120            link_status[addr] = 'linkDown'
     121          else:
     122            link_status[addr] = 'linkUp'
    86123
    87124          link_data[addr] = 1
     
    125162      for buur in leden[index + 1:]:
    126163        keys = {}
     164        keys['styleId'] = link_status[addr]
    127165        for key, value in hosts[buur].iteritems():
    128166           keys[key + 'A'] = value
Note: See TracChangeset for help on using the changeset viewer.