Add Istio to vm and pod11 sites
[icn.git] / Vagrantfile
index 8ab75ed..ea8593d 100644 (file)
@@ -11,13 +11,14 @@ require 'yaml'
 # by vagrant from the jump machine definition) is up.
 
 site = ENV['ICN_SITE'] || 'vm'
+with_jenkins = ENV['WITH_JENKINS'] || false
 
 # Calculate the baremetal network address from the bmcAddress (aka
 # IPMI address) specified in the machine pool values.  IPMI in the
 # virtual environment is emulated by virtualbmc listening on the host.
 baremetal_cidr = nil
 registry_mirrors = nil
-Dir.glob("deploy/site/#{site}/*.yaml") do |file|
+Dir.glob("deploy/site/#{site}/deployment/*.yaml") do |file|
   YAML.load_stream(File.read(file)) do |document|
     values = document.fetch('spec', {}).fetch('values', {})
     unless values['bmcAddress'].nil?
@@ -33,6 +34,7 @@ if baremetal_cidr.nil?
   puts "Missing bmcAddress value in site definition, can't determine baremetal network address"
   exit 1
 end
+baremetal_gw = IPAddr.new(baremetal_cidr).succ
 
 $post_up_message = <<MSG
 ------------------------------------------------------
@@ -65,13 +67,19 @@ Vagrant.configure("2") do |config|
     # Note the apparent typo in the name below, it is correct as-is
     m.vm.box = 'intergratedcloudnative/ubuntu2004'
     m.vm.hostname = 'jump'
-    m.vm.synced_folder '.', '/icn'
+    m.vm.synced_folder '.', '/icn', type: 'nfs'
     m.vm.provider :libvirt do |libvirt|
       libvirt.graphics_ip = '0.0.0.0'
       libvirt.default_prefix = "#{site}-"
       libvirt.cpu_mode = 'host-passthrough'
-      libvirt.cpus = 8
-      libvirt.memory = 24576
+      if with_jenkins
+        # With Jenkins and nested VMs increase cpus, memory
+        libvirt.cpus = 32
+        libvirt.memory = 65536
+      else
+        libvirt.cpus = 8
+        libvirt.memory = 24576
+      end
       libvirt.nested = true
 
       # The ICN baremetal network is the vagrant management network,
@@ -95,14 +103,14 @@ Vagrant.configure("2") do |config|
                  :libvirt__network_name => "#{site}-provisioning",
                  :type => 'dhcp'
 
-    # IPMI control of machines is provided by vbmc on the host
+    # BMC control of machines is provided by sushy-emulator on the host
     m.trigger.after [:up] do |trigger|
-      trigger.name = 'Starting virtualbmc for IPMI network'
-      trigger.run = {inline: "./tools/vagrant/start_vbmc.sh"}
+      trigger.name = 'Starting sushy for BMC network'
+      trigger.run = {inline: "./tools/vagrant/start_sushy.sh #{baremetal_gw}"}
     end
     m.trigger.after [:destroy] do |trigger|
-      trigger.name = 'Stopping virtualbmc for IPMI network'
-      trigger.run = {inline: "./tools/vagrant/stop_vbmc.sh"}
+      trigger.name = 'Stopping sushy for BMC network'
+      trigger.run = {inline: "./tools/vagrant/stop_sushy.sh #{baremetal_gw}"}
     end
 
     m.trigger.after [:up] do |trigger|
@@ -114,22 +122,29 @@ Vagrant.configure("2") do |config|
       DEBIAN_FRONTEND=noninteractive apt-get install -y make
     SHELL
     m.vm.post_up_message = $post_up_message
+
+    if with_jenkins
+      # Set up a port forward for an instance of Jenkins
+      m.vm.network "forwarded_port", guest: 8080, host: 8080
+    end
   end
 
   # Look for any HelmReleases in the site directory with machineName in
   # the values dictionary.  This will provide the values needed to
   # create the machine pool.
   legacy_machine_args = ""
-  Dir.glob("deploy/site/#{site}/*.yaml") do |file|
+  Dir.glob("deploy/site/#{site}/deployment/*.yaml") do |file|
     YAML.load_stream(File.read(file)) do |document|
       values = document.fetch('spec', {}).fetch('values', {})
       next if values['machineName'].nil? || values['bootMACAddress'].nil?
       machine_name = values['machineName']
       boot_mac_address = values['bootMACAddress']
       bmc_port = URI.parse(values['bmcAddress']).port
+      uuid = URI.parse(values['bmcAddress']).path.split('/').last
       config.vm.define machine_name do |m|
         m.vm.hostname = machine_name
         m.vm.provider :libvirt do |libvirt|
+          libvirt.uuid = "#{uuid}"
           libvirt.graphics_ip = '0.0.0.0'
           libvirt.default_prefix = "#{site}-"
           libvirt.cpu_mode = 'host-passthrough'
@@ -153,27 +168,6 @@ Vagrant.configure("2") do |config|
         m.vm.network :private_network,
                      :libvirt__network_name => "#{site}-baremetal",
                      :type => 'dhcp'
-
-        # IPMI control
-        m.trigger.after [:up] do |trigger|
-          trigger.name = 'Adding machine to IPMI network'
-          trigger.run = {inline: "./tools/vagrant/add_machine_to_vbmc.sh #{site} #{machine_name} #{bmc_port}"}
-        end
-        m.trigger.after [:destroy] do |trigger|
-          trigger.name = 'Removing machine from IPMI network'
-          trigger.run = {inline: "./tools/vagrant/remove_machine_from_vbmc.sh #{site} #{machine_name} #{bmc_port}"}
-        end
-
-        # Create configuration for ICN provisioning
-        legacy_machine_args = "#{legacy_machine_args} #{machine_name} #{bmc_port}"
-        m.trigger.after [:up] do |trigger|
-          trigger.info = 'Creating nodes.json.sample describing the machines'
-          trigger.run = {inline: "./tools/vagrant/create_nodes_json_sample.sh #{site} #{legacy_machine_args}"}
-        end
-        m.trigger.after [:up] do |trigger|
-          trigger.info = 'Creating Provisioning resource describing the cluster'
-          trigger.run = {inline: "./tools/vagrant/create_provisioning_cr.sh #{site} #{legacy_machine_args}"}
-        end
       end
     end
   end