Make mgmt network detachable from no box VMs

Pxe nodes are not provisioned, mgmt network is not required for them.
Provide new domain option 'mgmt_attach' which one can use to remove mgmt
interface from VM. Default behaviour is not changed.
Also take into account bridge interfaces when set boot order, to support
scenario when we would like to use vagrant VM to pxe boot physical nodes
in existing network.
This commit is contained in:
Michal Skalski
2016-12-13 15:36:05 +01:00
committed by Michal Skalski
parent 6c5680ab17
commit 8ef6df014d
7 changed files with 36 additions and 6 deletions

View File

@@ -105,7 +105,7 @@ module VagrantPlugins
b3.use ForwardPorts
b3.use PrepareNFSSettings
b3.use ShareFolders
end
end
end
end
end

View File

@@ -86,7 +86,7 @@ module VagrantPlugins
def search_network(nets, xml)
str = '/domain/devices/interface'
str += "[(@type='network' or @type='udp')"
str += "[(@type='network' or @type='udp' or @type='bridge')"
unless nets.empty?
str += " and source[@network='#{nets.first['network']}']"
end

View File

@@ -128,6 +128,9 @@ module VagrantPlugins
# Autostart
attr_accessor :autostart
# Attach mgmt network
attr_accessor :mgmt_attach
def initialize
@uri = UNSET_VALUE
@driver = UNSET_VALUE
@@ -212,6 +215,9 @@ module VagrantPlugins
# Autostart
@autostart = UNSET_VALUE
# Attach mgmt network
@mgmt_attach = UNSET_VALUE
end
def boot(device)
@@ -577,6 +583,9 @@ module VagrantPlugins
# Autostart
@autostart = false if @autostart == UNSET_VALUE
# Attach mgmt network
@mgmt_attach = true if @mgmt_attach == UNSET_VALUE
end
def validate(machine)

View File

@@ -108,6 +108,10 @@ module VagrantPlugins
error_key(:tunnel_port_not_defined)
end
class ManagementNetworkRequired < VagrantLibvirtError
error_key(:management_network_required)
end
# Other exceptions
class InterfaceSlotNotAvailable < VagrantLibvirtError
error_key(:interface_slot_not_available)

View File

@@ -44,8 +44,18 @@ module VagrantPlugins
management_network_options[:mac] = management_network_mac
end
if (env[:machine].config.vm.box &&
!env[:machine].provider_config.mgmt_attach)
raise Errors::ManagementNetworkRequired
end
# add management network to list of networks to check
networks = [management_network_options]
# unless mgmt_attach set to false
networks = if env[:machine].provider_config.mgmt_attach
[management_network_options]
else
[]
end
env[:machine].config.vm.networks.each do |type, original_options|
logger.debug "In config found network type #{type} options #{original_options}"