On 2013年12月18日 09:41, Aline Manera wrote:
On 12/17/2013 10:10 AM, lvroyce0210(a)gmail.com wrote:
> From: Royce Lv <lvroyce(a)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.
>
> Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
> ---
> 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
You should put it in utils.py as it isn't a feature test
Independent of the result of this function the NFS pool feature will
continue enable to user.
ACK
> +
> + @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()
Here you could use f.readlines() as Ramon suggested
I wrote parse function for
Popen.communicate result parse and file read
result. Popen.communicate result cannot apply readlines as I explained
in feed back to Ramon.
As
http://docs.python.org/3.3/library/io.html suggests, The line
terminator is always b'\n' for binary files; literally it is same as my
implementation.
> + 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)
> +
> + return res
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups
"project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.