From 36a56758975e6145eab87300f5e42d7fbfeaf89a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Andr=C3=A9?= <m.andre@redhat.com>
Date: Mon, 14 Sep 2015 23:01:10 +0900
Subject: [PATCH] Allow configuring number of nodes in Vagrantfile

Partially-Implements: blueprint vagrant-improvements
Change-Id: Icdf42f45dd5dec44dc02f073da0c4b863617cb1b
---
 vagrant/Vagrantfile | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
index f22e0c0b0..496e2d992 100644
--- a/vagrant/Vagrantfile
+++ b/vagrant/Vagrantfile
@@ -4,9 +4,15 @@
 # Whether to do Multi-node or All-in-One deployment
 MULTINODE=true
 
+# The following is only used when deploying in Multi-nodes
+NUMBER_OF_CONTROL_NODES=3
+NUMBER_OF_COMPUTE_NODES=1
+NUMBER_OF_STORAGE_NODES=1
+NUMBER_OF_NETWORK_NODES=1
+
 # Configure a new SSH key and config so the operator is able to connect with
 # the other cluster nodes.
-if not File.file?("./vagrantkey")
+unless File.file?("./vagrantkey")
   system("ssh-keygen -f ./vagrantkey -N '' -C this-is-vagrant")
 end
 
@@ -62,7 +68,7 @@ Vagrant.configure(2) do |config|
 
   if MULTINODE
     # Build compute nodes
-    (1..1).each do |i|
+    (1..NUMBER_OF_COMPUTE_NODES).each do |i|
       config.vm.define "compute0#{i}" do |compute|
         compute.vm.hostname = "compute0#{i}.local"
         compute.vm.provision :shell, path: "bootstrap.sh"
@@ -77,7 +83,7 @@ Vagrant.configure(2) do |config|
     end
 
     # Build storage nodes
-    (1..1).each do |i|
+    (1..NUMBER_OF_STORAGE_NODES).each do |i|
       config.vm.define "storage0#{i}" do |storage|
         storage.vm.hostname = "storage0#{i}.local"
         storage.vm.provision :shell, path: "bootstrap.sh"
@@ -92,7 +98,7 @@ Vagrant.configure(2) do |config|
     end
 
     # Build network nodes
-    (1..1).each do |i|
+    (1..NUMBER_OF_NETWORK_NODES).each do |i|
       config.vm.define "network0#{i}" do |network|
         network.vm.hostname = "network0#{i}.local"
         network.vm.provision :shell, path: "bootstrap.sh"
@@ -107,7 +113,7 @@ Vagrant.configure(2) do |config|
     end
 
     # Build control nodes
-    (1..3).each do |i|
+    (1..NUMBER_OF_CONTROL_NODES).each do |i|
       config.vm.define "control0#{i}" do |control|
         control.vm.hostname = "control0#{i}.local"
         control.vm.provision :shell, path: "bootstrap.sh"
@@ -118,13 +124,6 @@ Vagrant.configure(2) do |config|
           vb.memory = 2048
         end
         control.hostmanager.aliases = "control0#{i}"
-
-        # TODO: Here we bind local port 8080 to Horizon on control01 only.
-        # TODO: Once we implement Horizon behind a VIP, this obviously needs to
-        # be changed.
-        #if i < 2 then
-        #  config.vm.network "forwarded_port", guest: 80, host: 8080
-        #end
       end
     end
   end
-- 
GitLab