|
|
1a8d67 |
From c161b860e8c2dd006dbd576c720664b77ac2c858 Mon Sep 17 00:00:00 2001
|
|
|
1a8d67 |
From: Colin Walters <walters@redhat.com>
|
|
|
1a8d67 |
Date: Mon, 16 Jun 2014 16:27:41 +0200
|
|
|
1a8d67 |
Subject: [PATCH 1/2] ostreesetup: New command
|
|
|
1a8d67 |
|
|
|
1a8d67 |
This tells the installer to handle an OSTree repository.
|
|
|
1a8d67 |
|
|
|
1a8d67 |
Related: rhbz#1113535
|
|
|
1a8d67 |
Port of rpmostreepayload patches from master
|
|
|
1a8d67 |
commit dd1f59278ad2aa0cb2c79483528770b78488661d
|
|
|
1a8d67 |
---
|
|
|
1a8d67 |
pykickstart/commands/__init__.py | 2 +-
|
|
|
1a8d67 |
pykickstart/commands/ostreesetup.py | 76 +++++++++++++++++++++++++++++++++++++
|
|
|
1a8d67 |
pykickstart/handlers/control.py | 1 +
|
|
|
1a8d67 |
tests/commands/ostreesetup.py | 38 +++++++++++++++++++
|
|
|
1a8d67 |
4 files changed, 116 insertions(+), 1 deletion(-)
|
|
|
1a8d67 |
create mode 100644 pykickstart/commands/ostreesetup.py
|
|
|
1a8d67 |
create mode 100644 tests/commands/ostreesetup.py
|
|
|
1a8d67 |
|
|
|
1a8d67 |
diff --git a/pykickstart/commands/__init__.py b/pykickstart/commands/__init__.py
|
|
|
1a8d67 |
index c5145ba..4cc20af 100644
|
|
|
1a8d67 |
--- a/pykickstart/commands/__init__.py
|
|
|
1a8d67 |
+++ b/pykickstart/commands/__init__.py
|
|
|
1a8d67 |
@@ -21,6 +21,6 @@ import authconfig, autopart, autostep, bootloader, btrfs, clearpart, cdrom, devi
|
|
|
1a8d67 |
import deviceprobe, displaymode, dmraid, driverdisk, eula, fcoe, firewall, firstboot
|
|
|
1a8d67 |
import group, harddrive, ignoredisk, interactive, iscsi, iscsiname, key, keyboard, lang
|
|
|
1a8d67 |
import langsupport, lilocheck, liveimg, logging, logvol, mediacheck, method, monitor
|
|
|
1a8d67 |
-import mouse, multipath, network, nfs, partition, raid, realm, reboot, repo, rescue
|
|
|
1a8d67 |
+import mouse, multipath, network, nfs, ostreesetup, partition, raid, realm, reboot, repo, rescue
|
|
|
1a8d67 |
import rootpw, selinux, services, skipx, sshpw, timezone, updates, upgrade, url, user
|
|
|
1a8d67 |
import unsupported_hardware, vnc, volgroup, xconfig, zerombr, zfcp
|
|
|
1a8d67 |
diff --git a/pykickstart/commands/ostreesetup.py b/pykickstart/commands/ostreesetup.py
|
|
|
1a8d67 |
new file mode 100644
|
|
|
1a8d67 |
index 0000000..269d91f
|
|
|
1a8d67 |
--- /dev/null
|
|
|
1a8d67 |
+++ b/pykickstart/commands/ostreesetup.py
|
|
|
1a8d67 |
@@ -0,0 +1,76 @@
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+# Copyright (C) 2014 Red Hat, Inc.
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+# This copyrighted material is made available to anyone wishing to use,
|
|
|
1a8d67 |
+# modify, copy, or redistribute it subject to the terms and conditions of
|
|
|
1a8d67 |
+# the GNU General Public License v.2, or (at your option) any later version.
|
|
|
1a8d67 |
+# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
1a8d67 |
+# ANY WARRANTY expressed or implied, including the implied warranties of
|
|
|
1a8d67 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
1a8d67 |
+# Public License for more details. You should have received a copy of the
|
|
|
1a8d67 |
+# GNU General Public License along with this program; if not, write to the
|
|
|
1a8d67 |
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
1a8d67 |
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
|
1a8d67 |
+# source code or documentation are not subject to the GNU General Public
|
|
|
1a8d67 |
+# License and may only be used or replicated with the express permission of
|
|
|
1a8d67 |
+# Red Hat, Inc.
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+from pykickstart.base import KickstartCommand
|
|
|
1a8d67 |
+from pykickstart.options import KSOptionParser
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+import gettext
|
|
|
1a8d67 |
+_ = lambda x: gettext.ldgettext("pykickstart", x)
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+class RHEL7_OSTreeSetup(KickstartCommand):
|
|
|
1a8d67 |
+ removedKeywords = KickstartCommand.removedKeywords
|
|
|
1a8d67 |
+ removedAttrs = KickstartCommand.removedAttrs
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ def __init__(self, *args, **kwargs):
|
|
|
1a8d67 |
+ KickstartCommand.__init__(self, *args, **kwargs)
|
|
|
1a8d67 |
+ self.op = self._getParser()
|
|
|
1a8d67 |
+ self.osname = kwargs.get('osname', None)
|
|
|
1a8d67 |
+ self.remote = kwargs.get("remote", self.osname)
|
|
|
1a8d67 |
+ self.url = kwargs.get('url', None)
|
|
|
1a8d67 |
+ self.ref = kwargs.get('ref', None)
|
|
|
1a8d67 |
+ self.noGpg = kwargs.get('noGpg', False)
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ def __str__(self):
|
|
|
1a8d67 |
+ retval = KickstartCommand.__str__(self)
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ if self.osname:
|
|
|
1a8d67 |
+ retval += "# OSTree setup\n"
|
|
|
1a8d67 |
+ retval += "ostreesetup %s\n" % self._getArgsAsStr()
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ return retval
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ def _getArgsAsStr(self):
|
|
|
1a8d67 |
+ retcmd = []
|
|
|
1a8d67 |
+ if self.osname:
|
|
|
1a8d67 |
+ retcmd.append('--osname="%s"' % self.osname)
|
|
|
1a8d67 |
+ if self.remote:
|
|
|
1a8d67 |
+ retcmd.append('--remote="%s"' % self.remote)
|
|
|
1a8d67 |
+ if self.url:
|
|
|
1a8d67 |
+ retcmd.append('--url="%s"' % self.url)
|
|
|
1a8d67 |
+ if self.ref:
|
|
|
1a8d67 |
+ retcmd.append('--ref="%s"' % self.ref)
|
|
|
1a8d67 |
+ if self.noGpg:
|
|
|
1a8d67 |
+ retcmd.append('--nogpg')
|
|
|
1a8d67 |
+ return ' '.join(retcmd)
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ def _getParser(self):
|
|
|
1a8d67 |
+ op = KSOptionParser()
|
|
|
1a8d67 |
+ op.add_option("--osname", dest="osname", required=1)
|
|
|
1a8d67 |
+ op.add_option("--remote", dest="remote")
|
|
|
1a8d67 |
+ op.add_option("--url", dest="url", required=1)
|
|
|
1a8d67 |
+ op.add_option("--ref", dest="ref", required=1)
|
|
|
1a8d67 |
+ op.add_option("--nogpg", action="store_true")
|
|
|
1a8d67 |
+ return op
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ def parse(self, args):
|
|
|
1a8d67 |
+ (opts, _extra) = self.op.parse_args(args=args, lineno=self.lineno)
|
|
|
1a8d67 |
+ self._setToSelf(self.op, opts)
|
|
|
1a8d67 |
+ if self.remote is None:
|
|
|
1a8d67 |
+ self.remote = self.osname
|
|
|
1a8d67 |
+ return self
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
|
|
|
1a8d67 |
index 9d3bbf0..8b0d338 100644
|
|
|
1a8d67 |
--- a/pykickstart/handlers/control.py
|
|
|
1a8d67 |
+++ b/pykickstart/handlers/control.py
|
|
|
1a8d67 |
@@ -1349,6 +1349,7 @@ commandMap = {
|
|
|
1a8d67 |
"multipath": multipath.FC6_MultiPath,
|
|
|
1a8d67 |
"network": network.RHEL7_Network,
|
|
|
1a8d67 |
"nfs": nfs.FC6_NFS,
|
|
|
1a8d67 |
+ "ostreesetup": ostreesetup.RHEL7_OSTreeSetup,
|
|
|
1a8d67 |
"part": partition.F20_Partition,
|
|
|
1a8d67 |
"partition": partition.F20_Partition,
|
|
|
1a8d67 |
"poweroff": reboot.F18_Reboot,
|
|
|
1a8d67 |
diff --git a/tests/commands/ostreesetup.py b/tests/commands/ostreesetup.py
|
|
|
1a8d67 |
new file mode 100644
|
|
|
1a8d67 |
index 0000000..3c59a5a
|
|
|
1a8d67 |
--- /dev/null
|
|
|
1a8d67 |
+++ b/tests/commands/ostreesetup.py
|
|
|
1a8d67 |
@@ -0,0 +1,38 @@
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+# Colin Walters <walters@redhat.com>
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+# Copyright 2014 Red Hat, Inc.
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+# This copyrighted material is made available to anyone wishing to use, modify,
|
|
|
1a8d67 |
+# copy, or redistribute it subject to the terms and conditions of the GNU
|
|
|
1a8d67 |
+# General Public License v.2. This program is distributed in the hope that it
|
|
|
1a8d67 |
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
|
|
|
1a8d67 |
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
1a8d67 |
+# See the GNU General Public License for more details.
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+# You should have received a copy of the GNU General Public License along with
|
|
|
1a8d67 |
+# this program; if not, write to the Free Software Foundation, Inc., 51
|
|
|
1a8d67 |
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
|
|
|
1a8d67 |
+# trademarks that are incorporated in the source code or documentation are not
|
|
|
1a8d67 |
+# subject to the GNU General Public License and may only be used or replicated
|
|
|
1a8d67 |
+# with the express permission of Red Hat, Inc.
|
|
|
1a8d67 |
+#
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+import unittest
|
|
|
1a8d67 |
+from tests.baseclass import *
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+class RHEL7_TestCase(CommandTest):
|
|
|
1a8d67 |
+ def runTest(self):
|
|
|
1a8d67 |
+ # pass
|
|
|
1a8d67 |
+ self.assert_parse("ostreesetup --osname=fedora-atomic --url=http://example.com/repo --ref=fedora-atomic/sometest/base/core")
|
|
|
1a8d67 |
+ cmdstr = "ostreesetup --osname=\"fedora-atomic\" --remote=\"fedora-atomic\" --url=\"http://example.com/repo\" --ref=\"fedora-atomic/sometest/base/core\""
|
|
|
1a8d67 |
+ self.assert_parse(cmdstr, cmdstr + '\n')
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+ # fail - we have required arguments
|
|
|
1a8d67 |
+ self.assert_parse_error("ostreesetup", KickstartValueError)
|
|
|
1a8d67 |
+ self.assert_parse_error("ostreesetup --os=fedora-atomic", KickstartValueError)
|
|
|
1a8d67 |
+ self.assert_parse_error("ostreesetup --os=fedora-atomic --url=http://example.com/repo", KickstartValueError)
|
|
|
1a8d67 |
+ self.assert_parse_error("ostreesetup --bacon=tasty")
|
|
|
1a8d67 |
+
|
|
|
1a8d67 |
+if __name__ == "__main__":
|
|
|
1a8d67 |
+ unittest.main()
|
|
|
1a8d67 |
--
|
|
|
1a8d67 |
1.9.3
|
|
|
1a8d67 |
|