Files
monasca-api/devstack/Vagrantfile
Darren Hague 279dc30ad1 devstack/Vagrant: cache files missed by vagrant-cachier plugin
When vagrant-cachier is enabled, it caches downloaded files in the host so
that apt-get doesn't have to download them from the internet every time
"vagrant up" is run.

This patch enables the same behaviour for files downloaded by pip, Maven,
Node.js and npm.

OpenStack files are still freshly downloaded via Git clone - this patch
only affects the 3rd-party dependencies.

The result is that, on my laptop via corporate proxy, a "vagrant up" takes
27 minutes instead of > 1 hour.

Change-Id: I5f81a217a30abce9ba2ecea6f3c1884ae40595e2
2017-03-31 12:38:39 +00:00

172 lines
6.1 KiB
Ruby

# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
# Handle local proxy settings
if Vagrant.has_plugin?("vagrant-proxyconf")
if ENV["http_proxy"]
config.proxy.http = ENV["http_proxy"]
end
if ENV["https_proxy"]
config.proxy.https = ENV["https_proxy"]
end
if ENV["no_proxy"]
config.proxy.no_proxy = ENV["no_proxy"] + ',192.168.10.6,10.0.2.15,127.0.0.1'
end
end
config.vm.hostname = "devstack"
config.vm.box = "bento/ubuntu-16.04"
config.vm.box_check_update = false
config.vm.network "private_network",ip:"192.168.10.6"
config.vm.synced_folder "~/", "/vagrant_home"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "12800"
vb.cpus = 4
# vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
end
config.vm.provision "shell", privileged: false, inline: <<-SHELL
# sudo apt-get update
# sudo apt-get -y upgrade
sudo apt-get -y install git
if [ $http_proxy ]; then
git config --global url.https://git.openstack.org/.insteadOf git://git.openstack.org/
sudo git config --global url.https://git.openstack.org/.insteadOf git://git.openstack.org/
protocol=`echo $http_proxy | awk -F: '{print $1}'`
host=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $1}'`
port=`echo $http_proxy | awk -F/ '{print $3}' | awk -F: '{print $2}'`
echo "<settings>
<proxies>
<proxy>
<id>$host</id>
<active>true</active>
<protocol>$protocol</protocol>
<host>$host</host>
<port>$port</port>
</proxy>
</proxies>
</settings>" > ./maven_proxy_settings.xml
mkdir -p ~/.m2
cp ./maven_proxy_settings.xml ~/.m2/settings.xml
sudo mkdir -p /root/.m2
sudo cp ./maven_proxy_settings.xml /root/.m2/settings.xml
fi
git clone https://git.openstack.org/openstack-dev/devstack -b master --depth 1
# If using vagrant-cachier, restore cached downloads of 3rd-party dependencies
if [ -d "/tmp/vagrant-cache" ]; then
if [ -d "/tmp/vagrant-cache/downloads" ]; then
echo "Restoring downloads"
cp /tmp/vagrant-cache/downloads/* devstack/files
fi
if [ -f "/tmp/vagrant-cache/pip-cache.tar.gz" ]; then
echo "Restoring ~/.cache"
tar xzf /tmp/vagrant-cache/pip-cache.tar.gz -C ~
fi
if [ -f "/tmp/vagrant-cache/nvm-cache.tar.gz" ]; then
echo "Restoring ~/.nvm/.cache"
mkdir -p ~/.nvm
tar xzf /tmp/vagrant-cache/nvm-cache.tar.gz -C ~/.nvm
fi
if [ -f "/tmp/vagrant-cache/npm-pkgs.tar.gz" ]; then
echo "Restoring ~/.npm"
tar xzf /tmp/vagrant-cache/npm-pkgs.tar.gz -C ~
fi
if [ -f "/tmp/vagrant-cache/root-pip-cache.tar.gz" ]; then
echo "Restoring ~root/.cache"
sudo tar xzf /tmp/vagrant-cache/root-pip-cache.tar.gz -C ~root
fi
if [ -f "/tmp/vagrant-cache/root-m2-cache.tar.gz" ]; then
echo "Restoring ~root/.m2"
sudo tar xzf /tmp/vagrant-cache/root-m2-cache.tar.gz -C ~root
fi
fi
cd devstack
echo '[[local|localrc]]
GIT_DEPTH=1
SERVICE_HOST=192.168.10.6
HOST_IP=192.168.10.6
HOST_IP_IFACE=eth1
DATABASE_PASSWORD=secretdatabase
RABBIT_PASSWORD=secretrabbit
ADMIN_PASSWORD=secretadmin
SERVICE_PASSWORD=secretservice
LOGFILE=$DEST/logs/stack.sh.log
LOGDIR=$DEST/logs
LOG_COLOR=False
DEST=/opt/stack
disable_all_services
enable_service zookeeper rabbit key tempest horizon
# Uncomment one of the following lines to use either MySQL or PostgreSQL
# as RDB (relational database) backend for monasca.
enable_service mysql
#enable_service postgresql
# Enable/Disable ORM support for mysql/postgresql
# HINT: If postgresql service is enabled, ORM is enforced
MONASCA_DATABASE_USE_ORM=${MONASCA_DATABASE_USE_ORM:-false}
# The following two variables allow switching between Java and Python for the implementations
# of the Monasca API and the Monasca Persister. If these variables are not set, then the
# default is to install the Python implementations of both the Monasca API and the Monasca Persister.
# Uncomment one of the following two lines to choose Java or Python for the Monasca API.
# MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-java}
MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-python}
# Uncomment one of the following two lines to choose Java or Python for the Monasca Pesister.
# MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-java}
MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-python}
# Uncomment one of the following three lines to choose either InfluxDB, Vertica or Cassandra.
# MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-vertica}
# MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-cassandra}
MONASCA_METRICS_DB=${MONASCA_METRICS_DB:-influxdb}
# Uncomment one of the following lines and modify accordingly to enable the Monasca DevStack Plugin
enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api
# enable_plugin monasca-api file:///vagrant_home/Documents/repos/openstack/monasca-api.vertica
' > local.conf
./stack.sh
# Cache downloaded files for future runs
if [ -d "/tmp/vagrant-cache" ]; then
mkdir -p /tmp/vagrant-cache/downloads
cp files/*gz files/*.deb /tmp/vagrant-cache/downloads
tar czf /tmp/vagrant-cache/pip-cache.tar.gz -C ~ .cache
tar czf /tmp/vagrant-cache/nvm-cache.tar.gz -C ~/.nvm .cache
tar czf /tmp/vagrant-cache/npm-pkgs.tar.gz -C ~ .npm
sudo tar czf /tmp/vagrant-cache/root-pip-cache.tar.gz -C ~root .cache
sudo tar czf /tmp/vagrant-cache/root-m2-cache.tar.gz -C ~root .m2
fi
SHELL
end