Skip to content

Commit

Permalink
change the arch filter to use the channel_arch value instead
Browse files Browse the repository at this point in the history
  • Loading branch information
waterflow80 committed Jul 15, 2024
1 parent 49aee7c commit 209696e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
10 changes: 5 additions & 5 deletions python/lzreposync/src/lzreposync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def main():

parser.add_argument(
"--channel",
help="The channel id of which you want to synchronize repositories",
help="The channel label of which you want to synchronize repositories",
dest="channel",
type=int,
type=str,
default=None,
)

Expand All @@ -113,12 +113,12 @@ def main():
else:
# No url specified
if args.channel:
channel_id = args.channel
target_repos = db_utils.get_repositories_by_channel_id(channel_id)
channel_label = args.channel
target_repos = db_utils.get_repositories_by_channel_label(channel_label)
for repo in target_repos:
if repo.repo_type == "yum":
rpm_repository = RPMRepo(
repo.repo_label, args.cache, repo.source_url, arch
repo.repo_label, args.cache, repo.source_url, repo.channel_arch
)
logging.debug("Importing package for repo %s", repo.repo_label)
failed = import_repository_package_batches(
Expand Down
19 changes: 12 additions & 7 deletions python/lzreposync/src/lzreposync/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@
from spacewalk.server import rhnSQL


def get_repositories_by_channel_id(channel_id):
def get_repositories_by_channel_label(channel_label):
"""
Fetch repositories information form the database, and return a list of
Fetch repositories information of a given channel form the database, and return a list of
RepoDTO objects
"""
rhnSQL.initDB()
h = rhnSQL.prepare(
"""
select s.id, s.source_url, s.metadata_signed, s.label as repo_label, cst.label as repo_type_label
from rhnContentSource s,
select s.id, c_ark.name as channel_arch, s.source_url, s.metadata_signed, s.label as repo_label, cst.label as repo_type_label
from rhnChannel c,
rhnChannelArch c_ark,
rhnContentSource s,
rhnChannelContentSource cs,
rhnContentSourceType cst
where s.id = cs.source_id
where c.label = :channel_label
and c.channel_arch_id = c_ark.id
and s.id = cs.source_id
and cst.id = s.type_id
and cs.channel_id = :channel_id"""
and cs.channel_id = c.id"""
)
h.execute(channel_id=int(channel_id))
h.execute(channel_label=channel_label)
sources = h.fetchall_dict()
repositories = map(
lambda source: RepoDTO(
repo_id=source["id"],
channel_arch=source["channel_arch"],
repo_label=source["repo_label"],
repo_type=source["repo_type_label"],
source_url=source["source_url"],
Expand Down
3 changes: 2 additions & 1 deletion python/lzreposync/src/lzreposync/repo_dto.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# pylint: disable=missing-module-docstring

class RepoDTO:
def __init__(self, repo_id, repo_label, repo_type, source_url, metadata_signed="N"):
def __init__(self, repo_id, channel_arch, repo_label, repo_type, source_url, metadata_signed="N"):
self.repo_id = repo_id
self.channel_arch = channel_arch
self.repo_label = repo_label
self.repo_type = repo_type
self.source_url = source_url
Expand Down

0 comments on commit 209696e

Please sign in to comment.