import socket
import pwd
import grp
+import tempfile
# Third party modules
import six
from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
-__version__ = '0.4.2'
+__version__ = '0.4.3'
LOG = logging.getLogger(__name__)
self.zones = []
self.pidfile = None
+ self.tempdir = None
+ self.temp_named_conf = None
+ self.temp_acl_cfg_file = None
+ self.temp_log_cfg_file = None
+ self.temp_zones_cfg_file = None
+
description = textwrap.dedent('''\
Generation of configuration of named (the BIND 9 name daemon).
''').strip()
return
try:
+
self.get_api_zones()
+ self.init_temp_objects()
+
finally:
+ if self.tempdir:
+ LOG.debug("Destroying temporary directory {!r} ...".format(self.tempdir.name))
+ self.tempdir.cleanup()
+ self.tempdir = None
self.pidfile = None
+ # -------------------------------------------------------------------------
+ def init_temp_objects(self):
+ """Init temporary objects and properties."""
+
+ self.tempdir = tempfile.TemporaryDirectory(
+ prefix=(self.appname + '.'), suffix='.tmp.d'
+ )
+ LOG.debug("Temporary directory: {!r}.".format(self.tempdir.name))
+
+ self.temp_named_conf = os.path.join(
+ self.tempdir.name, self.default_named_conf)
+ self.temp_acl_cfg_file = os.path.join(
+ self.tempdir.name, self.default_named_acl_cfg_file)
+ self.temp_log_cfg_file = os.path.join(
+ self.tempdir.name, self.default_named_log_cfg_file)
+ self.temp_zones_cfg_file = os.path.join(
+ self.tempdir.name, self.default_named_zones_cfg_file)
+
+ if self.verbose > 1:
+ LOG.debug("Temporary named.conf: {!r}".format(self.temp_named_conf))
+ LOG.debug("Temporary ACL conf: {!r}".format(self.temp_acl_cfg_file))
+ LOG.debug("Temporary LOG conf: {!r}".format(self.temp_log_cfg_file))
+ LOG.debug("Temporary zones conf: {!r}".format(self.temp_zones_cfg_file))
+
# -------------------------------------------------------------------------
def get_api_zones(self):