Rename hide_unsupported_rhel_options to stable_defaults and clean-up its usage

There were multiple problems with the setting and usage of
hide_unsupported_rhel_options.  Due to the fact that the option has
several diferent namings throughout the code, this patch is renaming
it to stable_defaults, which basically says what the option does and
makes it possible to use it without need for more than one negation
(where the old code had up to 4 of them in some places), which also
helps understanding it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-01-20 17:09:13 +01:00
parent d2f625cb22
commit dc0b9bbaaf
17 changed files with 73 additions and 77 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (C) 2013 Red Hat, Inc.
# Copyright (C) 2013, 2014 Red Hat, Inc.
# pylint: disable=W0201
# Attribute defined outside __init__: custom commands require breaking this
@ -320,8 +320,8 @@ class configure(Command):
"name of your distro's askpass package(s) (default=none)"),
("preferred-distros=", None,
"Distros to list first in the New VM wizard (default=none)"),
("hide-unsupported-rhel-options", None,
"Hide config bits that are not supported on RHEL (default=no)"),
("stable-defaults", None,
"Hide config bits that are not considered stable (default=no)"),
("default-graphics=", None,
"Default graphics type (spice or vnc) (default=spice)"),
@ -339,7 +339,7 @@ class configure(Command):
self.kvm_package_names = None
self.askpass_package_names = None
self.preferred_distros = None
self.hide_unsupported_rhel_options = None
self.stable_defaults = None
self.default_graphics = None
@ -359,9 +359,9 @@ class configure(Command):
template += "askpass_packages = %s\n" % self.askpass_package_names
if self.preferred_distros is not None:
template += "preferred_distros = %s\n" % self.preferred_distros
if self.hide_unsupported_rhel_options is not None:
template += ("hide_unsupported_rhel_options = %s\n" %
self.hide_unsupported_rhel_options)
if self.stable_defaults is not None:
template += ("stable_defaults = %s\n" %
self.stable_defaults)
if self.default_graphics is not None:
template += "default_graphics = %s\n" % self.default_graphics

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013 Red Hat, Inc.
# Copyright (C) 2013, 2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -24,7 +24,7 @@ os.environ["VIRTINST_TEST_TRACKPROPS"] = "1"
os.environ["VIRTINST_TEST_SUITE"] = "1"
import virtinst
virtinst.enable_rhel_defaults = False
virtinst.stable_defaults = False
from virtcli import cliconfig
# This sets all the cli bits back to their defaults

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013 Red Hat, Inc.
# Copyright (C) 2013, 2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -325,7 +325,7 @@ class TestXMLConfig(unittest.TestCase):
self._compare(g, "install-f11-norheldefaults", do_install)
try:
virtinst.enable_rhel_defaults = True
virtinst.stable_defaults = True
origemu = g.emulator
g.emulator = "/usr/libexec/qemu-kvm"
g.conn._support_cache = {}
@ -333,7 +333,7 @@ class TestXMLConfig(unittest.TestCase):
g.emulator = origemu
g.conn._support_cache = {}
finally:
virtinst.enable_rhel_defaults = False
virtinst.stable_defaults = False
# Verify main guest wasn't polluted
self._compare(g, "install-f11-norheldefaults", do_install)

View File

@ -2,7 +2,7 @@
%define with_guestfs 0
%define disable_unsupported_rhel 0
%define stable_defaults 0
%define askpass_package "openssh-askpass"
%define qemu_user "qemu"
%define libvirt_packages "libvirt-daemon-kvm,libvirt-daemon-config-network"
@ -12,7 +12,7 @@
%if 0%{?rhel}
%define preferred_distros "rhel,fedora"
%define kvm_packages "qemu-kvm"
%define disable_unsupported_rhel 1
%define stable_defaults 1
%endif
@ -125,8 +125,8 @@ machine).
%define _askpass_package --askpass-package-names=%{askpass_package}
%endif
%if %{disable_unsupported_rhel}
%define _disable_unsupported_rhel --hide-unsupported-rhel-options
%if %{stable_defaults}
%define _stable_defaults --stable-defaults
%endif
python setup.py configure \
@ -136,7 +136,7 @@ python setup.py configure \
%{?_libvirt_packages} \
%{?_askpass_package} \
%{?_preferred_distros} \
%{?_disable_unsupported_rhel}
%{?_stable_defaults}
%install

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006-2007, 2013 Red Hat, Inc.
# Copyright (C) 2006-2007, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2006 Hugh O. Brock <hbrock@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -525,7 +525,7 @@ class vmmAddHardware(vmmGObjectUI):
model.append(["ide", "IDE"])
model.append(["fdc", "Floppy"])
if self.vm.rhel6_defaults():
if self.vm.stable_defaults():
model.append(["scsi", "SCSI"])
model.append(["usb", "USB"])
@ -938,7 +938,7 @@ class vmmAddHardware(vmmGObjectUI):
return uihelpers.get_list_selection(self.widget("hw-list"))
def update_char_device_type_model(self):
rhel6_blacklist = ["pipe", "udp"]
stable_blacklist = ["pipe", "udp"]
# Char device type
char_devtype = self.widget("char-device-type")
@ -948,8 +948,8 @@ class vmmAddHardware(vmmGObjectUI):
# Type name, desc
for t in char_class.TYPES:
if (t in rhel6_blacklist and
not self.vm.rhel6_defaults()):
if (t in stable_blacklist and
self.vm.stable_defaults()):
continue
desc = char_class.pretty_type(t)
@ -1755,8 +1755,7 @@ class vmmAddHardware(vmmGObjectUI):
if self.storage_browser is None:
self.storage_browser = vmmStorageBrowser(conn)
rhel6 = self.vm.rhel6_defaults()
self.storage_browser.rhel6_defaults = rhel6
self.storage_browser.stable_defaults = self.vm.stable_defaults()
self.storage_browser.set_finish_cb(set_storage_cb)
self.storage_browser.set_browse_reason(reason)

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006, 2013 Red Hat, Inc.
# Copyright (C) 2006, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2006 Hugh O. Brock <hbrock@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -173,8 +173,7 @@ class vmmChooseCD(vmmGObjectUI):
self.storage_browser.connect("storage-browse-finish",
self.set_storage_path)
rhel6 = self.vm.rhel6_defaults()
self.storage_browser.rhel6_defaults = rhel6
self.storage_browser.stable_defaults = self.vm.stable_defaults()
if self.media_type == MEDIA_FLOPPY:
self.storage_browser.set_browse_reason(

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006, 2012-2013 Red Hat, Inc.
# Copyright (C) 2006, 2012-2014 Red Hat, Inc.
# Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -160,7 +160,7 @@ class vmmConfig(object):
self.keyring = None
self.default_qemu_user = cliconfig.default_qemu_user
self.rhel6_defaults = not cliconfig.rhel_enable_unsupported_opts
self.stable_defaults = cliconfig.stable_defaults
self.preferred_distros = cliconfig.preferred_distros
self.hv_packages = cliconfig.hv_packages
self.libvirt_packages = cliconfig.libvirt_packages

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006, 2013 Red Hat, Inc.
# Copyright (C) 2006, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -307,19 +307,18 @@ class vmmConnection(vmmGObject):
# Connection capabilities debug helpers
def rhel6_defaults(self, emulator):
def stable_defaults(self, emulator=None):
if not self.is_qemu_system():
return True
if not str(emulator).startswith("/usr/libexec"):
return True
return self.config.rhel6_defaults
def rhel6_defaults_caps(self):
for guest in self.caps.guests:
for dom in guest.domains:
if dom.emulator.startswith("/usr/libexec"):
return self.config.rhel6_defaults
return True
return False
if emulator:
if not str(emulator).startswith("/usr/libexec"):
return False
else:
for guest in self.caps.guests:
for dom in guest.domains:
if dom.emulator.startswith("/usr/libexec"):
return self.config.stable_defaults
return self.config.stable_defaults
def get_cache_dir(self):
uri = self.get_uri().replace("/", "_")

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2008, 2013 Red Hat, Inc.
# Copyright (C) 2008, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2008 Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -57,7 +57,7 @@ INSTALL_PAGE_IMPORT = 3
INSTALL_PAGE_CONTAINER_APP = 4
INSTALL_PAGE_CONTAINER_OS = 5
RHEL6_OS_SUPPORT = [
STABLE_OS_SUPPORT = [
"rhel3", "rhel4", "rhel5.4", "rhel6",
"win2k3", "winxp", "win2k8", "vista", "win7",
]
@ -841,8 +841,8 @@ class vmmCreate(vmmGObjectUI):
widget = self.widget("install-os-type")
model = widget.get_model()
model.clear()
filtervars = (not self._rhel6_defaults() and
RHEL6_OS_SUPPORT or
filtervars = (self._stable_defaults() and
STABLE_OS_SUPPORT or
None)
types = virtinst.osdict.list_os(list_types=True)
@ -879,8 +879,8 @@ class vmmCreate(vmmGObjectUI):
self._add_os_row(model, None, _("Generic"), True)
return
filtervars = (not self._rhel6_defaults() and
RHEL6_OS_SUPPORT or
filtervars = (not self._stable_defaults() and
STABLE_OS_SUPPORT or
None)
preferred = self.config.preferred_distros
@ -2178,14 +2178,14 @@ class vmmCreate(vmmGObjectUI):
logging.exception("Error detecting distro.")
self.detectedDistro = -1
def _rhel6_defaults(self):
def _stable_defaults(self):
emu = None
if self.guest:
emu = self.guest.emulator
elif self.capsdomain:
emu = self.capsdomain.emulator
ret = self.conn.rhel6_defaults(emu)
ret = self.conn.stable_defaults(emu)
return ret
def _browse_file(self, cbwidget, cb=None, is_media=False, is_dir=False):
@ -2205,7 +2205,7 @@ class vmmCreate(vmmGObjectUI):
if self.storage_browser is None:
self.storage_browser = vmmStorageBrowser(self.conn)
self.storage_browser.rhel6_defaults = self._rhel6_defaults()
self.storage_browser.stable_defaults = self._stable_defaults()
self.storage_browser.set_vm_name(self.get_config_name())
self.storage_browser.set_finish_cb(callback)

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2008, 2013 Red Hat, Inc.
# Copyright (C) 2008, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2008 Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -212,7 +212,7 @@ class vmmCreateVolume(vmmGObjectUI):
return None
def populate_vol_format(self):
rhel6_file_whitelist = ["raw", "qcow2", "qed"]
stable_whitelist = ["raw", "qcow2", "qed"]
model = self.widget("vol-format").get_model()
model.clear()
@ -221,9 +221,9 @@ class vmmCreateVolume(vmmGObjectUI):
formats = self.vol.list_create_formats()
if (self.vol.file_type == self.vol.TYPE_FILE and
not self.conn.rhel6_defaults_caps()):
self.conn.stable_defaults()):
newfmts = []
for f in rhel6_file_whitelist:
for f in stable_whitelist:
if f in formats:
newfmts.append(f)
formats = newfmts

View File

@ -3433,12 +3433,12 @@ class vmmDetails(vmmGObjectUI):
buses.append(["fdc", "Floppy"])
elif devtype == virtinst.VirtualDisk.DEVICE_CDROM:
buses.append(["ide", "IDE"])
if self.vm.rhel6_defaults():
if not self.vm.stable_defaults():
buses.append(["scsi", "SCSI"])
else:
if self.vm.is_hvm():
buses.append(["ide", "IDE"])
if self.vm.rhel6_defaults():
if not self.vm.stable_defaults():
buses.append(["scsi", "SCSI"])
buses.append(["usb", "USB"])
if self.vm.get_hv_type() in ["kvm", "test"]:

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006, 2013 Red Hat, Inc.
# Copyright (C) 2006, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -371,8 +371,8 @@ class vmmDomain(vmmLibvirtObject):
def get_install_abort(self):
return bool(self._install_abort)
def rhel6_defaults(self):
return self.conn.rhel6_defaults(self.get_emulator())
def stable_defaults(self):
return self.conn.stable_defaults(self.get_emulator())
def is_read_only(self):
if self.is_management_domain():

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006-2007, 2013 Red Hat, Inc.
# Copyright (C) 2006-2007, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2006 Hugh O. Brock <hbrock@redhat.com>
# Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -411,8 +411,7 @@ class vmmFSDetails(vmmGObjectUI):
if self.storage_browser is None:
self.storage_browser = vmmStorageBrowser(conn)
rhel6 = self.vm.rhel6_defaults()
self.storage_browser.rhel6_defaults = rhel6
self.storage_browser.stable_defaults = self.vm.stable_defaults()
self.storage_browser.set_finish_cb(set_storage_cb)
self.storage_browser.set_browse_reason(reason)

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2009, 2013 Red Hat, Inc.
# Copyright (C) 2009, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -54,9 +54,10 @@ class vmmStorageBrowser(vmmGObjectUI):
# Arguments to pass to util.browse_local for local storage
self.browse_reason = None
self.rhel6_defaults = True
self.local_args = {}
self.stable_defaults = False
self.builder.connect_signals({
"on_vmm_storage_browse_delete_event" : self.close,
"on_browse_cancel_clicked" : self.close,
@ -332,7 +333,7 @@ class vmmStorageBrowser(vmmGObjectUI):
if ((self.browse_reason == self.config.CONFIG_DIR_FS)
and fmt != 'dir'):
return False
elif not self.rhel6_defaults:
elif self.stable_defaults:
if fmt == "vmdk":
return False
return True

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2009, 2013 Red Hat, Inc.
# Copyright (C) 2009, 2013, 2014 Red Hat, Inc.
# Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -162,7 +162,7 @@ def populate_video_combo(vm, combo, no_default=None):
model.clear()
tmpdev = virtinst.VirtualVideoDevice(vm.conn.get_backend())
for m in tmpdev.MODELS:
if not vm.rhel6_defaults():
if vm.stable_defaults():
if m == "qxl" and not has_spice and not has_qxl:
# Only list QXL video option when VM has SPICE video
continue
@ -181,14 +181,14 @@ def build_sound_combo(vm, combo, no_default=False):
set_combo_text_column(combo, 0)
model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
disable_rhel = not vm.rhel6_defaults()
rhel_soundmodels = ["ich6", "ac97"]
stable_defaults = vm.stable_defaults()
stable_soundmodels = ["ich6", "ac97"]
for m in virtinst.VirtualAudio.MODELS:
if m == virtinst.VirtualAudio.MODEL_DEFAULT and no_default:
continue
if (disable_rhel and m not in rhel_soundmodels):
if (stable_defaults and m not in stable_soundmodels):
continue
model.append([m])
@ -426,7 +426,7 @@ def update_storage_format_combo(vm, combo, create):
formats = ["raw", "qcow2", "qed"]
no_create_formats = []
if vm.rhel6_defaults():
if not vm.stable_defaults():
formats.append("vmdk")
no_create_formats.append("vdi")

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2013 Red Hat, Inc.
# Copyright (C) 2013, 2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -81,8 +81,7 @@ else:
icon_dir = os.path.join(asset_dir, "icons")
default_qemu_user = _get_param("default_qemu_user", "root")
rhel_enable_unsupported_opts = not bool(int(
_get_param("hide_unsupported_rhel_options", "0")))
stable_defaults = bool(int(_get_param("stable_defaults", "0")))
preferred_distros = _split_list(_get_param("preferred_distros", ""))
hv_packages = _split_list(_get_param("hv_packages", ""))

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013 Red Hat, Inc.
# Copyright (C) 2013, 2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@
# MA 02110-1301 USA.
from virtcli import cliconfig, cliutils
enable_rhel_defaults = not cliconfig.rhel_enable_unsupported_opts
stable_defaults = cliconfig.stable_defaults
cliutils.setup_i18n()