Update CI scripts for CAPI changes
[icn.git] / Vagrantfile
index 656c25c..bd770f7 100644 (file)
@@ -11,17 +11,23 @@ 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|
   YAML.load_stream(File.read(file)) do |document|
     values = document.fetch('spec', {}).fetch('values', {})
-    next if values['machineName'].nil? || values['bootMACAddress'].nil?
-    bmc_host = URI.parse(values['bmcAddress']).host
-    baremetal_cidr = "#{IPAddr.new(bmc_host).mask(24)}/24"
+    unless values['bmcAddress'].nil?
+      bmc_host = URI.parse(values['bmcAddress']).host
+      baremetal_cidr = "#{IPAddr.new(bmc_host).mask(24)}/24"
+    end
+    unless values['dockerRegistryMirrors'].nil?
+      registry_mirrors = values['dockerRegistryMirrors'].join(' ')
+    end
   end
 end
 if baremetal_cidr.nil?
@@ -65,8 +71,14 @@ Vagrant.configure("2") do |config|
       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,
@@ -102,13 +114,18 @@ Vagrant.configure("2") do |config|
 
     m.trigger.after [:up] do |trigger|
       trigger.name = 'Creating ICN user_config.sh'
-      trigger.run = {inline: "./tools/vagrant/create_user_config.sh"}
+      trigger.run = {inline: "bash -c 'DOCKER_REGISTRY_MIRRORS=\"#{registry_mirrors}\" ./tools/vagrant/create_user_config.sh'"}
     end
     m.vm.provision 'Configuring ICN prerequisites', type: 'shell', privileged: true, inline: <<-SHELL
       ssh-keygen -f "${HOME}/.ssh/id_rsa" -P "" <<<y
       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