Skip to content

Commit 9414d56

Browse files
lib/host: Avoid using identical source and destination paths in execute_script scp
Using the same path for both source and destination may cause scp to fail, especially when the source path (e.g. a temp path on macOS) does not exist on the remote system. Thus, resorting to use `/tmp/` and random name from `sctipt.name` on destination. Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent d2fdebe commit 9414d56

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/host.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ def execute_script(self, script_contents, shebang='sh', simple_output=True):
201201
script.write('#!/usr/bin/env ' + shebang + '\n')
202202
script.write(script_contents)
203203
script.flush()
204-
self.scp(script.name, script.name)
204+
self.scp(script.name, "/tmp/" + os.path.basename(script.name))
205205

206206
try:
207207
logging.debug(f"[{self}] # Will execute this temporary script:\n{script_contents.strip()}")
208-
return self.ssh([script.name], simple_output=simple_output)
208+
return self.ssh(["/tmp/" + os.path.basename(script.name)], simple_output=simple_output)
209209
finally:
210-
self.ssh(['rm', '-f', script.name])
210+
self.ssh(['rm', '-f', "/tmp/" + os.path.basename(script.name)])
211211

212212
def _get_xensource_inventory(self) -> Dict[str, str]:
213213
output = self.ssh(['cat', '/etc/xensource-inventory'])

0 commit comments

Comments
 (0)