Home | History | Annotate | Download | only in virt
      1 import logging, os, sys, fcntl
      2 kvm_test_dir = "/usr/local/autotest/client/tests/kvm"
      3 from autotest_lib.client.common_lib import cartesian_config
      4 
      5 def get_control(params, custom_cfg):
      6     control = '''
      7 import sys, os, logging
      8 os.environ['LANG'] = 'en_US.UTF-8'
      9 kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests', 'kvm')
     10 sys.path.append(kvm_test_dir)
     11 from autotest_lib.client.common_lib import cartesian_config
     12 from autotest_lib.client.virt import virt_utils
     13 
     14 kernel_install_params = %s
     15 custom_cfg = %s
     16 
     17 def step_init():
     18     job.next_step([step_test])
     19     virt_utils.install_host_kernel(job, kernel_install_params)
     20 
     21 def step_test():
     22     parser = cartesian_config.Parser()
     23     parser.parse_file(os.path.join(kvm_test_dir, "redhat.cfg"))
     24     for line in custom_cfg:
     25         parser.parse_string(line)
     26     virt_utils.run_tests(parser, job)
     27 ''' % (params, custom_cfg)
     28     return control
     29 
     30 def run(machine):
     31     parser = cartesian_config.Parser()
     32     parser.parse_file(os.path.join(kvm_test_dir, "redhat.cfg"))
     33     custom_cfg = $custom_job_cfg
     34     for line in custom_cfg:
     35         parser.parse_string(line)
     36     generator = parser.get_dicts()
     37     params = generator.next()
     38     host = hosts.create_host(machine)
     39     profile = params.get('host_install_profile')
     40     timeout = int(params.get('host_install_timeout', 3600))
     41     if profile:
     42         host.install(profile=profile, timeout=timeout)
     43     at = autotest.Autotest(host)
     44     control = get_control(params, custom_cfg)
     45     at.run(control)
     46 
     47 job.parallel_simple(run, machines)
     48