Changeset 1473 for trunk/packages


Ignore:
Timestamp:
Oct 31, 2008, 10:58:23 PM (16 years ago)
Author:
broder
Message:

Validate hostnames by querying to see if the name exists in DNS, and
add an appropriate dependency

Location:
trunk/packages/invirt-web
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-web/code/validation.py

    r1318 r1473  
    55import re
    66import string
     7import dns.resolver
    78from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall
    89from invirt.config import structs as config
     
    271272    if machine is not None and name == machine.name:
    272273        return None
    273     if not Machine.query().filter_by(name=name).count():
     274    try:
     275        f = open('/tmp/log', 'a')
     276        dns.resolver.query('%s.%s.' % (name, config.dns.domains[0]), 'A')
     277        # If the hostname didn't exist, it would have thrown an
     278        # exception by now - error out
     279        raise InvalidInput('name', name, 'Name is already taken.')
     280    except dns.resolver.NXDOMAIN, e:
    274281        if not validMachineName(name):
    275282            raise InvalidInput('name', name, 'You must provide a machine name.  Max 63 chars, alnum plus \'-\', does not begin or end with \'-\'.')
    276283        return name
    277     raise InvalidInput('name', name, "Name is already taken.")
     284    except InvalidInput:
     285        raise
     286    except:
     287        # Any other error is a validation failure
     288        raise InvalidInput('name', name, 'We were unable to verify that this name is available. If you believe this is in error, please contact us at %s' % config.dns.contact)
    278289
    279290def testDescription(user, description, machine=None):
  • trunk/packages/invirt-web/debian/changelog

    r1372 r1473  
     1invirt-web (0.0.5) unstable; urgency=low
     2
     3  * Add new dependency on python-dns
     4
     5 -- Evan Broder <broder@mit.edu>  Fri, 31 Oct 2008 22:57:41 -0400
     6
    17invirt-web (0.0.4) unstable; urgency=low
    28
  • trunk/packages/invirt-web/debian/control

    r1372 r1473  
    99Architecture: all
    1010Depends: ${misc:Depends}, libapache2-mod-fcgid, python-flup,
    11  python-cheetah, python-simplejson, invirt-database,
     11 python-cheetah, python-simplejson, python-dns, invirt-database,
    1212 invirt-vnc-client, kstart, debathena-afs-config, invirt-base,
    13  libapache2-svn, libapache2-mod-auth-kerb, postfix, subversion, zephyr-clients
     13 libapache2-svn, libapache2-mod-auth-kerb, postfix, subversion,
     14 zephyr-clients
    1415Description: the Invirt web interface
Note: See TracChangeset for help on using the changeset viewer.