lib/vagrant-qienv/config/config_network.rb
# Configure the network section of a virtual machine. You can set the type of
# the network, the ip address if needed and a list of forwarded ports.
# Params:
# +instance+: The instance of the VM to configure
# +vm_config+: the definition of the VM. There are to type of networks: private
# - where the IP setting is available, and public - where virtualbox will set
# the interface as an external NIC.
Configure the network section of a virtual machine. You can set the type of
the network, the ip address if needed and a list of forwarded ports.
Params:
+instance+: The instance of the VM to configure
+vm_config+: the definition of the VM. There are to type of networks: private
where the IP setting is available, and public - where virtualbox will set
the interface as an external NIC.
Configure the network section of a virtual machine . You can set the type of the network the ip address if needed and a list of forwarded ports . Params : + instance + : The instance of the VM to configure + vm_config + : the definition of the VM . There are to type of networks : private where the IP setting is available and public - where virtualbox will set the interface as an external NIC .
def config_network(instance, vm_config)
  vm_config["networks"].each do |network, config|
    if config["type"] == "private" then
      if config["ip"] then
        instance.vm.network :private_network, ip: config["ip"]
      end
    elsif config["type"] == "public" then
      instance.vm.network :public_network
    end
  end if vm_config["networks"]
  vm_config["ports"].each do |port, config|
    raise "At least the guest port is needed in 'guest_port' variable" \
      if config["guest_port"].nil?
    instance.vm.network "forwarded_port",
      guest: config["guest_port"],
      host: config["host_port"] || config["guest_port"],
      protocol: config["protocol"] || "tcp",
      auto_correct: config["auto_correct"] || true
  end if vm_config["ports"]
end
def config_network ( instance , vm_config ) vm_config [ "networks" ] . each do | network , config | if config [ "type" ] == "private" then if config [ "ip" ] then instance . vm . network :private_network , ip : config [ "ip" ] end elsif config [ "type" ] == "public" then instance . vm . network :public_network end end if vm_config [ "networks" ] vm_config [ "ports" ] . each do | port , config | raise "At least the guest port is needed in 'guest_port' variable" if config [ "guest_port" ] . nil? instance . vm . network "forwarded_port" , guest : config [ "guest_port" ] , host : config [ "host_port" ] || config [ "guest_port" ] , protocol : config [ "protocol" ] || "tcp" , auto_correct : config [ "auto_correct" ] || true end if vm_config [ "ports" ] end
Configure the network section of a virtual machine.
Configure the network section of a virtual machine .
instance
vm_config