From: Frank Brehm Date: Thu, 25 Jul 2024 16:24:27 +0000 (+0200) Subject: Changing command line options. X-Git-Tag: 1.11.0^2~2 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=b1e22f4cc8668d9077b8afde127977994a2a914e;p=pixelpark%2Fcreate-terraform.git Changing command line options. --- diff --git a/lib/create_terraform/app.py b/lib/create_terraform/app.py index 64a5981..605a561 100644 --- a/lib/create_terraform/app.py +++ b/lib/create_terraform/app.py @@ -42,7 +42,7 @@ from .xlate import __base_dir__ as __xlate_base_dir__ from .xlate import __mo_file__ as __xlate_mo_file__ from .xlate import XLATOR, LOCALE_DIR, DOMAIN -__version__ = '1.5.0' +__version__ = '1.6.0' LOG = logging.getLogger(__name__) SIGNAL_NAMES = { @@ -428,10 +428,19 @@ class CrTfApplication(BaseApplication): # PowerDNS options pdns_group = self.arg_parser.add_argument_group(_('PowerDNS options')) - pdns_group.add_argument( - '--pdns', action="store_true", dest='do_pdns', - help=_('Execute PowerDNS checks or actions.') - ) + enable_pdns_group = pdns_group.add_mutually_exclusive_group() + + help_text = _('Execute PowerDNS checks or actions.') + if not CrTfConfiguration.default_no_pdns: + help_text += ' ' + _('(Default)') + enable_pdns_group.add_argument( + '--pdns', action="store_true", dest='do_pdns', help=help_text) + + help_text = _('Do not execute PowerDNS checks or actions.') + if CrTfConfiguration.default_no_pdns: + help_text += ' ' + _('(Default)') + enable_pdns_group.add_argument( + '--no-pdns', action="store_false", dest='do_pdns', help=help_text) pdns_group.add_argument( '-M', '--pdns-master', metavar=_("HOST"), dest='pdns_master', @@ -492,8 +501,13 @@ class CrTfApplication(BaseApplication): # ------------------------------------------------------------------------- def perform_arg_parser_pdns(self): - if self.args.do_pdns: - self.config.no_pdns = False + do_pdns = getattr(self.args, 'do_pdns', None) + if do_pdns is not None: + if do_pdns: + self.config.no_pdns = False + else: + self.config.no_pdns = True + if self.args.pdns_master: self.config.pdns_master_server = self.args.pdns_master if self.args.pdns_api_port: @@ -512,6 +526,23 @@ class CrTfApplication(BaseApplication): LOG.info(_("Starting {a!r}, version {v!r} ...").format( a=self.appname, v=__pkg_version__)) + LOG.debug('self.args.do_pdns: {!r}'.format(self.args.do_pdns)) + LOG.debug('self.config.no_pdns: {!r}'.format(self.config.no_pdns)) + + if self.config.no_pdns: + msg = _('Automatic creation of DNS A- and PTR-records is disabled.') + else: + msg = _('Automatic creation of DNS A- and PTR-records is enabled.') + length = len(msg) + 6 + star = self.colored('*', 'cyan') + msg = star + ' ' + self.colored(msg, 'yellow') + ' ' + star + line = self.colored(('*' * length), 'cyan') + print() + print(line) + print(msg) + print(line) + print() + try: if self.handler.first_call(self.yaml_file): self.verify_vsphere_credentials() diff --git a/lib/create_terraform/config.py b/lib/create_terraform/config.py index d165563..22d1dcc 100644 --- a/lib/create_terraform/config.py +++ b/lib/create_terraform/config.py @@ -33,7 +33,7 @@ from .vs_config import VsphereConfig from .xlate import XLATOR -__version__ = '1.11.0' +__version__ = '1.12.0' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -47,6 +47,8 @@ class CrTfConfiguration(BaseConfiguration): and methods to read it from configuration files. """ + default_no_pdns = True + default_spinner = 'random' default_pdns_master_server = 'master.pp-dns.com' @@ -155,7 +157,7 @@ class CrTfConfiguration(BaseConfiguration): self._vsphere_tag_os_rhel_name = self.default_vsphere_tag_os_rhel_name self._vsphere_tag_os_rhel_desc = self.default_vsphere_tag_os_rhel_desc - self._no_pdns = True + self._no_pdns = self.default_no_pdns self.puppet_envs_add = set() self.puppet_envs_delete = set()