# Promote all content views to 'DEV' lifecycle for cvname in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv content-view list --organization="${ORG}" | cut -d ',' -f 2 | grep -vi '^Name' | grep -vi '^Default' |sort); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view version promote --id=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" content-view info --name="${cvname}" --organization="${ORG}" | grep '^Versions:' -A10 | grep '1)' | cut -d ':' -f2 | sed -e 's/^[ \t]*//') --content-view="${cvname}" --organization="${ORG}" --to-lifecycle-environment='DEV' --async; done # Create Host Collections for version in 5 6 7; do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" host-collection create --name="RHEL ${version}" --organization="${ORG}"; done # Create Activation Keys for each OS x Arch combination ## "ak-${name%-cv}" takes the content view name (eg. rhel-7-scientific-x86_64-cv) and lops off the '-cv' part for name in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv content-view list --organization="${ORG}" | cut -d ',' -f 2 | grep -vi '^Name' | grep -vi '^Default' |sort); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" activation-key create --name="ak-${name%-cv}" --organization="${ORG}" --content-view="${name}" --lifecycle-environment="DEV"; done # Add host collection to corresponding Activation Key ## ${name:8:1} takes the activationkey name (eg. ak-rhel-7-scientific-x86_64) and slice the 8th character (i.e '7') for name in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv activation-key list --organization="${ORG}" | cut -d ',' -f2 | grep -vi '^Name'); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" activation-key add-host-collection --name="${name}" --host-collection="RHEL ${name:8:1}" --organization="${ORG}"; done # Add all available subscriptions to all Activation Keys ## Use the Employee SKU EMPLOYEE_SKU=$(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv subscription list --organization="${ORG}" | grep 'Employee SKU' | cut -d ',' -f 8) for id in $(hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" --csv activation-key list --organization="${ORG}" | cut -d ',' -f1 | grep -vi '^id'); do hammer -u "${ADMIN_USER}" -p "${ADMIN_PASSWORD}" activation-key add-subscription --id="${id}" --organization="${ORG}" --subscription-id="${EMPLOYEE_SKU}"; done