Author: tomaz
Date: Thu Mar 7 06:33:29 2013
New Revision: 1453705
URL: http://svn.apache.org/r1453705
Log:
Fix an issue with default ScriptDeployment script file location being /root
which might not always be writable by ssh user. New location defaults to ssh
user's home directory.
Part of LIBCLOUD-302, reported by "rotem".
Modified:
libcloud/trunk/CHANGES
libcloud/trunk/libcloud/compute/deployment.py
libcloud/trunk/libcloud/compute/ssh.py
Modified: libcloud/trunk/CHANGES
URL:
http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1453705&r1=1453704&r2=1453705&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Thu Mar 7 06:33:29 2013
@@ -14,6 +14,16 @@ Changes with Apache Libcloud 0.12.2:
Reported by Hutson Betts.
[Tomaz Muraus]
+ - Improve deploy code to work correctly if the ssh user doesn't have access
+ to the /root directory.
+
+ Previously the ScriptDeployment script was stored in /root folder by
+ default. Now it's stored in users home directory under filename
+ ~/libcloud_deploymeny_<random>.sh. (LIBCLOUD-302)
+
+ Reported by rotem on #libcloud.
+ [Tomaz Muraus]
+
*) Compute
- Improve public and private IP address handling in OpenStack 1.1 driver.
Modified: libcloud/trunk/libcloud/compute/deployment.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/deployment.py?rev=1453705&r1=1453704&r2=1453705&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/deployment.py (original)
+++ libcloud/trunk/libcloud/compute/deployment.py Thu Mar 7 06:33:29 2013
@@ -91,7 +91,7 @@ class FileDeployment(Deployment):
@keyword source: Local path of file to be installed
@type target: C{str}
- @keyword target: Path to install file on node
+ @keyword target: Path to install file on node
"""
self.source = source
self.target = target
@@ -137,8 +137,11 @@ class ScriptDeployment(Deployment):
self.exit_status = None
self.delete = delete
self.name = name
+
if self.name is None:
- self.name = "/root/deployment_%s.sh" %
(binascii.hexlify(os.urandom(4)))
+ # File is put under user's home directory
+ # (~/libcloud_deployment_<random_string>.sh)
+ self.name = 'libcloud_deployment_%s.sh' %
(binascii.hexlify(os.urandom(4)))
def run(self, node, client):
"""
@@ -149,8 +152,10 @@ class ScriptDeployment(Deployment):
client.put(path=self.name, chmod=int('755', 8), contents=self.script)
self.stdout, self.stderr, self.exit_status = client.run(self.name)
+
if self.delete:
client.delete(self.name)
+
return node
Modified: libcloud/trunk/libcloud/compute/ssh.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/ssh.py?rev=1453705&r1=1453704&r2=1453705&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/ssh.py (original)
+++ libcloud/trunk/libcloud/compute/ssh.py Thu Mar 7 06:33:29 2013
@@ -157,8 +157,13 @@ class ParamikoSSHClient(BaseSSHClient):
sftp = self.client.open_sftp()
# less than ideal, but we need to mkdir stuff otherwise file() fails
head, tail = psplit(path)
+
if path[0] == "/":
sftp.chdir("/")
+ else:
+ # Relative path - start from a home directory (~)
+ sftp.chdir('.')
+
for part in head.split("/"):
if part != "":
try:
@@ -168,6 +173,7 @@ class ParamikoSSHClient(BaseSSHClient):
# catch EEXIST consistently *sigh*
pass
sftp.chdir(part)
+
ak = sftp.file(tail, mode=mode)
ak.write(contents)
if chmod is not None: