Skip to content
Permalink
Browse files

Updating Galaxy API code to work with content changes

Updated the galaxy api code to work on changes to the content app. Also,
fixing the instructions.

fixes #4576
https://pulp.plan.io/issues/4576
  • Loading branch information...
daviddavis committed Apr 4, 2019
1 parent 2fc17eb commit 11c66dfabb2c17d222b8389fbd39f1d12299f25e
Showing with 7 additions and 8 deletions.
  1. +3 −3 README.rst
  2. +4 −5 pulp_ansible/app/galaxy/serializers.py
@@ -222,7 +222,7 @@ Using a direct path

To install your role using a link to the direct tarball, do the following:

``$ ansible-galaxy install http://localhost:8000/pulp/content/dev/elastic/elasticsearch/6.2.4.tar.gz,,elastic.elasticsearch``
``$ ansible-galaxy install http://localhost:8080/pulp/content/dev/elastic/elasticsearch/6.2.4.tar.gz,,elastic.elasticsearch``


Using the Pulp Galaxy API
@@ -240,9 +240,9 @@ Then install your role using namespace and name:

.. code::

$ ansible-galaxy install elastic.elasticsearch
$ ansible-galaxy install elastic.elasticsearch,6.2.4
- downloading role 'elasticsearch', owned by elastic
- downloading role from http://localhost:8000/pulp/content/dev/elastic/elasticsearch/6.2.4.tar.gz
- downloading role from http://localhost:8080/pulp/content/dev/elastic/elasticsearch/6.2.4.tar.gz
- extracting elastic.elasticsearch to /home/vagrant/.ansible/roles/elastic.elasticsearch
- elastic.elasticsearch (6.2.4) was installed successfully

@@ -1,6 +1,5 @@
from django.conf import settings
from rest_framework import serializers
from rest_framework.reverse import reverse

from pulp_ansible.app.models import AnsibleRole, AnsibleRoleVersion

@@ -12,7 +11,7 @@ class GalaxyAnsibleRoleSerializer(serializers.ModelSerializer):

name = serializers.CharField()
namespace = serializers.CharField()
id = serializers.UUIDField()
id = serializers.UUIDField(source="_id")

class Meta:
fields = ('id', 'name', 'namespace')
@@ -32,14 +31,14 @@ def get_source(self, obj):
"""
Get source.
"""
if settings.CONTENT['HOST']:
host = settings.CONTENT['HOST']
if settings.CONTENT_HOST:
host = settings.CONTENT_HOST
else:
host = self.context['request'].get_host()
host = "{}://{}".format(self.context['request'].scheme, host)

distro_base = self.context['request'].parser_context['kwargs']['path']
distro_path = ''.join([host, reverse('content-app'), distro_base])
distro_path = ''.join([host, settings.CONTENT_PATH_PREFIX, distro_base])

return ''.join([distro_path, '/', obj.relative_path])

0 comments on commit 11c66df

Please sign in to comment.
You can’t perform that action at this time.