Don't error out if raid --useexisting is given with no members (#741728).
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 " % (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 " % (self.bytesPerInode)) > + self.assert_parse("raid / --device=md0 --level=6 --useexisting %s" % (self.bytesPerInode), > + "raid / --device=0 --level=RAID6 --useexisting %s " % (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 " % (self.bytesPerInode)) > + self.assert_parse("raid / --device=md0 --level=6 --noformat --useexisting %s" % (self.bytesPerInode), > + "raid / --device=0 --level=RAID6 --noformat --useexisting %s " % (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 ") > - self.assert_parse("raid / --device=md0 --encrypted --backuppassphrase " > - "raid.01 raid.02", > - "raid / --device=0 --encrypted raid.01 raid.02 ") > - 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 ") > - 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 ") > - 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 ") > + 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 ") > + self.assert_parse("raid / --device=md0 --encrypted --backuppassphrase --level=1 raid.01 raid.02", > + "raid / --device=0 --level=RAID1 --encrypted raid.01 raid.02 ") > + 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 ") > + 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 ") > + 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 ") > > # 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 ") > + 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 ") > > if __name__ == "__main__": > unittest.main() _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list Wed Oct 5 23:30:01 2011 Return-path: <bounce-debian-user=tom=linux-archive.org@lists.debian.org> Envelope-to: tom@linux-archive.org Delivery-date: Wed, 05 Oct 2011 23:17:24 +0300 Received: from liszt.debian.org ([82.195.75.100]:59450) by s2.java-tips.org with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from <bounce-debian-user=tom=linux-archive.org@lists.debian.org>) id 1RBXu8-0006zw-6n for tom@linux-archive.org; Wed, 05 Oct 2011 23:17:24 +0300 Received: from localhost (localhost [127.0.0.1]) by liszt.debian.org (Postfix) with QMQP id B199D13A64A0; Wed, 5 Oct 2011 20:26:43 +0000 (UTC) Old-Return-Path: <irek.szczesniak@gmail.com> X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on liszt.debian.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=4.0 tests=GMAIL,LDOSUBSCRIBER, LDO_WHITELIST,MONEY,RCVD_IN_DNSWL_LOW autolearn=failed version=3.2.5 X-Original-To: lists-debian-user@liszt.debian.org Delivered-To: lists-debian-user@liszt.debian.org Received: from localhost (localhost [127.0.0.1]) by liszt.debian.org (Postfix) with ESMTP id 2F44A13A5028 for <lists-debian-user@liszt.debian.org>; Wed, 5 Oct 2011 20:26:36 +0000 (UTC) X-Virus-Scanned: at lists.debian.org with policy bank en-ht X-Amavis-Spam-Status: No, score=-6.5 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, GMAIL=1, LDO_WHITELIST=-5, MONEY=0.5, RCVD_IN_DNSWL_LOW=-1] autolearn=ham Received: from liszt.debian.org ([127.0.0.1]) by localhost (lists.debian.org [127.0.0.1]) (amavisd-new, port 2525) with ESMTP id Kf7+TijbVv8X for <lists-debian-user@liszt.debian.org>; Wed, 5 Oct 2011 20:26:28 +0000 (UTC) X-policyd-weight: using cached result; rate: -6.9 Received: from mail-ey0-f175.google.com (mail-ey0-f175.google.com [209.85.215.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by liszt.debian.org (Postfix) with ESMTPS id 8718E13A5037 for <debian-user@lists.debian.org>; Wed, 5 Oct 2011 20:26:16 +0000 (UTC) Received: by eyx24 with SMTP id 24so550123eyx.6 for <debian-user@lists.debian.org>; Wed, 05 Oct 2011 13:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=tSdAunqDpOlGvTYOptSIAWv1HG8JuSpm3tczxbmBWrw=; b=KquBfAlmKQUhCmqKR1u7+LyfLj4dI3v1GdPxjPlyijnfNCRR gR/25A08OT0Ec7lwKq /HgWs6OL1xGZdzxsJflQiT/AH+PVhGnLFUO3DFYidtpBfnyyetQVcRv0+iJUdPuvYRNt qO/ZiUko6LMoOGK0p5aW/IF6azS79S+t7rUx4= Received: by 10.223.36.68 with SMTP id s4mr4091668fad.92.1317846368357; Wed, 05 Oct 2011 13:26:08 -0700 (PDT) Received: from [192.168.2.156] (host-83.2.142.85.tvksmp.pl. [83.2.142.85]) by mx.google.com with ESMTPS id k26sm3778631fab.12.2011.10.05.13.26.06 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Oct 2011 13:26:07 -0700 (PDT) Message-ID: <4E8CBD5D.3000008@gmail.com> Date: Wed, 05 Oct 2011 22:26:05 +0200 From: =?UTF-8?B?SXJlbmV1c3ogU3pjemXFm25pYWs=?= <irek.szczesniak@gmail.com> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20110818 Icedove/3.0.11 MIME-Version: 1.0 To: debian-user@lists.debian.org Subject: Re: IP address depending on the MAC References: <4E8891FF.4020606@gmail.com> <CAL5yMZS7LCV89=epUiVV1b8E_0=oBZp7W87nbEydfgwUqJ9Z dg@mail.gmail.com> <8s5pl8xttd.ln2@news.roaima.co.uk> In-Reply-To: <8s5pl8xttd.ln2@news.roaima.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rc-Virus: 2007-09-13_01 X-Rc-Spam: 2008-11-04_01 Resent-Message-ID: <Pk1aDo1a0jE.A.VvE.D2LjOB@liszt> Resent-From: debian-user@lists.debian.org X-Mailing-List: <debian-user@lists.debian.org> archive/latest/614238 X-Loop: debian-user@lists.debian.org List-Id: <debian-user.lists.debian.org> List-Post: <mailto:debian-user@lists.debian.org> List-Help: <mailto:debian-user-request@lists.debian.org?subject=help> List-Subscribe: <mailto:debian-user-request@lists.debian.org?subject=subscribe> List-Unsubscribe: <mailto:debian-user-request@lists.debian.org?subject=unsubscribe> Precedence: list Resent-Sender: debian-user-request@lists.debian.org Resent-Date: Wed, 5 Oct 2011 20:26:43 +0000 (UTC) Thank you, Chris, for the idea. The IP addresses would be randomly distributed, while I would like to keep them in a contiguous range. On 03.10.2011 18:52, Chris Davies wrote: > Javier Barroso<javibarroso@gmail.com> wrote: >> If you know which macs you will have, you can make an init script >> which generate /etc/network/interface and /etc/hostname and /etc/hosts >> the first boot and then remove itself. > > You don't even need to know in advance the MACs as long as enough of > the address is unique. > >> $ cat /etc/init.d/10setnetworkonlyfirstboot >> #!/bin/bash > #> mymac=$(ip add show dev eth0 | awk '/ether/ {print $2}') > #> myhost=$(awk "/$mymac/ {print $3}") > #> myip=$(awk "/$mymac/ {print $2}") > > myhex=$( > ip add show dev eth0 | # Get the interface detail > awk '/ether/ {print toupper($2)}' | # Extract MAC > cut -d: -f6 # Get last octet (as hex) > ) > mydec=$( echo "16 i $myhex p" | dc ) # Convert hex to dec > myip="192.168.1.$mydec" # Must guarantee not 0 or 255 > > >> sed -i "s/IP/$myip" /etc/network/interfaces # and probably some >> changes in /etc/hosts >> sed -i "s/HOSTNAME/$myhost" /etc/hostname # and probably some changes >> in /etc/hosts >> rm -f /etc/init.d/10setnetworkonlyfirstboot > > Rather than removing the configuration file, you could add, say, > "# Configured eth0" to /etc/network/interfaces during setup. Next time > just exit if that line exists in the file. -- Ireneusz (Irek) Szczesniak http://www.irkos.org -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org Archive: http://lists.debian.org/4E8CBD5D.3000008@gmail.com |
| All times are GMT. The time now is 04:21 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.