Skip to content

Instantly share code, notes, and snippets.

@parthaa
Created October 19, 2020 19:54
Show Gist options
  • Save parthaa/f877c1088d66d92e87ab8b9194f8291c to your computer and use it in GitHub Desktop.
Save parthaa/f877c1088d66d92e87ab8b9194f8291c to your computer and use it in GitHub Desktop.
export script
#!/bin/bash
shopt -s expand_aliases
set -e
set -x
EXPORT_ORG="export-$RANDOM"
PRODUCT="prod"
REPO1="katello"
REPO1_URL="https://fedorapeople.org/groups/katello/releases/yum/3.8/katello/el7/x86_64/"
REPO2="misc"
REPO2_URL="https://partha.fedorapeople.org/test-repos/pteradactly-with-dino-errata/"
CONTENT_VIEW="view"
# create import export orgs
hammer organization create --name=$EXPORT_ORG
#create the products in both import and export orgs
hammer product create --name=$PRODUCT --organization=$EXPORT_ORG
#create and sync repositories in export org
hammer repository create --content-type=yum --product=$PRODUCT --name=$REPO1 --url=$REPO1_URL --organization=$EXPORT_ORG
hammer repository create --content-type=yum --product=$PRODUCT --name=$REPO2 --url=$REPO2_URL --organization=$EXPORT_ORG
hammer repository synchronize --product=$PRODUCT --name=$REPO1 --organization=$EXPORT_ORG
hammer repository synchronize --product=$PRODUCT --name=$REPO2 --organization=$EXPORT_ORG
# create content view in EXPORT_ORG
hammer content-view create --name=$CONTENT_VIEW --organization=$EXPORT_ORG
hammer content-view add-repository --name=$CONTENT_VIEW --repository=$REPO1 --product=$PRODUCT --organization=$EXPORT_ORG
hammer content-view add-repository --name=$CONTENT_VIEW --repository=$REPO2 --product=$PRODUCT --organization=$EXPORT_ORG
hammer content-view publish --name=$CONTENT_VIEW --organization=$EXPORT_ORG
curl -X POST -s -k -u admin:changeme "http://$(hostname -f):3000/katello/api/content_view_versions/3/export" -d '{"destination_server": "downstream.example.com"}' -H "Content-Type: application/json" | jq
curl -X GET -s -k -u admin:changeme "http://$(hostname -f):3000/katello/api/content_view_versions/export_histories" | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment