[DRE-commits] [vagrant-libvirt] 72/104: MAC address can be specified on all network interfaces.
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Apr 24 13:55:47 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag 0.0.11
in repository vagrant-libvirt.
commit 3bcf9496de420f5865a27dd3bcd7d91607f2ca66
Author: Jevgeni Kiski <jevgeni.kiski at skype.net>
Date: Tue Sep 17 00:23:24 2013 +0300
MAC address can be specified on all network interfaces.
---
README.md | 8 +++++---
lib/vagrant-libvirt/action/create_network_interfaces.rb | 5 ++++-
lib/vagrant-libvirt/templates/interface.xml.erb | 4 ++--
lib/vagrant-libvirt/templates/public_interface.xml.erb | 3 +++
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index b71fe1c..f48007a 100644
--- a/README.md
+++ b/README.md
@@ -167,12 +167,12 @@ An examples of network interface definitions:
```ruby
# Private network
config.vm.define :test_vm1 do |test_vm1|
- test_vm1.vm.network :private_network, :ip => "10.20.30.40",
+ test_vm1.vm.network :private_network, :ip => "10.20.30.40"
end
# Public Network
config.vm.define :test_vm1 do |test_vm1|
- test_vm1.vm.network :public_network, :dev => "eth0", :mode => 'bridge', :mac => '92-c6-8f-94-b5-8d'
+ test_vm1.vm.network :public_network, :dev => "eth0", :mode => 'bridge'
end
```
@@ -191,7 +191,7 @@ The second interface is created and bridged into the physical device 'eth0'.
This mechanism uses the macvtap Kernel driver and therefore does not require
an existing bridge device. This configuration assumes that DHCP and DNS services
are being provided by the public network. This public interface should be reachable
-by anyone with access to the public network. If `:mac` is not defined it will be generated.
+by anyone with access to the public network.
### Private Network Options
@@ -217,12 +217,14 @@ starts with 'libvirt__' string. Here is a list of those options:
* `:libvirt__forward_device` - Name of interface/device, where network should
be forwarded (NATed or routed). Used only when creating new network. By
default, all physical interfaces are used.
+* `:mac` - MAC address for the interface.
### Public Network Options
* `:dev` - Physical device that the public interface should use. Default is 'eth0'
* `:mode` - The mode in which the public interface should operate in. Supported
modes are available from the [libvirt documentation](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
Default mode is 'bridge'.
+* `:mac` - MAC address for the interface.
## Obtaining Domain IP Address
diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb
index 87eb6b8..1f69f51 100644
--- a/lib/vagrant-libvirt/action/create_network_interfaces.rb
+++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -65,6 +65,7 @@ module VagrantPlugins
adapters.each_with_index do |iface_configuration, slot_number|
@iface_number = slot_number
@network_name = iface_configuration[:network_name]
+ @mac = iface_configuration.fetch(:mac, false)
template_name = 'interface'
# Configuration for public interfaces which use the macvtap driver
@@ -72,12 +73,14 @@ module VagrantPlugins
template_name = 'public_interface'
@device = iface_configuration.fetch(:dev, 'eth0')
@mode = iface_configuration.fetch(:mode, 'bridge')
- @mac = iface_configuration.fetch(:mac, false)
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
end
message = "Creating network interface eth#{@iface_number}"
message << " connected to network #{@network_name}."
+ if @mac
+ message << "Using MAC address: #{@mac}"
+ end
@logger.info(message)
begin
diff --git a/lib/vagrant-libvirt/templates/interface.xml.erb b/lib/vagrant-libvirt/templates/interface.xml.erb
index 4e203b0..616c9a4 100644
--- a/lib/vagrant-libvirt/templates/interface.xml.erb
+++ b/lib/vagrant-libvirt/templates/interface.xml.erb
@@ -1,8 +1,8 @@
<interface type='network'>
<source network='<%= @network_name %>'/>
- <% if @mac %>
+ <% if @mac %>
<mac address='<%= @mac %>'/>
- <% end %>
+ <% end %>
<target dev='vnet<%= @iface_number %>'/>
<alias name='net<%= @iface_number %>'/>
<model type='virtio'/>
diff --git a/lib/vagrant-libvirt/templates/public_interface.xml.erb b/lib/vagrant-libvirt/templates/public_interface.xml.erb
index fe5d65e..d4a7fbf 100644
--- a/lib/vagrant-libvirt/templates/public_interface.xml.erb
+++ b/lib/vagrant-libvirt/templates/public_interface.xml.erb
@@ -1,4 +1,7 @@
<interface type='direct'>
+ <% if @mac %>
+ <mac address='<%= @mac %>'/>
+ <% end %>
<source dev='<%= @device %>' mode='<%= @mode %>'/>
</interface>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git
More information about the Pkg-ruby-extras-commits
mailing list