]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Cleanup handling of failing VSphere username and password.
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 25 Jul 2024 12:46:14 +0000 (14:46 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 25 Jul 2024 12:46:14 +0000 (14:46 +0200)
lib/create_terraform/app.py
lib/create_terraform/handler/__init__.py
lib/create_terraform/handler/vmware.py
locale/de_DE/LC_MESSAGES/create_terraform.po

index 37864bbc17f866abeb24f2749fba8dc76d863c13..64a598117b856058e93b3e06aa844ea692ba0630 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.4.1'
+__version__ = '1.5.0'
 LOG = logging.getLogger(__name__)
 
 SIGNAL_NAMES = {
@@ -527,58 +527,7 @@ class CrTfApplication(BaseApplication):
         if not self.handler:
             raise TerraformHandlerError(_("No handler object available."))
 
-        need_nl = False
-
-        if not self.handler.vsphere_user:
-
-            need_nl = True
-            msg = '\n' + _("Please input the {}.").format(self.colored(
-                _('vSphere user name'), 'AQUA'))
-            print(msg)
-            self.handler.vsphere_user = input(self.colored(_('Name'), 'AQUA') + ': ')
-            if not self.handler.vsphere_user:
-                msg = _("No {} given.").format(_('vSphere user name'))
-                raise ExpectedHandlerError(msg)
-
-            for vsphere_name in self.handler.vsphere.keys():
-                LOG.debug(_("Setting user for vSphere {vs!r} to {usr!r}.").format(
-                    vs=vsphere_name, usr=self.handler.vsphere_user))
-                # Dirty, but else a change of fb_tools would be necessary (later)
-                self.handler.vsphere[vsphere_name]._user = self.handler.vsphere_user
-            print('')
-            need_nl = False
-
-        if not self.handler.vsphere_password:
-
-            # Get the name of the first (and hopefully only) VSphere
-            vsphere_name = None
-            for vn in self.handler.vsphere.keys():
-                vsphere_name = vn
-                break
-
-            if need_nl:
-                print('')
-            prompt = self.colored(_("User password of {!r}").format(
-                self.handler.vsphere_user), 'AQUA')
-            item = _('Password for user {u!r} of vSphere {n} on {h!r}').format(
-                u=self.handler.vsphere_user, n=vsphere_name,
-                h=self.config.vsphere[vsphere_name].host)
-            item = self.colored(item, 'AQUA')
-            self.handler.vsphere_password = self.get_secret(prompt=prompt, item_name=item)
-            if not self.handler.vsphere_password:
-                msg = _("No {} given.").format(_('password of vSphere user'))
-                raise ExpectedHandlerError(msg)
-
-            for vsphere_name in self.handler.vsphere.keys():
-                LOG.debug(_("Setting passwort of vSphere {vs!r} user {usr!r}.").format(
-                    vs=vsphere_name, usr=self.handler.vsphere_user))
-                # Dirty, but else a change of fb_tools would be necessary (later)
-                self.handler.vsphere[vsphere_name]._password = self.handler.vsphere_password
-            print('')
-            need_nl = False
-
-        if need_nl:
-            print('')
+        return
 
     # -------------------------------------------------------------------------
     def post_run(self):
index b83bc3a523ee5c36ea6a002f80c9e867dba1d65f..dff853a30b874897671990189d40cd3d8013c96b 100644 (file)
@@ -32,8 +32,8 @@ from fb_tools.handling_obj import HandlingObject, CalledProcessError
 from fb_tools.handler import BaseHandler
 
 # Own modules
+from ..errors import ConsulApiNotFoundError
 from .dns import CrTfHandlerDnsMixin
-from .errors import ConsulApiNotFoundError
 from .files import CrTfHandlerFilesMixin
 from .first import CrTfHandlerFirstMixin
 from .read import CrTfHandlerReadMixin
@@ -50,7 +50,7 @@ from ..errors import AbortExecution
 
 from ..xlate import XLATOR
 
-__version__ = '4.3.1'
+__version__ = '4.3.2'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -148,9 +148,6 @@ class CreateTerraformHandler(
 
         self.vsphere_vm_cache = {}
 
-        self.vsphere_user = None
-        self.vsphere_password = None
-
         self.used_networks = {}
         self.used_dc_clusters = {}
         self.used_datastores = {}
index e52f5b3293bcbc55cf4d8c92d5e801873a411a1d..ed8fa7c77fbf5ec8ab1c7f46346030955276beb2 100644 (file)
@@ -31,7 +31,7 @@ from ..slim_vm import SlimVm
 
 from ..xlate import XLATOR
 
-__version__ = '1.0.1'
+__version__ = '1.1.0'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -127,14 +127,6 @@ class CrTfHandlerVmwMixin():
                 msg = _("VSPhere {!r} not defined in configuration.").format(vsphere_name)
                 raise ExpectedHandlerError(msg)
 
-            if not self.vsphere_user and self.config.vsphere[vsphere_name].user:
-                LOG.debug(_("Setting {st} to {what!r}.").format(
-                    st='handler.vsphere_user', what=self.config.vsphere[vsphere_name].user))
-                self.vsphere_user = self.config.vsphere[vsphere_name].user
-            if not self.vsphere_password and self.config.vsphere[vsphere_name].password:
-                LOG.debug(_("Setting {}.").format('handler.vsphere_password'))
-                self.vsphere_password = self.config.vsphere[vsphere_name].password
-
             try:
                 params = {
                     'appname': self.appname,
@@ -153,8 +145,8 @@ class CrTfHandlerVmwMixin():
 
                 connect_info = VSPhereConfigInfo(
                     appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
-                    host=vs_host, port=vs_port, dc=vs_dc, user=self.vsphere_user,
-                    password=self.vsphere_password, initialized=True)
+                    host=vs_host, port=vs_port, dc=vs_dc, user=self.config.vsphere[vsphere_name].user,
+                    configured_password=self.config.vsphere[vsphere_name].password, initialized=True)
 
                 params['connect_info'] = connect_info
                 show_params['connect_info'] = connect_info.as_dict()
@@ -167,6 +159,7 @@ class CrTfHandlerVmwMixin():
                     LOG.debug(msg)
 
                 vsphere = VsphereConnection(**params)
+                vsphere._check_credentials()
                 self.vsphere[vsphere_name] = vsphere
 
             except VSphereExpectedError as e:
index 41f5ed93cb58ea182d37e480055b689752eaefb9..d70cf31a4795ff9645959c250e5fa8807da0a778 100644 (file)
@@ -63,23 +63,23 @@ msgstr "Gelesene Konfiguration:"
 
 #: lib/create_terraform/app.py:292
 msgid "Removing allowed puppet environments ..."
-msgstr "Ungültige Puppet-Umgebung {!r}."
+msgstr "Entferne erlaubte Puppet-Umgebungen …"
 
 #: lib/create_terraform/app.py:296
 msgid "Removing puppet environment {!r} ..."
-msgstr "Setze Puppet Umgebung auf {!r}."
+msgstr "Entferne Puppet Umgebung {!r} …"
 
 #: lib/create_terraform/app.py:300
 msgid "Adding allowed puppet environments ..."
-msgstr "Ungültige Puppet-Umgebung {!r}."
+msgstr "Füge erlaubte Puppet-Umgebungen hinzu …"
 
 #: lib/create_terraform/app.py:304
 msgid "Adding puppet environment {!r} ..."
-msgstr "Ungültige Puppet-Umgebung {!r}."
+msgstr "Füge Puppet-Umgebung {!r} hinzu …"
 
 #: lib/create_terraform/app.py:309
 msgid "Allowed puppet environments:"
-msgstr "Ungültige Puppet-Umgebung {!r}."
+msgstr "Erlaubte Puppet-Umgebungen:"
 
 #: lib/create_terraform/app.py:321
 msgid "PowerDNS API key for {!r}"