Created
February 2, 2017 22:08
-
-
Save chrishultin/b1072b6b300bac6a7a8791bf49fb2c2e 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
function venv_create { | |
VENV_PATH="$1" | |
VENV_FILE="$2" | |
# If the venv working directory already exists remove it | |
[[ -d "/tmp/${VENV_PATH}" ]] && rm -rf "/tmp/${VENV_PATH}" | |
# If the pip build directory already exists remove it | |
[[ -d "/tmp/${VENV_FILE}" ]] && rm -rf "/tmp/${VENV_FILE}" | |
# Create the virtualenv shell | |
/usr/local/bin/virtualenv --always-copy --extra-search-dir /var/www/repo/os-releases/r13.1.0rc1 --never-download "${VENV_PATH}" | |
# Create the pip build directory | |
mkdir -p "/tmp/${VENV_FILE}" | |
# Activate the python virtual environment for good measure | |
source "${VENV_PATH}/bin/activate" | |
# Run the pip install within the venv and specify a specific build directory which | |
# resolves pip locking issues when run in parallel. | |
${VENV_PATH}/bin/pip install --build "/tmp/${VENV_FILE}" --timeout 120 --find-links /var/www/repo/os-releases/r13.1.0rc1 --no-index --log /var/log/repo/repo_venv_builder.log $3 | |
# Deactivate the venv for good measure | |
deactivate | |
# Find and remove all of the python pyc files | |
find "${VENV_PATH}" -type f -name '*.pyc' -delete | |
# Create the archive | |
tar czf "${VENV_FILE}.tgz" -C "${VENV_PATH}" . | |
# Create a checksum file for the archive | |
sha1sum "${VENV_FILE}.tgz" | awk '{print $1}' > "${VENV_FILE}.checksum" | |
# Remove the working directories | |
rm -rf "${VENV_PATH}" | |
rm -rf "/tmp/${VENV_FILE}" | |
} | |
# First operation is to sort and set the known os_* roles and create a unique dict. | |
# NOTE: this is a Jinja loop and will not be rendered within the script. For debugging | |
# purposes the group data will be rendered as a comment. | |
# venv to build os_magnum | |
# * packages within the os_magnum venv: [u'magnum', u'mysql-python', u'pymysql', u'python-memcached'] | |
# venv to build os_glance | |
# * packages within the os_glance venv: [u'glance', u'keystonemiddleware', u'os-brick', u'pycrypto', u'pymysql', u'python-cinderclient', u'python-glanceclient', u'python-keystoneclient', u'python-memcached', u'python-swiftclient', u'warlock'] | |
# venv to build os_heat | |
# * packages within the os_heat venv: [u'heat', u'keystonemiddleware', u'pycrypto', u'pymysql', u'python-ceilometerclient', u'python-cinderclient', u'python-glanceclient', u'python-heatclient', u'python-keystoneclient', u'python-memcached', u'python-neutronclient', u'python-novaclient', u'python-openstackclient', u'python-swiftclient', u'python-troveclient'] | |
# venv to build os_neutron | |
# * packages within the os_neutron venv: [u'cliff', u'configobj', u'keystonemiddleware', u'neutron', u'pycrypto', u'pymysql', u'python-glanceclient', u'python-keystoneclient', u'python-memcached', u'python-neutronclient', u'python-novaclient', u'repoze.lru'] | |
# venv to build os_cinder | |
# * packages within the os_cinder venv: [u'cinder', u'ecdsa', u'httplib2', u'keystonemiddleware', u'pycrypto', u'pymysql', u'python-cinderclient', u'python-keystoneclient', u'python-memcached'] | |
# venv to build os_tempest | |
# * packages within the os_tempest venv: [u'junitxml', u'nose', u'python-ceilometerclient', u'python-cinderclient', u'python-glanceclient', u'python-heatclient', u'python-keystoneclient', u'python-memcached', u'python-neutronclient', u'python-novaclient', u'python-openstackclient', u'python-saharaclient', u'python-subunit', u'python-swiftclient', u'tempest'] | |
# venv to build os_keystone | |
# * packages within the os_keystone venv: [u'argparse', u'keystone', u'keystonemiddleware', u'ldappool', u'lxml', u'oslo.log', u'oslo.middleware', u'pbr', u'pycrypto', u'pymysql', u'pysaml2', u'python-keystoneclient', u'python-ldap', u'python-memcached', u'python-openstackclient', u'repoze.lru', u'uwsgi'] | |
# venv to build os_rally | |
# * packages within the os_rally venv: [u'pymysql', u'rally', u'setuptools'] | |
# venv to build os_nova | |
# * packages within the os_nova venv: [u'libvirt-python', u'nova-powervm', u'pyasn1-modules', u'keystonemiddleware', u'nova', u'pycrypto', u'pymysql', u'python-keystoneclient', u'python-memcached', u'python-novaclient', u'python-ironicclient', u'websockify', u'nova-lxd', u'pylxd'] | |
# venv to build os_horizon | |
# * packages within the os_horizon venv: [u'django-appconf', u'django-openstack-auth', u'greenlet', u'horizon', u'ironic-ui', u'keystonemiddleware', u'magnum-ui', u'mysql-python', u'neutron-lbaas-dashboard', u'oslo.config', u'ply', u'pycrypto', u'pymysql', u'python-keystoneclient', u'python-memcached', u'sahara_dashboard'] | |
PID=() | |
# Run the venv create. This will loop over all of the os_group role packages and create a python virtual env. | |
# Venv creation is done parallel at a count of the known "ansible_processor_count" or using a default of 5. | |
# This loop will enter the venv build directory and create tagged venvs in a distribution directory | |
# If the venv archive already exists the creation process will be skipped | |
pushd "/var/www/repo/venvs/r13.1.0rc1/ubuntu" | |
/var/www/repo/venvs/r13.1.0rc1/ubuntu /opt | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/heat" | |
ROLE_VENV_FILE="heat-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "heat keystonemiddleware pycrypto pymysql python-ceilometerclient python-cinderclient python-glanceclient python-heatclient python-keystoneclient python-memcached python-neutronclient python-novaclient python-openstackclient python-swiftclient python-troveclient" & | |
pid[1]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/neutron" | |
ROLE_VENV_FILE="neutron-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "cliff configobj keystonemiddleware neutron pycrypto pymysql python-glanceclient python-keystoneclient python-memcached python-neutronclient python-novaclient repoze.lru" & | |
pid[2]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/magnum" | |
ROLE_VENV_FILE="magnum-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "magnum mysql-python pymysql python-memcached" & | |
pid[3]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/cinder" | |
ROLE_VENV_FILE="cinder-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "cinder ecdsa httplib2 keystonemiddleware pycrypto pymysql python-cinderclient python-keystoneclient python-memcached" & | |
pid[4]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/glance" | |
ROLE_VENV_FILE="glance-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "glance keystonemiddleware os-brick pycrypto pymysql python-cinderclient python-glanceclient python-keystoneclient python-memcached python-swiftclient warlock" & | |
pid[5]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/nova" | |
ROLE_VENV_FILE="nova-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "libvirt-python nova-powervm pyasn1-modules keystonemiddleware nova pycrypto pymysql python-keystoneclient python-memcached python-novaclient python-ironicclient websockify nova-lxd pylxd" & | |
pid[6]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/horizon" | |
ROLE_VENV_FILE="horizon-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "django-appconf django-openstack-auth greenlet horizon ironic-ui keystonemiddleware magnum-ui mysql-python neutron-lbaas-dashboard oslo.config ply pycrypto pymysql python-keystoneclient python-memcached sahara_dashboard" & | |
pid[7]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
ROLE_VENV_PATH="/tmp/openstack-venv-builder/venvs/tempest" | |
ROLE_VENV_FILE="tempest-r13.1.0rc1-x86_64" | |
if [ ! -f "${ROLE_VENV_FILE}.tgz" ];then | |
venv_create "${ROLE_VENV_PATH}" "${ROLE_VENV_FILE}" "junitxml nose python-ceilometerclient python-cinderclient python-glanceclient python-heatclient python-keystoneclient python-memcached python-neutronclient python-novaclient python-openstackclient python-saharaclient python-subunit python-swiftclient tempest" & | |
pid[8]=$! | |
fi | |
unset ROLE_VENV_PATH | |
unset ROLE_VENV_FILE | |
for job_pid in ${!pid[@]}; do | |
wait ${pid[$job_pid]} || exit 99 | |
done | |
New python executable in /tmp/openstack-venv-builder/venvs/magnum/bin/python | |
Installing setuptools, pip, wheel...done. | |
# This file must be used with "source bin/activate" *from bash* | |
# you cannot run it directly | |
deactivate () { | |
unset -f pydoc >/dev/null 2>&1 | |
# reset old environment variables | |
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all | |
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then | |
PATH="$_OLD_VIRTUAL_PATH" | |
export PATH | |
unset _OLD_VIRTUAL_PATH | |
fi | |
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then | |
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" | |
export PYTHONHOME | |
unset _OLD_VIRTUAL_PYTHONHOME | |
fi | |
# This should detect bash and zsh, which have a hash command that must | |
# be called to get it to forget past commands. Without forgetting | |
# past commands the $PATH changes we made may not be respected | |
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then | |
hash -r 2>/dev/null | |
fi | |
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then | |
PS1="$_OLD_VIRTUAL_PS1" | |
export PS1 | |
unset _OLD_VIRTUAL_PS1 | |
fi | |
unset VIRTUAL_ENV | |
if [ ! "${1-}" = "nondestructive" ] ; then | |
# Self destruct! | |
unset -f deactivate | |
fi | |
} | |
# unset irrelevant variables | |
deactivate nondestructive | |
VIRTUAL_ENV="/tmp/openstack-venv-builder/venvs/magnum" | |
export VIRTUAL_ENV | |
_OLD_VIRTUAL_PATH="$PATH" | |
PATH="$VIRTUAL_ENV/bin:$PATH" | |
export PATH | |
# unset PYTHONHOME if set | |
if ! [ -z "${PYTHONHOME+_}" ] ; then | |
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" | |
unset PYTHONHOME | |
fi | |
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then | |
_OLD_VIRTUAL_PS1="$PS1" | |
if [ "x" != x ] ; then | |
PS1="$PS1" | |
else | |
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1" | |
fi | |
export PS1 | |
fi | |
basename "$VIRTUAL_ENV" | |
# Make sure to unalias pydoc if it's already there | |
alias pydoc 2>/dev/null >/dev/null && unalias pydoc | |
pydoc () { | |
python -m pydoc "$@" | |
} | |
# This should detect bash and zsh, which have a hash command that must | |
# be called to get it to forget past commands. Without forgetting | |
# past commands the $PATH changes we made may not be respected | |
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then | |
hash -r 2>/dev/null | |
fi | |
Collecting magnum | |
Collecting mysql-python | |
Collecting pymysql | |
Collecting python-memcached | |
Collecting oslo.log>=3.11.0 (from magnum) | |
Collecting PrettyTable<0.8,>=0.7.1 (from magnum) | |
Collecting keystonemiddleware!=4.5.0,>=4.2.0 (from magnum) | |
Collecting cryptography!=1.3.0,>=1.0 (from magnum) | |
Collecting oslo.concurrency>=3.8.0 (from magnum) | |
Collecting python-glanceclient>=2.5.0 (from magnum) | |
Collecting oslo.config!=3.18.0,>=3.14.0 (from magnum) | |
Collecting python-k8sclient>=0.2.0 (from magnum) | |
Collecting oslo.service>=1.10.0 (from magnum) | |
Collecting taskflow>=1.26.0 (from magnum) | |
Collecting decorator>=3.4.0 (from magnum) | |
Collecting enum34; python_version == "2.7" or python_version == "2.6" or python_version == "3.3" (from magnum) | |
Collecting jsonpatch>=1.1 (from magnum) | |
Collecting greenlet>=0.3.2 (from magnum) | |
Collecting oslo.policy>=1.15.0 (from magnum) | |
Could not find a version that satisfies the requirement oslo.policy>=1.15.0 (from magnum) (from versions: 1.14.0) | |
No matching distribution found for oslo.policy>=1.15.0 (from magnum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment