Darryl L. Pierce
2008-Oct-15 20:45 UTC
[Ovirt-devel] [PATCH server] This patch hardcodes support for ovirtbr0 bridge.
Currently the node configuration has no explicit way of configuring a bridged interface. This patch provides a hardcoded bridge and associates each nic with it Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- src/host-browser/host-browser.rb | 2 +- src/lib/managed_node_configuration.rb | 22 ++++++++++++-- .../functional/managed_node_configuration_test.rb | 30 ++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/host-browser/host-browser.rb b/src/host-browser/host-browser.rb index 79d34e8..d228a59 100755 --- a/src/host-browser/host-browser.rb +++ b/src/host-browser/host-browser.rb @@ -302,7 +302,7 @@ class HostBrowser end # iterate over any nics left and create new records for them. - boot_type = BootType.find_by_proto('dhcp') + boot_type = BootType.find_by_proto('static') nic_info.collect do |nic| puts "Creating a new nic..." diff --git a/src/lib/managed_node_configuration.rb b/src/lib/managed_node_configuration.rb index 4ade235..93f8448 100644 --- a/src/lib/managed_node_configuration.rb +++ b/src/lib/managed_node_configuration.rb @@ -59,10 +59,19 @@ class ManagedNodeConfiguration end end + has_bridge = false host.nics.each do |nic| # only process this nic if it doesn't have a bonding + # TODO remove the hack to force a bridge into the picture if nic.bonding.empty? - process_nic result, nic, macs + process_nic result, nic, macs, nil, false, true + + # TODO remove this when bridges are properly supported + unless has_bridge + macs[nic.mac] = "ovirtbr0" + process_nic result, nic, macs, nil, true, false + has_bridge = true + end end end @@ -74,7 +83,7 @@ class ManagedNodeConfiguration private - def self.process_nic(result, nic, macs, bonding = nil) + def self.process_nic(result, nic, macs, bonding = nil, is_bridge = false, bridged = true) iface_name = macs[nic.mac] if iface_name @@ -92,9 +101,16 @@ class ManagedNodeConfiguration result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/NETMASK #{nic.netmask}" result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/BROADCAST #{nic.broadcast}" end + + if bridged + result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/BRIDGE ovirtbr0" + elsif is_bridge + result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/TYPE bridge" + result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/PEERNTP yes" + result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/DELAY 0" + end end - result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/BRIDGE #{nic.bridge}" if nic.bridge result.puts "set #{NIC_ENTRY_PREFIX}/ifcfg-#{iface_name}/ONBOOT yes" end end diff --git a/src/test/functional/managed_node_configuration_test.rb b/src/test/functional/managed_node_configuration_test.rb index b5a7ec5..d0d8aa3 100644 --- a/src/test/functional/managed_node_configuration_test.rb +++ b/src/test/functional/managed_node_configuration_test.rb @@ -50,7 +50,15 @@ cat <<\EOF > /var/tmp/node-augtool rm /files/etc/sysconfig/network-scripts/ifcfg-eth0 set /files/etc/sysconfig/network-scripts/ifcfg-eth0/DEVICE eth0 set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BOOTPROTO #{nic.boot_type.proto} +set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BRIDGE ovirtbr0 set /files/etc/sysconfig/network-scripts/ifcfg-eth0/ONBOOT yes +rm /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/DEVICE ovirtbr0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/BOOTPROTO #{nic.boot_type.proto} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/TYPE bridge +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/PEERNTP yes +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/DELAY 0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/ONBOOT yes save EOF HERE @@ -80,6 +88,16 @@ set /files/etc/sysconfig/network-scripts/ifcfg-eth0/NETMASK #{nic.netmask} set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BROADCAST #{nic.broadcast} set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BRIDGE ovirtbr0 set /files/etc/sysconfig/network-scripts/ifcfg-eth0/ONBOOT yes +rm /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/DEVICE ovirtbr0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/BOOTPROTO #{nic.boot_type.proto} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/IPADDR #{nic.ip_addr} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/NETMASK #{nic.netmask} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/BROADCAST #{nic.broadcast} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/TYPE bridge +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/PEERNTP yes +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/DELAY 0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/ONBOOT yes save EOF HERE @@ -108,10 +126,22 @@ set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BOOTPROTO #{nic1.boot_type.p set /files/etc/sysconfig/network-scripts/ifcfg-eth0/IPADDR #{nic1.ip_addr} set /files/etc/sysconfig/network-scripts/ifcfg-eth0/NETMASK #{nic1.netmask} set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BROADCAST #{nic1.broadcast} +set /files/etc/sysconfig/network-scripts/ifcfg-eth0/BRIDGE ovirtbr0 set /files/etc/sysconfig/network-scripts/ifcfg-eth0/ONBOOT yes +rm /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/DEVICE ovirtbr0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/BOOTPROTO #{nic1.boot_type.proto} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/IPADDR #{nic1.ip_addr} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/NETMASK #{nic1.netmask} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/BROADCAST #{nic1.broadcast} +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/TYPE bridge +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/PEERNTP yes +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/DELAY 0 +set /files/etc/sysconfig/network-scripts/ifcfg-ovirtbr0/ONBOOT yes rm /files/etc/sysconfig/network-scripts/ifcfg-eth1 set /files/etc/sysconfig/network-scripts/ifcfg-eth1/DEVICE eth1 set /files/etc/sysconfig/network-scripts/ifcfg-eth1/BOOTPROTO #{nic2.boot_type.proto} +set /files/etc/sysconfig/network-scripts/ifcfg-eth1/BRIDGE ovirtbr0 set /files/etc/sysconfig/network-scripts/ifcfg-eth1/ONBOOT yes save EOF -- 1.5.5.1
Alan Pevec
2008-Oct-16 10:33 UTC
[Ovirt-devel] Re: [PATCH server] This patch hardcodes support for ovirtbr0 bridge.
Darryl L. Pierce wrote:> --- a/src/host-browser/host-browser.rb > +++ b/src/host-browser/host-browser.rb > # iterate over any nics left and create new records for them. > - boot_type = BootType.find_by_proto('dhcp') > + boot_type = BootType.find_by_proto('static')I'll revert that, since this breaks default network config: DHCP on ovirtbr0 and eth0 bridged to it. Any objections?