Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: better exception handling on APIs connection
......................................................................

packaging: setup: better exception handling on APIs connection

Better handling of APIs connection errors better discriminating
and reporting them.
Adding some debug log lines.

Bug-Url: https://bugzilla.redhat.com/1168267
Change-Id: I13a286ffaac955b821de830a4562413ee071c860
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
(cherry picked from commit dbbeab01dcea61039ef49cfb80a6be41903e3ed9)
---
M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
1 file changed, 31 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/08/35608/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 19d9069..603c94e 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
@@ -464,6 +464,7 @@
         name=ohostedcons.Stages.HOST_ADDED,
     )
     def _closeup(self):
+        # TODO: refactor into shorter and simpler functions
         self._getPKICert()
         self._getSSHkey()
         cluster_name = None
@@ -484,15 +485,40 @@
                     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
+                    ],
+                )
+            )
 
+        try:
             conn = vdscli.connect()
             net_info = netinfo.NetInfo(vds_info.capabilities(conn))
             bridge_port = self.environment[ohostedcons.NetworkEnv.BRIDGE_IF]
             if bridge_port in net_info.vlans:
                 self.logger.debug(
-                    'Updating engine\'s management network to be vlanned'
+                    "Updating engine's management network to be vlanned"
                 )
                 vlan_id = net_info.vlans[bridge_port]['vlanid']
+                self.logger.debug(
+                    "Getting engine's management network via engine's APIs"
+                )
                 mgmt_network = engine_api.networks.get(
                     name=self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]
                 )
@@ -501,10 +527,12 @@
                 )
                 mgmt_network.update()
 
-            self.logger.debug('Adding the host to the cluster')
             cluster_name = self.environment[
                 ohostedcons.EngineEnv.HOST_CLUSTER_NAME
             ]
+            self.logger.debug(
+                "Getting the list of available clusters via engine's APIs"
+            )
             if cluster_name is not None:
                 if cluster_name not in [
                     c.get_name()
@@ -536,6 +564,7 @@
                 self.environment[
                     ohostedcons.EngineEnv.HOST_CLUSTER_NAME
                 ] = cluster_name
+            self.logger.debug('Adding the host to the cluster')
             engine_api.hosts.add(
                 self._ovirtsdk_xml.params.Host(
                     name=self.environment[


-- 
To view, visit http://gerrit.ovirt.org/35608
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I13a286ffaac955b821de830a4562413ee071c860
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: ovirt-hosted-engine-setup-1.2
Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to