From 006b3e6228af5d292ee682ba4b56dd1dd9bf8f6d Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Fri, 16 Oct 2015 11:46:13 +0100 Subject: [PATCH] Install IPA in a virtual environment In order to avoid conflict with installing dependencies for IPA from pypi and distribution packages this patch propose installing IPA in a virtual environment. Closes-Bug: #1506792 Change-Id: I6a4c6403813d86f4110e98449ddd874109101b9e --- elements/ironic-agent/element-deps | 1 + .../60-ironic-agent-install | 22 +++++++++---------- .../ironic-python-agent.conf | 2 +- .../ironic-python-agent.init | 2 +- .../ironic-python-agent.service | 2 +- .../source-repository-ironic-agent | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) mode change 100755 => 100644 elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.conf mode change 100755 => 100644 elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.service diff --git a/elements/ironic-agent/element-deps b/elements/ironic-agent/element-deps index f332d35b..ee8155c4 100644 --- a/elements/ironic-agent/element-deps +++ b/elements/ironic-agent/element-deps @@ -1,5 +1,6 @@ dhcp-all-interfaces package-installs +pip-and-virtualenv pkg-map source-repositories svc-map diff --git a/elements/ironic-agent/install.d/ironic-agent-source-install/60-ironic-agent-install b/elements/ironic-agent/install.d/ironic-agent-source-install/60-ironic-agent-install index 0cac68f5..17ac2831 100755 --- a/elements/ironic-agent/install.d/ironic-agent-source-install/60-ironic-agent-install +++ b/elements/ironic-agent/install.d/ironic-agent-source-install/60-ironic-agent-install @@ -7,27 +7,25 @@ set -eu set -o pipefail SCRIPTDIR=$(dirname $0) +IPADIR=/usr/share/ironic-python-agent -# Install the latest version of pip and setuptools which has some -# fixes for building behind proxy. -curl -o /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py -python /tmp/get-pip.py -rm -f /tmp/get-pip.py -pip install -U setuptools +# create the virtual environment +virtualenv $IPADIR/venv -pip install -r /tmp/ironic-python-agent/requirements.txt -pip install /tmp/ironic-python-agent +# install IPA inside the virtual environment +$IPADIR/venv/bin/pip install $IPADIR -if [ ! -f /usr/bin/ironic-python-agent ]; then - ln -s /usr/local/bin/ironic-python-agent /usr/bin/ironic-python-agent -fi +# FIXME(lucasagomes): Figure out how we can use the "--install-option" +# parameter for pip install so we don't have to manually create a symlink +# create the launcher link so services can use it +ln -s $IPADIR/venv/bin/ironic-python-agent /usr/local/bin/ironic-python-agent case "$DIB_INIT_SYSTEM" in upstart) install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.conf /etc/init/ironic-python-agent.conf ;; systemd) - install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/$(svc-map ironic-python-agent).service + install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/ironic-python-agent.service ;; sysv) install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.init /etc/init.d/ironic-python-agent.init diff --git a/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.conf b/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.conf old mode 100755 new mode 100644 index 4601f19e..eab28322 --- a/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.conf +++ b/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.conf @@ -17,4 +17,4 @@ pre-start script echo Starting Ironic Python Agent end script -exec /usr/bin/ironic-python-agent +exec /usr/local/bin/ironic-python-agent diff --git a/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.init b/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.init index 83035c26..7ecb3a0a 100755 --- a/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.init +++ b/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.init @@ -12,7 +12,7 @@ NAME=ironic-python-agent INIT_NAME=/etc/init.d/${NAME} -SCRIPT_NAME=/usr/bin/${NAME} +SCRIPT_NAME=/usr/local/bin/${NAME} [ -x $SCRIPT_NAME ] || exit 0 diff --git a/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.service b/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.service old mode 100755 new mode 100644 index a4593caf..6513cd63 --- a/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.service +++ b/elements/ironic-agent/install.d/ironic-agent-source-install/ironic-python-agent.service @@ -3,7 +3,7 @@ Description=Ironic Python Agent After=network.target [Service] -ExecStart=/usr/bin/ironic-python-agent +ExecStart=/usr/local/bin/ironic-python-agent Restart=always RestartSec=30s diff --git a/elements/ironic-agent/source-repository-ironic-agent b/elements/ironic-agent/source-repository-ironic-agent index 37422952..f657bdf4 100644 --- a/elements/ironic-agent/source-repository-ironic-agent +++ b/elements/ironic-agent/source-repository-ironic-agent @@ -1 +1 @@ -ironic-agent git /tmp/ironic-python-agent https://git.openstack.org/openstack/ironic-python-agent +ironic-agent git /usr/share/ironic-python-agent https://git.openstack.org/openstack/ironic-python-agent