Skip to content

Commit

Permalink
Add RPM OSTree source from container (#2125655)
Browse files Browse the repository at this point in the history
RPM OSTree is getting new functionality to use containers as the base
image. Thanks to that it's possible to use standard container
repositories.

This source enables to use these repositories.

Related: RHEL-2250
  • Loading branch information
rvykydal committed Jan 12, 2024
1 parent 83f02e9 commit 617bccb
Show file tree
Hide file tree
Showing 17 changed files with 386 additions and 4 deletions.
2 changes: 1 addition & 1 deletion anaconda.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Source0: %{name}-%{version}.tar.bz2
%define libxklavierver 5.4
%define mehver 0.23-1
%define nmver 1.0
%define pykickstartver 3.32.10-1
%define pykickstartver 3.32.11-1
%define pypartedver 2.5-2
%define pythonblivetver 1:3.6.0-4
%define rpmver 4.10.0
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ AC_CONFIG_FILES([Makefile
pyanaconda/modules/payloads/source/nfs/Makefile
pyanaconda/modules/payloads/source/repo_files/Makefile
pyanaconda/modules/payloads/source/rpm_ostree/Makefile
pyanaconda/modules/payloads/source/rpm_ostree_container/Makefile
pyanaconda/modules/payloads/source/url/Makefile
pyanaconda/modules/storage/Makefile
pyanaconda/modules/storage/bootloader/Makefile
Expand Down
1 change: 1 addition & 0 deletions pyanaconda/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ class DisplayModes(Enum):
SOURCE_TYPE_LIVE_OS_IMAGE = "LIVE_OS_IMAGE"
SOURCE_TYPE_LIVE_IMAGE = "LIVE_IMAGE"
SOURCE_TYPE_RPM_OSTREE = "RPM_OSTREE"
SOURCE_TYPE_RPM_OSTREE_CONTAINER = "RPM_OSTREE_CONTAINER"
SOURCE_TYPE_HMC = "HMC"
SOURCE_TYPE_CDROM = "CDROM"
SOURCE_TYPE_CLOSEST_MIRROR = "CLOSEST_MIRROR"
Expand Down
1 change: 1 addition & 0 deletions pyanaconda/core/kickstart/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from pykickstart.commands.nfs import FC6_NFS as NFS
from pykickstart.commands.nvdimm import F28_Nvdimm as Nvdimm
from pykickstart.commands.ostreesetup import RHEL9_OSTreeSetup as OSTreeSetup
from pykickstart.commands.ostreecontainer import RHEL9_OSTreeContainer as OSTreeContainer
from pykickstart.commands.partition import RHEL9_Partition as Partition
from pykickstart.commands.raid import RHEL9_Raid as Raid
from pykickstart.commands.realm import F19_Realm as Realm
Expand Down
5 changes: 5 additions & 0 deletions pyanaconda/modules/common/constants/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
basename="RPMOSTree"
)

PAYLOAD_SOURCE_RPM_OSTREE_CONTAINER = DBusInterfaceIdentifier(
namespace=SOURCE_NAMESPACE,
basename="RPMOSTreeContainer"
)

PAYLOAD_SOURCE = DBusInterfaceIdentifier(
namespace=SOURCE_NAMESPACE
)
Expand Down
74 changes: 73 additions & 1 deletion pyanaconda/modules/common/structures/rpm_ostree.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from dasbus.structure import DBusData
from dasbus.typing import Str, Bool

__all__ = ["RPMOSTreeConfigurationData"]
__all__ = ["RPMOSTreeConfigurationData", "RPMOSTreeContainerConfigurationData"]


class RPMOSTreeConfigurationData(DBusData):
Expand All @@ -33,6 +33,11 @@ def __init__(self):
self._ref = ""
self._gpg_verification_enabled = True

@staticmethod
def is_container():
"""Is this native container source?"""
return False

@property
def osname(self) -> Str:
"""Management root for OS installation."""
Expand Down Expand Up @@ -77,3 +82,70 @@ def gpg_verification_enabled(self) -> Bool:
@gpg_verification_enabled.setter
def gpg_verification_enabled(self, value: Bool):
self._gpg_verification_enabled = value


class RPMOSTreeContainerConfigurationData(DBusData):
"""Structure to hold RPM OSTree from container configuration."""

def __init__(self):
self._stateroot = ""
self._remote = ""
self._transport = ""
self._url = ""
self._signature_verification_enabled = True

@staticmethod
def is_container():
"""Is this native container source?"""
return True

@property
def stateroot(self) -> Str:
"""Name for the state directory, also known as "osname".
This could be optional.
"""
return self._stateroot

@stateroot.setter
def stateroot(self, value: Str):
self._stateroot = value

@property
def transport(self) -> Str:
"""Ostree transport protocol used.
This could be optional (default will be 'repository').
"""
return self._transport

@transport.setter
def transport(self, value: Str):
self._transport = value

@property
def remote(self) -> Str:
"""Name of the OSTree remote."""
return self._remote

@remote.setter
def remote(self, value: Str):
self._remote = value

@property
def url(self) -> Str:
"""URL of the repository to install from."""
return self._url

@url.setter
def url(self, value: Str):
self._url = value

@property
def signature_verification_enabled(self) -> Bool:
"""Is the GPG key verification enabled?"""
return self._signature_verification_enabled

@signature_verification_enabled.setter
def signature_verification_enabled(self, value: Bool):
self._signature_verification_enabled = value
4 changes: 3 additions & 1 deletion pyanaconda/modules/payloads/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
PAYLOAD_TYPE_DNF, PAYLOAD_TYPE_LIVE_OS, PAYLOAD_TYPE_LIVE_IMAGE, \
SOURCE_TYPE_LIVE_OS_IMAGE, SOURCE_TYPE_HMC, SOURCE_TYPE_CDROM, SOURCE_TYPE_REPO_FILES, \
SOURCE_TYPE_NFS, SOURCE_TYPE_URL, SOURCE_TYPE_HDD, SOURCE_TYPE_CDN, \
SOURCE_TYPE_CLOSEST_MIRROR, PAYLOAD_TYPE_RPM_OSTREE, SOURCE_TYPE_RPM_OSTREE, \
SOURCE_TYPE_CLOSEST_MIRROR, PAYLOAD_TYPE_RPM_OSTREE, \
SOURCE_TYPE_RPM_OSTREE, SOURCE_TYPE_RPM_OSTREE_CONTAINER, \
SOURCE_TYPE_LIVE_IMAGE


Expand All @@ -48,6 +49,7 @@ class SourceType(Enum):
LIVE_OS_IMAGE = SOURCE_TYPE_LIVE_OS_IMAGE
LIVE_IMAGE = SOURCE_TYPE_LIVE_IMAGE
RPM_OSTREE = SOURCE_TYPE_RPM_OSTREE
RPM_OSTREE_CONTAINER = SOURCE_TYPE_RPM_OSTREE_CONTAINER
HMC = SOURCE_TYPE_HMC
CDROM = SOURCE_TYPE_CDROM
CLOSEST_MIRROR = SOURCE_TYPE_CLOSEST_MIRROR
Expand Down
1 change: 1 addition & 0 deletions pyanaconda/modules/payloads/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class PayloadKickstartSpecification(KickstartSpecification):
"hmc": COMMANDS.Hmc,
"liveimg": COMMANDS.Liveimg,
"nfs": COMMANDS.NFS,
"ostreecontainer": COMMANDS.OSTreeContainer,
"ostreesetup": COMMANDS.OSTreeSetup,
"url": COMMANDS.Url
}
Expand Down
3 changes: 2 additions & 1 deletion pyanaconda/modules/payloads/source/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

SUBDIRS = live_os hmc cdrom repo_files nfs url harddrive cdn closest_mirror rpm_ostree live_image
SUBDIRS = live_os hmc cdrom repo_files nfs url harddrive cdn closest_mirror rpm_ostree \
rpm_ostree_container live_image

pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
payload_moduledir = $(pkgpyexecdir)/modules/payloads/source
Expand Down
4 changes: 4 additions & 0 deletions pyanaconda/modules/payloads/source/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def create_source(source_type: SourceType):
from pyanaconda.modules.payloads.source.rpm_ostree.rpm_ostree import \
RPMOSTreeSourceModule
return RPMOSTreeSourceModule()
elif source_type == SourceType.RPM_OSTREE_CONTAINER:
from pyanaconda.modules.payloads.source.rpm_ostree_container.rpm_ostree_container import \
RPMOSTreeContainerSourceModule
return RPMOSTreeContainerSourceModule()

raise ValueError("Unknown source type: {}".format(source_type))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def setup_kickstart(self, data):
data.ostreesetup.url = self.configuration.url
data.ostreesetup.ref = self.configuration.ref
data.ostreesetup.nogpg = not self.configuration.gpg_verification_enabled
data.ostreesetup.seen = True

def set_up_with_tasks(self):
"""Set up the installation source for installation.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
payload_moduledir = $(pkgpyexecdir)/modules/payloads/source/rpm_ostree_container
payload_module_PYTHON = $(srcdir)/*.py

MAINTAINERCLEANFILES = Makefile.in

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#
# The RPM OSTree source module.
#
# Copyright (C) 2024 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.core.i18n import _
from pyanaconda.modules.common.structures.rpm_ostree import RPMOSTreeContainerConfigurationData
from pyanaconda.modules.payloads.constants import SourceType
from pyanaconda.modules.payloads.source.rpm_ostree.rpm_ostree import \
RPMOSTreeSourceModule
from pyanaconda.modules.payloads.source.rpm_ostree_container.rpm_ostree_container_interface import \
RPMOSTreeContainerSourceInterface

log = get_module_logger(__name__)

__all__ = ["RPMOSTreeContainerSourceModule"]


class RPMOSTreeContainerSourceModule(RPMOSTreeSourceModule):
"""The RPM OSTree from container source module."""

def __init__(self):
super().__init__()
self._configuration = RPMOSTreeContainerConfigurationData()

@property
def type(self):
"""Get type of this source."""
return SourceType.RPM_OSTREE_CONTAINER

@property
def description(self):
"""Get description of this source."""
return _("RPM OSTree Container")

def for_publication(self):
"""Return a DBus representation."""
return RPMOSTreeContainerSourceInterface(self)

@property
def network_required(self):
"""Does the source require a network?
:return: True or False
"""
# FIXME: Missing network detection logic based on the URL
return False

def process_kickstart(self, data):
"""Process the kickstart data."""
configuration = RPMOSTreeContainerConfigurationData()

configuration.stateroot = data.ostreecontainer.stateroot
configuration.url = data.ostreecontainer.url
configuration.remote = data.ostreecontainer.remote
configuration.transport = data.ostreecontainer.transport
configuration.signature_verification_enabled = not data.ostreecontainer.noSignatureVerification

self.set_configuration(configuration)

def setup_kickstart(self, data):
"""Setup the kickstart data."""
data.ostreecontainer.stateroot = self.configuration.stateroot
data.ostreecontainer.remote = self.configuration.remote
data.ostreecontainer.transport = self.configuration.transport
data.ostreecontainer.url = self.configuration.url
data.ostreecontainer.noSignatureVerification = not self.configuration.signature_verification_enabled
data.ostreecontainer.seen = True

def __repr__(self):
"""Return a string representation of the source."""
return "Source(type='{}', stateroot='{}', transport='{}', url='{}')".format(
self.type.value,
self.configuration.stateroot,
self.configuration.transport,
self.configuration.url
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# DBus interface for the RPM OSTree source module.
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from dasbus.server.property import emits_properties_changed
from dasbus.typing import * # pylint: disable=wildcard-import
from dasbus.server.interface import dbus_interface
from pyanaconda.modules.common.constants.interfaces import PAYLOAD_SOURCE_RPM_OSTREE_CONTAINER
from pyanaconda.modules.common.structures.rpm_ostree import RPMOSTreeContainerConfigurationData
from pyanaconda.modules.payloads.source.source_base_interface import PayloadSourceBaseInterface

__all__ = ["RPMOSTreeContainerSourceInterface"]


@dbus_interface(PAYLOAD_SOURCE_RPM_OSTREE_CONTAINER.interface_name)
class RPMOSTreeContainerSourceInterface(PayloadSourceBaseInterface):
"""DBus interface for the RPM OSTree source module."""

def connect_signals(self):
"""Connect the signals."""
super().connect_signals()
self.watch_property("Configuration", self.implementation.configuration_changed)

@property
def Configuration(self) -> Structure:
"""The source configuration.
:return: a structure of the type RPMOSTreeConfigurationData
"""
return RPMOSTreeContainerConfigurationData.to_structure(
self.implementation.configuration
)

@emits_properties_changed
def SetConfiguration(self, data: Structure):
"""Set the source configuration.
:param data: a structure of the type RPMOSTreeConfigurationData
"""
self.implementation.set_configuration(
RPMOSTreeContainerConfigurationData.from_structure(data)
)
Loading

0 comments on commit 617bccb

Please sign in to comment.