Created
February 3, 2020 11:59
-
-
Save bmbouter/4c3cae55e67c3229ba07e3089128d8ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import path | |
import pdb | |
import subprocess | |
import tempfile | |
from pulpcore.client.pulp_ansible import ( | |
DistributionsAnsibleApi, | |
RepositoriesAnsibleApi, | |
RepositorySyncURL, | |
RemotesCollectionApi, | |
) | |
from pulp_smash.pulp3.utils import gen_distribution, gen_repo | |
from pulp_ansible.tests.functional.constants import ( | |
ANSIBLE_COLLECTION_TESTING_URL_V2, | |
COLLECTION_WHITELIST, | |
) | |
from pulp_ansible.tests.functional.utils import ( | |
gen_ansible_client, | |
gen_ansible_remote, | |
monitor_task, | |
) | |
client = gen_ansible_client() | |
repo_api = RepositoriesAnsibleApi(client) | |
remote_collection_api = RemotesCollectionApi(client) | |
distributions_api = DistributionsAnsibleApi(client) | |
repo = repo_api.create(gen_repo()) | |
pdb.set_trace() | |
# Create a distribution. | |
body = gen_distribution() | |
body["repository"] = repo.pulp_href | |
distribution_create = distributions_api.create(body) | |
distribution_url = monitor_task(distribution_create.task) | |
distribution = distributions_api.read(distribution_url[0]) | |
pdb.set_trace() | |
body = gen_ansible_remote(url=ANSIBLE_COLLECTION_TESTING_URL_V2) | |
remote = remote_collection_api.create(body) | |
pdb.set_trace() | |
# Sync the repository. | |
repository_sync_data = RepositorySyncURL(remote=remote.pulp_href) | |
sync_response = repo_api.sync(repo.pulp_href, repository_sync_data) | |
monitor_task(sync_response.task) | |
repo = repo_api.read(repo.pulp_href) | |
with tempfile.TemporaryDirectory() as temp_dir: | |
cmd = "ansible-galaxy collection install {} -c -s {} -p {}".format( | |
COLLECTION_WHITELIST, distribution.client_url, temp_dir | |
) | |
print(cmd) | |
directory = "{}/ansible_collections/{}".format( | |
temp_dir, COLLECTION_WHITELIST.replace(".", "/") | |
) | |
pdb.set_trace() | |
subprocess.run(cmd.split()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment