[Erp5-report] r35307 rafael - /erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 14 03:56:11 CEST 2010


Author: rafael
Date: Fri May 14 03:56:11 2010
New Revision: 35307

URL: http://svn.erp5.org?rev=35307&view=rev
Log:
Write the ssh key, if setted.

Modified:
    erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/__init__.py

Modified: erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/__init__.py?rev=35307&r1=35306&r2=35307&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/__init__.py [utf8] Fri May 14 03:56:11 2010
@@ -56,6 +56,15 @@
     options.setdefault("kvm_redir", "")
     options.setdefault("kvm_net", "")
 
+  def _writeSSHKey(self, key, key_path):
+    """ Write the SSK key into the file
+    """
+    if not os.path.exists(key_path):
+      f = file(key_path, 'w')
+      f.write(key)
+      f.close()
+      os.chmod(key_path, 0700)
+    
   def install(self):
     options = self.options
     location = options['location']
@@ -83,6 +92,9 @@
       ssh_port = options.get("ssh_port")
       ssh_hostname = options.get("ssh_hostname", "localhost")
       ssh_key_path = options.get("ssh_key_path")
+      ssh_key = options.get("ssh_key", "")
+      if ssh_key not in [ None, "" ]:
+        self._writeSSHKey(ssh_key, ssh_key_path)
       ssh_user = options.get("ssh_user", "root")
 
       kvm_redir.append(" tcp:%s::22 " % ssh_port)




More information about the Erp5-report mailing list