#!/bin/env python3
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
-__version__ = '0.6.0'
+# Standard modules
+import shutil
+
+# Own modules
+import fb_tools.common
+
+__version__ = '0.7.0'
MAX_PORT_NUMBER = (2 ** 16) - 1
DEFAULT_CONFIG_DIR = 'pixelpark'
+DEFAULT_TERMINAL_WIDTH = 99
+DEFAULT_TERMINAL_HEIGHT = 40
+
+
+# =============================================================================
+def pp(value, indent=4, width=None, depth=None):
+ """
+ Return a pretty print string of the given value.
+
+ @return: pretty print string
+ @rtype: str
+ """
+
+ if not width:
+ term_size = shutil.get_terminal_size((DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT))
+ width = term_size.columns
+
+ return fb_tools.common.pp(value, indent=indent, width=width, depth=depth)
+
+
+# =============================================================================
# vim: ts=4 et list
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.5.1'
+__version__ = '0.6.1'
# =============================================================================
env_prefix=env_prefix, config_dir=config_dir
)
+ # -------------------------------------------------------------------------
+ def line(self, width=80, linechar='-', color=None):
+ """Print out an line on stdout, if not in quiet mode."""
+ if self.quiet:
+ return
+
+ lchar = str(linechar).strip()
+ if not lchar:
+ lchar = '-'
+
+ lin = (lchar * width)[0:width]
+ if color:
+ lin=self.colored(lin, color)
+ print(lin)
+
# -------------------------------------------------------------------------
def empty_line(self):
"""Print out an empty line on stdout, if not in quiet mode."""
from pytz import timezone, UnknownTimeZoneError
# Own modules
-from fb_tools.common import pp, to_str
+from fb_tools.common import to_str
from fb_tools.app import BaseApplication
from fb_tools.pidfile import PidFileError, PidFile
from .. import __version__ as GLOBAL_VERSION
+from .. import pp
from .pdns import PpPDNSAppError, PpPDNSApplication
from ..xlate import XLATOR
-__version__ = '0.8.5'
+__version__ = '0.8.6'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
from ldap3.core.exceptions import LDAPException
# from ldap3.core.exceptions import LDAPException, LDAPBindError
-from fb_tools.common import pp, is_sequence, to_bool
+from fb_tools.common import is_sequence, to_bool
from fb_tools.argparse_actions import TimeoutOptionAction
from fb_tools.mailaddress import MailAddress
from fb_tools.collections import FrozenCIStringSet, CIStringSet, CIDict
# Own modules
from .. import __version__ as GLOBAL_VERSION
+from .. import pp
from ..xlate import XLATOR, format_list
# rom ..config.ldap import DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS
from ..config.ldap import DEFAULT_TIMEOUT
-__version__ = '0.10.0'
+__version__ = '0.10.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
attributes = ['objectClass']
ldap_filter = '(objectClass=*)'
+ LOG.debug(_("Getting all Entry DNs of LDAP instance {i!r} below {b!r}.").format(
+ i=inst, b=base_dn))
+
req_status, req_result, req_response, req_whatever = ldap.search(
search_base=base_dn, search_scope=SUBTREE, search_filter=ldap_filter,
get_operational_attributes=False, attributes=attributes,
import smtplib
# Third party modules
-from fb_tools.common import pp
from fb_tools.xlate import format_list
from fb_tools import MailAddress
# Own modules
from .. import __version__ as GLOBAL_VERSION
from .. import MAX_PORT_NUMBER, DEFAULT_CONFIG_DIR
+from .. import pp
from ..xlate import XLATOR
from . import DPXAppError, BaseDPXApplication
-__version__ = '0.3.1'
+__version__ = '0.3.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
# from ldap3 import MODIFY_REPLACE, MODIFY_ADD, MODIFY_DELETE
# Own modules
-# from fb_tools.common import to_bool, is_sequence, pp
-from fb_tools.common import pp
+# from fb_tools.common import to_bool, is_sequence
# from fb_tools.collections import FrozenCIStringSet, CIStringSet, CIDict
from fb_tools.collections import CIDict, CIStringSet
+from .. import pp
+
from ..xlate import XLATOR
from ..config.mirror_ldap import MirrorLdapConfiguration
from ..argparse_actions import NonNegativeItegerOptionAction
from ..argparse_actions import LimitedFloatOptionAction
-__version__ = '0.5.3'
+__version__ = '0.6.0'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.src_dns = []
self.tgt_dns_current = CIDict()
- self.registered_tgt_dns = CIDict()
self.limit = 0
self.wait_after_write = self.default_wait_after_write
self.countdown(number=5, delay=1, prompt=msg)
self.empty_line()
+ self.line(linechar='=', color='CYAN')
LOG.info("I'm walking, yes indeed I'm walking ...")
try:
- self.clean_target_instance()
+ self.get_current_src_entries()
+ self.get_current_tgt_entries()
+ self.eval_sync_entries()
+ # self.clean_target_instance()
except KeyboardInterrupt:
msg = _("Got a {}:").format('KeyboardInterrupt') + ' ' + _("Interrupted on demand.")
"Removing all existing entries in target LDAP instance "
"(except the base DN entry, of course)."))
- self.get_current_tgt_entries()
- self.eval_sync_entries()
- self.clean_tgt_non_struct_entries()
- self.clean_tgt_struct_entries()
+ # self.clean_tgt_non_struct_entries()
+ # self.clean_tgt_struct_entries()
+
+ # -------------------------------------------------------------------------
+ def get_current_src_entries(self):
+ """Get DNs of all entries in the source LDAP instance and sort them."""
+
+ self.empty_line()
+ self.line(color='CYAN')
+ LOG.info(_("Trying to get DNs of all entries in the source LDAP instance."))
+
+ self.src_dns = self.get_all_entry_dns_hash(self.src_instance)
+
+ sorted_dns = sorted(list(self.src_dns.keys()), key=cmp_to_key(self.compare_ldap_dns))
+
+ for dn in sorted_dns:
+ self.register_dn_tokens(dn, self.src_dns[dn], self.src_dns)
+
+ if self.verbose > 2:
+ if self.verbose > 4:
+ LOG.debug("Current source entries:\n" + pp(self.src_dns.dict()))
+ else:
+ msg = _("Found DNs in instance {!r}:").format(self.src_instance)
+ LOG.debug(msg + '\n' + pp(sorted_dns))
# -------------------------------------------------------------------------
def get_current_tgt_entries(self):
"""Get DNs of all entries in the target LDAP instance and sort them."""
- LOG.debug(_("Trying to get DNs of all entries in the target LDAP instance."))
+ self.empty_line()
+ self.line(color='CYAN')
+ LOG.info(_("Trying to get DNs of all entries in the target LDAP instance."))
self.tgt_dns_current = self.get_all_entry_dns_hash(self.tgt_instance)
+ sorted_dns = sorted(
+ list(self.tgt_dns_current.keys()), key=cmp_to_key(self.compare_ldap_dns))
- for dn in sorted(list(self.tgt_dns_current.keys()), key=cmp_to_key(self.compare_ldap_dns)):
+ for dn in sorted_dns:
self.register_dn_tokens(dn, self.tgt_dns_current[dn], self.tgt_dns_current)
- if self.verbose > 4:
- LOG.debug("Current target entries:\n" + pp(self.tgt_dns_current.dict()))
+ if self.verbose > 2:
+ if self.verbose > 4:
+ LOG.debug("Current target entries:\n" + pp(self.tgt_dns_current.dict()))
+ else:
+ msg = _("Found DNs in instance {!r}:").format(self.tgt_instance)
+ LOG.debug(msg + '\n' + pp(sorted_dns))
# -------------------------------------------------------------------------
def eval_sync_entries(self):
import psutil
# Own modules
-from fb_tools.common import pp
from fb_tools.xlate import format_list
from fb_pdnstools.zone import PowerDNSZone
from fb_pdnstools.errors import PDNSApiValidationError
from .. import __version__ as GLOBAL_VERSION
+from .. import pp
from ..argparse_actions import PortOptionAction
from ..xlate import XLATOR
-__version__ = '0.9.5'
+__version__ = '0.9.6'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
from ldap3 import MODIFY_REPLACE, MODIFY_ADD, MODIFY_DELETE
# Own modules
-from fb_tools.common import to_bool, is_sequence, pp
+from fb_tools.common import to_bool, is_sequence
+
+from .. import pp
from ..xlate import XLATOR
from .ldap import LdapAppError, FatalLDAPError
from .ldap import BaseLdapApplication
-__version__ = '0.5.7'
+__version__ = '0.5.8'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
# Own modules
# from fb_tools.common import to_bool, is_sequence, pp
-from fb_tools.common import is_sequence, pp
+from fb_tools.common import is_sequence
+
+from .. import pp
from ..xlate import XLATOR
from .ldap import BaseLdapApplication
from .ldap import PasswordFileOptionAction
-__version__ = '0.6.5'
+__version__ = '0.6.6'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
# Own modules
-from fb_tools.common import is_sequence, pp, to_bool
+from fb_tools.common import is_sequence, to_bool
# from .config import ConfigError, BaseConfiguration
from fb_tools.multi_config import DEFAULT_ENCODING
from .pdns import PdnsConfigError, PdnsConfiguration
from .mail import DEFAULT_CONFIG_DIR
+from .. import pp
+
from ..xlate import XLATOR
-__version__ = '0.2.2'
+__version__ = '0.2.3'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
# Own modules
from fb_tools import MAX_TIMEOUT
-# from fb_tools.common import pp
from fb_tools.common import is_sequence, to_bool
from fb_tools.multi_config import DEFAULT_ENCODING
from fb_tools.obj import FbGenericBaseObject, FbBaseObject
from . import PpConfigurationError, PpBaseConfiguration
from .. import MAX_PORT_NUMBER, DEFAULT_CONFIG_DIR
+# from .. import pp
from . import VALID_TIERS, DEFAULT_TIER
from ..xlate import XLATOR
-__version__ = '0.6.1'
+__version__ = '0.6.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
# Own modules
-from fb_tools.common import is_sequence, pp, to_bool
+from fb_tools.common import is_sequence, to_bool
from fb_tools.multi_config import DEFAULT_ENCODING
from .. import __version__ as GLOBAL_VERSION
from .. import MAX_PORT_NUMBER, DEFAULT_CONFIG_DIR
+from .. import pp
from . import PpConfigurationError, PpBaseConfiguration
from ..xlate import XLATOR
-__version__ = '0.2.1'
+__version__ = '0.2.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
from collections.abc import Mapping
# Third party modules
-from fb_tools.common import is_sequence, pp
+from fb_tools.common import is_sequence
from fb_tools.multi_config import DEFAULT_ENCODING
# Own modules
from .. import DEFAULT_CONFIG_DIR
+from .. import pp
from .ldap import LdapConfigError, LdapConfiguration
from ..xlate import XLATOR
-__version__ = '0.2.0'
+__version__ = '0.2.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
# Own modules
from fb_tools import MAX_TIMEOUT
-from fb_tools.common import is_sequence, pp
+from fb_tools.common import is_sequence
# from .config import ConfigError, BaseConfiguration
from fb_tools.multi_config import DEFAULT_ENCODING
from .. import __version__ as GLOBAL_VERSION
from .. import MAX_PORT_NUMBER
+from .. import pp
from .mail import MailConfigError, MailConfiguration
from .mail import DEFAULT_CONFIG_DIR
LIBRARY_NAME = "pp-pdns-api-client"
-__version__ = '0.2.4'
+__version__ = '0.2.5'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext