summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/group.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/group.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/group.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/group.py b/scripts/lib/mic/3rdparty/pykickstart/commands/group.py
new file mode 100644
index 0000000000..80ba5bdca6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/group.py
@@ -0,0 +1,88 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 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#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class F12_GroupData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35 self.name = kwargs.get("name", "")
36 self.gid = kwargs.get("gid", None)
37
38 def __eq__(self, y):
39 return self.name == y.name
40
41 def __str__(self):
42 retval = BaseData.__str__(self)
43 retval += "group"
44
45 if self.name:
46 retval += " --name=%s" % self.name
47 if self.gid:
48 retval += " --gid=%s" % self.gid
49
50 return retval + "\n"
51
52class F12_Group(KickstartCommand):
53 removedKeywords = KickstartCommand.removedKeywords
54 removedAttrs = KickstartCommand.removedAttrs
55
56 def __init__(self, writePriority=0, *args, **kwargs):
57 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
58 self.op = self._getParser()
59
60 self.groupList = kwargs.get("groupList", [])
61
62 def __str__(self):
63 retval = ""
64 for user in self.groupList:
65 retval += user.__str__()
66
67 return retval
68
69 def _getParser(self):
70 op = KSOptionParser()
71 op.add_option("--name", required=1)
72 op.add_option("--gid", type="int")
73 return op
74
75 def parse(self, args):
76 gd = self.handler.GroupData()
77 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
78 self._setToObj(self.op, opts, gd)
79 gd.lineno = self.lineno
80
81 # Check for duplicates in the data list.
82 if gd in self.dataList():
83 warnings.warn(_("A group with the name %s has already been defined.") % gd.name)
84
85 return gd
86
87 def dataList(self):
88 return self.groupList