Changeset 8320 in genesis
- Timestamp:
- Aug 12, 2010, 3:07:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/make-map.py
r8306 r8320 100 100 101 101 def make_graph(): 102 status = None 103 try: 104 stream = file('/tmp/nodemap_status.yaml','r') 105 status = yaml.load(stream) 106 except IOError,e: 107 print "# Error loading status '%s'" % e 108 102 109 f = open('kmlfile.kml', 'w') 103 110 f.write("""<?xml version="1.0" encoding="UTF-8"?> … … 120 127 </Style> 121 128 <Style id="node_status_planned"> 129 <IconStyle> 130 <scale>0.5</scale> 131 <Icon><href>http://www.google.com/mapfiles/kml/paddle/wht-stars-lv.png</href></Icon> 132 </IconStyle> 133 </Style> 134 <Style id="node_status_unknown"> 122 135 <IconStyle> 123 136 <scale>0.5</scale> … … 162 175 lam, phi = rd2etrs(datadump['rdnap_x'], datadump['rdnap_y']) 163 176 node[host] = (lam, phi) 177 if not status: 178 # By default assume up 179 node_status = "up" 180 elif status['node'][host] == gformat.OK: 181 node_status = "up" 182 elif status['node'][host] == gformat.DOWN: 183 node_status = "down" 184 elif status['node'][host] == gformat.UNKNOWN: 185 node_status = "unknown" 186 else: 187 assert False, "Status cannot be generated" 164 188 f.write(""" 165 189 <description>All active nodes</description> … … 167 191 <name>Node %(name)s</name> 168 192 <description>%(desc)s</description> 169 <styleUrl> #node_status_up</styleUrl>193 <styleUrl>%(style)s</styleUrl> 170 194 <Point><coordinates>%(lam)s,%(phi)s,0</coordinates></Point> 171 195 </Placemark> 172 """ % {'name' : host, 'desc' : cgi.escape(datadump['location']), ' lam' : lam, 'phi' : phi})196 """ % {'name' : host, 'desc' : cgi.escape(datadump['location']), 'style' : '#node_status_' + node_status, 'lam' : lam, 'phi' : phi}) 173 197 nodes += [("POINT(%s, %s)" % (lam, phi))] 174 198 except (KeyError, ValueError), e: … … 186 210 for addr,leden in poel.iteritems(): 187 211 if link_type[addr] == '11a': 188 color = '#ff0000ff'189 212 weight = 2 190 213 elif link_type[addr] == 'eth': 191 color = '#ffff0000'192 214 weight = 4 193 215 else: 194 color = '#ff000000'195 216 weight = 1 196 217 … … 198 219 for index,lid in enumerate(leden[:-1]): 199 220 for buur in leden[index + 1:]: 221 key = (lid + ".wLeiden.NET", buur + ".wLeiden.NET") 222 rev_key = (key[1],key[0]) 223 link_status = None 224 if not status: 225 # Default assume OK 226 link_status = gformat.OK 227 elif status['link'].has_key(key): 228 link_status = status['link'][key] 229 elif status['link'].has_key(rev_key): 230 link_status = status['link'][rev_key] 231 else: 232 # If link is not known assume nothing 233 link_status = gformat.UNKNOWN 234 235 236 if link_status == gformat.OK: 237 color = '#ffff0000' # green 238 elif link_status == gformat.DOWN: 239 color = '#ff0000ff' # red 240 elif link_status == gformat.UNKNOWN: 241 color = '#55000000' # black 242 else: 243 assert False, "Link status not mapped properly" 244 245 200 246 f.write(""" 201 247 <Placemark>
Note:
See TracChangeset
for help on using the changeset viewer.