Rename command objects by inserting an underscore between the version part
[pykickstart.git] / pykickstart / commands / dmraid.py
blobfbb527b07bb1cbb014b210bcb0381ff22468e374
2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2006, 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.
13 import string
15 from pykickstart.base import *
16 from pykickstart.errors import *
17 from pykickstart.options import *
19 from rhpl.translate import _
20 import rhpl.translate as translate
22 translate.textdomain("pykickstart")
24 class FC6_DmRaidData(BaseData):
25 def __init__(self, name="", devices=None, dmset=None):
26 BaseData.__init__(self)
27 self.name = name
29 if devices == None:
30 devices = []
32 self.devices = devices
33 self.dmset = dmset
35 def __str__(self):
36 retval = "dmraid --name=%s" % self.name
38 for dev in self.devices:
39 retval += " --dev=\"%s\"" % dev
41 return retval + "\n"
43 class FC6_DmRaid(KickstartCommand):
44 def __init__(self, writePriority=60, dmraids=None):
45 KickstartCommand.__init__(self, writePriority)
47 if dmraids == None:
48 dmraids = []
50 self.dmraids = dmraids
52 def __str__(self):
53 retval = ""
54 for dm in self.dmraids:
55 retval += dm.__str__()
57 return retval
59 def parse(self, args):
60 op = KSOptionParser(lineno=self.lineno)
61 op.add_option("--name", dest="name", action="store", type="string",
62 required=1)
63 op.add_option("--dev", dest="devices", action="append", type="string",
64 required=1)
66 dm = FC6_DmRaidData()
67 (opts, extra) = op.parse_args(args=args)
68 dm.name = dm.name.split('/')[-1]
69 self._setToObj(op, opts, dm)
70 self.add(dm)
72 def add(self, newObj):
73 self.dmraids.append(newObj)