Skip to content

Commit

Permalink
Fix no directory issue
Browse files Browse the repository at this point in the history
When the directory is not exist, process.getoutput may return empty,
which will cause the directory creation step to be skipped. So update code.

Signed-off-by: lcheng <[email protected]>
  • Loading branch information
cliping committed Sep 27, 2024
1 parent 5ca5488 commit e182e1e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions virttest/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,15 @@ def setup_remote(self):
"""
check_mount_dir_cmd = self.ssh_cmd + "'ls -d %s'" % self.mount_dir
LOG.debug("To check if the %s exists", self.mount_dir)
output = process.getoutput(check_mount_dir_cmd)
if re.findall("No such file or directory", output, re.M):
mkdir_cmd = self.ssh_cmd + "'mkdir -p %s'" % self.mount_dir
LOG.debug("Prepare to create %s", self.mount_dir)
s, o = process.getstatusoutput(mkdir_cmd)
if s != 0:
raise exceptions.TestFail("Failed to run %s: %s" % (mkdir_cmd, o))
self.mkdir_mount_remote = True
ret = process.run(check_mount_dir_cmd, shell=True, ignore_status=True)
if ret.exit_status:
if re.findall("No such file or directory", ret.stderr_text, re.M):
mkdir_cmd = self.ssh_cmd + "'mkdir -p %s'" % self.mount_dir
LOG.debug("Prepare to create %s", self.mount_dir)
s, o = process.getstatusoutput(mkdir_cmd)
if s != 0:
raise exceptions.TestFail("Failed to run %s: %s" % (mkdir_cmd, o))
self.mkdir_mount_remote = True

if self.params.get("firewall_to_permit_nfs", "yes") == "yes":
if distro.detect().name != "Ubuntu":
Expand Down

0 comments on commit e182e1e

Please sign in to comment.