8ee0d717f60c53515fbe0c3d20de996e717476d3
[icn.git] / cmd / bpa-operator / e2etest / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3 # SPDX-license-identifier: Apache-2.0
4 ##############################################################################
5 # Copyright (c) 2018
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 box = {
13   :virtualbox => { :name => "elastic/ubuntu-18.04-x86_64", :version=> '20191020.0.0' },
14   :libvirt => { :name => "generic/ubuntu1804", :version=> "1.9.38"}
15 }
16
17
18
19 provider = (ENV["VAGRANT_DEFAULT_PROVIDER"] || :libvirt).to_sym
20 puts "[INFO] Provider: #{provider} "
21
22 if ENV["no_proxy"] != nil or ENV["NO_PROXY"]
23   $no_proxy = ENV["NO_PROXY"] || ENV["no_proxy"] || "127.0.0.1,localhost,192.168.50.63"
24   $subnet = "192.168.121"
25   if provider == :virtualbox
26     $subnet = "10.0.2"
27   end
28   # NOTE: This range is based on vagrant-libvirt network definition CIDR 192.168.121.0/27
29   (1..31).each do |i|
30     $no_proxy += ",#{$subnet}.#{i}"
31   end
32 end
33
34 Vagrant.configure("2") do |config|
35   config.vm.box =  box[provider][:name]
36   config.ssh.insert_key = false
37   config.vm.box_version = box[provider][:version]
38   config.vm.provision "file", source: "vm_authorized_keys", destination: "/home/vagrant/.ssh/authorized_keys"
39
40    config.vm.provision "shell" do |sh|
41      sh.inline = "mkdir -p /root/.ssh; cp /home/vagrant/.ssh/authorized_keys /root/.ssh/authorized_keys"
42      sh.privileged = true
43    end
44
45   if ENV["http_proxy"] != nil and ENV["https_proxy"] != nil
46     if Vagrant.has_plugin?("vagrant-proxyconf")
47       config.proxy.http     = ENV["http_proxy"] || ENV["HTTP_PROXY"] || ""
48       config.proxy.https    = ENV["https_proxy"] || ENV["HTTPS_PROXY"] || ""
49       config.proxy.no_proxy = $no_proxy
50       config.proxy.enabled = { docker: false }
51     end
52   end
53   config.vm.provider "libvirt" do |v|
54     v.nested = true
55     v.cpu_mode = "host-passthrough"
56     v.management_network_address = "192.168.121.0/27"
57     v.random_hostname = true
58   end
59
60
61    config.vm.define vm_name = "bpa-test-vm" do |config|
62      config.vm.hostname = "master-test"
63      config.vm.network :private_network, :ip => "192.168.50.63", :type => :static, :mac => "080027efab60"
64    end
65    config.vm.provider "virtualbox" do |v|
66       v.customize ["modifyvm", :id, "--memory", 16384]
67       v.customize ["modifyvm", :id, "--cpus", 16]
68    end
69      
70    config.vm.provider "libvirt" do |v|
71       v.memory = 16384
72       v.cpus = 16
73         
74    end
75    #end
76  
77   sync_type = "virtualbox"
78   if provider == :libvirt
79     sync_type = "nfs"
80   end
81 end