kexec-tools/anaconda-addon/com_redhat_kdump/tui/spokes/kdump.py
Arthur Zou 2553056c74 Rename the subpackage kdump-anaconda-addon
Rename the subpackage kdump-anaconda-addon to kexec-tools-anaconda-addon
to keep consistency and make fedpkg build happy

Because every time fedpkg builds a new release the package version number
should increase. But kdump-annaconda-addon just keep same version, so let's
rename it to kexec-tools-annaconda-addon here kexec-tools- is a default prefix.
For version let's use default top level version.

At the same time, rename the kdump-anaconda-addon directory name to anaconda-addon
to make it more standard. Using the current data instead of version number as a
surfix of kdump-anaconda-addon tarball just like kexec-tools-po did.

Signed-off-by: Arthur Zou <zzou@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2014-05-22 18:32:43 +08:00

88 lines
2.9 KiB
Python

# Kdump anaconda configuration
#
# Copyright (C) 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
# Red Hat Author(s): David Shea <dshea@redhat.com>
#
"""Kdump anaconda TUI configuration"""
import re
from pyanaconda.ui.tui.spokes import EditTUISpoke
from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
from com_redhat_kdump.common import getOS, getMemoryBounds
from com_redhat_kdump.i18n import N_, _
__all__ = ["KdumpSpoke"]
class _re:
def __init__(self, patten, low, up):
self.re = re.compile(patten)
self.low = low
self.up = up
def match(self, key):
if self.re.match(key):
if key == "auto":
return True
if key[-1] == 'M':
key = key[:-1]
key = int(key)
if key <= self.up and key >= self.low :
return True
return False
lower, upper ,step = getMemoryBounds()
# Allow either "auto" or a string of digits optionally followed by 'M'
RESERVE_VALID = _re(r'^((auto)|(\d+M?))$', lower, upper)
FEDORA_RESERVE_VALID = _re(r'^(\d+M?)$', lower, upper)
class KdumpSpoke(EditTUISpoke):
title = N_("Kdump")
category = "system"
edit_fields = [
Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
Entry("Reserve amount", "reserveMB", RESERVE_VALID, lambda self,args: args.enabled)
]
def __init__(self, app, data, storage, payload, instclass):
if getOS() == "fedora":
KdumpSpoke.edit_fields = [
Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
Entry("Reserve amount", "reserveMB", FEDORA_RESERVE_VALID, lambda self,args: args.enabled)
]
EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
self.args = self.data.addons.com_redhat_kdump
def apply(self):
pass
@property
def completed(self):
return True
@property
def status(self):
if self.args.enabled:
state = _("Kdump is enabled")
else:
state = _("Kdump is disabled")
return state