From 0ed536701f4d2dc937dc77b2472b4165f40c62c5 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 3 Sep 2021 18:20:09 +0200 Subject: [PATCH] Changing the way of asking for passwords --- lib/cr_tf/app.py | 5 ++++- lib/cr_tf/handler.py | 23 +++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/cr_tf/app.py b/lib/cr_tf/app.py index c1a4755..7836f8e 100644 --- a/lib/cr_tf/app.py +++ b/lib/cr_tf/app.py @@ -45,7 +45,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.1.5' +__version__ = '1.1.6' LOG = logging.getLogger(__name__) SIGNAL_NAMES = { @@ -326,6 +326,9 @@ class CrTfApplication(BaseApplication): simulate=self.simulate, force=self.force, config=self.config, terminal_has_colors=self.terminal_has_colors) + self.handler.get_secret = self.get_secret + self.handler.exit = self.exit + if self.args.stop_after: self.handler.stop_at_step = self.args.stop_after diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index 8eb0971..2cdabda 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -67,7 +67,7 @@ from .terraform.disk import TerraformDisk from .xlate import XLATOR -__version__ = '3.5.2' +__version__ = '3.5.3' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -415,16 +415,6 @@ class CreateTerraformHandler(BaseHandler): raise CommandNotFoundError('terraform') self.check_terraform_version() - pdns_api_key = self.config.pdns_api_key - if not pdns_api_key: - msg = '\n' + _("Please input the {}:").format(self.colored( - 'PowerDNS API key', 'AQUA')) - print(msg) - pdns_api_key = password_input(prompt='Key: ') - if pdns_api_key == '': - msg = _("No {} given.").format('PowerDNS API key') - raise ExpectedHandlerError(msg) - self.pdns = PowerDNSServer( appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, master_server=self.config.pdns_master_server, @@ -760,13 +750,10 @@ class CreateTerraformHandler(BaseHandler): raise ExpectedHandlerError(msg) if not vsphere_password: - msg = '\n' + _("Please input the {}:").format(self.colored( - _('vSphere user password'), 'AQUA')) - print(msg) - vsphere_password = password_input(prompt=(_('vSphere user name') + ': ')) - if vsphere_password == '': - msg = _("No {} given.").format(_('vSphere user password')) - raise ExpectedHandlerError(msg) + prompt = _("User password") + item = _('Password for user {u!r} of vSphere {n} on {h!r}').format( + u=vsphere_user, n=vname, h=self.config.vsphere[vname].host) + vsphere_password = self.get_secret(prompt=prompt, item_name=item) try: params = { -- 2.39.5