File uyuni-cobbler-helper-git-0.a6c43c5.obscpio of Package uyuni-cobbler-helper
07070100000000000041FD00000000000000000000000268F1FCA100000000000000000000000000000000000000000000001500000000uyuni-cobbler-helper07070100000001000081B400000000000000000000000168F1FCA100000041000000000000000000000000000000000000003200000000uyuni-cobbler-helper/uyuni-cobbler-helper.changes- Add helper function getting channels from a distribution tree
07070100000002000081B400000000000000000000000168F1FCA10000003B000000000000000000000000000000000000004400000000uyuni-cobbler-helper/uyuni-cobbler-helper.changes.cbosdo.ca-snippet- Add snippet helper reading the SSL root CA (bsc#1194792)
07070100000003000081B400000000000000000000000168F1FCA1000007A5000000000000000000000000000000000000002F00000000uyuni-cobbler-helper/uyuni-cobbler-helper.spec#
# spec file for package uyuni-cobbler-helper
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
## The productprettyname macros is controlled in the prjconf. If not defined, we fallback here
%{!?productprettyname: %global productprettyname Uyuni}
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: uyuni-cobbler-helper
Version: 5.2.0
Release: 0
Summary: Python helper functions for %{productprettyname} Cobbler snippets
License: Apache-2.0
Group: System/Management
URL: https://github.com/uyuni-project/uyuni
#!CreateArchive: %{name}
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
BuildRequires: python-rpm-macros
BuildRequires: %{python_module base}
Requires: python
Requires: python-psycopg2 >= 2.8.4
Provides: uyuni-cobbler-helper
%python_subpackages
%description
This package provides utility functions to expose %{productprettyname} data to Cobbler snippets.
%prep
%autosetup
%build
%install
%{python_expand # expanded-body:
install -d %{buildroot}%{$python_sitelib}
install -m 644 uyuni_cobbler_helper.py %{buildroot}%{$python_sitelib}/uyuni_cobbler_helper.py
}
%files %{python_files}
%{python_sitelib}/uyuni_cobbler_helper.py
%changelog
07070100000004000081B400000000000000000000000168F1FCA100000563000000000000000000000000000000000000002D00000000uyuni-cobbler-helper/uyuni_cobbler_helper.py"""
cobbler helper module for kickstart macros
"""
import psycopg2
import configparser
def channels(distrotree):
cnx = _connect_db()
cursor = cnx.cursor()
query = """SELECT CT.name, CT.label, CP.product
FROM rhnkickstartabletree T,
rhnchanneltreeview CT,
rhnchannel C
LEFT JOIN rhnchannelproduct CP ON C.channel_product_id = CP.id
WHERE T.channel_id = CT.parent_or_self_id
AND CT.id = C.id
AND T.label = %s;"""
cursor.execute(query, (distrotree,))
result = {}
for name, label, product in cursor.fetchall():
result[label] = {"name": name, "product": product}
cnx.close()
return result
def _connect_db():
config = configparser.ConfigParser()
with open("/etc/rhn/rhn.conf", "r", encoding="utf-8") as fd:
content = "[default]\n" + fd.read()
config.read_string(content)
# pylint: disable-next=undefined-variable
return psycopg2.connect(
host=config.get("default", "db_host"),
user=config.get("default", "db_user"),
password=config.get("default", "db_password"),
dbname=config.get("default", "db_name"),
port=int(config.get("default", "db_port")),
)
def get_ssl_ca_cert():
with open(
"/etc/pki/trust/anchors/LOCAL-RHN-ORG-TRUSTED-SSL-CERT", "r", encoding="utf-8"
) as fd:
content = fd.read()
return content
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!