mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
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:
committed by
Michal Skalski
parent
6c5680ab17
commit
8ef6df014d
@@ -105,7 +105,7 @@ module VagrantPlugins
|
||||
b3.use ForwardPorts
|
||||
b3.use PrepareNFSSettings
|
||||
b3.use ShareFolders
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user