Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: asking again on wrong engine password
......................................................................

packaging: setup: asking again on wrong engine password

Asking for engine password till the engine accepts it.

Change-Id: Ieabac668ee21d2f023cfb2b8167e5626553e5d27
Bug-Url: https://bugzilla.redhat.com/1108341
Signed-off-by: Simone Tiraboschi <[email protected]>
---
M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
1 file changed, 59 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/47/40347/1

diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py 
b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
index 81071a7..08dcb11 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
@@ -528,43 +528,68 @@
         self._getSSHkey()
         cluster_name = None
         default_cluster_name = 'Default'
-        try:
-            self.logger.debug('Connecting to the Engine')
-            engine_api = self._ovirtsdk_api.API(
-                url='https://{fqdn}/ovirt-engine/api'.format(
-                    fqdn=self.environment[
-                        ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
+        valid = False
+        while not valid:
+            try:
+                self.logger.info(_('Connecting to the Engine'))
+                engine_api = self._ovirtsdk_api.API(
+                    url='https://{fqdn}/ovirt-engine/api'.format(
+                        fqdn=self.environment[
+                            ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
+                        ],
+                    ),
+                    username='admin@internal',
+                    password=self.environment[
+                        ohostedcons.EngineEnv.ADMIN_PASSWORD
                     ],
-                ),
-                username='admin@internal',
-                password=self.environment[
-                    ohostedcons.EngineEnv.ADMIN_PASSWORD
-                ],
-                ca_file=self.environment[
-                    ohostedcons.EngineEnv.TEMPORARY_CERT_FILE
-                ],
-            )
-        except ovirtsdk.infrastructure.errors.RequestError as e:
-            self.logger.error(
-                _(
-                    'Cannot connect to engine APIs on {fqdn}:\n '
-                    '{details}\n'
-                ).format(
-                    fqdn=self.environment[
-                        ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
-                    ],
-                    details=e.detail
-                )
-            )
-            raise RuntimeError(
-                _(
-                    'Cannot connect to engine APIs on {fqdn}'
-                ).format(
-                    fqdn=self.environment[
-                        ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
+                    ca_file=self.environment[
+                        ohostedcons.EngineEnv.TEMPORARY_CERT_FILE
                     ],
                 )
-            )
+                # trigger first access
+                engine_api.clusters.list()
+            except ovirtsdk.infrastructure.errors.RequestError as e:
+                if e.status == 401:
+                    self.logger.error(
+                        _(
+                            "The engine API didn't accepted"
+                            "the password you provided\n"
+                            "Please enter it again to retry."
+                        )
+                    )
+                    self.environment[
+                        ohostedcons.EngineEnv.ADMIN_PASSWORD
+                    ] = self.dialog.queryString(
+                        name='ENGINE_ADMIN_PASSWORD',
+                        note=_(
+                            "Enter 'admin@internal' user password that "
+                            'will be used for accessing '
+                            'the Administrator Portal: '
+                        ),
+                        prompt=True,
+                        hidden=True,
+                    )
+                else:
+                    self.logger.error(
+                        _(
+                            'Cannot connect to engine APIs on {fqdn}:\n '
+                            '{details}\n'
+                        ).format(
+                            fqdn=self.environment[
+                                ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
+                            ],
+                            details=e.detail
+                        )
+                    )
+                    raise RuntimeError(
+                        _(
+                            'Cannot connect to engine APIs on {fqdn}'
+                        ).format(
+                            fqdn=self.environment[
+                                ohostedcons.NetworkEnv.OVIRT_HOSTED_ENGINE_FQDN
+                            ],
+                        )
+                    )
 
         try:
             conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI]


-- 
To view, visit https://gerrit.ovirt.org/40347
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieabac668ee21d2f023cfb2b8167e5626553e5d27
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Simone Tiraboschi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to