Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 1 | # -*- mode: ruby -*- |
| 2 | # vi: set ft=ruby : |
| 3 | |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 4 | require 'yaml' |
| 5 | |
David K. Bainbridge | a2a46ae | 2017-10-24 14:05:33 -0700 | [diff] [blame] | 6 | if ENV['VAGRANT_SETTINGS'] and ENV['VAGRANT_SETTINGS'] != '' |
| 7 | settings_file = ENV['VAGRANT_SETTINGS'] |
| 8 | else |
| 9 | settings_file = 'settings.vagrant.yaml' |
| 10 | end |
| 11 | puts("Loading vagrant settings from " + settings_file) |
| 12 | settings = YAML.load_file settings_file |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 13 | |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 14 | Vagrant.configure(2) do |config| |
| 15 | |
Sergio Slobodrian | 2f1a3f8 | 2017-05-31 10:35:00 -0400 | [diff] [blame] | 16 | if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM |
| 17 | puts("Configuring for windows") |
alshabib | eef9b13 | 2017-02-02 17:46:51 -0800 | [diff] [blame] | 18 | config.vm.synced_folder "../..", "/cord", mount_options: ["dmode=700,fmode=600"] |
David K. Bainbridge | e2c0810 | 2017-10-31 11:55:25 -0700 | [diff] [blame] | 19 | if settings['vagrant_box'] |
| 20 | Box = settings['vagrant_box'] |
| 21 | else |
| 22 | Box = "ubuntu/xenial64" |
| 23 | end |
Sergio Slobodrian | 2f1a3f8 | 2017-05-31 10:35:00 -0400 | [diff] [blame] | 24 | Provider = "virtualbox" |
| 25 | elsif RUBY_PLATFORM =~ /linux/ |
| 26 | puts("Configuring for linux") |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 27 | if settings['vProvider'] == "virtualbox" |
| 28 | puts("Using the virtualbox configuration"); |
| 29 | config.vm.synced_folder "../..", "/cord" |
David K. Bainbridge | e2c0810 | 2017-10-31 11:55:25 -0700 | [diff] [blame] | 30 | if settings['vagrant_box'] |
| 31 | Box = settings['vagrant_box'] |
| 32 | else |
| 33 | Box = "ubuntu/xenial64" |
| 34 | end |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 35 | Provider = "virtualbox" |
khenaidoo | 079a776 | 2017-10-26 21:42:05 -0400 | [diff] [blame] | 36 | config.disksize.size = '50GB' |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 37 | else |
| 38 | puts("Using the QEMU/KVM configuration"); |
David K. Bainbridge | e2c0810 | 2017-10-31 11:55:25 -0700 | [diff] [blame] | 39 | if settings['vagrant_box'] |
| 40 | Box = settings['vagrant_box'] |
| 41 | else |
| 42 | Box = "ubuntu1604" |
| 43 | end |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 44 | Provider = "libvirt" |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 45 | if settings['testMode'] == "true" or settings['installMode'] == "true" |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 46 | config.vm.synced_folder ".", "/vagrant", disabled: true |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 47 | config.vm.synced_folder "../..", "/cord", type: "rsync", rsync__exclude: [".git", "venv-linux", "install/volthaInstaller", "install/volthaInstaller-2"], rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"] |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 48 | else |
David K. Bainbridge | a2a46ae | 2017-10-24 14:05:33 -0700 | [diff] [blame] | 49 | config.vm.synced_folder ".", "/vagrant", rsync__exclude: [".git", "venv-linux", "install/volthaInstaller", "install/volthaInstaller-2"], rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"] |
| 50 | config.vm.synced_folder "../..", "/cord", type: "nfs", rsync__exclude: [".git", "venv-linux", "install/volthaInstaller", "install/volthaInstaller-2"], rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"] |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 51 | end |
Sergio Slobodrian | bf77c86 | 2017-06-08 13:24:27 -0400 | [diff] [blame] | 52 | end |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 53 | else |
Sergio Slobodrian | 2f1a3f8 | 2017-05-31 10:35:00 -0400 | [diff] [blame] | 54 | puts("Configuring for other") |
alshabib | eef9b13 | 2017-02-02 17:46:51 -0800 | [diff] [blame] | 55 | config.vm.synced_folder "../..", "/cord" |
David K. Bainbridge | e2c0810 | 2017-10-31 11:55:25 -0700 | [diff] [blame] | 56 | if settings['vagrant_box'] |
| 57 | Box = settings['vagrant_box'] |
| 58 | else |
| 59 | Box = "ubuntu/xenial64" |
| 60 | end |
Sergio Slobodrian | 2f1a3f8 | 2017-05-31 10:35:00 -0400 | [diff] [blame] | 61 | Provider = "virtualbox" |
khenaidoo | 079a776 | 2017-10-26 21:42:05 -0400 | [diff] [blame] | 62 | config.disksize.size = '50GB' |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 63 | end |
| 64 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 65 | config.vm.define "#{settings['server_name']}" do |d| |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 66 | d.ssh.forward_agent = true |
Sergio Slobodrian | 2f1a3f8 | 2017-05-31 10:35:00 -0400 | [diff] [blame] | 67 | d.vm.box = Box |
David K. Bainbridge | e2c0810 | 2017-10-31 11:55:25 -0700 | [diff] [blame] | 68 | if settings['vagrant_box_version'] |
| 69 | d.vm.box_version = settings['vagrant_box_version'] |
| 70 | elsif Box == "ubuntu/xenial64" |
| 71 | d.vm.box_version = "20170207.0.0" |
khenaidoo | 3a7a4e5 | 2017-07-14 15:31:46 -0400 | [diff] [blame] | 72 | end |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 73 | d.vm.hostname = "#{settings['server_name']}" |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 74 | d.vm.network "private_network", ip: "10.100.198.220" |
| 75 | d.vm.provision :shell, path: "ansible/scripts/bootstrap_ansible.sh" |
alshabib | eef9b13 | 2017-02-02 17:46:51 -0800 | [diff] [blame] | 76 | d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/incubator/voltha/ansible/voltha.yml -c local" |
| 77 | d.vm.provision :shell, inline: "cd /cord/incubator/voltha && source env.sh && make install-protoc && chmod 777 /tmp/fluentd" |
Sergio Slobodrian | 2f1a3f8 | 2017-05-31 10:35:00 -0400 | [diff] [blame] | 78 | d.vm.provider Provider do |v| |
Zsolt Haraszti | 9b485fb | 2016-12-26 23:11:15 -0800 | [diff] [blame] | 79 | v.memory = 6144 |
Sergio Slobodrian | cab0a39 | 2017-07-13 08:42:10 -0400 | [diff] [blame] | 80 | v.cpus = 4 |
Sergio Slobodrian | fb89efa | 2017-08-02 14:16:14 -0400 | [diff] [blame] | 81 | if settings['vProvider'] == "KVM" |
| 82 | v.cpu_mode = 'host-passthrough' |
| 83 | v.cpu_fallback = 'allow' |
| 84 | end |
Zsolt Haraszti | 3d16353 | 2016-09-08 15:57:32 -0700 | [diff] [blame] | 85 | end |
| 86 | end |
| 87 | |
| 88 | if Vagrant.has_plugin?("vagrant-cachier") |
| 89 | config.cache.scope = :box |
| 90 | end |
| 91 | |
| 92 | end |