Martin Peřina has uploaded a new change for review.

Change subject: kdump: Try to resolve kdump destination host
......................................................................

kdump: Try to resolve kdump destination host

Tries to resolve kdump destination host as a part of checks to ensure
kdump integration is supported on host.

Change-Id: Ibb5e83769ec9d6511d90f0e4f9b218338bb5d99a
Bug-Url: https://bugzilla.redhat.com/1131161
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M src/plugins/ovirt-host-deploy/kdump/packages.py
1 file changed, 41 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy 
refs/changes/60/31760/1

diff --git a/src/plugins/ovirt-host-deploy/kdump/packages.py 
b/src/plugins/ovirt-host-deploy/kdump/packages.py
index b43e0ee..f9bd10f 100644
--- a/src/plugins/ovirt-host-deploy/kdump/packages.py
+++ b/src/plugins/ovirt-host-deploy/kdump/packages.py
@@ -24,6 +24,7 @@
 import gettext
 import platform
 import re
+import socket
 
 
 from otopi import util
@@ -106,6 +107,30 @@
                     crashkernel = True
                     break
         return crashkernel
+
+    def _destination_address_resolvable(self, host):
+        resolvable = False
+        try:
+            addresses = set([
+                address[0] for __, __, __, __, address in
+                socket.getaddrinfo(
+                    host,
+                    None
+                )
+            ])
+            self.logger.debug(
+                "Kdump destination '%s' addresses: '%s'",
+                host,
+                addresses
+            )
+            resolvable = True
+        except socket.gaierror as e:
+            self.logger.debug(
+                "Cannot resolve kdump destination '%s'",
+                host,
+                exc_info=True
+            )
+        return resolvable
 
     def _kexec_tools_version_supported(self):
         from rpmUtils.miscutils import compareEVR
@@ -191,12 +216,14 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
-        priority=plugin.Stages.PRIORITY_HIGH,
     )
     def _customization(self):
         self.environment[odeploycons.KdumpEnv.SUPPORTED] = (
             self._crashkernel_param_present() and
-            self._kexec_tools_version_supported()
+            self._kexec_tools_version_supported() and
+            self._destination_address_resolvable(
+                self.environment[odeploycons.KdumpEnv.DESTINATION_ADDRESS]
+            )
         )
 
         self.logger.info(
@@ -211,7 +238,10 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_PACKAGES,
-        condition=lambda self: self.environment[odeploycons.KdumpEnv.ENABLE],
+        condition=lambda self: (
+            self.environment[odeploycons.KdumpEnv.SUPPORTED] and
+            self.environment[odeploycons.KdumpEnv.ENABLE]
+        ),
     )
     def _packages(self):
         self.packager.installUpdate(
@@ -220,7 +250,10 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_MISC,
-        condition=lambda self: self.environment[odeploycons.KdumpEnv.ENABLE],
+        condition=lambda self: (
+            self.environment[odeploycons.KdumpEnv.SUPPORTED] and
+            self.environment[odeploycons.KdumpEnv.ENABLE]
+        ),
     )
     def _misc(self):
         with open(odeploycons.FileLocations.KDUMP_CONFIG_FILE, 'r') as f:
@@ -253,7 +286,10 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CLOSEUP,
-        condition=lambda self: self.environment[odeploycons.KdumpEnv.ENABLE],
+        condition=lambda self: (
+            self.environment[odeploycons.KdumpEnv.SUPPORTED] and
+            self.environment[odeploycons.KdumpEnv.ENABLE]
+        ),
     )
     def _closeup(self):
         self.logger.info(_('Restarting kdump'))


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb5e83769ec9d6511d90f0e4f9b218338bb5d99a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-host-deploy
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to