diff options
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py')
| -rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py | 216 |
1 files changed, 0 insertions, 216 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py b/scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py deleted file mode 100644 index c2b552f689..0000000000 --- a/scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py +++ /dev/null | |||
| @@ -1,216 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Chris Lumens <clumens@redhat.com> | ||
| 3 | # | ||
| 4 | # Copyright 2007 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 | class FC3_Bootloader(KickstartCommand): | ||
| 24 | removedKeywords = KickstartCommand.removedKeywords | ||
| 25 | removedAttrs = KickstartCommand.removedAttrs | ||
| 26 | |||
| 27 | def __init__(self, writePriority=10, *args, **kwargs): | ||
| 28 | KickstartCommand.__init__(self, writePriority, *args, **kwargs) | ||
| 29 | self.op = self._getParser() | ||
| 30 | |||
| 31 | self.driveorder = kwargs.get("driveorder", []) | ||
| 32 | self.appendLine = kwargs.get("appendLine", "") | ||
| 33 | self.forceLBA = kwargs.get("forceLBA", False) | ||
| 34 | self.linear = kwargs.get("linear", True) | ||
| 35 | self.location = kwargs.get("location", "") | ||
| 36 | self.md5pass = kwargs.get("md5pass", "") | ||
| 37 | self.password = kwargs.get("password", "") | ||
| 38 | self.upgrade = kwargs.get("upgrade", False) | ||
| 39 | self.useLilo = kwargs.get("useLilo", False) | ||
| 40 | |||
| 41 | self.deleteRemovedAttrs() | ||
| 42 | |||
| 43 | def _getArgsAsStr(self): | ||
| 44 | retval = "" | ||
| 45 | |||
| 46 | if self.appendLine != "": | ||
| 47 | retval += " --append=\"%s\"" % self.appendLine | ||
| 48 | if self.linear: | ||
| 49 | retval += " --linear" | ||
| 50 | if self.location: | ||
| 51 | retval += " --location=%s" % self.location | ||
| 52 | if hasattr(self, "forceLBA") and self.forceLBA: | ||
| 53 | retval += " --lba32" | ||
| 54 | if self.password != "": | ||
| 55 | retval += " --password=\"%s\"" % self.password | ||
| 56 | if self.md5pass != "": | ||
| 57 | retval += " --md5pass=\"%s\"" % self.md5pass | ||
| 58 | if self.upgrade: | ||
| 59 | retval += " --upgrade" | ||
| 60 | if self.useLilo: | ||
| 61 | retval += " --useLilo" | ||
| 62 | if len(self.driveorder) > 0: | ||
| 63 | retval += " --driveorder=\"%s\"" % ",".join(self.driveorder) | ||
| 64 | |||
| 65 | return retval | ||
| 66 | |||
| 67 | def __str__(self): | ||
| 68 | retval = KickstartCommand.__str__(self) | ||
| 69 | |||
| 70 | if self.location != "": | ||
| 71 | retval += "# System bootloader configuration\nbootloader" | ||
| 72 | retval += self._getArgsAsStr() + "\n" | ||
| 73 | |||
| 74 | return retval | ||
| 75 | |||
| 76 | def _getParser(self): | ||
| 77 | def driveorder_cb (option, opt_str, value, parser): | ||
| 78 | for d in value.split(','): | ||
| 79 | parser.values.ensure_value(option.dest, []).append(d) | ||
| 80 | |||
| 81 | op = KSOptionParser() | ||
| 82 | op.add_option("--append", dest="appendLine") | ||
| 83 | op.add_option("--linear", dest="linear", action="store_true", | ||
| 84 | default=True) | ||
| 85 | op.add_option("--nolinear", dest="linear", action="store_false") | ||
| 86 | op.add_option("--location", dest="location", type="choice", | ||
| 87 | default="mbr", | ||
| 88 | choices=["mbr", "partition", "none", "boot"]) | ||
| 89 | op.add_option("--lba32", dest="forceLBA", action="store_true", | ||
| 90 | default=False) | ||
| 91 | op.add_option("--password", dest="password", default="") | ||
| 92 | op.add_option("--md5pass", dest="md5pass", default="") | ||
| 93 | op.add_option("--upgrade", dest="upgrade", action="store_true", | ||
| 94 | default=False) | ||
| 95 | op.add_option("--useLilo", dest="useLilo", action="store_true", | ||
| 96 | default=False) | ||
| 97 | op.add_option("--driveorder", dest="driveorder", action="callback", | ||
| 98 | callback=driveorder_cb, nargs=1, type="string") | ||
| 99 | return op | ||
| 100 | |||
| 101 | def parse(self, args): | ||
| 102 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 103 | self._setToSelf(self.op, opts) | ||
| 104 | |||
| 105 | if self.currentCmd == "lilo": | ||
| 106 | self.useLilo = True | ||
| 107 | |||
| 108 | return self | ||
| 109 | |||
| 110 | class FC4_Bootloader(FC3_Bootloader): | ||
| 111 | removedKeywords = FC3_Bootloader.removedKeywords + ["linear", "useLilo"] | ||
| 112 | removedAttrs = FC3_Bootloader.removedAttrs + ["linear", "useLilo"] | ||
| 113 | |||
| 114 | def __init__(self, writePriority=10, *args, **kwargs): | ||
| 115 | FC3_Bootloader.__init__(self, writePriority, *args, **kwargs) | ||
| 116 | |||
| 117 | def _getArgsAsStr(self): | ||
| 118 | retval = "" | ||
| 119 | if self.appendLine != "": | ||
| 120 | retval += " --append=\"%s\"" % self.appendLine | ||
| 121 | if self.location: | ||
| 122 | retval += " --location=%s" % self.location | ||
| 123 | if hasattr(self, "forceLBA") and self.forceLBA: | ||
| 124 | retval += " --lba32" | ||
| 125 | if self.password != "": | ||
| 126 | retval += " --password=\"%s\"" % self.password | ||
| 127 | if self.md5pass != "": | ||
| 128 | retval += " --md5pass=\"%s\"" % self.md5pass | ||
| 129 | if self.upgrade: | ||
| 130 | retval += " --upgrade" | ||
| 131 | if len(self.driveorder) > 0: | ||
| 132 | retval += " --driveorder=\"%s\"" % ",".join(self.driveorder) | ||
| 133 | return retval | ||
| 134 | |||
| 135 | def _getParser(self): | ||
| 136 | op = FC3_Bootloader._getParser(self) | ||
| 137 | op.remove_option("--linear") | ||
| 138 | op.remove_option("--nolinear") | ||
| 139 | op.remove_option("--useLilo") | ||
| 140 | return op | ||
| 141 | |||
| 142 | def parse(self, args): | ||
| 143 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 144 | self._setToSelf(self.op, opts) | ||
| 145 | return self | ||
| 146 | |||
| 147 | class F8_Bootloader(FC4_Bootloader): | ||
| 148 | removedKeywords = FC4_Bootloader.removedKeywords | ||
| 149 | removedAttrs = FC4_Bootloader.removedAttrs | ||
| 150 | |||
| 151 | def __init__(self, writePriority=10, *args, **kwargs): | ||
| 152 | FC4_Bootloader.__init__(self, writePriority, *args, **kwargs) | ||
| 153 | |||
| 154 | self.timeout = kwargs.get("timeout", None) | ||
| 155 | self.default = kwargs.get("default", "") | ||
| 156 | |||
| 157 | def _getArgsAsStr(self): | ||
| 158 | ret = FC4_Bootloader._getArgsAsStr(self) | ||
| 159 | |||
| 160 | if self.timeout is not None: | ||
| 161 | ret += " --timeout=%d" %(self.timeout,) | ||
| 162 | if self.default: | ||
| 163 | ret += " --default=%s" %(self.default,) | ||
| 164 | |||
| 165 | return ret | ||
| 166 | |||
| 167 | def _getParser(self): | ||
| 168 | op = FC4_Bootloader._getParser(self) | ||
| 169 | op.add_option("--timeout", dest="timeout", type="int") | ||
| 170 | op.add_option("--default", dest="default") | ||
| 171 | return op | ||
| 172 | |||
| 173 | class F12_Bootloader(F8_Bootloader): | ||
| 174 | removedKeywords = F8_Bootloader.removedKeywords | ||
| 175 | removedAttrs = F8_Bootloader.removedAttrs | ||
| 176 | |||
| 177 | def _getParser(self): | ||
| 178 | op = F8_Bootloader._getParser(self) | ||
| 179 | op.add_option("--lba32", dest="forceLBA", deprecated=1, action="store_true") | ||
| 180 | return op | ||
| 181 | |||
| 182 | class F14_Bootloader(F12_Bootloader): | ||
| 183 | removedKeywords = F12_Bootloader.removedKeywords + ["forceLBA"] | ||
| 184 | removedAttrs = F12_Bootloader.removedKeywords + ["forceLBA"] | ||
| 185 | |||
| 186 | def _getParser(self): | ||
| 187 | op = F12_Bootloader._getParser(self) | ||
| 188 | op.remove_option("--lba32") | ||
| 189 | return op | ||
| 190 | |||
| 191 | class F15_Bootloader(F14_Bootloader): | ||
| 192 | removedKeywords = F14_Bootloader.removedKeywords | ||
| 193 | removedAttrs = F14_Bootloader.removedAttrs | ||
| 194 | |||
| 195 | def __init__(self, writePriority=10, *args, **kwargs): | ||
| 196 | F14_Bootloader.__init__(self, writePriority, *args, **kwargs) | ||
| 197 | |||
| 198 | self.isCrypted = kwargs.get("isCrypted", False) | ||
| 199 | |||
| 200 | def _getArgsAsStr(self): | ||
| 201 | ret = F14_Bootloader._getArgsAsStr(self) | ||
| 202 | |||
| 203 | if self.isCrypted: | ||
| 204 | ret += " --iscrypted" | ||
| 205 | |||
| 206 | return ret | ||
| 207 | |||
| 208 | def _getParser(self): | ||
| 209 | def password_cb(option, opt_str, value, parser): | ||
| 210 | parser.values.isCrypted = True | ||
| 211 | parser.values.password = value | ||
| 212 | |||
| 213 | op = F14_Bootloader._getParser(self) | ||
| 214 | op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False) | ||
| 215 | op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string") | ||
| 216 | return op | ||
