diff options
Diffstat (limited to 'ATFInit.py')
-rwxr-xr-x | ATFInit.py | 233 |
1 files changed, 0 insertions, 233 deletions
diff --git a/ATFInit.py b/ATFInit.py deleted file mode 100755 index 7f28aca..0000000 --- a/ATFInit.py +++ /dev/null @@ -1,233 +0,0 @@ -#!/usr/bin/env python - -import re -import ConfigParser -import ATFUtils - -######################################################################## -## GlobalParameter file ConfigParser Object -######################################################################## -Config = ConfigParser.ConfigParser() - -def initialize(): - """ - Description: - Initialize ATFUtils.Logger, TestEnvironments - - Parameters: - None - - Returns: - Success: 0 - Failure: 1 - """ - - if ATFUtils.LogObj.create('ATF_LOG'): - return 1 - - if parseGPFile(): - return 1 - - ATFUtils.TestEnvObj.create_servershostlist() - ATFUtils.TestEnvObj.create_clientshostlist() - return 0 - -def ConfigSectionMap(section): - """ - Description: - Get the key=value pair for the Section 'section' - in the GlobalParam File - - Parameters: - section: Section Name in the GlobalParam File - - Returns: - Success: Dictionary: List of key=value pairs from section 'section' - Failure: 1 - """ - - dict1 = {} - - try: - options = Config.options(section) - - except ConfigParser.NoSectionError: - return 1 - - else: - for option in options: - dict1[option] = Config.get(section, option, raw=True) - - return dict1 - -def parseGPFile(): - """ - Description: - Parse Global Parameter file - - Parameters: - filename: Name of GlobalParam File - - Returns: - Success: 0 - Failure: 1 - """ - - filename = ATFUtils.TestEnvObj.get_globalparamfile() - status = Config.read(filename) - - if len(status) == 0: - ATFUtils.Logger.error("GlobalParam File: " + filename + "Not Found") - return 1 - else: - ### Parse Section: [Hosts] ### - Map = ConfigSectionMap('Hosts') - - if Map == 1: - ATFUtils.Logger.error( - "Section [Hosts] Not Found In GlobalParam File: " + - filename) - return 1 - else: - for key in Map.keys(): - name = key - host = Map[key] - name = name.lower() - ATFUtils.TestEnvObj.add_host(name, host) - - ### Parse Section: [Users] ### - Map = ConfigSectionMap("Users") - - if Map == 1: - ATFUtils.Logger.error( - "Section [Users] Not Found In GlobalParam File") - return 1 - else: - for key in Map.keys(): - name = key - user = Map[key] - name = name.lower() - ATFUtils.TestEnvObj.add_user(name, user) - - ### Parse Section: [Servers] ### - - Map = ConfigSectionMap('Servers') - - if Map == 1: - ATFUtils.Logger.error( - "Section [Servers] Not Found In GlobalParam File") - return 1 - else: - for key in Map.keys(): - name = key - value = Map[key] - user, host = re.split('@', value) - name = name.lower() - if ATFUtils.TestEnvObj.add_server(name, host, user): - return 1 - else: - continue - - ### Parse Section: [Clients] ### - Map = ConfigSectionMap('Clients') - - if Map == 1: - ATFUtils.Logger.error( - "Section [Clients] Not Found in GlobalParam File") - return 1 - else: - for key in Map.keys(): - name = key - value = Map[key] - user, host = re.split('@', value) - name = name.lower() - - if ATFUtils.TestEnvObj.add_client(name, host, user): - return 1 - else: - continue - - ### Parse Section: [ExportDirs] ### - Map = ConfigSectionMap('ExportDirs') - - if Map == 1: - ATFUtils.Logger.error( - "Section [ExportDirs] Not Found in GlobalParam File") - return 1 - else: - for key in Map.keys(): - exportname = key - exportdir = Map[key] - exportname = exportname.lower() - ATFUtils.TestEnvObj.add_exportdir(exportname, exportdir) - - ### Parse Section: [MountPoints] ### - Map = ConfigSectionMap('MountPoints') - - if Map == 1: - ATFUtils.Logger.error( - "Section [MountPoints] Not Found in GlobalParam File") - return 1 - else: - for key in Map.keys(): - mountname = key - mountpoint = Map[key] - mountname = mountname.lower() - ATFUtils.TestEnvObj.add_mountpoint(mountname, mountpoint) - - ### Parse Section: [Volumes] ### - Map = ConfigSectionMap('Volumes') - - if Map == 1: - ATFUtils.Logger.error( - "Section [Volumes] Not Found in GlobalParam File") - return 1 - else: - for key in Map.keys(): - volumekey = key - volumename = Map[volumekey] - volumekey = volumekey.lower() - ATFUtils.TestEnvObj.add_volume(volumekey, volumename) - - ### Parse Section: [GlusterfsVersion] ### - Map = ConfigSectionMap('GlusterfsVersion') - - if Map == 1: - ATFUtils.Logger.warning("Section: [GlusterfsVersion] Not Found") - else: - GlusterfsVersion = Map['version'] - if GlusterfsVersion == None: - GlusterfsVersion = '' - - ATFUtils.TestsObj.set_version(GlusterfsVersion) - - try: - fhr = open(filename, "r") - - except IOError: - ATFUtils.Logger.error("IOError:Cannot Open GlobalParam File " + - filename + "For Logging to Summary Log") - - else: - summarylog = ATFUtils.get_environ('ATF_SUMMARYLOG') - try: - fhw = open(summarylog, "a") - - except: - print "IOError: Cannot Open Summary Log FIle " + summarylog - ATFUtils.Logger.warning ( - "Unable to write GlobalParam Contents to SummaryLog: " + - summarylog) - - fhr.close() - - else: - lines = fhr.readlines() - fhw.write(("-" * 50) + "\nExported GlobalParam File: \n" + - ("-" * 50) + "\n") - fhw.writelines(lines) - - fhw.close() - fhr.close() - - return 0 |