Last active
January 17, 2023 11:32
-
-
Save sayan3296/5642a55407e97c1cc4ff3b5552ac3520 to your computer and use it in GitHub Desktop.
To create problems during pulp2 to pulp3 migration
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
#!/bin/bash | |
# | |
## Assuming satellite 6.9 is installed with organization name RedHat and a manifest with valid rhel sub has been imported. | |
## No repositories are enabled at this stage. | |
## Setup the basic environment | |
hammer subscription refresh-manifest --organization RedHat | |
hammer repository-set disable --name "Red Hat Enterprise Linux 7 Server (RPMs)" --product "Red Hat Enterprise Linux Server" --basearch x86_64 --releasever 7Server --organization RedHat | |
hammer repository-set disable --name "Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)" --product "Red Hat Enterprise Linux for x86_64" --releasever 8 --organization RedHat | |
hammer repository-set disable --name "Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)" --product "Red Hat Enterprise Linux for x86_64" --releasever 8 --organization RedHat | |
hammer repository-set disable --name "Red Hat Satellite Tools 6.9 for RHEL 8 x86_64 (RPMs)" --product "Red Hat Enterprise Linux for x86_64" --organization RedHat | |
## | |
hammer repository-set enable --name "Red Hat Satellite Tools 6.9 (for RHEL 7 Server) (RPMs)" --product "Red Hat Enterprise Linux Server" --basearch x86_64 --releasever 7Server --organization RedHat | |
hammer repository-set enable --name "Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server" --product "Red Hat Ansible Engine" --basearch x86_64 --organization RedHat | |
hammer repository update --name "Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server x86_64" --product "Red Hat Ansible Engine" --organization RedHat --download-policy immediate | |
hammer repository synchronize --name "Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server x86_64" --product "Red Hat Ansible Engine" --organization RedHat | |
hammer repository synchronize --name "Red Hat Satellite Tools 6.9 for RHEL 7 Server RPMs x86_64" --product "Red Hat Enterprise Linux Server" --organization RedHat | |
REPO_IDS=$(hammer --no-headers repository list --organization RedHat --fields Id | xargs | tr " " ",") | |
hammer content-view create --name TestCV --organization RedHat --repository-ids $REPO_IDS | |
hammer content-view publish --name TestCV --organization RedHat | |
## Now break the environment | |
## Delete\corrupt some immediate content | |
find /var/lib/pulp/content/units/rpm/ -name "ansible-test*.rpm" -type f -exec rm -f {} \; | |
ANSIBLE_RPM=$(find /var/lib/pulp/content/units/rpm/ -name "ansible-2.9.0-2.el7.noarch.rpm" -type f) | |
echo --- > $ANSIBLE_RPM | |
unset ANSIBLE_RPM | |
## Remove lazy content catalogue entry for some on_demand rpms. | |
echo "COPY(select pulp_id,filename from katello_rpms) TO STDOUT WITH CSV;" | su - postgres -c "psql foreman" | egrep "katello-agent|gofer|katello-host-tools" > /tmp/rpm_to_break | |
for i in `cat /tmp/rpm_to_break | cut -d, -f1 | xargs`; do mongo pulp_database --eval "DBQuery.shellBatchSize = 10000000; db.lazy_content_catalog.remove({'unit_id':'$i'})"; done | |
rm -f /tmp/rpm_to_break | |
## Reproduce this issue: https://access.redhat.com/solutions/6898881 | |
foreman-rake console <<< cat << EOF | |
conf.echo = false | |
cv = Katello::ContentView.find_by(:name => 'TestCV') | |
cv.versions.each do |cvv| | |
ForemanTasks.async_task(::Actions::BulkAction, ::Actions::Katello::Repository::Destroy, cvv.archived_repos) | |
end | |
EOF | |
## Reproduce this issue: https://access.redhat.com/solutions/6549711 | |
su - postgres -c "psql foreman -c \"COPY(select root.name,main.pulp_id from katello_root_repositories root left JOIN katello_repositories main on main.root_id=root.id where main.library_instance_id is not null and root.name like '%Ansible%') TO STDOUT WITH CSV;\"" > /tmp/repo_to_break | |
for i in `cat /tmp/repo_to_break | cut -d, -f2 | xargs`; do mongo pulp_database --eval "DBQuery.shellBatchSize = 10000000; db.repo_importers.remove({'repo_id':'$i'})"; done | |
rm -f /tmp/rpm_to_break | |
rm -f /tmp/repo_to_break | |
## Now once the satrellite is broken , ask user to perform the migration and troubleshoot accordingly | |
satellite-maintain prep-6.10-upgrade | |
satellite-maintain content prepare | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Validation script: