On Wed, 2011-10-05 at 10:49 -0400, Chris Lumens wrote: > This also adds extra error checking from anaconda and makes --level= a required > argument, like the wiki indicates it is. I'm not sure if level should be required with preexisting arrays, but it's not a horrible requirement. Both patches look okay to me. > --- > pykickstart/commands/raid.py | 12 ++++++- > tests/commands/raid.py | 63 ++++++++++++++++------------------------- > 2 files changed, 35 insertions(+), 40 deletions(-) > > diff --git a/pykickstart/commands/raid.py b/pykickstart/commands/raid.py > index 0f4c92a..575bd0a 100644 > --- a/pykickstart/commands/raid.py > +++ b/pykickstart/commands/raid.py > @@ -249,8 +249,11 @@ class FC3_Raid(KickstartCommand): > > if len(extra) == 0: > raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid") > - if len(extra) == 1: > + > + if len(extra) == 1 and not opts.preexist: > raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid") > + elif len(extra) > 1 and opts.preexist: > + raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Members may not be specified for preexisting RAID device")) > > rd = self.handler.RaidData() > self._setToObj(self.op, opts, rd) > @@ -261,12 +264,17 @@ class FC3_Raid(KickstartCommand): > # it runs int(). > rd.device = int(rd.device) > rd.mountpoint = extra[0] > - rd.members = extra[1:] > + > + if len(extra) > 1: > + rd.members = extra[1:] > > # Check for duplicates in the data list. > if rd in self.dataList(): > warnings.warn(_("A RAID device with the name %s has already been defined.") % rd.device) > > + if not rd.preexist and not rd.level: > + raise KickstartValueError, formatErrorMsg(self.lineno, msg="RAID Partition defined without RAID level") > + > return rd > > def dataList(self): > diff --git a/tests/commands/raid.py b/tests/commands/raid.py > index 060bced..7b6675a 100644 > --- a/tests/commands/raid.py > +++ b/tests/commands/raid.py > @@ -63,12 +63,12 @@ class FC3_TestCase(CommandTest): > self.assert_parse("raid / --device=md0 --fstype=ASDF --level=6 %sraid.01 raid.02" % (self.bytesPerInode), \ > "raid / --device=0 --fstype=\"ASDF\" --level=RAID6 %sraid.01 raid.02\n" % (self.bytesPerInode)) > # useexisting > - self.assert_parse("raid / --device=md0 --level=6 --useexisting %sraid.01 raid.02" % (self.bytesPerInode), \ > - "raid / --device=0 --level=RAID6 --useexisting %sraid.01 raid.02\n" % (self.bytesPerInode)) > + self.assert_parse("raid / --device=md0 --level=6 --useexisting %s" % (self.bytesPerInode), \ > + "raid / --device=0 --level=RAID6 --useexisting %s\n" % (self.bytesPerInode)) > > # noformat > - self.assert_parse("raid / --device=md0 --level=6 --noformat --useexisting %sraid.01 raid.02" % (self.bytesPerInode), \ > - "raid / --device=0 --level=RAID6 --noformat --useexisting %sraid.01 raid.02\n" % (self.bytesPerInode)) > + self.assert_parse("raid / --device=md0 --level=6 --noformat --useexisting %s" % (self.bytesPerInode), \ > + "raid / --device=0 --level=RAID6 --noformat --useexisting %s\n" % (self.bytesPerInode)) > > # fail > # no mountpoint or options > @@ -81,10 +81,12 @@ class FC3_TestCase(CommandTest): > self.assert_parse_error("raid /", KickstartValueError) > # no device > self.assert_parse_error("raid / --level=0", KickstartValueError) > - # no level -- FIXME -- I would think should should fail, but it doesn't > - # self.assert_parse_error("raid / --device=md0", KickstartValueError) > + # no level > + self.assert_parse_error("raid / --device=md0", KickstartValueError) > # No raid members defined > self.assert_parse_error("raid / --level=0 --device=md0", KickstartValueError) > + # Both raid members and useexisting given > + self.assert_parse_error("raid / --level=0 --device=md0 --useexisting raid.01 raid.02", KickstartValueError) > > # Invalid device string - device=asdf0 > self.assert_parse_error("raid / --device=asdf0 --level=RAID1 raid.01 raid.02 raid.03", ValueError) > @@ -154,38 +156,23 @@ class F12_TestCase(F9_TestCase): > F9_TestCase.runTest(self) > > # pass > - self.assert_parse("raid / --device=md0 --escrowcert=\"http://x/y\" " > - "raid.01 raid.02", > - "raid / --device=0 raid.01 raid.02\n") > - self.assert_parse("raid / --device=md0 --encrypted --backuppassphrase " > - "raid.01 raid.02", > - "raid / --device=0 --encrypted raid.01 raid.02\n") > - self.assert_parse("raid / --device=md0 --encrypted " > - "--escrowcert=\"http://x/y\" raid.01 raid.02", > - "raid / --device=0 --encrypted " > - "--escrowcert=\"http://x/y\" raid.01 raid.02\n") > - self.assert_parse("raid / --device=md0 --encrypted " > - "--escrowcert=\"http://x/y\" --backuppassphrase " > - "raid.01 raid.02", > - "raid / --device=0 --encrypted " > - "--escrowcert=\"http://x/y\" --backuppassphrase " > - "raid.01 raid.02\n") > - self.assert_parse("raid / --device=md0 --encrypted " > - "--escrowcert=http://x/y raid.01 raid.02", > - "raid / --device=0 --encrypted " > - "--escrowcert=\"http://x/y\" raid.01 raid.02\n") > + self.assert_parse("raid / --device=md0 --escrowcert=\"http://x/y\" --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 raid.01 raid.02\n") > + self.assert_parse("raid / --device=md0 --encrypted --backuppassphrase --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 --encrypted raid.01 raid.02\n") > + self.assert_parse("raid / --device=md0 --encrypted --escrowcert=\"http://x/y\" --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 --encrypted --escrowcert=\"http://x/y\" raid.01 raid.02\n") > + self.assert_parse("raid / --device=md0 --encrypted --escrowcert=\"http://x/y\" --backuppassphrase --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 --encrypted --escrowcert=\"http://x/y\" --backuppassphrase raid.01 raid.02\n") > + self.assert_parse("raid / --device=md0 --encrypted --escrowcert=http://x/y --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 --encrypted --escrowcert=\"http://x/y\" raid.01 raid.02\n") > > # fail > - self.assert_parse_error("raid / --device=md0 raid.01 raid.02 " > - "--escrowcert") > - self.assert_parse_error("raid / --device=md0 --escrowcert " > - "--backuppassphrase raid.01 raid.02") > - self.assert_parse_error("raid / --device=md0 --encrypted --escrowcert " > - "--backuppassphrase raid.01 raid.02") > - self.assert_parse_error("raid / --device=md0 --backuppassphrase=False " > - "raid.01 raid.02") > - self.assert_parse_error("raid / --device=md0 --backuppassphrase=True " > - "raid.01 raid.02") > + self.assert_parse_error("raid / --device=md0 --level=1 raid.01 raid.02 -escrowcert") > + self.assert_parse_error("raid / --device=md0 --escrowcert --backuppassphrase --level=1 raid.01 raid.02") > + self.assert_parse_error("raid / --device=md0 --encrypted --escrowcert --backuppassphrase --level=1 raid.01 raid.02") > + self.assert_parse_error("raid / --device=md0 --backuppassphrase=False --level=1 raid.01 raid.02") > + self.assert_parse_error("raid / --device=md0 --backuppassphrase=True --level=1 raid.01 raid.02") > > class F13_TestCase(F12_TestCase): > def __init__(self, *kargs, **kwargs): > @@ -202,8 +189,8 @@ class F15_TestCase(F14_TestCase): > F14_TestCase.runTest(self) > > # pass > - self.assert_parse("raid / --device=md0 --label=ROOT raid.01 raid.02", > - "raid / --device=0 --label=ROOT raid.01 raid.02\n") > + self.assert_parse("raid / --device=md0 --label=ROOT --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 --label=ROOT raid.01 raid.02\n") > > if __name__ == "__main__": > unittest.main() _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list