]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Changing command line options.
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 25 Jul 2024 16:24:27 +0000 (18:24 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 25 Jul 2024 16:24:27 +0000 (18:24 +0200)
lib/create_terraform/app.py
lib/create_terraform/config.py

index 64a598117b856058e93b3e06aa844ea692ba0630..605a561aa6d3525665169907560408d249645cd0 100644 (file)
@@ -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()
index d1655634c678f73c9c69cbe1c488c8f070b5ed36..22d1dcc0777324fed4ca087b4312993e667e2563 100644 (file)
@@ -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()