Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 1 | USE_STRATUM = ENV['USE_STRATUM'] || "false" |
| 2 | |
| 3 | REQUIRED_PLUGINS = %w( vagrant-vbguest vagrant-reload vagrant-disksize ) |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 4 | |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 5 | Vagrant.configure(2) do |config| |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 6 | |
| 7 | # Install plugins if missing... |
| 8 | _retry = false |
| 9 | REQUIRED_PLUGINS.each do |plugin| |
| 10 | unless Vagrant.has_plugin? plugin |
| 11 | system "vagrant plugin install #{plugin}" |
| 12 | _retry = true |
Carmelo Cascone | c5569c2 | 2018-04-18 10:09:15 +0900 | [diff] [blame] | 13 | end |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 14 | end |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 15 | |
| 16 | if (_retry) |
| 17 | exec "vagrant " + ARGV.join(' ') |
| 18 | end |
| 19 | |
| 20 | # Common config. |
| 21 | config.vm.box = "ubuntu/bionic64" |
| 22 | config.vbguest.auto_update = true |
| 23 | config.disksize.size = '50GB' |
| 24 | config.vm.synced_folder ".", "/vagrant", disabled: false, type: "virtualbox" |
Carmelo Cascone | d661507 | 2017-12-15 00:53:43 -0800 | [diff] [blame] | 25 | config.vm.network "private_network", :type => 'dhcp', :adapter => 2 |
Carmelo Cascone | ada7b5b | 2019-04-23 13:50:03 -0700 | [diff] [blame] | 26 | |
| 27 | # Dev VM |
| 28 | config.vm.define "dev" do |d| |
| 29 | d.vm.hostname = "onos-p4-dev" |
| 30 | d.vm.provider "virtualbox" do |vb| |
| 31 | vb.name = "ONOS+P4 Dev " + Time.now.strftime("(%Y-%m-%d)") |
| 32 | vb.gui = false |
| 33 | vb.cpus = 2 |
| 34 | vb.memory = 4096 |
| 35 | vb.customize ["modifyvm", :id, "--vram", "32"] |
| 36 | end |
| 37 | d.vm.provision "shell", path: "root-bootstrap.sh", :args => ["dev", USE_STRATUM] |
| 38 | d.vm.provision "shell", inline: "su sdn '/vagrant/user-bootstrap.sh' dev %s" % ["dev", USE_STRATUM] |
| 39 | end |
| 40 | |
| 41 | # Tutorial VM (with desktop) |
| 42 | config.vm.define "tutorial" do |d| |
| 43 | d.vm.hostname = "onos-p4-tutorial" |
| 44 | d.vm.provider "virtualbox" do |vb| |
| 45 | vb.name = "ONOS+P4 Tutorial " + Time.now.strftime("(%Y-%m-%d)") |
| 46 | vb.gui = true |
| 47 | vb.cpus = 4 |
| 48 | vb.memory = 4096 |
| 49 | vb.customize ['modifyvm', :id, '--clipboard', 'bidirectional'] |
| 50 | vb.customize ["modifyvm", :id, "--accelerate3d", "on"] |
| 51 | vb.customize ["modifyvm", :id, "--vram", "128"] |
| 52 | end |
| 53 | d.vm.provision "shell", path: "root-bootstrap.sh", :args => ["tutorial"] |
| 54 | d.vm.provision "shell", path: "tutorial-bootstrap.sh" |
| 55 | d.vm.provision "shell", inline: "su sdn '/vagrant/user-bootstrap.sh' %s %s" % ["tutorial", USE_STRATUM] |
| 56 | end |
| 57 | |
| 58 | config.vm.provision :reload |
| 59 | end |