summaryrefslogtreecommitdiffstats
path: root/Libraries/Validate/ATFValidate.py
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/Validate/ATFValidate.py')
-rw-r--r--Libraries/Validate/ATFValidate.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/Libraries/Validate/ATFValidate.py b/Libraries/Validate/ATFValidate.py
new file mode 100644
index 0000000..9cebbf8
--- /dev/null
+++ b/Libraries/Validate/ATFValidate.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+import re
+import ATFUtils
+
+def validate_replication(**arguments):
+ """
+ Description:
+ Validate whether the files are replicated or not
+
+ Parameters:
+ arguments: key=value pair.
+ key: file1..filen
+ value: host:exportdir:filename comabination
+
+ Example:f1 = 'host1:export1:file1.txt', f2 = 'host1:export2:file1.txt
+
+ Returns:
+ Success: 0
+ Failure: 1
+ """
+
+ Map = []
+ command = "ls"
+
+ for key in arguments.keys():
+ value = arguments[key]
+ hostkey, exportkey, filename = re.split(":", value)
+
+ host = ATFUtils.TestEnvObj.get_host(hostkey)
+ if (host == ''):
+ ATFUtils.Logger.error("Host %s Not defined in GlobalParam File" %
+ hostkey)
+ return 1
+
+ exportdir = ATFUtils.TestEnvObj.get_exportdir(exportkey)
+ if (exportdir == ''):
+ ATFUtils.Logger.error(
+ "ExportDir %s Not defined in GlobalParam File" % exportkey)
+ return 1
+ else:
+ abspath = exportdir + "/" + filename
+ Map.append({'host':host, 'path':abspath})
+
+
+ for item in Map:
+ arguments['host'] = item['host']
+ arguments['user'] = 'root'
+ abspath = item['path']
+ val_command = command + " " + abspath
+
+ status, stdin, stdout, stderr = ATFUtils.execute_command(val_command,
+ **arguments)
+
+ if ( status == 1):
+ ATFUtils.Logger.error("Error in Validation")
+ else:
+ status = False
+ readout = stdout.readlines()
+ readerr = stderr.readlines()
+
+ if( len(readerr) == 0):
+ for line in readout:
+ if ( re.match(abspath, line)):
+ status = True
+ else:
+ status = False
+
+ if (status == False):
+ ATFUtils.Logger.error("Validation Failed: Path Not found - %s" % abspath)
+ return
+ else:
+ continue
+
+ if(status == True):
+ ATFUtils.Logger.info("Validate_replication Successfully Complete")
+
+ return 0
+