2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2007 Red Hat, Inc.
6 # This software may be freely redistributed under the terms of the GNU
7 # general public license.
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software
11 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 from pykickstart
.base
import *
16 from pykickstart
.options
import *
18 class FC3_Bootloader(KickstartCommand
):
19 def __init__(self
, writePriority
=0, appendLine
="", driveorder
=None,
20 forceLBA
=False, linear
=True, location
="", md5pass
="",
21 password
="", upgrade
=False, useLilo
=False):
22 KickstartCommand
.__init
__(self
, writePriority
)
23 self
.appendLine
= appendLine
25 if driveorder
== None:
28 self
.driveorder
= driveorder
30 self
.forceLBA
= forceLBA
32 self
.location
= location
33 self
.md5pass
= md5pass
34 self
.password
= password
35 self
.upgrade
= upgrade
36 self
.useLilo
= useLilo
39 if self
.location
!= "":
40 retval
= "# System bootloader configuration\nbootloader"
42 if self
.appendLine
!= "":
43 retval
+= " --append=\"%s\"" % self
.appendLine
47 retval
+= " --location=%s" % self
.location
50 if self
.password
!= "":
51 retval
+= " --password=%s" % self
.password
52 if self
.md5pass
!= "":
53 retval
+= " --md5pass=%s" % self
.md5pass
55 retval
+= " --upgrade"
57 retval
+= " --useLilo"
58 if len(self
.driveorder
) > 0:
59 retval
+= " --driveorder=%s" % string
.join(self
.driveorder
, ",")
65 def parse(self
, args
):
66 def driveorder_cb (option
, opt_str
, value
, parser
):
67 for d
in value
.split(','):
68 parser
.values
.ensure_value(option
.dest
, []).append(d
)
70 op
= KSOptionParser(lineno
=self
.lineno
)
71 op
.add_option("--append", dest
="appendLine")
72 op
.add_option("--linear", dest
="linear", action
="store_true",
74 op
.add_option("--nolinear", dest
="linear", action
="store_false")
75 op
.add_option("--location", dest
="location", type="choice",
77 choices
=["mbr", "partition", "none", "boot"])
78 op
.add_option("--lba32", dest
="forceLBA", action
="store_true",
80 op
.add_option("--password", dest
="password", default
="")
81 op
.add_option("--md5pass", dest
="md5pass", default
="")
82 op
.add_option("--upgrade", dest
="upgrade", action
="store_true",
84 op
.add_option("--useLilo", dest
="useLilo", action
="store_true",
86 op
.add_option("--driveorder", dest
="driveorder", action
="callback",
87 callback
=driveorder_cb
, nargs
=1, type="string")
89 (opts
, extra
) = op
.parse_args(args
=args
)
90 self
._setToSelf
(op
, opts
)
92 if self
.currentCmd
== "lilo":
95 class FC4_Bootloader(FC3_Bootloader
):
96 def __init__(self
, writePriority
=0, appendLine
="", driveorder
=None,
97 forceLBA
=False, location
="", md5pass
="", password
="",
99 KickstartCommand
.__init
__(self
, writePriority
)
100 self
.appendLine
= appendLine
102 if driveorder
== None:
105 self
.driveorder
= driveorder
107 self
.forceLBA
= forceLBA
108 self
.location
= location
109 self
.md5pass
= md5pass
110 self
.password
= password
111 self
.upgrade
= upgrade
114 if self
.location
!= "":
115 retval
= "# System bootloader configuration\nbootloader"
117 if self
.appendLine
!= "":
118 retval
+= " --append=\"%s\"" % self
.appendLine
120 retval
+= " --location=%s" % self
.location
123 if self
.password
!= "":
124 retval
+= " --password=%s" % self
.password
125 if self
.md5pass
!= "":
126 retval
+= " --md5pass=%s" % self
.md5pass
128 retval
+= " --upgrade"
129 if len(self
.driveorder
) > 0:
130 retval
+= " --driveorder=%s" % string
.join(self
.driveorder
, ",")
136 def parse(self
, args
):
137 def driveorder_cb (option
, opt_str
, value
, parser
):
138 for d
in value
.split(','):
139 parser
.values
.ensure_value(option
.dest
, []).append(d
)
141 op
= KSOptionParser(lineno
=self
.lineno
)
142 op
.add_option("--append", dest
="appendLine")
143 op
.add_option("--location", dest
="location", type="choice",
145 choices
=["mbr", "partition", "none", "boot"])
146 op
.add_option("--lba32", dest
="forceLBA", action
="store_true",
148 op
.add_option("--password", dest
="password", default
="")
149 op
.add_option("--md5pass", dest
="md5pass", default
="")
150 op
.add_option("--upgrade", dest
="upgrade", action
="store_true",
152 op
.add_option("--driveorder", dest
="driveorder", action
="callback",
153 callback
=driveorder_cb
, nargs
=1, type="string")
155 (opts
, extra
) = op
.parse_args(args
=args
)
156 self
._setToSelf
(op
, opts
)