blob: a0f3a192651b9f0d3108a6ea0083d4bb265946bb [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
Victor Morales7abf1a82017-11-06 09:20:27 -080026 'debug' => 'True',
Victor Morales6a919972017-09-28 18:29:54 -070027 'build_image' => 'True',
Idan Amit1690e082017-08-20 08:58:14 +030028 'clone_repo' => 'True',
Victor Morales2909e2e2017-08-08 15:51:52 -050029 'compile_repo' => 'False',
Victor Morales6a919972017-09-28 18:29:54 -070030 'enable_oparent' => 'True',
31 'skip_get_images' => 'False',
32 'skip_install' => 'True'
Victor Morales89ce3212017-06-16 18:32:48 -050033}
34
Idan Amit46123862017-09-19 13:43:32 +030035box = {
36 :virtualbox => 'ubuntu/trusty64',
37 :libvirt => 'sputnik13/trusty64',
38 :openstack => nil
39}
40
Idan Amit46123862017-09-19 13:43:32 +030041nodes = [
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070042 {
Idan Amit46123862017-09-19 13:43:32 +030043 :name => "aai",
44 :ips => ['10.252.0.6', "192.168.50.6"],
45 :macs => [],
46 :cpus => 2,
47 :cpu => "50",
48 :ram => 4 * 1024,
49 :groups => ["individual"],
50 :args => ["aai"]
51 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070052 {
Idan Amit46123862017-09-19 13:43:32 +030053 :name => "all-in-one",
Victor Morales071b81c2017-11-07 14:13:07 -080054 :ips => ['10.252.1.3', "192.168.51.3"],
Idan Amit46123862017-09-19 13:43:32 +030055 :macs => [],
56 :cpus => 2,
57 :cpu => "50",
58 :ram => 12 * 1024,
59 :groups => ["all-in-one"],
60 :flavor => 'm1.xlarge',
61 :args => ['mr', 'sdc', 'aai', 'mso', 'robot', 'vid', 'sdnc', 'portal', 'dcae', 'policy', 'appc', 'vfc', 'ccsdk'],
62 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070063 {
Idan Amit46123862017-09-19 13:43:32 +030064 :name => "appc",
65 :ips => ['10.252.0.14', "192.168.50.14"],
66 :macs => [],
67 :cpus => 2,
68 :cpu => "50",
69 :ram => 4 * 1024,
70 :groups => ["individual"],
71 :args => ["appc"],
72 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070073 {
Idan Amit46123862017-09-19 13:43:32 +030074 :name => "ccsdk",
75 :ips => ['10.252.0.14', "192.168.50.17"],
76 :macs => [],
77 :cpus => 2,
78 :cpu => "50",
79 :ram => 4 * 1024,
80 :groups => ["individual"],
81 :args => ["ccsdk"],
82 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070083 {
Idan Amit46123862017-09-19 13:43:32 +030084 :name => "dcae",
85 :ips => ['10.252.0.12', "192.168.50.12"],
86 :macs => [],
87 :cpus => 2,
88 :cpu => "50",
89 :ram => 4 * 1024,
90 :groups => ["individual"],
91 :args => ["dcae"],
92 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070093 {
Idan Amit46123862017-09-19 13:43:32 +030094 :name => "dns",
95 :ips => ['10.252.0.3', "192.168.50.3"],
96 :macs => [],
97 :cpus => 2,
98 :cpu => "50",
99 :ram => 1 * 1024,
100 :groups => ["individual"],
101 :flavor => 'm1.small',
102 :args => [" "]
103 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700104 {
Idan Amit46123862017-09-19 13:43:32 +0300105 :name => "message-router",
106 :ips => ['10.252.0.4', "192.168.50.4"],
107 :macs => [],
108 :cpus => 2,
109 :cpu => "50",
110 :ram => 4 * 1024,
111 :groups => ["individual"],
112 :args => ["mr"],
113 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700114 {
Idan Amit46123862017-09-19 13:43:32 +0300115 :name => "mso",
116 :ips => ['10.252.0.7', "192.168.50.7"],
117 :macs => [],
118 :cpus => 2,
119 :cpu => "50",
120 :ram => 4 * 1024,
121 :groups => ["individual"],
122 :args => ["mso"],
123 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700124 {
Idan Amit46123862017-09-19 13:43:32 +0300125 :name => "multicloud",
126 :ips => ['10.252.0.16', "192.168.50.16"],
127 :macs => [],
128 :cpus => 2,
129 :cpu => "50",
130 :ram => 4 * 1024,
131 :groups => ["individual"],
132 :args => ["multicloud"],
133 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700134 {
Idan Amit46123862017-09-19 13:43:32 +0300135 :name => "policy",
136 :ips => ['10.252.0.13', "192.168.50.13"],
137 :macs => [],
138 :cpus => 2,
139 :cpu => "50",
140 :ram => 4 * 1024,
141 :groups => ["individual"],
142 :args => ["policy"],
143 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700144 {
Idan Amit46123862017-09-19 13:43:32 +0300145 :name => "portal",
146 :ips => ['10.252.0.11', "192.168.50.11"],
147 :macs => [],
148 :cpus => 2,
149 :cpu => "50",
150 :ram => 4 * 1024,
151 :groups => ["individual"],
152 :args => ["portal"],
153 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700154 {
Idan Amit46123862017-09-19 13:43:32 +0300155 :name => "robot",
156 :ips => ['10.252.0.8', "192.168.50.8"],
157 :macs => [],
158 :cpus => 2,
159 :cpu => "50",
160 :ram => 4 * 1024,
161 :groups => ["individual"],
162 :args => ["robot"],
163 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700164 {
Idan Amit46123862017-09-19 13:43:32 +0300165 :name => "sdc",
166 :ips => ['10.252.0.5', "192.168.50.5"],
167 :macs => [],
168 :cpus => 2,
169 :cpu => "50",
170 :ram => 8 * 1024,
171 :groups => ["individual"],
172 :args => ["sdc"],
173 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700174 {
Idan Amit46123862017-09-19 13:43:32 +0300175 :name => "sdnc",
176 :ips => ['10.252.0.10', "192.168.50.10"],
177 :macs => [],
178 :cpus => 2,
179 :cpu => "50",
180 :ram => 4 * 1024,
181 :groups => ["individual"],
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700182 :args => ["sdnc"],
Idan Amit46123862017-09-19 13:43:32 +0300183 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700184 {
Idan Amit46123862017-09-19 13:43:32 +0300185 :name => "testing",
Victor Morales071b81c2017-11-07 14:13:07 -0800186 :ips => ['10.252.2.3', "192.168.52.3"],
Idan Amit46123862017-09-19 13:43:32 +0300187 :macs => [],
188 :cpus => 2,
189 :cpu => "50",
190 :ram => 4 * 1024,
191 :groups => ["testing"],
192 :flavor => 'm1.small',
193 :args => [""],
194 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700195 {
Idan Amit46123862017-09-19 13:43:32 +0300196 :name => "vfc",
197 :ips => ['10.252.0.15', "192.168.50.15"],
198 :macs => [],
199 :cpus => 2,
200 :cpu => "50",
201 :ram => 4 * 1024,
202 :groups => ["individual"],
203 :args => ['vfc'],
204 },
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700205 {
Idan Amit46123862017-09-19 13:43:32 +0300206 :name => "vid",
207 :ips => ['10.252.0.9', "192.168.50.9"],
208 :macs => [],
209 :cpus => 2,
210 :cpu => "50",
211 :ram => 4 * 1024,
212 :groups => ["individual"],
213 :args => ['vid'],
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700214 },
Victor Moralesd3cbcf22017-10-25 16:01:58 -0700215 {
Victor Morales071b81c2017-11-07 14:13:07 -0800216 :name => "vnfsdk",
217 :ips => ['10.252.0.18', "192.168.50.18"],
218 :macs => [],
219 :cpus => 2,
220 :cpu => "50",
221 :ram => 4 * 1024,
222 :groups => ["individual"],
223 :args => ['vnfsdk'],
Shashank Kumar Shankarf84c9a12017-10-23 11:08:31 -0700224 },
225 {
Victor Moralesd3cbcf22017-10-25 16:01:58 -0700226 :name => "vvp",
227 :ips => ['10.252.0.17', "192.168.50.17"],
228 :macs => [],
229 :cpus => 2,
230 :cpu => "50",
231 :ram => 4 * 1024,
232 :groups => ["individual"],
233 :args => ['vvp'],
Victor Morales4ab71c12017-11-08 07:28:28 -0800234 },
235 {
236 :name => "openstack",
237 :ips => ['10.252.3.3', "192.168.53.3"],
238 :macs => [],
239 :cpus => 2,
240 :cpu => "50",
241 :ram => 8 * 1024,
242 :groups => ["individual"],
243 :args => ['openstack'],
Shashank Kumar Shankarf84c9a12017-10-23 11:08:31 -0700244 }
Idan Amit46123862017-09-19 13:43:32 +0300245]
246
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700247run_path = 'vagrant_utils/postinstall.sh'
248sdc_volume = 'vol1-sdc-data.vdi'
Idan Amit46123862017-09-19 13:43:32 +0300249
Victor Moralesdd074802017-07-26 16:06:35 -0500250Vagrant.require_version ">= 1.8.6"
251
Victor Moralesdd074802017-07-26 16:06:35 -0500252# Determine the provider used
253provider = (ENV['VAGRANT_DEFAULT_PROVIDER'] || :virtualbox).to_sym
Idan Amit46123862017-09-19 13:43:32 +0300254puts "[INFO] Provider: #{provider} "
255
Victor Morales89ce3212017-06-16 18:32:48 -0500256vd_conf = ENV.fetch('VD_CONF', 'etc/settings.yaml')
257if File.exist?(vd_conf)
258 require 'yaml'
259 user_conf = YAML.load_file(vd_conf)
Idan Amit46123862017-09-19 13:43:32 +0300260 configuration.update(user_conf)
Victor Morales89ce3212017-06-16 18:32:48 -0500261end
262
Victor Morales6a919972017-09-28 18:29:54 -0700263# Set network interface
Areli Fussf57e9e72017-09-28 14:24:53 +0300264net_interface = 'vboxnet0'
Idan Amit46123862017-09-19 13:43:32 +0300265is_windows = Gem.win_platform?
266if is_windows
267 net_interface = 'VirtualBox Host-Only Ethernet Adapter #2'
Idan Amit46123862017-09-19 13:43:32 +0300268end
269puts "[INFO] Net interface: #{net_interface}"
270
271
Victor Morales6a919972017-09-28 18:29:54 -0700272# If argument is given use it. Otherwise use Env: DEPLOY_MODE else use default
Idan Amit46123862017-09-19 13:43:32 +0300273requested_machine = ARGV[1]
274
Victor Morales89ce3212017-06-16 18:32:48 -0500275deploy_mode = ENV.fetch('DEPLOY_MODE', 'individual')
Idan Amit46123862017-09-19 13:43:32 +0300276if requested_machine != nil
277 if requested_machine.include?("all-in-one") || requested_machine.include?("testing")
278 deploy_mode = requested_machine
279 end
280end
281
Victor Morales6a919972017-09-28 18:29:54 -0700282# Catch the status of all machines
Idan Amit46123862017-09-19 13:43:32 +0300283if ARGV[0] == 'status' || ARGV[0] == 'destroy'
284 deploy_mode = 'NA'
285end
286
287puts "[INFO] Deploy Mode: #{deploy_mode}"
288
Victor Morales6a919972017-09-28 18:29:54 -0700289# In case of all-in-one or testing clean the nodes list
Idan Amit46123862017-09-19 13:43:32 +0300290case deploy_mode
291 when 'all-in-one'
292 nodes.select! do |node|
293 if node[:name].include?("all-in-one")
294 true if node[:name]
295 end
296 end
297
298 when 'individual'
299 nodes.select! do |node|
300 if node[:groups][0].include?("individual")
301 true if node[:name]
Idan Amit46123862017-09-19 13:43:32 +0300302 end
303 end
304
305 when 'testing'
306 nodes.select! do |node|
307 if node[:name].include?("testing")
308 true if node[:name]
309 end
310 end
311end
Victor Morales89ce3212017-06-16 18:32:48 -0500312
313Vagrant.configure("2") do |config|
314
Idan Amit46123862017-09-19 13:43:32 +0300315 # PROXY definitions
316 if ENV['http_proxy'] != nil and ENV['https_proxy'] != nil and ENV['no_proxy'] != nil
317 if not Vagrant.has_plugin?('vagrant-proxyconf')
318 system 'vagrant plugin install vagrant-proxyconf'
319 raise 'vagrant-proxyconf was installed but it requires to execute again'
320 end
321 config.proxy.http = ENV['http_proxy']
322 config.proxy.https = ENV['https_proxy']
323 config.proxy.no_proxy = ENV['no_proxy']
Victor Moralescf269992017-10-18 09:29:55 -0700324 configuration['socks_proxy'] = ENV['socks_proxy']
Victor Morales89ce3212017-06-16 18:32:48 -0500325 end
Victor Morales89ce3212017-06-16 18:32:48 -0500326
Idan Amit46123862017-09-19 13:43:32 +0300327 if Vagrant.has_plugin?('vagrant-vbguest')
328 puts 'vagrant-vbguest auto_update feature will be disable to avoid sharing conflicts'
329 config.vbguest.auto_update = false
Victor Moralesf62e7b82017-07-27 17:26:06 -0500330 end
Idan Amit46123862017-09-19 13:43:32 +0300331
332 if provider == :libvirt
333 if not Vagrant.has_plugin?('vagrant-libvirt')
334 system 'vagrant plugin install vagrant-libvirt'
335 raise 'vagrant-libvirt was installed but it requires to execute again'
336 end
Victor Moralesdd074802017-07-26 16:06:35 -0500337 end
Areli Fussf57e9e72017-09-28 14:24:53 +0300338
Idan Amit46123862017-09-19 13:43:32 +0300339 if provider == :openstack
340 config.ssh.username = 'ubuntu'
341 if not Vagrant.has_plugin?('vagrant-openstack-provider')
342 system 'vagrant plugin install vagrant-openstack-provider'
343 raise 'vagrant-openstack-provider was installed but it requires to execute again'
344 end
345 end
Victor Morales89ce3212017-06-16 18:32:48 -0500346
Idan Amit46123862017-09-19 13:43:32 +0300347 nodes.each do |node|
348 config.vm.define node[:name] do |nodeconfig|
Victor Moralesdd074802017-07-26 16:06:35 -0500349
Idan Amit46123862017-09-19 13:43:32 +0300350 # Common Settings:
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700351
Idan Amit46123862017-09-19 13:43:32 +0300352 nodeconfig.vm.provider "virtualbox" do |vbox|
353 vbox.customize ['modifyvm', :id, '--nictype1', 'virtio']
354 vbox.customize ['modifyvm', :id, '--audio', 'none']
355 vbox.customize ['modifyvm', :id, '--vram', '1']
356 vbox.customize ['modifyvm', :id, "--cpuhotplug", "off"]
357 vbox.customize ['modifyvm', :id, "--cpuexecutioncap", node[:cpu]]
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700358 vbox.customize ['modifyvm', :id, "--cpus", node[:cpus]]
Idan Amit46123862017-09-19 13:43:32 +0300359 vbox.customize ["modifyvm", :id, "--memory", node[:ram]]
Victor Morales89ce3212017-06-16 18:32:48 -0500360 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700361
Idan Amit46123862017-09-19 13:43:32 +0300362 nodeconfig.vm.provider "libvirt" do |lbox|
363 lbox.memory = node[:ram]
364 lbox.nested = true
Victor Morales89ce3212017-06-16 18:32:48 -0500365 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700366
Idan Amit46123862017-09-19 13:43:32 +0300367 nodeconfig.vm.provider :openstack do |obox|
368 obox.openstack_auth_url = ENV.fetch('OS_AUTH_URL', '')
369 obox.tenant_name = ENV.fetch('OS_TENANT_NAME', '')
370 obox.username = ENV.fetch('OS_USERNAME', '')
371 obox.password = ENV.fetch('OS_PASSWORD', '')
372 obox.region = ENV.fetch('OS_REGION_NAME', '')
373 obox.identity_api_version = ENV.fetch('OS_IDENTITY_API_VERSION', '')
374 obox.domain_name = ENV.fetch('OS_PROJECT_DOMAIN_ID', '')
375 obox.project_name = ENV.fetch('OS_PROJECT_NAME', '')
376 obox.floating_ip_pool = ENV.fetch('OS_FLOATING_IP_POOL', '')
377 obox.floating_ip_pool_always_allocate = (ENV['OS_FLOATING_IP_ALWAYS_ALLOCATE'] == 'true')
378 obox.image = ENV.fetch('OS_IMAGE', '')
379 obox.security_groups = [ENV.fetch('OS_SEC_GROUP', '')]
380 obox.networks = ENV.fetch('OS_NETWORK', '')
381 obox.flavor = node[:flavor]
382 obox.server_name = node[:name]
Idan Amit46123862017-09-19 13:43:32 +0300383 end
Victor Moralesd4036482017-08-15 17:54:14 -0500384
Idan Amit46123862017-09-19 13:43:32 +0300385 # Set Box type
386 nodeconfig.vm.box = box[provider]
Victor Morales4ab71c12017-11-08 07:28:28 -0800387 if "openstack" == node[:name]
388 nodeconfig.vm.box = "ubuntu/xenial64"
389 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700390
Idan Amit46123862017-09-19 13:43:32 +0300391 # Set Node name
392 nodeconfig.vm.hostname = node[:name]
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700393
Idan Amit46123862017-09-19 13:43:32 +0300394 # Set Sync Folder
395 nodeconfig.vm.synced_folder ".", "/vagrant", disabled: true
396 nodeconfig.vm.synced_folder './opt', '/opt/', create: true
397 nodeconfig.vm.synced_folder './lib', '/var/onap/', create: true
398 if !is_windows
399 nodeconfig.vm.synced_folder '~/.m2', '/root/.m2/', create: true
400 end
Victor Morales6a919972017-09-28 18:29:54 -0700401
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700402 # Set Network
Areli Fussf57e9e72017-09-28 14:24:53 +0300403 nodeconfig.vm.network :private_network,
404 :adapter => 2,
405 :name => net_interface,
406 :ip => node[:ips][0]
407
408 nodeconfig.vm.network :private_network,
409 :adapter => 3,
410 :ip => node[:ips][1],
411 :type => :static
Idan Amit46123862017-09-19 13:43:32 +0300412
413 # Specific settings:
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700414
Victor Morales6a919972017-09-28 18:29:54 -0700415 # Set Storage (For SDC or All-in-one)
Idan Amit46123862017-09-19 13:43:32 +0300416 if node[:name].include?("all-in-one") || node[:name].include?("sdc")
417 nodeconfig.vm.provider "virtualbox" do |v|
418 unless File.exist?(sdc_volume)
419 v.customize ['createhd', '--filename', sdc_volume, '--size', 20 * 1024]
420 end
421 v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', sdc_volume]
422 end
Victor Moralesdbe2e0b2017-09-20 09:55:45 -0700423
Idan Amit46123862017-09-19 13:43:32 +0300424 nodeconfig.vm.provider "libvirt" do |v|
425 v.storage :file, path: sdc_volume, bus: 'sata', device: 'vdb', size: '2G'
426 end
427 end
Areli Fussf57e9e72017-09-28 14:24:53 +0300428
Idan Amit46123862017-09-19 13:43:32 +0300429 if node[:name].include? "testing"
430 nodeconfig.vm.synced_folder './tests', '/var/onap_tests/', create: true
431 test_suite = ENV.fetch('TEST_SUITE', '*')
432 test_case = ENV.fetch('TEST_CASE', '*')
433 # Override variables
434 run_path = 'vagrant_utils/unit_testing.sh'
435 node[:args] = [test_suite, test_case]
Victor Morales6a919972017-09-28 18:29:54 -0700436 else
437 configuration['skip_get_images'] = ENV.fetch('SKIP_GET_IMAGES', configuration['skip_get_images'])
438 configuration['skip_install'] = ENV.fetch('SKIP_INSTALL', configuration['skip_install'])
Idan Amit46123862017-09-19 13:43:32 +0300439 end
440
Idan Amit46123862017-09-19 13:43:32 +0300441 if node[:name].include? "vfc"
442 nodeconfig.vm.provision 'docker'
443 end
444
445 nodeconfig.vm.provision 'shell' do |s|
446 s.path = run_path
447 s.args = node[:args]
448 s.env = configuration
449 end
450
451 end #nodeconfig
452 end #node
453end #config