Exemplo n.º 1
0
 def _process_spice_specific_options(self):
     """
     Calls for processing all options specific to spice test
     """
     # We can call here for self._process_qemu_specific_options()
     # to process some --options, but let SpiceQA tests will be independent
     set_opt(self.config, 'no_downloads', True)
Exemplo n.º 2
0
 def __init__(self, args, extra_params):
     """
     Following extra_params are supported:
      * avocado_vt_extra_params: Will override the "vt_extra_params"
        of this plugins "self.args" (extends the --vt-extra-params)
     """
     vt_extra_params = extra_params.pop("avocado_vt_extra_params", None)
     # Compatibility with nrunner Avocado
     if isinstance(args, dict):
         args = argparse.Namespace(**args)
     super(VirtTestLoader, self).__init__(args, extra_params)
     # Avocado has renamed "args" to "config" in 84ae9a5d61, lets
     # keep making the old name available for compatibility with
     # new and old releases
     if hasattr(self, 'config'):
         self.args = self.config
     self._fill_optional_args()
     if vt_extra_params:
         # We don't want to override the original args
         self.args = copy.deepcopy(self.args)
         extra = get_opt(self.args, 'vt_extra_params')
         if extra is not None:
             extra += vt_extra_params
         else:
             extra = vt_extra_params
         set_opt(self.args, 'vt_extra_params', extra)
Exemplo n.º 3
0
 def __init__(self, config, extra_params):
     """
     Following extra_params are supported:
      * avocado_vt_extra_params: Will override the "vt_extra_params"
        of this plugins "self.config" (extends the --vt-extra-params)
     """
     vt_extra_params = extra_params.pop("avocado_vt_extra_params", None)
     super(VirtTestLoader, self).__init__(config, extra_params)
     # Avocado has renamed "args" to "config" in 84ae9a5d61, lets
     # keep making the old name available for compatibility with
     # new and old releases
     if hasattr(self, 'config'):
         self.args = self.config  # pylint: disable=E0203
     # And in case an older Avocado is used, the Loader class will
     # contain an "args" attribute instead
     else:
         self.config = self.args  # pylint: disable=E0203
     if vt_extra_params:
         # We don't want to override the original config
         self.config = copy.deepcopy(self.config)
         extra = get_opt(self.config, 'vt.extra_params')
         if extra is not None:
             extra += vt_extra_params
         else:
             extra = vt_extra_params
         set_opt(self.config, 'vt.extra_params', extra)
Exemplo n.º 4
0
 def get_extra_listing(self):
     if get_opt(self.args, 'vt_list_guests'):
         args = copy.copy(self.args)
         set_opt(args, 'vt_config', None)
         set_opt(args, 'vt_guest_os', None)
         guest_listing(args)
     if get_opt(self.args, 'vt_list_archs'):
         args = copy.copy(self.args)
         set_opt(args, 'vt_machine_type', None)
         set_opt(args, 'vt_arch', None)
         arch_listing(args)
Exemplo n.º 5
0
 def get_extra_listing(self):
     if get_opt(self.config, 'vt.list_guests'):
         config = copy.copy(self.config)
         set_opt(config, 'vt.config', None)
         set_opt(config, 'vt.guest_os', None)
         guest_listing(config)
     if get_opt(self.config, 'vt.list_archs'):
         config = copy.copy(self.config)
         set_opt(config, 'vt.common.machine_type', None)
         set_opt(config, 'vt.common.arch', None)
         arch_listing(config)
Exemplo n.º 6
0
    def _process_bridge_mode(self):
        nettype_setting = 'config vt.qemu.nettype'
        if not get_opt(self.config, 'vt.config'):
            # Let's select reasonable defaults depending on vt.type
            if not get_opt(self.config, 'vt.common.nettype'):
                if get_opt(self.config, 'vt.type') == 'qemu':
                    set_opt(self.config, 'vt.common.nettype',
                            ("bridge" if os.getuid() == 0 else "user"))
                elif get_opt(self.config, 'vt.type') == 'spice':
                    set_opt(self.config, 'vt.common.nettype', "none")
                else:
                    set_opt(self.config, 'vt.common.nettype', "bridge")

            if get_opt(self.config,
                       'vt.common.nettype') not in SUPPORTED_NET_TYPES:
                raise ValueError("Invalid %s '%s'. "
                                 "Valid values: (%s)" %
                                 (nettype_setting,
                                  get_opt(self.config, 'vt.common.nettype'),
                                  ", ".join(SUPPORTED_NET_TYPES)))
            if get_opt(self.config, 'vt.common.nettype') == 'bridge':
                if os.getuid() != 0:
                    raise ValueError(
                        "In order to use %s '%s' you "
                        "need to be root" %
                        (nettype_setting,
                         get_opt(self.config, 'vt.common.nettype')))
                self.cartesian_parser.assign("nettype", "bridge")
                self.cartesian_parser.assign(
                    "netdst", get_opt(self.config, 'vt.common.netdst'))
            elif get_opt(self.config, 'vt.common.nettype') == 'user':
                self.cartesian_parser.assign("nettype", "user")
        else:
            LOG.info("Config provided, ignoring %s", nettype_setting)
Exemplo n.º 7
0
 def _add_if_not_exist(arg, value):
     if not get_opt(self.args, arg):
         set_opt(self.args, arg, value)
Exemplo n.º 8
0
 def _process_lvsb_specific_options(self):
     """
     Calls for processing all options specific to LVSB test
     """
     set_opt(self.config, 'no_downloads', True)
Exemplo n.º 9
0
    def __init__(self, options):
        """
        Parses options and initializes attributes.
        """
        # Compatibility with nrunner Avocado
        if isinstance(options, dict):
            self.options = argparse.Namespace(**options)
        else:
            self.options = options
        # There are a few options from the original virt-test runner
        # that don't quite make sense for avocado (avocado implements a
        # better version of the virt-test feature).
        # So let's just inject some values into options.
        set_opt(self.options, 'vt_verbose', False)
        set_opt(self.options, 'vt_log_level', logging.DEBUG)
        set_opt(self.options, 'vt_console_level', logging.DEBUG)
        set_opt(self.options, 'vt_no_downloads', False)
        set_opt(self.options, 'vt_selinux_setup', False)

        # Here we'll inject values from the config file.
        # Doing this makes things configurable yet the number of options
        # is not overwhelming.
        # setup section
        set_opt(
            self.options, 'vt_backup_image_before_test',
            settings.get_value('vt.setup',
                               'backup_image_before_test',
                               key_type=bool,
                               default=True))
        set_opt(
            self.options, 'vt_restore_image_after_test',
            settings.get_value('vt.setup',
                               'restore_image_after_test',
                               key_type=bool,
                               default=True))
        set_opt(
            self.options, 'vt_keep_guest_running',
            settings.get_value('vt.setup',
                               'keep_guest_running',
                               key_type=bool,
                               default=False))
        # common section
        set_opt(self.options, 'vt_data_dir',
                settings.get_value('vt.common', 'data_dir', default=None))
        set_opt(self.options, 'vt_tmp_dir',
                settings.get_value('vt.common', 'tmp_dir', default=''))
        set_opt(
            self.options, 'vt_type_specific',
            settings.get_value('vt.common',
                               'type_specific_only',
                               key_type=bool,
                               default=False))
        set_opt(
            self.options, 'vt_mem',
            settings.get_value('vt.common', 'mem', key_type=int, default=None))
        set_opt(self.options, 'vt_nettype',
                settings.get_value('vt.common', 'nettype', default=None))
        set_opt(self.options, 'vt_netdst',
                settings.get_value('vt.common', 'netdst', default='virbr0'))
        # qemu section
        set_opt(self.options, 'vt_accel',
                settings.get_value('vt.qemu', 'accel', default='kvm'))
        set_opt(self.options, 'vt_vhost',
                settings.get_value('vt.qemu', 'vhost', default='off'))
        set_opt(self.options, 'vt_monitor',
                settings.get_value('vt.qemu', 'monitor', default=None))
        set_opt(self.options, 'vt_smp',
                settings.get_value('vt.qemu', 'smp', default='2'))
        set_opt(self.options, 'vt_image_type',
                settings.get_value('vt.qemu', 'image_type', default='qcow2'))
        set_opt(
            self.options, 'vt_nic_model',
            settings.get_value('vt.qemu', 'nic_model', default='virtio_net'))
        set_opt(
            self.options, 'vt_disk_bus',
            settings.get_value('vt.qemu', 'disk_bus', default='virtio_blk'))
        set_opt(self.options, 'vt_qemu_sandbox',
                settings.get_value('vt.qemu', 'sandbox', default='on'))
        set_opt(self.options, 'vt_qemu_defconfig',
                settings.get_value('vt.qemu', 'defconfig', default='yes'))
        set_opt(self.options, 'vt_malloc_perturb',
                settings.get_value('vt.qemu', 'malloc_perturb', default='yes'))

        # debug section
        set_opt(
            self.options, 'vt_no_cleanup',
            settings.get_value('vt.debug',
                               'no_cleanup',
                               key_type=bool,
                               default=False))

        self.cartesian_parser = None