#!/usr/bin/env python2
+from __future__ import print_function
import errno
import shutil
import os
except OSError as e:
if e.errno != errno.ENOENT:
raise
- os.mkdir(confdir, 0755)
+ os.mkdir(confdir, 0o755)
@classmethod
def generateAuthZone(cls, confdir, zonename, zonecontent):
'create-bind-db',
bind_dnssec_db]
- print ' '.join(pdnsutilCmd)
+ print(' '.join(pdnsutilCmd))
try:
subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- print e.output
- raise
+ raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))
@classmethod
def secureZone(cls, confdir, zonename, key=None):
'active',
'ksk']
- print ' '.join(pdnsutilCmd)
+ print(' '.join(pdnsutilCmd))
try:
subprocess.check_output(pdnsutilCmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- print e.output
- raise
+ raise AssertionError('%s failed (%d): %s' % (pdnsutilCmd, e.returncode, e.output))
@classmethod
def generateAllAuthConfig(cls, confdir):
authcmd.append('--local-address=%s' % ipaddress)
authcmd.append('--local-port=%s' % cls._authPort)
authcmd.append('--loglevel=9')
- authcmd.append('--enable-lua-record')
+ authcmd.append('--enable-lua-records')
print(' '.join(authcmd))
logFile = os.path.join(confdir, 'pdns.log')
if e.errno != errno.ESRCH:
raise
with open(logFile, 'r') as fdLog:
- print fdLog.read()
+ print(fdLog.read())
sys.exit(cls._auths[ipaddress].returncode)
@classmethod
if not found :
raise AssertionError("RRset not found in answer\n\n%s" % ret)
+ def sortRRsets(self, rrsets):
+ """Sorts RRsets in a more useful way than dnspython's default behaviour
+
+ @param rrsets: an array of dns.rrset.RRset objects"""
+
+ return sorted(rrsets, key=lambda rrset: (rrset.name, rrset.rdtype))
+
def assertAnyRRsetInAnswer(self, msg, rrsets):
"""Asserts that any of the supplied rrsets exists (without comparing TTL)
in the answer section of msg