diff options
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py')
| -rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py b/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py new file mode 100644 index 0000000000..82a58c0e28 --- /dev/null +++ b/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py | |||
| @@ -0,0 +1,184 @@ | |||
| 1 | # | ||
| 2 | # Chris Lumens <clumens@redhat.com> | ||
| 3 | # | ||
| 4 | # Copyright 2005, 2006, 2007, 2008 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_DriverDiskData(BaseData): | ||
| 27 | removedKeywords = BaseData.removedKeywords | ||
| 28 | removedAttrs = BaseData.removedAttrs | ||
| 29 | |||
| 30 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 31 | BaseData.__init__(self, *args, **kwargs) | ||
| 32 | |||
| 33 | self.partition = kwargs.get("partition", "") | ||
| 34 | self.source = kwargs.get("source", "") | ||
| 35 | self.type = kwargs.get("type", "") | ||
| 36 | |||
| 37 | def _getArgsAsStr(self): | ||
| 38 | retval = "" | ||
| 39 | |||
| 40 | if self.partition: | ||
| 41 | retval += "%s" % self.partition | ||
| 42 | |||
| 43 | if hasattr(self, "type") and self.type: | ||
| 44 | retval += " --type=%s" % self.type | ||
| 45 | elif self.source: | ||
| 46 | retval += "--source=%s" % self.source | ||
| 47 | return retval | ||
| 48 | |||
| 49 | def __str__(self): | ||
| 50 | retval = BaseData.__str__(self) | ||
| 51 | retval += "driverdisk %s\n" % self._getArgsAsStr() | ||
| 52 | return retval | ||
| 53 | |||
| 54 | class FC4_DriverDiskData(FC3_DriverDiskData): | ||
| 55 | removedKeywords = FC3_DriverDiskData.removedKeywords | ||
| 56 | removedAttrs = FC3_DriverDiskData.removedAttrs | ||
| 57 | |||
| 58 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 59 | FC3_DriverDiskData.__init__(self, *args, **kwargs) | ||
| 60 | self.deleteRemovedAttrs() | ||
| 61 | |||
| 62 | self.biospart = kwargs.get("biospart", "") | ||
| 63 | |||
| 64 | def _getArgsAsStr(self): | ||
| 65 | retval = "" | ||
| 66 | |||
| 67 | if self.partition: | ||
| 68 | retval += "%s" % self.partition | ||
| 69 | |||
| 70 | if hasattr(self, "type") and self.type: | ||
| 71 | retval += " --type=%s" % self.type | ||
| 72 | elif self.source: | ||
| 73 | retval += "--source=%s" % self.source | ||
| 74 | elif self.biospart: | ||
| 75 | retval += "--biospart=%s" % self.biospart | ||
| 76 | |||
| 77 | return retval | ||
| 78 | |||
| 79 | class F12_DriverDiskData(FC4_DriverDiskData): | ||
| 80 | removedKeywords = FC4_DriverDiskData.removedKeywords + ["type"] | ||
| 81 | removedAttrs = FC4_DriverDiskData.removedAttrs + ["type"] | ||
| 82 | |||
| 83 | def __init__(self, *args, **kwargs): | ||
| 84 | FC4_DriverDiskData.__init__(self, *args, **kwargs) | ||
| 85 | self.deleteRemovedAttrs() | ||
| 86 | |||
| 87 | F14_DriverDiskData = F12_DriverDiskData | ||
| 88 | |||
| 89 | class FC3_DriverDisk(KickstartCommand): | ||
| 90 | removedKeywords = KickstartCommand.removedKeywords | ||
| 91 | removedAttrs = KickstartCommand.removedAttrs | ||
| 92 | |||
| 93 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 94 | KickstartCommand.__init__(self, writePriority, *args, **kwargs) | ||
| 95 | self.op = self._getParser() | ||
| 96 | |||
| 97 | self.driverdiskList = kwargs.get("driverdiskList", []) | ||
| 98 | |||
| 99 | def __str__(self): | ||
| 100 | retval = "" | ||
| 101 | for dd in self.driverdiskList: | ||
| 102 | retval += dd.__str__() | ||
| 103 | |||
| 104 | return retval | ||
| 105 | |||
| 106 | def _getParser(self): | ||
| 107 | op = KSOptionParser() | ||
| 108 | op.add_option("--source") | ||
| 109 | op.add_option("--type") | ||
| 110 | return op | ||
| 111 | |||
| 112 | def parse(self, args): | ||
| 113 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 114 | |||
| 115 | if len(extra) > 1: | ||
| 116 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")) | ||
| 117 | |||
| 118 | if len(extra) == 1 and opts.source: | ||
| 119 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")) | ||
| 120 | |||
| 121 | if not extra and not opts.source: | ||
| 122 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command.")) | ||
| 123 | |||
| 124 | ddd = self.handler.DriverDiskData() | ||
| 125 | self._setToObj(self.op, opts, ddd) | ||
| 126 | ddd.lineno = self.lineno | ||
| 127 | if len(extra) == 1: | ||
| 128 | ddd.partition = extra[0] | ||
| 129 | |||
| 130 | return ddd | ||
| 131 | |||
| 132 | def dataList(self): | ||
| 133 | return self.driverdiskList | ||
| 134 | |||
| 135 | class FC4_DriverDisk(FC3_DriverDisk): | ||
| 136 | removedKeywords = FC3_DriverDisk.removedKeywords | ||
| 137 | removedAttrs = FC3_DriverDisk.removedKeywords | ||
| 138 | |||
| 139 | def _getParser(self): | ||
| 140 | op = FC3_DriverDisk._getParser(self) | ||
| 141 | op.add_option("--biospart") | ||
| 142 | return op | ||
| 143 | |||
| 144 | def parse(self, args): | ||
| 145 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 146 | |||
| 147 | if len(extra) > 1: | ||
| 148 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")) | ||
| 149 | |||
| 150 | if len(extra) == 1 and opts.source: | ||
| 151 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")) | ||
| 152 | elif len(extra) == 1 and opts.biospart: | ||
| 153 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command.")) | ||
| 154 | elif opts.source and opts.biospart: | ||
| 155 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command.")) | ||
| 156 | |||
| 157 | if not extra and not opts.source and not opts.biospart: | ||
| 158 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command.")) | ||
| 159 | |||
| 160 | ddd = self.handler.DriverDiskData() | ||
| 161 | self._setToObj(self.op, opts, ddd) | ||
| 162 | ddd.lineno = self.lineno | ||
| 163 | if len(extra) == 1: | ||
| 164 | ddd.partition = extra[0] | ||
| 165 | |||
| 166 | return ddd | ||
| 167 | |||
| 168 | class F12_DriverDisk(FC4_DriverDisk): | ||
| 169 | removedKeywords = FC4_DriverDisk.removedKeywords | ||
| 170 | removedAttrs = FC4_DriverDisk.removedKeywords | ||
| 171 | |||
| 172 | def _getParser(self): | ||
| 173 | op = FC4_DriverDisk._getParser(self) | ||
| 174 | op.add_option("--type", deprecated=1) | ||
| 175 | return op | ||
| 176 | |||
| 177 | class F14_DriverDisk(F12_DriverDisk): | ||
| 178 | removedKeywords = F12_DriverDisk.removedKeywords | ||
| 179 | removedAttrs = F12_DriverDisk.removedKeywords | ||
| 180 | |||
| 181 | def _getParser(self): | ||
| 182 | op = F12_DriverDisk._getParser(self) | ||
| 183 | op.remove_option("--type") | ||
| 184 | return op | ||
