Skip to content

Commit

Permalink
Fix comps group attrs missing from publish of centos7 remote
Browse files Browse the repository at this point in the history
Output lacked desc_by_lang, name_by_lang, and default, now corrected.

closes #5741
https://pulp.plan.io/issues/5741
  • Loading branch information
CodeHeeler committed Dec 9, 2019
1 parent 744ae4b commit a404dcb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES/5741.bugfix
@@ -0,0 +1 @@
Fix comps.xml publish: missing group attributes desc_by_lang, name_by_lang, and default now appear properly.
17 changes: 17 additions & 0 deletions pulp_rpm/app/comps.py
Expand Up @@ -41,6 +41,23 @@ def strdict_to_dict(value):
return lang_dict


def dict_to_strdict(value):
"""
Convert standard dict object to libcomps StrDict type object.
Args:
value: a dict
Returns:
strdict: a libcomps StrDict
"""
strdict = libcomps.StrDict()
for i, j in value.items():
strdict[i] = j
return strdict


def dict_digest(dict):
"""
Calculate a hexdigest for a given dictionary.
Expand Down
14 changes: 7 additions & 7 deletions pulp_rpm/app/models/comps.py
Expand Up @@ -17,7 +17,7 @@
PULP_LANGPACKS_ATTRS,
)

from pulp_rpm.app.comps import strdict_to_dict, list_to_idlist
from pulp_rpm.app.comps import dict_to_strdict, list_to_idlist, strdict_to_dict
from pulp_rpm.app.models.package import Package

log = getLogger(__name__)
Expand Down Expand Up @@ -188,8 +188,8 @@ def pkg_grp_to_libcomps(self):
group.desc = getattr(self, PULP_GROUP_ATTRS.DESCRIPTION)
group.packages = self.list_to_pkglist(getattr(self, PULP_GROUP_ATTRS.PACKAGES))
group.biarchonly = getattr(self, PULP_GROUP_ATTRS.BIARCH_ONLY)
group.desc_by_lang = libcomps.StrDict(**getattr(self, PULP_GROUP_ATTRS.DESC_BY_LANG))
group.name_by_lang = libcomps.StrDict(**getattr(self, PULP_GROUP_ATTRS.NAME_BY_LANG))
group.desc_by_lang = dict_to_strdict(getattr(self, PULP_GROUP_ATTRS.DESC_BY_LANG))
group.name_by_lang = dict_to_strdict(getattr(self, PULP_GROUP_ATTRS.NAME_BY_LANG))

return group

Expand Down Expand Up @@ -316,8 +316,8 @@ def pkg_cat_to_libcomps(self):
cat.desc = getattr(self, PULP_CATEGORY_ATTRS.DESCRIPTION)
cat.display_order = getattr(self, PULP_CATEGORY_ATTRS.DISPLAY_ORDER)
cat.group_ids = list_to_idlist(getattr(self, PULP_CATEGORY_ATTRS.GROUP_IDS))
cat.desc_by_lang = libcomps.StrDict(**getattr(self, PULP_CATEGORY_ATTRS.DESC_BY_LANG))
cat.name_by_lang = libcomps.StrDict(**getattr(self, PULP_CATEGORY_ATTRS.NAME_BY_LANG))
cat.desc_by_lang = dict_to_strdict(getattr(self, PULP_CATEGORY_ATTRS.DESC_BY_LANG))
cat.name_by_lang = dict_to_strdict(getattr(self, PULP_CATEGORY_ATTRS.NAME_BY_LANG))

return cat

Expand Down Expand Up @@ -455,8 +455,8 @@ def pkg_env_to_libcomps(self):
env.display_order = getattr(self, PULP_ENVIRONMENT_ATTRS.DISPLAY_ORDER)
env.group_ids = list_to_idlist(getattr(self, PULP_ENVIRONMENT_ATTRS.GROUP_IDS))
env.option_ids = list_to_idlist(getattr(self, PULP_ENVIRONMENT_ATTRS.OPTION_IDS))
env.desc_by_lang = libcomps.StrDict(**getattr(self, PULP_ENVIRONMENT_ATTRS.DESC_BY_LANG))
env.name_by_lang = libcomps.StrDict(**getattr(self, PULP_ENVIRONMENT_ATTRS.NAME_BY_LANG))
env.desc_by_lang = dict_to_strdict(getattr(self, PULP_ENVIRONMENT_ATTRS.DESC_BY_LANG))
env.name_by_lang = dict_to_strdict(getattr(self, PULP_ENVIRONMENT_ATTRS.NAME_BY_LANG))

return env

Expand Down
7 changes: 5 additions & 2 deletions pulp_rpm/app/tasks/publishing.py
Expand Up @@ -17,6 +17,7 @@

from pulpcore.plugin.tasking import WorkingDirectory

from pulp_rpm.app.comps import dict_to_strdict
from pulp_rpm.app.models import (
DistributionTree,
Modulemd,
Expand Down Expand Up @@ -288,10 +289,12 @@ def create_repomd_xml(content, publication, extra_repomdrecords, sub_folder=None
comps.environments.append(env)
has_comps = True
for pkg_lng in PackageLangpacks.objects.filter(pk__in=content).iterator():
comps.langpacks = libcomps.StrDict(**pkg_lng.matches)
comps.langpacks = dict_to_strdict(pkg_lng.matches)
has_comps = True

comps.toxml_f(comps_xml_path)
comps.toxml_f(comps_xml_path, xml_options={"default_explicit": True,
"empty_groups": True,
"uservisible_explicit": True})

pri_xml.close()
fil_xml.close()
Expand Down

0 comments on commit a404dcb

Please sign in to comment.