def load_config(self): """ Load the configuration file for Hekate. @return: a dict including successful - whether the function executed successfully or not. """ operation = inspect.stack()[0][3] result = {'successful': False} try: self.log.trace("%s ..." % operation.replace('_', ' ')) # read config file data config_data = read_file_into_list(CONFIG_FILE_PATH)['list'] # parse data into configuration parameters = [] for line in config_data: if 'PARAM =' in line.lower(): self.PARAM = line.lower().strip().split('PARAM = ')[1] parameters.append(['PARAM', self.PARAM]) # log parameters in output for param in parameters: self.log.trace("CONFIGURATION: %s = %s" % (param[0], param[1])) result['successful'] = True except BaseException, e: self.handle_exception(self.log, e, operation="load configuration")
def load_config(self): """ Load the configuration file for Tantalus. OUPUT successful: whether the function executed successfully or not. """ self.log.debug("Loading configuration ...") result = {'successful': False} try: # read config file data config_data = read_file_into_list(CONFIG_FILE_PATH)['list'] # parse data into configuration parameters = [] for line in config_data: if 'mode =' in line.lower(): self.mode = line.lower().strip().split('mode = ')[1] parameters.append(['Mode', self.mode]) elif 'connection_lapse_max =' in line.lower(): self.vim_connection_lapse_max = int(line.lower().strip().split( 'connection_lapse_max = ')[1]) parameters.append(['ViM Connection Lapse Max', self.vim_connection_lapse_max]) if 'diag_start_time = none' in line.lower(): self.vim_connection_diagnostic_start_time = None parameters.append( ['ViM Connection Lapse Max', self.vim_connection_diagnostic_start_time]) elif 'diag_start_time =' in line.lower(): self.vim_connection_diagnostic_start_time = \ self.utc.convert_date_string_to_db_time( line.lower().strip().split('diag_start_time = ')[1])['db time'] parameters.append(['ViM Connection Lapse Max', self.vim_connection_diagnostic_start_time]) if 'diag_end_time = none' in line.lower(): self.vim_connection_diagnostic_end_time = None parameters.append(['ViM Connection Lapse Max', self.vim_connection_diagnostic_end_time]) elif 'diag_end_time =' in line.lower(): self.vim_connection_diagnostic_end_time = \ self.utc.convert_date_string_to_db_time( line.lower().strip().split('diag_end_time = ')[1])['db time'] parameters.append(['ViM Connection Lapse Max', self.vim_connection_diagnostic_end_time]) # log parameters in output for param in parameters: self.log.trace("CONFIGURATION: %s = %s" % (param[0], param[1])) self.log.debug("... DONE loading configuration.") result['successful'] = True except BaseException, e: self.handle_exception(e, operation="load configuration")
def load_config(self): """ Load the configuration file. :return: a dict including successful - whether the function executed successfully or not. """ operation = inspect.stack()[0][3] result = {'successful': False} try: self.log.trace("%s ..." % operation.replace('_', ' ')) # read config file data config_data = read_file_into_list(CONFIG_FILE_PATH)['list'] # parse data into configuration parameters = [] for line in config_data: if 'SITES = ' in line: sites = line.strip().split('SITES = ')[1].split(',') parameters.append(['SITES', str(sites)]) for site in sites: self.sites_to_ping.append(site.strip()) if 'TRACEROUTE = ' in line: if 'true' in line.lower(): parameters.append(['TRACEROUTE', 'True']) self.traceroute = True if 'MULTITHREADED = ' in line: if 'true' in line.lower(): parameters.append(['MULTITHREADED', 'True']) self.multithreaded = True if 'RECIPIENTS = ' in line: recipients = line.strip().split('RECIPIENTS = ')[1].split(',') parameters.append(['RECIPIENTS', str(recipients)]) for recipient in recipients: self.email_recipients.append(recipient.strip()) # log parameters in output for param in parameters: self.log.trace("CONFIGURATION: %s = %s" % (param[0], param[1])) result['successful'] = True except BaseException, e: self.handle_exception(self.log, e, operation="load configuration")
def update_number_of_vim_site_connections(self, num_handles, num_channels, testcase=None): """ Update the number of handles/channels used in connecting to sites. INPUT num handles: number of handles to configure. num channels: number of channels to configure. testcase: a testcase object supplied when executing function as part of a testcase step. OUPUT successful: whether the function executed successfully or not. verified: whether the operation was verified or not. """ self.log.debug("Updating number of ViM site connections with %s handles and %s channels ..." % (num_handles, num_channels)) result = {'successful': False} try: # read VIM.properties file into list properties_data = read_file_into_list(self.properties_path)['list'] # read properties data list into updated data list updated_data = [] for line in properties_data: # update handles if in line if "VIM.handles" in line: line = "VIM.handles: %d\n" % num_handles # update channels if in line if "VIM.channels" in line: line = "VIM.channels: %d\n" % num_channels # write line to updated data list updated_data.append(line) # write updated data list to properties file write_list_to_file(self.properties_path, updated_data) self.log.trace("Updated number of ViM site connections.") result['successful'] = True except BaseException, e: self.handle_exception(e, operation="update number of ViM site connections")