+ def update_rally_logs(self, rally_conf='/etc/rally/rally.conf'):
+ """Print rally logs in res dir"""
+ if not os.path.exists(self.res_dir):
+ os.makedirs(self.res_dir)
+ rconfig = configparser.RawConfigParser()
+ rconfig.read(rally_conf)
+ rconfig.set('DEFAULT', 'log-file', 'rally.log')
+ rconfig.set('DEFAULT', 'log_dir', self.res_dir)
+ with open(rally_conf, 'wb') as config_file:
+ rconfig.write(config_file)
+
+ @staticmethod
+ def clean_rally_conf(rally_conf='/etc/rally/rally.conf'):
+ """Clean Rally config"""
+ rconfig = configparser.RawConfigParser()
+ rconfig.read(rally_conf)
+ if rconfig.has_option('openstack', 'img_name_regex'):
+ rconfig.remove_option('openstack', 'img_name_regex')
+ if rconfig.has_option('openstack', 'swift_operator_role'):
+ rconfig.remove_option('openstack', 'swift_operator_role')
+ if rconfig.has_option('DEFAULT', 'log-file'):
+ rconfig.remove_option('DEFAULT', 'log-file')
+ if rconfig.has_option('DEFAULT', 'log_dir'):
+ rconfig.remove_option('DEFAULT', 'log_dir')
+ with open(rally_conf, 'wb') as config_file:
+ rconfig.write(config_file)
+
+ def update_scenario_section(self):
+ """Update scenario section in tempest.conf"""
+ rconfig = configparser.RawConfigParser()
+ rconfig.read(self.conf_file)
+ filename = getattr(
+ config.CONF, '{}_image'.format(self.case_name), self.filename)
+ if not rconfig.has_section('scenario'):
+ rconfig.add_section('scenario')
+ rconfig.set('scenario', 'img_file', os.path.basename(filename))
+ rconfig.set('scenario', 'img_dir', os.path.dirname(filename))
+ rconfig.set('scenario', 'img_disk_format', getattr(
+ config.CONF, '{}_image_format'.format(self.case_name),
+ self.image_format))
+ extra_properties = self.extra_properties.copy()
+ if env.get('IMAGE_PROPERTIES'):
+ extra_properties.update(
+ functest_utils.convert_ini_to_dict(
+ env.get('IMAGE_PROPERTIES')))
+ extra_properties.update(
+ getattr(config.CONF, '{}_extra_properties'.format(
+ self.case_name), {}))
+ rconfig.set(
+ 'scenario', 'img_properties',
+ functest_utils.convert_dict_to_ini(extra_properties))
+ with open(self.conf_file, 'wb') as config_file:
+ rconfig.write(config_file)
+