New hypervisor implementation: chroot manager
[ganeti-local] / lib / ssh.py
index aabb4bb..40df999 100644 (file)
@@ -25,6 +25,7 @@
 
 
 import os
+import logging
 
 from ganeti import utils
 from ganeti import errors
@@ -75,6 +76,19 @@ class SshRunner:
 
   def _BuildSshOptions(self, batch, ask_key, use_cluster_key,
                        strict_host_check):
+    """Builds a list with needed SSH options.
+
+    @param batch: same as ssh's batch option
+    @param ask_key: allows ssh to ask for key confirmation; this
+        parameter conflicts with the batch one
+    @param use_cluster_key: if True, use the cluster name as the
+        HostKeyAlias name
+    @param strict_host_check: this makes the host key checking strict
+
+    @rtype: list
+    @return: the list of options ready to use in L{utils.RunCmd}
+
+    """
     options = [
       "-oEscapeChar=none",
       "-oHashKnownHosts=no",
@@ -205,6 +219,9 @@ class SshRunner:
       output = retval.output
       if output:
         msg += ": %s" % output
+      else:
+        msg += ": %s (no output)" % retval.fail_reason
+      logging.error("Command %s failed: %s" % (retval.cmd, msg))
       return False, msg
 
     remotehostname = retval.stdout.strip()
@@ -219,6 +236,6 @@ def WriteKnownHostsFile(cfg, file_name):
   """Writes the cluster-wide equally known_hosts file.
 
   """
-  utils.WriteFile(file_name, mode=0700,
+  utils.WriteFile(file_name, mode=0600,
                   data="%s ssh-rsa %s\n" % (cfg.GetClusterName(),
                                             cfg.GetHostKey()))