Changeset 7027


Ignore:
Timestamp:
Jun 30, 2009, 3:47:11 PM (16 years ago)
Author:
roland
Message:

Mainly code cleanup.
Removed some odd import from networkx and fixed it in views.py.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/base.cfg

    r6637 r7027  
    11[buildout]
    22parts =
    3   extras
    43  django
    54  testrunner
     
    76
    87[versions]
    9 djangorecipe=0.15
     8djangorecipe=0.19.1
     9django-extensions=0.4.1
    1010zc.recipe.egg=1.0.0
    1111zc.recipe.testrunner=1.0.0
     
    1616  ${django:eggs}
    1717extra-paths =
    18   ${django:pythonpath}
    1918  ${buildout:directory}
    2019  ${django:location}
     
    2625  os.environ['DJANGO_SETTINGS_MODULE'] = 'exodus.development'
    2726
    28 [extras]
    29 recipe = iw.recipe.subversion
    30 urls =
    31   http://django-command-extensions.googlecode.com/svn/trunk@178 django-command-extensions
    32 
    3327[django]
    3428recipe = djangorecipe
    35 version = 1.0
     29version = 1.0.2
    3630project = exodus
    3731wsgi = true
    3832eggs =
    3933  Werkzeug
    40 pythonpath =
    41   ${extras:location}/django-command-extensions/
    42 
     34  django-extensions
     35  networkx
    4336[supervisor]
    4437recipe = zc.recipe.egg
  • TabularUnified trunk/exodus/settings.py

    r6645 r7027  
    2121# AP subnet size
    2222AP_NETMASK = 26
    23 # Graph for network
    24 try:
    25     import networkx as nx
    26     G = nx.Graph()
    27 except:
    28     G = 'no_networkx'
    2923# Master super path, set to current working path
    3024EXODUS_ROOT =  os.path.dirname(__file__)
  • TabularUnified trunk/exodus/urls.py

    r6645 r7027  
    11# (c) Roland van Laar
    22
    3 from django.conf.urls.defaults import *
    4 from exodus.models import *
     3from django.conf.urls.defaults import patterns, url
     4#from exodus.models import *
    55from django.conf import settings
    66from django.views.generic.simple import direct_to_template
  • TabularUnified trunk/exodus/views.py

    r6645 r7027  
    99
    1010from exodus.models import Node, Network, Location
    11 from exodus.settings import G
     11import networkx as nx
    1212
    1313# Views
     
    4242    writer.writerow(['name', 'location', 'longitude', 'latitude', 'masterip'])
    4343    for node in nodes:
    44         writer.writerow([node.name, node.location.description, node.location.longitude, node.location.latitude, node.masterip])
    45 
     44        writer.writerow([node.name, node.location.description,
     45                         node.location.longitude, node.location.latitude,
     46                         node.masterip])
    4647    return response
    4748
     
    5354
    5455    writer = csv.writer(response)
    55     writer.writerow(["iface","node","type","ssid","channel","antenna","polar","direction","mode","ip","netmask","linknode", "linkiface"])
     56    writer.writerow(["iface","node","type","ssid","channel","antenna","polar",
     57                     "direction","mode","ip","netmask","linknode",
     58                     "linkiface"])
    5659    for node in nodes:
    5760        for nic in node.interface_set.all():
     
    7477   
    7578    templateFile = version + '/' + file
    76     return render_to_response(templateFile, {'node' : node, 'server' : server},\
     79    return render_to_response(templateFile, {'node' : node, 'server' : server},
    7780            mimetype='text/plain')
    7881
    79 def viewNagios(request, monitor='none'):
     82def viewNagios(request, monitor=None):
    8083    nodes = Node.objects.all()
    8184    networks = Network.objects.all()
     
    8790    viewpoint=monitor
    8891    # check if networkx is available
    89     if G == 'no_networkx':
    90         monitor = 'none'
    91         print 'Networkx is not available'
     92    G = nx.Graph()
    9293    #only if monitor is set create a graph to work with
    93     if monitor != 'none':
    94         G.clear
     94    if monitor:
     95        G.clear()
    9596        for node in Node.objects.all():
    9697            if node.status == 'up':
    9798                    G.add_node(node.name)
    9899                    for interface in node.interface_set.all():
    99                         if interface.mode == 'mn' and interface.link.node.status == 'up':
     100                        if interface.mode == 'mn' and \
     101                                interface.link.node.status == 'up':
    100102                            G.add_edge(node.name,interface.link.node.name)
    101103   
    102     return render_to_response('nagios/exodus.cfg', {'nodes' : nodes, 'networks' : networks, 'locations' : locations, 'viewpoint' : viewpoint}, mimetype='text/plain')
    103 
    104 
     104    return render_to_response('nagios/exodus.cfg',
     105                              {'nodes' : nodes, 'networks' : networks,
     106                               'locations' : locations,
     107                               'viewpoint' : viewpoint},
     108                              mimetype='text/plain')
Note: See TracChangeset for help on using the changeset viewer.