Blame SOURCES/cobbler-bz-253274.patch

1070a0
From 51f0baf6c7e6ef042ce6fa7543b37b0d2d723ae0 Mon Sep 17 00:00:00 2001
1070a0
From: =?UTF-8?q?Miroslav=20Such=C3=BD?= <msuchy@redhat.com>
1070a0
Date: Fri, 23 Sep 2011 13:56:07 +0200
1070a0
Subject: [PATCH] if hostname is not resolvable do not fail and use that
1070a0
 hostname
1070a0
1070a0
in commit 588756aa7aefc122310847d007becf3112647944 cobbler start using IP address in kickstart path due s390x
1070a0
but in BZ 253274 we have example where hostname is not resolvable from the location where cobbler run.
1070a0
But it is resolvable from location where client runs.
1070a0
So if cobbler is unable to resolve hostname, do not fail and revert to behaviour prior 588756aa7aefc122310847d007becf3112647944.
1070a0
1070a0
Addressing:
1070a0
Fri Sep 23 04:51:12 2011 - INFO | Exception occured: <class 'socket.gaierror'>
1070a0
Fri Sep 23 04:51:12 2011 - INFO | Exception value: [Errno -2] Name or service
1070a0
not known
1070a0
Fri Sep 23 04:51:12 2011 - INFO | Exception Info:
1070a0
  File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 1759, in
1070a0
_dispatch
1070a0
    return method_handle(*params)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 874, in
1070a0
save_system
1070a0
    return self.save_item("system",object_id,token,editmode=editmode)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 866, in
1070a0
save_item
1070a0
    rc = self.api.add_item(what,obj)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/api.py", line 394, in
1070a0
add_item
1070a0
    return
1070a0
self.get_items(what).add(ref,check_for_duplicate_names=check_for_duplicate_names,save=save,logger=logger)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/collection.py", line 284, in
1070a0
add
1070a0
    self.lite_sync.add_single_system(ref.name)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/action_litesync.py", line
1070a0
142, in add_single_system
1070a0
    self.sync.pxegen.write_all_system_files(system)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/pxegen.py", line 295, in
1070a0
write_all_system_files
1070a0
    self.write_pxe_file(f2,system,profile,distro,working_arch)
1070a0
   File "/usr/lib/python2.6/site-packages/cobbler/pxegen.py", line 566, in
1070a0
write_pxe_file
1070a0
    ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
---
1070a0
 cobbler/pxegen.py |   19 ++++++++++++++-----
1070a0
 1 files changed, 14 insertions(+), 5 deletions(-)
1070a0
1070a0
diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py
1070a0
index 889f363..32c8f01 100644
1070a0
--- a/cobbler/pxegen.py
1070a0
+++ b/cobbler/pxegen.py
1070a0
@@ -209,8 +209,11 @@ class PXEGen:
1070a0
             blended = utils.blender(self.api, True, system)
1070a0
             self.templar.render(template_cf, blended, cf)
1070a0
             # FIXME: profiles also need this data!
1070a0
-            # FIXME: the _conf and _parm files are limited to 80 characters in length 
1070a0
-            ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
+            # FIXME: the _conf and _parm files are limited to 80 characters in length
1070a0
+            try: 
1070a0
+                ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
+            except socket.gaierror:
1070a0
+                ipaddress = blended["http_server"]
1070a0
             kickstart_path = "http://%s/cblr/svc/op/ks/system/%s" % (ipaddress, system.name)
1070a0
             # gather default kernel_options and default kernel_options_s390x
1070a0
             kopts = blended.get("kernel_options","")
1070a0
@@ -321,8 +324,11 @@ class PXEGen:
1070a0
                 blended = utils.blender(self.api, True, profile)
1070a0
                 self.templar.render(template_cf, blended, cf)
1070a0
                 # FIXME: profiles also need this data!
1070a0
-                # FIXME: the _conf and _parm files are limited to 80 characters in length 
1070a0
-                ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
+                # FIXME: the _conf and _parm files are limited to 80 characters in length
1070a0
+                try: 
1070a0
+                    ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
+                except socket.gaierror:
1070a0
+                    ipaddress = blended["http_server"]
1070a0
                 kickstart_path = "http://%s/cblr/svc/op/ks/profile/%s" % (ipaddress, profile.name)
1070a0
                 # gather default kernel_options and default kernel_options_s390x
1070a0
                 kopts = blended.get("kernel_options","")
1070a0
@@ -666,7 +672,10 @@ class PXEGen:
1070a0
 
1070a0
             # FIXME: need to make shorter rewrite rules for these URLs
1070a0
 
1070a0
-            ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
+            try:
1070a0
+                ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
1070a0
+            except socket.gaierror:
1070a0
+                ipaddress = blended["http_server"]
1070a0
             if system is not None and kickstart_path.startswith("/"):
1070a0
                 kickstart_path = "http://%s/cblr/svc/op/ks/system/%s" % (ipaddress, system.name)
1070a0
             elif kickstart_path.startswith("/"):
1070a0
-- 
1070a0
1.7.6.2
1070a0