X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=Vagrantfile;h=6d60f7d5e309473a3c3c2f5996e8107e3bfa4132;hb=refs%2Fchanges%2F07%2F4807%2F1;hp=656c25cac52c7e703b3864a3f002dd876ea1aeb6;hpb=7d9a147be328eb6fa90d64ef845635d506601d12;p=icn.git diff --git a/Vagrantfile b/Vagrantfile index 656c25c..6d60f7d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,23 +11,57 @@ 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 -Dir.glob("deploy/site/#{site}/*.yaml") do |file| +baremetal4_gw = '192.168.151.1' +baremetal4_netmask = '255.255.255.0' +baremetal6_gw = nil +baremetal6_prefix = nil +bmc_host = '192.168.121.1' # From the default vagrant-libvirt network +registry_mirrors = nil +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? - bmc_host = URI.parse(values['bmcAddress']).host - baremetal_cidr = "#{IPAddr.new(bmc_host).mask(24)}/24" + unless values['networkData'].nil? or values['networkData']['networks'].nil? + networks = values['networkData']['networks'] + unless networks['ipv4'].nil? + networks['ipv4'].select {|name,network| network.fetch('link', name) == 'baremetal'}.each_value do |network| + if network.key?('gateway') + baremetal4_gw = network['gateway'] + elsif network.key?('fromIPPool') + pool = network['fromIPPool'] + if values['ipPools']["#{pool}"].key?('gateway') + baremetal4_gw = values['ipPools']["#{pool}"]['gateway'] + end + end + end + end + unless networks['ipv6'].nil? + networks['ipv6'].select {|name,network| network.fetch('link', name) == 'baremetal'}.each_value do |network| + if network.key?('gateway') + baremetal6_gw = network['gateway'] + baremetal6_prefix = 64 + elsif network.key?('fromIPPool') + pool = network['fromIPPool'] + if values['ipPools']["#{pool}"].key?('gateway') + baremetal6_gw = values['ipPools']["#{pool}"]['gateway'] + baremetal6_prefix = 64 + end + end + end + end + end + unless values['bmcAddress'].nil? + bmc_host = URI.parse(values['bmcAddress']).host + end + unless values['dockerRegistryMirrors'].nil? + registry_mirrors = values['dockerRegistryMirrors'].join(' ') + end end end -if baremetal_cidr.nil? - puts "Missing bmcAddress value in site definition, can't determine baremetal network address" - exit 1 -end $post_up_message = < "#{site}-baremetal", + :type => 'dhcp' # The ICN provisioning network will be a vagrant private network # created upon bringing up the jump machine @@ -90,41 +138,55 @@ 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 #{bmc_host}"} 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 #{bmc_host}"} end 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 "" << "#{site}-provisioning", :mac => boot_mac_address, :type => 'dhcp' - 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}"} + if baremetal_mac_address.nil? + m.vm.network :private_network, + :libvirt__network_name => "#{site}-baremetal", + :type => 'dhcp' + else + m.vm.network :private_network, + :libvirt__network_name => "#{site}-baremetal", + :mac => baremetal_mac_address, + :type => 'dhcp' end end end