Some of the auxiliary kvm test programs need to use logging configuration, we ended up duplicating code across the test. Move the duplicated instances to a single one living in kvm_utils.py. Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx> --- client/tests/kvm/cd_hash.py | 7 +------ client/tests/kvm/kvm_config.py | 8 +------- client/tests/kvm/kvm_utils.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/client/tests/kvm/cd_hash.py b/client/tests/kvm/cd_hash.py index 483d71c..a857ed8 100755 --- a/client/tests/kvm/cd_hash.py +++ b/client/tests/kvm/cd_hash.py @@ -10,11 +10,6 @@ import common, kvm_utils from autotest_lib.client.common_lib import logging_config, logging_manager -class KvmLoggingConfig(logging_config.LoggingConfig): - def configure_logging(self, results_dir=None, verbose=False): - super(KvmLoggingConfig, self).configure_logging(use_console=True, - verbose=verbose) - if __name__ == "__main__": parser = optparse.OptionParser() parser.add_option('-i', '--iso', type="string", dest="filename", @@ -25,7 +20,7 @@ if __name__ == "__main__": options, args = parser.parse_args() filename = options.filename - logging_manager.configure_logging(KvmLoggingConfig()) + logging_manager.configure_logging(kvm_utils.KvmLoggingConfig()) if not filename: parser.print_help() diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 798ef56..51f069a 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -11,12 +11,6 @@ from autotest_lib.client.common_lib import error from autotest_lib.client.common_lib import logging_config, logging_manager -class KvmLoggingConfig(logging_config.LoggingConfig): - def configure_logging(self, results_dir=None, verbose=False): - super(KvmLoggingConfig, self).configure_logging(use_console=True, - verbose=verbose) - - class config: """ Parse an input file or string that follows the KVM Test Config File format @@ -517,7 +511,7 @@ if __name__ == "__main__": # Here we configure the stand alone program to use the autotest # logging system. - logging_manager.configure_logging(KvmLoggingConfig(), verbose=debug) + logging_manager.configure_logging(kvm_utils.KvmLoggingConfig(), verbose=debug) list = config(filename, debug=debug).get_list() i = 0 for dict in list: diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index f8089f7..5452026 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -970,6 +970,16 @@ def get_vendor_from_pci_id(pci_id): return re.sub(":", " ", commands.getoutput(cmd)) +class KvmLoggingConfig(logging_config.LoggingConfig): + """ + Used with the sole purpose of providing convenient logging setup + for the KVM test auxiliary programs. + """ + def configure_logging(self, results_dir=None, verbose=False): + super(KvmLoggingConfig, self).configure_logging(use_console=True, + verbose=verbose) + + class PciAssignable(object): """ Request PCI assignable devices on host. It will check whether to request -- 1.6.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html