From: Royce Lv <
lvr...@linux.vnet.ibm.com>
To prevent future mount of nfs path will hang,
we will try nfs path with a quick mount,
if this test fails, report warning to user.
src/kimchi/featuretests.py | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
index 4cabdc9..36036e5 100644
--- a/src/kimchi/featuretests.py
+++ b/src/kimchi/featuretests.py
@@ -23,10 +23,12 @@
import libvirt
import os
import subprocess
+import tempfile
import threading
from kimchi import config
+from kimchi.utils import parse_cmd_output
ISO_STREAM_XML = """
@@ -111,3 +113,33 @@ class FeatureTests(object):
return False
return True
+
+ @staticmethod
+ def check_nfs_export(export_path):
+ res = False
+ outputs = None
+ mnt_point = tempfile.mkdtemp(dir='/tmp')
+ cmd = ["mount", "-o", 'soft,timeo=30,retrans=3,retry=0',
+ export_path, mnt_point]
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ thread = threading.Thread(target = proc.communicate)
+ thread.start()
+ thread.join(9)
+
+ if thread.is_alive():
+ proc.kill()
+ thread.join()
+
+ with open("/proc/mounts" , "rb") as f:
+ outputs = f.read()
+ output_items = ['dev_path', 'mnt_point', 'type']
+ mounts = parse_cmd_output(outputs, output_items)
+ for item in mounts:
+ if 'dev_path' in item and item['dev_path'] == export_path:
+ res = True
+ cmd = ["umount", "-f", export_path]
+ subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)