Changeset 6244


Ignore:
Timestamp:
Sep 4, 2008, 10:37:42 AM (16 years ago)
Author:
RIck van der Zwet
Message:
  • Extended wllogic with some network/broadcast logic
  • Used templates and filters in order to be able to properly find and display the network and broadcast of a network which needs to be used a various templates.
Location:
exodus
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • exodus/templates/dhcpd.conf

    r6242 r6244  
     1{% load network %}
    12# The file is WirelessLeiden specific. Please make all changes in exodus
    23#
     
    1617option domain-name-servers {{ object.masterip }};
    1718
    18 {% for nic in object.nic %}
    19         # {{ nic.iface }} {{ nic.desc }}
    20        
     19{% for nic in object.nic.all %}
     20# {{ nic.iface }} {{ nic.desc }}
     21        {% for omni in nic.omni.all %}
     22subnet {% network omni.ip omni.netmask %} netmask {{ omni.netmask|subnet }} {
     23        range {{ omni.dhcpstart }} {{ omni.dhcpstop }};
     24        option routers {{ omni.ip }};
     25        option broadcast-address {% broadcast omni.ip omni.netmask %};
     26        option subnet-mask {{ omni.netmask|subnet }};
     27}
     28        {% endfor %}
     29
    2130{% endfor %}
  • exodus/wllogic.py

    r6231 r6244  
    11# (c) Roland van Laar
    22
    3 from exodus.models import Node, Network, Interlink
     3#from exodus.models import Node, Network, Interlink
    44
    55def newSSIDName(node, nic, desc):
     
    2323def showaddr(a):
    2424        return "%d.%d.%d.%d" % ((a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff)
     25
     26def netmask2subnet(s):
     27        """IPv4 netmask to subnet"""
     28        return (0xffffffff << (32 - s))
     29
     30def getSubnet(netmask):
     31        return(showaddr(netmask2subnet(netmask)))
     32
     33def network(address, netmask):
     34        """IPv4 network address when address and netmask are given"""
     35        return(parseaddr(address) & netmask2subnet(netmask))
     36
     37def broadcast(address, netmask):
     38        """IPv4 network address when address and netmask are given"""
     39        return((parseaddr(address) & netmask2subnet(netmask)) | 0xffffffff >> netmask)
     40
     41def getNetwork(address, netmask):
     42        return(showaddr(network(address,netmask)))
     43
     44def getBroadcast(address, netmask):
     45        return(showaddr(broadcast(address,netmask)))
     46
    2547
    2648def freemasterip():
Note: See TracChangeset for help on using the changeset viewer.