Skip to content

TFTPProviderDriver/HTTPProviderDriver should create symlinks when staging files for local TFTPProvider/HTTPProvider #1662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions labgrid/util/managedfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ def sync_to_resource(self, symlink=None):
self.local_path,
f"{self.rpath}{os.path.basename(self.local_path)}"
)

if symlink is not None:
self.logger.info("Linking")
try:
conn.run_check(f"test ! -e {symlink} -o -L {symlink}")
except ExecutionError:
raise ManagedFileError(f"Path {symlink} exists but is not a symlink.")
# use short options to be compatible with busybox
# --symbolic --force --no-dereference
conn.run_check(f"ln -sfn {self.rpath}{os.path.basename(self.local_path)} {symlink}")

else:
conn = sshmanager.open("localhost")
self.rpath = os.path.dirname(self.local_path) + "/"

if symlink is not None:
self.logger.info("Linking")
try:
conn.run_check(f"test ! -e {symlink} -o -L {symlink}")
except ExecutionError:
raise ManagedFileError(f"Path {symlink} exists but is not a symlink.")
conn.run_check(f"mkdir -p {os.path.dirname(symlink)}")
# use short options to be compatible with busybox
# --symbolic --force --no-dereference
conn.run_check(f"ln -sfn {self.rpath}{os.path.basename(self.local_path)} {symlink}")

def _on_nfs(self, conn):
if self._on_nfs_cached is not None:
Expand Down