Skip to content

Commit

Permalink
adding mazer_url to AnsibleDistribution
Browse files Browse the repository at this point in the history
closes #4970
  • Loading branch information
fao89 committed Jul 31, 2019
1 parent e90b634 commit 3c065bc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES/4970.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adding mazer_url to AnsibleDistribution
1 change: 1 addition & 0 deletions CHANGES/4996.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Validating collection remote URL
1 change: 1 addition & 0 deletions CHANGES/5167.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mirror ansible collection
24 changes: 23 additions & 1 deletion pulp_ansible/app/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from gettext import gettext as _

from django.conf import settings
from rest_framework import serializers

from pulpcore.plugin.serializers import (
Expand Down Expand Up @@ -111,8 +112,29 @@ class AnsibleDistributionSerializer(RepositoryVersionDistributionSerializer):
Serializer for Ansible Distributions.
"""

mazer_url = serializers.SerializerMethodField(
read_only=True, help_text=_("The URL of a mazer content source.")
)

def get_mazer_url(self, obj):
"""
Get mazer_url.
"""
return "{hostname}/pulp_ansible/galaxy/{base_path}".format(
hostname=settings.ANSIBLE_API_HOSTNAME, base_path=obj.base_path
)

class Meta:
fields = RepositoryVersionDistributionSerializer.Meta.fields
fields = (
"_href",
"_created",
"base_path",
"content_guard",
"name",
"repository",
"repository_version",
"mazer_url",
)
model = AnsibleDistribution


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# coding=utf-8
"""Tests that content hosted by Pulp can be consumed by mazer."""
import unittest
from functools import reduce
from urllib.parse import urljoin

from pulp_smash import api, cli, config, exceptions
from pulp_smash.pulp3.constants import REPO_PATH
Expand Down Expand Up @@ -52,12 +50,10 @@ def test_consume_content(self):
)
self.addCleanup(self.client.delete, distribution["_href"])

galaxy_url = reduce(
urljoin, (self.cfg.get_base_url(), "/pulp_ansible/galaxy/", distribution["base_path"])
)

self.cli_client.run(
"mazer install {} -c -s {}".format(COLLECTION_WHITELIST, galaxy_url).split()
"mazer install {} -c -s {}".format(
COLLECTION_WHITELIST, distribution["mazer_url"]
).split()
)
self.addCleanup(self.cli_client.run, "mazer remove {}".format(COLLECTION_WHITELIST).split())

Expand Down

0 comments on commit 3c065bc

Please sign in to comment.