New version.
[pykickstart.git] / pykickstart / commands / ostreesetup.py
blob3b8f31c01b1ee7e33003a3a14d59bb2eb12ed338
2 # Copyright (C) 2014 Red Hat, Inc.
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions of
6 # the GNU General Public License v.2, or (at your option) any later version.
7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY expressed or implied, including the implied warranties of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10 # Public License for more details. You should have received a copy of the
11 # GNU General Public License along with this program; if not, write to the
12 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13 # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
14 # source code or documentation are not subject to the GNU General Public
15 # License and may only be used or replicated with the express permission of
16 # Red Hat, Inc.
19 from pykickstart.base import KickstartCommand
20 from pykickstart.options import KSOptionParser
22 import gettext
23 _ = lambda x: gettext.ldgettext("pykickstart", x)
25 class F21_OSTreeSetup(KickstartCommand):
26 removedKeywords = KickstartCommand.removedKeywords
27 removedAttrs = KickstartCommand.removedAttrs
29 def __init__(self, *args, **kwargs):
30 KickstartCommand.__init__(self, *args, **kwargs)
31 self.op = self._getParser()
32 self.osname = kwargs.get('osname', None)
33 self.remote = kwargs.get("remote", self.osname)
34 self.url = kwargs.get('url', None)
35 self.ref = kwargs.get('ref', None)
36 self.nogpg = kwargs.get('nogpg', False)
38 def __str__(self):
39 retval = KickstartCommand.__str__(self)
41 if self.osname:
42 retval += "# OSTree setup\n"
43 retval += "ostreesetup %s\n" % self._getArgsAsStr()
45 return retval
47 def _getArgsAsStr(self):
48 retcmd = []
49 if self.osname:
50 retcmd.append('--osname="%s"' % self.osname)
51 if self.remote:
52 retcmd.append('--remote="%s"' % self.remote)
53 if self.url:
54 retcmd.append('--url="%s"' % self.url)
55 if self.ref:
56 retcmd.append('--ref="%s"' % self.ref)
57 if self.nogpg:
58 retcmd.append('--nogpg')
59 return ' '.join(retcmd)
61 def _getParser(self):
62 op = KSOptionParser()
63 op.add_option("--osname", dest="osname", required=1)
64 op.add_option("--remote", dest="remote")
65 op.add_option("--url", dest="url", required=1)
66 op.add_option("--ref", dest="ref", required=1)
67 op.add_option("--nogpg", action="store_true")
68 return op
70 def parse(self, args):
71 (opts, _extra) = self.op.parse_args(args=args, lineno=self.lineno)
72 self._setToSelf(self.op, opts)
73 if self.remote is None:
74 self.remote = self.osname
75 return self