You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2012/04/21 20:44:11 UTC

svn commit: r1328723 - in /libcloud/trunk: CHANGES libcloud/compute/deployment.py libcloud/compute/ssh.py test/compute/test_deployment.py

Author: tomaz
Date: Sat Apr 21 18:44:11 2012
New Revision: 1328723

URL: http://svn.apache.org/viewvc?rev=1328723&view=rev
Log:
Allow user to pass mode argument to SSHClient.put method and default it to
'w'. Also  modify SSHKeyDeployment step to use append mode so it doesn't
overwrite existing entries in .ssh/authorized_keys. This patches have been
contributed by Jay Doane and are part of LIBCLOUD-187 and LIBCLOUD-188.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/compute/deployment.py
    libcloud/trunk/libcloud/compute/ssh.py
    libcloud/trunk/test/compute/test_deployment.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1328723&r1=1328722&r2=1328723&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Sat Apr 21 18:44:11 2012
@@ -52,6 +52,14 @@ Changes with Apache Libcloud in developm
       for the vCloud version 1.5. LIBCLOUD-183
       [Michal Galet, Sengor Kusturica]
 
+    - Allow user to pass mode argument to SSHClient.put method and default it to
+      'w'. ; LIBCLOUD-188
+      [Jay Doane]
+
+    - Modify SSHKeyDeployment step to use append mode so it doesn't overwrite
+      existing entries in .ssh/authorized_keys. ; LIBCLOUD-187
+      [Jay Doane]
+
   *) Storage
 
     - Large object upload support for CloudFiles driver

Modified: libcloud/trunk/libcloud/compute/deployment.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/deployment.py?rev=1328723&r1=1328722&r2=1328723&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/deployment.py (original)
+++ libcloud/trunk/libcloud/compute/deployment.py Sat Apr 21 18:44:11 2012
@@ -73,7 +73,7 @@ class SSHKeyDeployment(Deployment):
 
         See also L{Deployment.run}
         """
-        client.put(".ssh/authorized_keys", contents=self.key)
+        client.put(".ssh/authorized_keys", contents=self.key, mode='a')
         return node
 
 

Modified: libcloud/trunk/libcloud/compute/ssh.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/ssh.py?rev=1328723&r1=1328722&r2=1328723&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/ssh.py (original)
+++ libcloud/trunk/libcloud/compute/ssh.py Sat Apr 21 18:44:11 2012
@@ -70,7 +70,7 @@ class BaseSSHClient(object):
         raise NotImplementedError(
             'connect not implemented for this ssh client')
 
-    def put(self, path, contents=None, chmod=None):
+    def put(self, path, contents=None, chmod=None, mode='w'):
         """
         Upload a file to the remote node.
 
@@ -82,6 +82,9 @@ class BaseSSHClient(object):
 
         @type chmod: C{int}
         @keyword chmod: chmod file to this after creation.
+
+        @type mode: C{str}
+        @keyword mode: Mode in which the file is opened.
         """
         raise NotImplementedError(
             'put not implemented for this ssh client')
@@ -147,7 +150,7 @@ class ParamikoSSHClient(BaseSSHClient):
         self.client.connect(**conninfo)
         return True
 
-    def put(self, path, contents=None, chmod=None):
+    def put(self, path, contents=None, chmod=None, mode='w'):
         sftp = self.client.open_sftp()
         # less than ideal, but we need to mkdir stuff otherwise file() fails
         head, tail = psplit(path)
@@ -162,7 +165,7 @@ class ParamikoSSHClient(BaseSSHClient):
                     # catch EEXIST consistently *sigh*
                     pass
                 sftp.chdir(part)
-        ak = sftp.file(tail, mode='w')
+        ak = sftp.file(tail, mode=mode)
         ak.write(contents)
         if chmod is not None:
             ak.chmod(chmod)

Modified: libcloud/trunk/test/compute/test_deployment.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_deployment.py?rev=1328723&r1=1328722&r2=1328723&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_deployment.py (original)
+++ libcloud/trunk/test/compute/test_deployment.py Sat Apr 21 18:44:11 2012
@@ -46,7 +46,7 @@ class MockClient(BaseSSHClient):
         self.stderr = ''
         self.exit_status = 0
 
-    def put(self, path, contents, chmod=755):
+    def put(self, path, contents, chmod=755, mode='w'):
         return contents
 
     def run(self, name):