blob: dc8b34768134f9cfe8d11626c8a93c91ab1c607a [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
Idan Amit46123862017-09-19 13:43:32 +03004configuration = {
5 # Generic parameters used across all ONAP components
Victor Morales89ce3212017-06-16 18:32:48 -05006 'key_name' => 'ecomp_key',
7 'pub_key' => '',
8 'nexus_repo' => 'https://nexus.onap.org/content/sites/raw',
Victor Morales6a919972017-09-28 18:29:54 -07009 'nexus_repo_root' => 'https://nexus.onap.org',
10 'nexus_url_snapshot' => 'https://nexus.onap.org/content/repositories/snapshots',
Victor Morales89ce3212017-06-16 18:32:48 -050011 'nexus_docker_repo' => 'nexus3.onap.org:10001',
12 'nexus_username' => 'docker',
13 'nexus_password' => 'docker',
14 'dmaap_topic' => 'AUTO',
15 'artifacts_version' => '1.0.0',
16 'docker_version' => '1.0-STAGING-latest',
Victor Morales6a919972017-09-28 18:29:54 -070017 # Parameters for DCAE instantiation
Victor Morales89ce3212017-06-16 18:32:48 -050018 'dcae_zone' => 'iad4',
19 'dcae_state' => 'vi',
20 'openstack_tenant_id' => '',
21 'openstack_username' => '',
22 'openstack_api_key' => '',
23 'openstack_password' => '',
Victor Moralesdd074802017-07-26 16:06:35 -050024 'odl_version' => '0.5.3-Boron-SR3',
Victor Morales6a919972017-09-28 18:29:54 -070025 # Parameters for enabling features
26 'build_image' => 'True',
Idan Amit1690e082017-08-20 08:58:14 +030027 'clone_repo' => 'True',
Victor Morales2909e2e2017-08-08 15:51:52 -050028 'compile_repo' => 'False',
Victor Morales6a919972017-09-28 18:29:54 -070029 'enable_oparent' => 'True',
30 'skip_get_images' => 'False',
31 'skip_install' => 'True'
Victor Morales89ce3212017-06-16 18:32:48 -050032}
33
Idan Amit46123862017-09-19 13:43:32 +030034box = {
35 :virtualbox => 'ubuntu/trusty64',
36 :libvirt => 'sputnik13/trusty64',
37 :openstack => nil
38}
39
Idan Amit46123862017-09-19 13:43:32 +030040nodes = [
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070041 {
Idan Amit46123862017-09-19 13:43:32 +030042 :name => "aai",
43 :ips => ['10.252.0.6', "192.168.50.6"],
44 :macs => [],
45 :cpus => 2,
46 :cpu => "50",
47 :ram => 4 * 1024,
48 :groups => ["individual"],
49 :args => ["aai"]
50 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070051 {
Idan Amit46123862017-09-19 13:43:32 +030052 :name => "all-in-one",
53 :ips => ['10.252.0.3', "192.168.50.3"],
54 :macs => [],
55 :cpus => 2,
56 :cpu => "50",
57 :ram => 12 * 1024,
58 :groups => ["all-in-one"],
59 :flavor => 'm1.xlarge',
60 :args => ['mr', 'sdc', 'aai', 'mso', 'robot', 'vid', 'sdnc', 'portal', 'dcae', 'policy', 'appc', 'vfc', 'ccsdk'],
61 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070062 {
Idan Amit46123862017-09-19 13:43:32 +030063 :name => "appc",
64 :ips => ['10.252.0.14', "192.168.50.14"],
65 :macs => [],
66 :cpus => 2,
67 :cpu => "50",
68 :ram => 4 * 1024,
69 :groups => ["individual"],
70 :args => ["appc"],
71 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070072 {
Idan Amit46123862017-09-19 13:43:32 +030073 :name => "ccsdk",
74 :ips => ['10.252.0.14', "192.168.50.17"],
75 :macs => [],
76 :cpus => 2,
77 :cpu => "50",
78 :ram => 4 * 1024,
79 :groups => ["individual"],
80 :args => ["ccsdk"],
81 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070082 {
Idan Amit46123862017-09-19 13:43:32 +030083 :name => "dcae",
84 :ips => ['10.252.0.12', "192.168.50.12"],
85 :macs => [],
86 :cpus => 2,
87 :cpu => "50",
88 :ram => 4 * 1024,
89 :groups => ["individual"],
90 :args => ["dcae"],
91 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070092 {
Idan Amit46123862017-09-19 13:43:32 +030093 :name => "dns",
94 :ips => ['10.252.0.3', "192.168.50.3"],
95 :macs => [],
96 :cpus => 2,
97 :cpu => "50",
98 :ram => 1 * 1024,
99 :groups => ["individual"],
100 :flavor => 'm1.small',
101 :args => [" "]
102 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700103 {
Idan Amit46123862017-09-19 13:43:32 +0300104 :name => "message-router",
105 :ips => ['10.252.0.4', "192.168.50.4"],
106 :macs => [],
107 :cpus => 2,
108 :cpu => "50",
109 :ram => 4 * 1024,
110 :groups => ["individual"],
111 :args => ["mr"],
112 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700113 {
Idan Amit46123862017-09-19 13:43:32 +0300114 :name => "mso",
115 :ips => ['10.252.0.7', "192.168.50.7"],
116 :macs => [],
117 :cpus => 2,
118 :cpu => "50",
119 :ram => 4 * 1024,
120 :groups => ["individual"],
121 :args => ["mso"],
122 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700123 {
Idan Amit46123862017-09-19 13:43:32 +0300124 :name => "multicloud",
125 :ips => ['10.252.0.16', "192.168.50.16"],
126 :macs => [],
127 :cpus => 2,
128 :cpu => "50",
129 :ram => 4 * 1024,
130 :groups => ["individual"],
131 :args => ["multicloud"],
132 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700133 {
Idan Amit46123862017-09-19 13:43:32 +0300134 :name => "policy",
135 :ips => ['10.252.0.13', "192.168.50.13"],
136 :macs => [],
137 :cpus => 2,
138 :cpu => "50",
139 :ram => 4 * 1024,
140 :groups => ["individual"],
141 :args => ["policy"],
142 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700143 {
Idan Amit46123862017-09-19 13:43:32 +0300144 :name => "portal",
145 :ips => ['10.252.0.11', "192.168.50.11"],
146 :macs => [],
147 :cpus => 2,
148 :cpu => "50",
149 :ram => 4 * 1024,
150 :groups => ["individual"],
151 :args => ["portal"],
152 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700153 {
Idan Amit46123862017-09-19 13:43:32 +0300154 :name => "robot",
155 :ips => ['10.252.0.8', "192.168.50.8"],
156 :macs => [],
157 :cpus => 2,
158 :cpu => "50",
159 :ram => 4 * 1024,
160 :groups => ["individual"],
161 :args => ["robot"],
162 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700163 {
Idan Amit46123862017-09-19 13:43:32 +0300164 :name => "sdc",
165 :ips => ['10.252.0.5', "192.168.50.5"],
166 :macs => [],
167 :cpus => 2,
168 :cpu => "50",
169 :ram => 8 * 1024,
170 :groups => ["individual"],
171 :args => ["sdc"],
172 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700173 {
Idan Amit46123862017-09-19 13:43:32 +0300174 :name => "sdnc",
175 :ips => ['10.252.0.10', "192.168.50.10"],
176 :macs => [],
177 :cpus => 2,
178 :cpu => "50",
179 :ram => 4 * 1024,
180 :groups => ["individual"],
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700181 :args => ["sdnc"],
Idan Amit46123862017-09-19 13:43:32 +0300182 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700183 {
Idan Amit46123862017-09-19 13:43:32 +0300184 :name => "testing",
185 :ips => ['10.252.0.3', "192.168.50.3"],
186 :macs => [],
187 :cpus => 2,
188 :cpu => "50",
189 :ram => 4 * 1024,
190 :groups => ["testing"],
191 :flavor => 'm1.small',
192 :args => [""],
193 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700194 {
Idan Amit46123862017-09-19 13:43:32 +0300195 :name => "vfc",
196 :ips => ['10.252.0.15', "192.168.50.15"],
197 :macs => [],
198 :cpus => 2,
199 :cpu => "50",
200 :ram => 4 * 1024,
201 :groups => ["individual"],
202 :args => ['vfc'],
203 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700204 {
Idan Amit46123862017-09-19 13:43:32 +0300205 :name => "vid",
206 :ips => ['10.252.0.9', "192.168.50.9"],
207 :macs => [],
208 :cpus => 2,
209 :cpu => "50",
210 :ram => 4 * 1024,
211 :groups => ["individual"],
212 :args => ['vid'],
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700213 },
Idan Amit46123862017-09-19 13:43:32 +0300214]
215
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700216run_path = 'vagrant_utils/postinstall.sh'
217sdc_volume = 'vol1-sdc-data.vdi'
Idan Amit46123862017-09-19 13:43:32 +0300218
Victor Moralesdd074802017-07-26 16:06:35 -0500219Vagrant.require_version ">= 1.8.6"
220
Victor Moralesdd074802017-07-26 16:06:35 -0500221# Determine the provider used
222provider = (ENV['VAGRANT_DEFAULT_PROVIDER'] || :virtualbox).to_sym
Idan Amit46123862017-09-19 13:43:32 +0300223puts "[INFO] Provider: #{provider} "
224
Victor Morales89ce3212017-06-16 18:32:48 -0500225vd_conf = ENV.fetch('VD_CONF', 'etc/settings.yaml')
226if File.exist?(vd_conf)
227 require 'yaml'
228 user_conf = YAML.load_file(vd_conf)
Idan Amit46123862017-09-19 13:43:32 +0300229 configuration.update(user_conf)
Victor Morales89ce3212017-06-16 18:32:48 -0500230end
231
Victor Morales6a919972017-09-28 18:29:54 -0700232# Set network interface
Areli Fussf57e9e72017-09-28 14:24:53 +0300233net_interface = 'vboxnet0'
Idan Amit46123862017-09-19 13:43:32 +0300234is_windows = Gem.win_platform?
235if is_windows
236 net_interface = 'VirtualBox Host-Only Ethernet Adapter #2'
Idan Amit46123862017-09-19 13:43:32 +0300237end
238puts "[INFO] Net interface: #{net_interface}"
239
240
Victor Morales6a919972017-09-28 18:29:54 -0700241# If argument is given use it. Otherwise use Env: DEPLOY_MODE else use default
Idan Amit46123862017-09-19 13:43:32 +0300242requested_machine = ARGV[1]
243
Victor Morales89ce3212017-06-16 18:32:48 -0500244deploy_mode = ENV.fetch('DEPLOY_MODE', 'individual')
Idan Amit46123862017-09-19 13:43:32 +0300245if requested_machine != nil
246 if requested_machine.include?("all-in-one") || requested_machine.include?("testing")
247 deploy_mode = requested_machine
248 end
249end
250
Victor Morales6a919972017-09-28 18:29:54 -0700251# Catch the status of all machines
Idan Amit46123862017-09-19 13:43:32 +0300252if ARGV[0] == 'status' || ARGV[0] == 'destroy'
253 deploy_mode = 'NA'
254end
255
256puts "[INFO] Deploy Mode: #{deploy_mode}"
257
Victor Morales6a919972017-09-28 18:29:54 -0700258# In case of all-in-one or testing clean the nodes list
Idan Amit46123862017-09-19 13:43:32 +0300259case deploy_mode
260 when 'all-in-one'
261 nodes.select! do |node|
262 if node[:name].include?("all-in-one")
263 true if node[:name]
264 end
265 end
266
267 when 'individual'
268 nodes.select! do |node|
269 if node[:groups][0].include?("individual")
270 true if node[:name]
Idan Amit46123862017-09-19 13:43:32 +0300271 end
272 end
273
274 when 'testing'
275 nodes.select! do |node|
276 if node[:name].include?("testing")
277 true if node[:name]
278 end
279 end
280end
Victor Morales89ce3212017-06-16 18:32:48 -0500281
282Vagrant.configure("2") do |config|
283
Idan Amit46123862017-09-19 13:43:32 +0300284 # PROXY definitions
285 if ENV['http_proxy'] != nil and ENV['https_proxy'] != nil and ENV['no_proxy'] != nil
286 if not Vagrant.has_plugin?('vagrant-proxyconf')
287 system 'vagrant plugin install vagrant-proxyconf'
288 raise 'vagrant-proxyconf was installed but it requires to execute again'
289 end
290 config.proxy.http = ENV['http_proxy']
291 config.proxy.https = ENV['https_proxy']
292 config.proxy.no_proxy = ENV['no_proxy']
Victor Moralescf269992017-10-18 09:29:55 -0700293 configuration['socks_proxy'] = ENV['socks_proxy']
Victor Morales89ce3212017-06-16 18:32:48 -0500294 end
Victor Morales89ce3212017-06-16 18:32:48 -0500295
Idan Amit46123862017-09-19 13:43:32 +0300296 if Vagrant.has_plugin?('vagrant-vbguest')
297 puts 'vagrant-vbguest auto_update feature will be disable to avoid sharing conflicts'
298 config.vbguest.auto_update = false
Victor Moralesf62e7b82017-07-27 17:26:06 -0500299 end
Idan Amit46123862017-09-19 13:43:32 +0300300
301 if provider == :libvirt
302 if not Vagrant.has_plugin?('vagrant-libvirt')
303 system 'vagrant plugin install vagrant-libvirt'
304 raise 'vagrant-libvirt was installed but it requires to execute again'
305 end
Victor Moralesdd074802017-07-26 16:06:35 -0500306 end
Areli Fussf57e9e72017-09-28 14:24:53 +0300307
Idan Amit46123862017-09-19 13:43:32 +0300308 if provider == :openstack
309 config.ssh.username = 'ubuntu'
310 if not Vagrant.has_plugin?('vagrant-openstack-provider')
311 system 'vagrant plugin install vagrant-openstack-provider'
312 raise 'vagrant-openstack-provider was installed but it requires to execute again'
313 end
314 end
Victor Morales89ce3212017-06-16 18:32:48 -0500315
Idan Amit46123862017-09-19 13:43:32 +0300316 nodes.each do |node|
317 config.vm.define node[:name] do |nodeconfig|
Victor Moralesdd074802017-07-26 16:06:35 -0500318
Idan Amit46123862017-09-19 13:43:32 +0300319 # Common Settings:
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700320
Idan Amit46123862017-09-19 13:43:32 +0300321 nodeconfig.vm.provider "virtualbox" do |vbox|
322 vbox.customize ['modifyvm', :id, '--nictype1', 'virtio']
323 vbox.customize ['modifyvm', :id, '--audio', 'none']
324 vbox.customize ['modifyvm', :id, '--vram', '1']
325 vbox.customize ['modifyvm', :id, "--cpuhotplug", "off"]
326 vbox.customize ['modifyvm', :id, "--cpuexecutioncap", node[:cpu]]
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700327 vbox.customize ['modifyvm', :id, "--cpus", node[:cpus]]
Idan Amit46123862017-09-19 13:43:32 +0300328 vbox.customize ["modifyvm", :id, "--memory", node[:ram]]
Victor Morales89ce3212017-06-16 18:32:48 -0500329 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700330
Idan Amit46123862017-09-19 13:43:32 +0300331 nodeconfig.vm.provider "libvirt" do |lbox|
332 lbox.memory = node[:ram]
333 lbox.nested = true
Victor Morales89ce3212017-06-16 18:32:48 -0500334 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700335
Idan Amit46123862017-09-19 13:43:32 +0300336 nodeconfig.vm.provider :openstack do |obox|
337 obox.openstack_auth_url = ENV.fetch('OS_AUTH_URL', '')
338 obox.tenant_name = ENV.fetch('OS_TENANT_NAME', '')
339 obox.username = ENV.fetch('OS_USERNAME', '')
340 obox.password = ENV.fetch('OS_PASSWORD', '')
341 obox.region = ENV.fetch('OS_REGION_NAME', '')
342 obox.identity_api_version = ENV.fetch('OS_IDENTITY_API_VERSION', '')
343 obox.domain_name = ENV.fetch('OS_PROJECT_DOMAIN_ID', '')
344 obox.project_name = ENV.fetch('OS_PROJECT_NAME', '')
345 obox.floating_ip_pool = ENV.fetch('OS_FLOATING_IP_POOL', '')
346 obox.floating_ip_pool_always_allocate = (ENV['OS_FLOATING_IP_ALWAYS_ALLOCATE'] == 'true')
347 obox.image = ENV.fetch('OS_IMAGE', '')
348 obox.security_groups = [ENV.fetch('OS_SEC_GROUP', '')]
349 obox.networks = ENV.fetch('OS_NETWORK', '')
350 obox.flavor = node[:flavor]
351 obox.server_name = node[:name]
Idan Amit46123862017-09-19 13:43:32 +0300352 end
Victor Moralesd4036482017-08-15 17:54:14 -0500353
Idan Amit46123862017-09-19 13:43:32 +0300354 # Set Box type
355 nodeconfig.vm.box = box[provider]
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700356
Idan Amit46123862017-09-19 13:43:32 +0300357 # Set Node name
358 nodeconfig.vm.hostname = node[:name]
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700359
Idan Amit46123862017-09-19 13:43:32 +0300360 # Set Sync Folder
361 nodeconfig.vm.synced_folder ".", "/vagrant", disabled: true
362 nodeconfig.vm.synced_folder './opt', '/opt/', create: true
363 nodeconfig.vm.synced_folder './lib', '/var/onap/', create: true
364 if !is_windows
365 nodeconfig.vm.synced_folder '~/.m2', '/root/.m2/', create: true
366 end
Victor Morales6a919972017-09-28 18:29:54 -0700367
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700368 # Set Network
Areli Fussf57e9e72017-09-28 14:24:53 +0300369 nodeconfig.vm.network :private_network,
370 :adapter => 2,
371 :name => net_interface,
372 :ip => node[:ips][0]
373
374 nodeconfig.vm.network :private_network,
375 :adapter => 3,
376 :ip => node[:ips][1],
377 :type => :static
Idan Amit46123862017-09-19 13:43:32 +0300378
379 # Specific settings:
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700380
Victor Morales6a919972017-09-28 18:29:54 -0700381 # Set Storage (For SDC or All-in-one)
Idan Amit46123862017-09-19 13:43:32 +0300382 if node[:name].include?("all-in-one") || node[:name].include?("sdc")
383 nodeconfig.vm.provider "virtualbox" do |v|
384 unless File.exist?(sdc_volume)
385 v.customize ['createhd', '--filename', sdc_volume, '--size', 20 * 1024]
386 end
387 v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', sdc_volume]
388 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700389
Idan Amit46123862017-09-19 13:43:32 +0300390 nodeconfig.vm.provider "libvirt" do |v|
391 v.storage :file, path: sdc_volume, bus: 'sata', device: 'vdb', size: '2G'
392 end
393 end
Areli Fussf57e9e72017-09-28 14:24:53 +0300394
Idan Amit46123862017-09-19 13:43:32 +0300395 if node[:name].include? "testing"
396 nodeconfig.vm.synced_folder './tests', '/var/onap_tests/', create: true
397 test_suite = ENV.fetch('TEST_SUITE', '*')
398 test_case = ENV.fetch('TEST_CASE', '*')
399 # Override variables
400 run_path = 'vagrant_utils/unit_testing.sh'
401 node[:args] = [test_suite, test_case]
Victor Morales6a919972017-09-28 18:29:54 -0700402 else
403 configuration['skip_get_images'] = ENV.fetch('SKIP_GET_IMAGES', configuration['skip_get_images'])
404 configuration['skip_install'] = ENV.fetch('SKIP_INSTALL', configuration['skip_install'])
Idan Amit46123862017-09-19 13:43:32 +0300405 end
406
Idan Amit46123862017-09-19 13:43:32 +0300407 if node[:name].include? "vfc"
408 nodeconfig.vm.provision 'docker'
409 end
410
411 nodeconfig.vm.provision 'shell' do |s|
412 s.path = run_path
413 s.args = node[:args]
414 s.env = configuration
415 end
416
417 end #nodeconfig
418 end #node
419end #config