diff options
| author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:38:32 +0100 |
|---|---|---|
| committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:50:20 +0100 |
| commit | e2e6f6fe07049f33cb6348780fa975162752e421 (patch) | |
| tree | b1813295411235d1297a0ed642b1346b24fdfb12 /scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py | |
| download | poky-e2e6f6fe07049f33cb6348780fa975162752e421.tar.gz | |
initial commit of Enea Linux 3.1
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py')
| -rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py b/scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py new file mode 100644 index 0000000000..676d080836 --- /dev/null +++ b/scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | # | ||
| 2 | # Chris Lumens <clumens@redhat.com> | ||
| 3 | # | ||
| 4 | # Copyright 2005, 2006, 2007, 2009 Red Hat, Inc. | ||
| 5 | # | ||
| 6 | # This copyrighted material is made available to anyone wishing to use, modify, | ||
| 7 | # copy, or redistribute it subject to the terms and conditions of the GNU | ||
| 8 | # General Public License v.2. This program is distributed in the hope that it | ||
| 9 | # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the | ||
| 10 | # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 11 | # See the GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License along with | ||
| 14 | # this program; if not, write to the Free Software Foundation, Inc., 51 | ||
| 15 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat | ||
| 16 | # trademarks that are incorporated in the source code or documentation are not | ||
| 17 | # subject to the GNU General Public License and may only be used or replicated | ||
| 18 | # with the express permission of Red Hat, Inc. | ||
| 19 | # | ||
| 20 | from pykickstart.base import * | ||
| 21 | from pykickstart.options import * | ||
| 22 | |||
| 23 | import gettext | ||
| 24 | _ = lambda x: gettext.ldgettext("pykickstart", x) | ||
| 25 | |||
| 26 | class FC3_IgnoreDisk(KickstartCommand): | ||
| 27 | removedKeywords = KickstartCommand.removedKeywords | ||
| 28 | removedAttrs = KickstartCommand.removedAttrs | ||
| 29 | |||
| 30 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 31 | KickstartCommand.__init__(self, writePriority, *args, **kwargs) | ||
| 32 | self.op = self._getParser() | ||
| 33 | |||
| 34 | self.ignoredisk = kwargs.get("ignoredisk", []) | ||
| 35 | |||
| 36 | def __str__(self): | ||
| 37 | retval = KickstartCommand.__str__(self) | ||
| 38 | |||
| 39 | if len(self.ignoredisk) > 0: | ||
| 40 | retval += "ignoredisk --drives=%s\n" % ",".join(self.ignoredisk) | ||
| 41 | |||
| 42 | return retval | ||
| 43 | |||
| 44 | def _getParser(self): | ||
| 45 | def drive_cb (option, opt_str, value, parser): | ||
| 46 | for d in value.split(','): | ||
| 47 | parser.values.ensure_value(option.dest, []).append(d) | ||
| 48 | |||
| 49 | op = KSOptionParser() | ||
| 50 | op.add_option("--drives", dest="ignoredisk", action="callback", | ||
| 51 | callback=drive_cb, nargs=1, type="string", required=1) | ||
| 52 | return op | ||
| 53 | |||
| 54 | def parse(self, args): | ||
| 55 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 56 | self._setToSelf(self.op, opts) | ||
| 57 | return self | ||
| 58 | |||
| 59 | class F8_IgnoreDisk(FC3_IgnoreDisk): | ||
| 60 | removedKeywords = FC3_IgnoreDisk.removedKeywords | ||
| 61 | removedAttrs = FC3_IgnoreDisk.removedAttrs | ||
| 62 | |||
| 63 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 64 | FC3_IgnoreDisk.__init__(self, writePriority, *args, **kwargs) | ||
| 65 | |||
| 66 | self.onlyuse = kwargs.get("onlyuse", []) | ||
| 67 | |||
| 68 | def __str__(self): | ||
| 69 | retval = KickstartCommand.__str__(self) | ||
| 70 | |||
| 71 | if len(self.ignoredisk) > 0: | ||
| 72 | retval += "ignoredisk --drives=%s\n" % ",".join(self.ignoredisk) | ||
| 73 | elif len(self.onlyuse) > 0: | ||
| 74 | retval += "ignoredisk --only-use=%s\n" % ",".join(self.onlyuse) | ||
| 75 | |||
| 76 | return retval | ||
| 77 | |||
| 78 | def parse(self, args, errorCheck=True): | ||
| 79 | retval = FC3_IgnoreDisk.parse(self, args) | ||
| 80 | |||
| 81 | if errorCheck: | ||
| 82 | if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)): | ||
| 83 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command.")) | ||
| 84 | |||
| 85 | return retval | ||
| 86 | |||
| 87 | def _getParser(self): | ||
| 88 | def drive_cb (option, opt_str, value, parser): | ||
| 89 | for d in value.split(','): | ||
| 90 | parser.values.ensure_value(option.dest, []).append(d) | ||
| 91 | |||
| 92 | op = FC3_IgnoreDisk._getParser(self) | ||
| 93 | op.add_option("--drives", dest="ignoredisk", action="callback", | ||
| 94 | callback=drive_cb, nargs=1, type="string") | ||
| 95 | op.add_option("--only-use", dest="onlyuse", action="callback", | ||
| 96 | callback=drive_cb, nargs=1, type="string") | ||
| 97 | return op | ||
| 98 | |||
| 99 | class RHEL6_IgnoreDisk(F8_IgnoreDisk): | ||
| 100 | removedKeywords = F8_IgnoreDisk.removedKeywords | ||
| 101 | removedAttrs = F8_IgnoreDisk.removedAttrs | ||
| 102 | |||
| 103 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 104 | F8_IgnoreDisk.__init__(self, writePriority, *args, **kwargs) | ||
| 105 | |||
| 106 | self.interactive = kwargs.get("interactive", False) | ||
| 107 | if self.interactive: | ||
| 108 | self.ignoredisk = [] | ||
| 109 | |||
| 110 | def __str__(self): | ||
| 111 | retval = F8_IgnoreDisk.__str__(self) | ||
| 112 | |||
| 113 | if self.interactive: | ||
| 114 | retval = "ignoredisk --interactive\n" | ||
| 115 | |||
| 116 | return retval | ||
| 117 | |||
| 118 | def parse(self, args): | ||
| 119 | retval = F8_IgnoreDisk.parse(self, args, errorCheck=False) | ||
| 120 | |||
| 121 | howmany = 0 | ||
| 122 | if len(self.ignoredisk) > 0: | ||
| 123 | howmany += 1 | ||
| 124 | if len(self.onlyuse) > 0: | ||
| 125 | howmany += 1 | ||
| 126 | if self.interactive: | ||
| 127 | howmany += 1 | ||
| 128 | if howmany != 1: | ||
| 129 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command.")) | ||
| 130 | |||
| 131 | return retval | ||
| 132 | |||
| 133 | def _getParser(self): | ||
| 134 | op = F8_IgnoreDisk._getParser(self) | ||
| 135 | op.add_option("--interactive", dest="interactive", action="store_true", | ||
| 136 | default=False) | ||
| 137 | return op | ||
| 138 | |||
| 139 | F14_IgnoreDisk = RHEL6_IgnoreDisk | ||
