blob: b95e831c73f268a94da963c22971e89b69535d2e [file] [log] [blame]
Zsolt Haraszti3d163532016-09-08 15:57:32 -07001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
Sergio Slobodrianbf77c862017-06-08 13:24:27 -04004require 'yaml'
5
David K. Bainbridgea2a46ae2017-10-24 14:05:33 -07006if ENV['VAGRANT_SETTINGS'] and ENV['VAGRANT_SETTINGS'] != ''
7 settings_file = ENV['VAGRANT_SETTINGS']
8else
9 settings_file = 'settings.vagrant.yaml'
10end
11puts("Loading vagrant settings from " + settings_file)
12settings = YAML.load_file settings_file
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040013
Zsolt Haraszti3d163532016-09-08 15:57:32 -070014Vagrant.configure(2) do |config|
15
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040016 if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
17 puts("Configuring for windows")
alshabibeef9b132017-02-02 17:46:51 -080018 config.vm.synced_folder "../..", "/cord", mount_options: ["dmode=700,fmode=600"]
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040019 Box = "ubuntu/xenial64"
20 Provider = "virtualbox"
21 elsif RUBY_PLATFORM =~ /linux/
22 puts("Configuring for linux")
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040023 if settings['vProvider'] == "virtualbox"
24 puts("Using the virtualbox configuration");
25 config.vm.synced_folder "../..", "/cord"
26 Box = "ubuntu/xenial64"
27 Provider = "virtualbox"
28 else
29 puts("Using the QEMU/KVM configuration");
David K. Bainbridgea2a46ae2017-10-24 14:05:33 -070030 Box = "elastic/ubuntu-16.04-x86_64"
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040031 Provider = "libvirt"
Sergio Slobodrian36e16552017-06-19 11:00:45 -040032 if settings['testMode'] == "true" or settings['installMode'] == "true"
Sergio Slobodrian7c483622017-06-13 15:51:34 -040033 config.vm.synced_folder ".", "/vagrant", disabled: true
Sergio Slobodrian36e16552017-06-19 11:00:45 -040034 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 Slobodrian7c483622017-06-13 15:51:34 -040035 else
David K. Bainbridgea2a46ae2017-10-24 14:05:33 -070036 config.vm.synced_folder ".", "/vagrant", rsync__exclude: [".git", "venv-linux", "install/volthaInstaller", "install/volthaInstaller-2"], rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"]
37 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 Slobodrian7c483622017-06-13 15:51:34 -040038 end
Sergio Slobodrianbf77c862017-06-08 13:24:27 -040039 end
Zsolt Haraszti3d163532016-09-08 15:57:32 -070040 else
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040041 puts("Configuring for other")
alshabibeef9b132017-02-02 17:46:51 -080042 config.vm.synced_folder "../..", "/cord"
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040043 Box = "ubuntu/xenial64"
44 Provider = "virtualbox"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070045 end
46
Sergio Slobodrian7c483622017-06-13 15:51:34 -040047 config.vm.define "#{settings['server_name']}" do |d|
Zsolt Haraszti3d163532016-09-08 15:57:32 -070048 d.ssh.forward_agent = true
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040049 d.vm.box = Box
khenaidoo3a7a4e52017-07-14 15:31:46 -040050 if Box == "ubuntu/xenial64"
51 d.vm.box_version = "20170207.0.0"
52 end
Sergio Slobodrian7c483622017-06-13 15:51:34 -040053 d.vm.hostname = "#{settings['server_name']}"
Zsolt Haraszti3d163532016-09-08 15:57:32 -070054 d.vm.network "private_network", ip: "10.100.198.220"
55 d.vm.provision :shell, path: "ansible/scripts/bootstrap_ansible.sh"
alshabibeef9b132017-02-02 17:46:51 -080056 d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/incubator/voltha/ansible/voltha.yml -c local"
57 d.vm.provision :shell, inline: "cd /cord/incubator/voltha && source env.sh && make install-protoc && chmod 777 /tmp/fluentd"
Sergio Slobodrian2f1a3f82017-05-31 10:35:00 -040058 d.vm.provider Provider do |v|
Zsolt Haraszti9b485fb2016-12-26 23:11:15 -080059 v.memory = 6144
Sergio Slobodriancab0a392017-07-13 08:42:10 -040060 v.cpus = 4
Sergio Slobodrianfb89efa2017-08-02 14:16:14 -040061 if settings['vProvider'] == "KVM"
62 v.cpu_mode = 'host-passthrough'
63 v.cpu_fallback = 'allow'
64 end
Zsolt Haraszti3d163532016-09-08 15:57:32 -070065 end
66 end
67
68 if Vagrant.has_plugin?("vagrant-cachier")
69 config.cache.scope = :box
70 end
71
72end