Changeset 6513


Ignore:
Timestamp:
Dec 30, 2008, 12:50:29 AM (16 years ago)
Author:
roland
Message:

added get_direction_choices to get the full name directions from exodus
for use in the generation of ssid's.

Location:
trunk/exodus
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/exodus/forms.py

    r6509 r6513  
    33from exodus.wllogic import free_master_ip, link_has_compat_type, \
    44        link_is_wireless, new_ssid, new_ssid_for_existing_interface
    5 from exodus.wllogic import MASTER, MANAGED, calc_subnet, network, show_addr
     5from exodus.wllogic import MASTER, MANAGED, calc_subnet, network, show_addr, \
     6        get_direction_choices
    67from exodus.settings import AP_NETMASK
    78from exodus.wlipcalc import IPCalc
     
    5556                    i.ip = new_ip.ips.pop()
    5657                    i.ssid = new_ssid(new_network, self.instance, i.iface,
    57                             i.accesspoint, i.direction)
     58                            i.accesspoint, i.get_direction_display())
    5859                    for j in (j for j in all_links if not j.id == i.pk):
    5960                        j.ip  = new_ip.ips.pop()
     
    288289                    i.save()
    289290                if link.accesspoint:
    290                     # Need to reverse because when i.save() happens
    291                     # the database might have an old ipaddress and unique==True
    292                     static = link.dhcpstatic_set.all()
    293                     for i in static.order_by('ipaddress').reverse():
     291                    for i in link.dhcpstatic_set.all():
    294292                        i.ipaddress = new_ip.ips.pop()
    295293                        i.save()
     
    319317                    i.netmask = netmask
    320318                    i.save()
    321                 static = link.dhcpstatic_set.all()
    322                 for i in static.order_by('ipaddress').reverse():
     319                for i in link.dhcpstatic_set.all():
    323320                    i.ipaddress = new_ip.ips.pop()
    324321                    i.save()
     
    358355        iface = self.cleaned_data.get('iface')
    359356        accesspoint = self.cleaned_data.get('accesspoint')
    360         direction = self.cleaned_data.get('direction')
     357        direction = get_direction_choices(self.cleaned_data.get('direction'))
    361358        link = self.cleaned_data.get('link')
    362359        orig_ssid = self.cleaned_data.get('ssid')
  • TabularUnified trunk/exodus/models.py

    r6507 r6513  
    137137    macaddress = models.CharField(max_length=17)
    138138    accesspoint = models.ForeignKey(Interface)
    139     ipaddress = models.IPAddressField(unique=True, blank=True)
     139    ipaddress = models.IPAddressField(blank=True)
    140140
    141141    class Meta:
  • TabularUnified trunk/exodus/wllogic.py

    r6496 r6513  
    11# (c) Roland van Laar
    22
    3 from exodus.models import Node, WIFI_MODE_CHOICES
     3from exodus.models import Node, WIFI_MODE_CHOICES, DIRECTION_CHOICES
    44from exodus.settings import MASTERIP_NETMASK, WIRELESS, COMPAT
    55from math import ceil, log
     
    99MANAGED = WIFI_MODE_CHOICES[1][0]
    1010
     11def get_direction_choices(direction):
     12    """Return the full direction given an abbreviation."""
     13    l = {}
     14    for i in DIRECTION_CHOICES:
     15        l[i[0]]  = i[1]
     16    return l[direction]
     17   
     18
    1119def new_ssid_for_existing_interface(nic):
     20    """A parser that can be called in an easier way than new_ssid."""
    1221    return new_ssid(nic.network,nic.node, nic.iface, nic.accesspoint,
    13             nic.direction)
     22            nic.get_direction_dislay())
    1423
    1524def new_ssid(network, node, iface, accesspoint=False, direction=None):
     
    3241            return (ssid % (""))
    3342
    34                
    3543        # compensate for the first AP. First AP ssid is: ap.nodename.network
    3644        # second AP is ap2.nodename.network
Note: See TracChangeset for help on using the changeset viewer.