Changeset 1473 for trunk/packages/invirt-web/code
- Timestamp:
- Oct 31, 2008, 10:58:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-web/code/validation.py
r1318 r1473 5 5 import re 6 6 import string 7 import dns.resolver 7 8 from invirt.database import Machine, NIC, Type, Disk, CDROM, Autoinstall 8 9 from invirt.config import structs as config … … 271 272 if machine is not None and name == machine.name: 272 273 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: 274 281 if not validMachineName(name): 275 282 raise InvalidInput('name', name, 'You must provide a machine name. Max 63 chars, alnum plus \'-\', does not begin or end with \'-\'.') 276 283 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) 278 289 279 290 def testDescription(user, description, machine=None):
Note: See TracChangeset
for help on using the changeset viewer.