From 07687f4401d9ee7c82e1a552eaf858b7dc92f19c Mon Sep 17 00:00:00 2001 From: Jaume Devesa Date: Tue, 15 Dec 2015 17:11:54 +0100 Subject: [PATCH] Make ./stack.sh optional Create a new VAGRANT_KURYR_RUN_DEVSTACK environment variable to make the `stack.sh` call optional. Some people may want to edit the `local.conf` file before run `stack.sh` manually in the VM. Useful for the devstack/plugin.sh development, for instance. It is defaulted to `true` for backwards compatibility. Change-Id: Ia3fe8cb4416a75a3ec05cbb9ce698313daa555e4 --- contrib/vagrant/README.md | 3 +++ contrib/vagrant/Vagrantfile | 10 +++++++--- contrib/vagrant/devstack.sh | 10 +++++++--- contrib/vagrant/vagrant.sh | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/contrib/vagrant/README.md b/contrib/vagrant/README.md index 6f9bd5df..860e793a 100644 --- a/contrib/vagrant/README.md +++ b/contrib/vagrant/README.md @@ -45,3 +45,6 @@ the definition of the Virtual Machine spawned: * **VAGRANT\_KURYR\_VM\_MEMORY**: To modify the RAM of the VM. Defaulted to: 4096 * **VAGRANT\_KURYR\_VM\_CPU**: To modify the cpus of the VM. Defaulted to: 2 + * **VAGRANT\_KURYR\_RUN\_DEVSTACK**: Whether `vagrant up` should run devstack to + have an environment ready to use. Set it to 'false' if you want to edit + `local.conf` before run ./stack.sh manually in the VM. Defaulted to: true diff --git a/contrib/vagrant/Vagrantfile b/contrib/vagrant/Vagrantfile index d8fc4405..5167e8aa 100644 --- a/contrib/vagrant/Vagrantfile +++ b/contrib/vagrant/Vagrantfile @@ -2,8 +2,9 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - VM_MEMORY = ENV.fetch('VAGRANT_KURYR_VM_MEMORY', 4096) - VM_CPUS = ENV.fetch('VAGRANT_KURYR_VM_CPUS', 2) + VM_MEMORY = ENV.fetch('VAGRANT_KURYR_VM_MEMORY', 4096) + VM_CPUS = ENV.fetch('VAGRANT_KURYR_VM_CPUS', 2) + RUN_DEVSTACK = ENV.fetch('VAGRANT_KURYR_RUN_DEVSTACK', 'true') config.vm.hostname = 'devstack' @@ -33,7 +34,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # For CentOS machines it needs to be specified config.vm.synced_folder '.', '/vagrant' - config.vm.provision :shell, :path => 'vagrant.sh' + config.vm.provision :shell do |s| + s.path = 'vagrant.sh' + s.args = RUN_DEVSTACK + end if Vagrant.has_plugin?('vagrant-cachier') config.cache.scope = :box diff --git a/contrib/vagrant/devstack.sh b/contrib/vagrant/devstack.sh index 32119e93..7440d77f 100755 --- a/contrib/vagrant/devstack.sh +++ b/contrib/vagrant/devstack.sh @@ -3,6 +3,7 @@ set -e BASHPATH=$(dirname "$0"\") +RUN_DEVSTACK="$1" echo "Run script from $BASHPATH" # Copied shamelessly from Devstack @@ -47,6 +48,9 @@ then fi -# start devstack -echo "Start Devstack" -su "$OS_USER" -c "cd $DEVSTACK && ./stack.sh" +if $RUN_DEVSTACK; then + echo "Start Devstack" + su "$OS_USER" -c "cd $DEVSTACK && ./stack.sh" +else + echo "Virtual Machine ready. You can run devstack by executing '/home/vagrant/devstack/stack.sh'" +fi diff --git a/contrib/vagrant/vagrant.sh b/contrib/vagrant/vagrant.sh index b0c2b0bd..f56aaa2c 100755 --- a/contrib/vagrant/vagrant.sh +++ b/contrib/vagrant/vagrant.sh @@ -4,7 +4,7 @@ export OS_USER=vagrant export OS_HOST_IP=172.68.5.10 # run script -bash /vagrant/devstack.sh +bash /vagrant/devstack.sh "$1" #set environment variables for kuryr su "$OS_USER" -c "echo 'source /vagrant/config/kuryr_rc' >> ~/.bashrc"