handle all socket errors (socket-related/address-related and timeout related)
[certmaster.git] / certmaster / utils.py
index 6f73ccc..968d697 100644 (file)
@@ -137,6 +137,9 @@ def create_minion_keys(hostname=None):
 
     if hn is None:
         raise codes.CMException("Could not determine a hostname other than localhost")
+    else:
+        # use lowercase letters for hostnames
+        hostname = hostname.lower()
 
     key_file = '%s/%s.pem' % (cert_dir, hn)
     csr_file = '%s/%s.csr' % (cert_dir, hn)
@@ -169,8 +172,8 @@ def create_minion_keys(hostname=None):
             # print "DEBUG: submitting CSR to certmaster: %s" % master_uri
             log.debug("submitting CSR: %s  to certmaster %s" % (csr_file, master_uri))
             result, cert_string, ca_cert_string = submit_csr_to_master(csr_file, master_uri)
-        except socket.gaierror, e:
-            raise codes.CMException, "Could not locate certmaster at %s" % master_uri
+        except socket.error, e:
+            log.warning("Could not locate certmaster at %s" % master_uri)
 
         # logging here would be nice
         if not result: