[Ovirt-devel] [PATCH server] network-related fixes
Mohammed Morsi
mmorsi at redhat.com
Fri Mar 27 20:06:18 UTC 2009
- fix to host browser correcting comparison of nic mac addresses between
those received and those in db
- fixes to managed node configuration concerning proper usage of networks
associated w/ nics / bridges
---
src/host-browser/host-browser.rb | 2 +-
src/lib/managed_node_configuration.rb | 48 ++++++++++++++++++++++----------
2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/src/host-browser/host-browser.rb b/src/host-browser/host-browser.rb
index 1c5cf83..1f9e7d2 100755
--- a/src/host-browser/host-browser.rb
+++ b/src/host-browser/host-browser.rb
@@ -278,7 +278,7 @@ class HostBrowser
nic_info.collect do |detail|
# if we have a match, then update the database and remove
# the received data to avoid creating a dupe later
- if detail['MAC'] == nic.mac
+ if detail['MAC'].upcase == nic.mac
nic_info.delete(detail)
updated_nic = Nic.find_by_id(nic.id)
diff --git a/src/lib/managed_node_configuration.rb b/src/lib/managed_node_configuration.rb
index c412917..e8017ec 100644
--- a/src/lib/managed_node_configuration.rb
+++ b/src/lib/managed_node_configuration.rb
@@ -47,6 +47,15 @@ require 'stringio'
# +00:11:22:33:44+. It will use DHCP for retrieving it's IP address details,
# and will use the +breth0+ interface as a bridge.
#
+
+# FIXME
+# - look into whether or not we need macs hash here (passed in via url
+# by node, only used to lookup interface names which we already have
+# via ovirt-identify-node / host-browser (remember this module will only
+# be useful on 2nd boot)
+# - handle bridges correctly, right now we're only receiving bridges from the
+# node, but this will need to change in the future
+
class ManagedNodeConfiguration
NIC_ENTRY_PREFIX='/files/etc/sysconfig/network-scripts'
@@ -81,19 +90,11 @@ 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.bondings.empty?
process_nic result, nic, macs, nil, false, true
-
- # TODO remove this when bridges are properly supported
- unless has_bridge
- macs[nic.mac] = "breth0"
- process_nic result, nic, macs, nil, true, false
- has_bridge = true
- end
end
end
@@ -102,6 +103,7 @@ class ManagedNodeConfiguration
private
+ # FIXME remove macs, is_bridge (see FIXME above)
def self.process_nic(result, nic, macs, bonding = nil, is_bridge = false, bridged = true)
iface_name = macs[nic.mac]
@@ -111,14 +113,30 @@ class ManagedNodeConfiguration
if bonding
entry += "|MASTER=#{bonding.interface_name}|SLAVE=yes"
else
- entry += "|BOOTPROTO=#{nic.physical_network.boot_type.proto}"
- if nic.physical_network.boot_type.proto == 'static'
- ip = nic.ip_addresses[0]
- entry += "|IPADDR=#{ip.address}|NETMASK=#{ip.netmask}|BROADCAST=#{ip.broadcast}"
+ boot_proto = nic.physical_network.nil? ? 'dhcp' : nic.physical_network.boot_type.proto
+ entry += "|BOOTPROTO=#{boot_proto}"
+ if boot_proto == 'static'
+ ip = nic.ip_addresses[0].address
+ netmask = '255.255.255.0'
+ broadcast = '255.255.255.255'
+ unless nic.physical_network.nil? || nic.physical_network.ip_addresses.size == 0
+ netmask = nic.physical_network.ip_addresses[0].netmask
+ broadcast = nic.physical_network.ip_addresses[0].broadcast
+ end
+ entry += "|IPADDR=#{ip}|NETMASK=#{netmask}|BROADCAST=#{broadcast}"
+ end
+
+ # handling a bridge
+ if nic.interface_name =~ /^br.*/
+ entry += "|TYPE=bridge"
+ entry += "|PEERDNS=no"
+ else
+ if nic.bridge
+ entry += "|BRIDGE=#{nic.bridge}"
+ else
+ entry += "|BRIDGE=breth0"
+ end
end
- entry += "|BRIDGE=#{nic.bridge}" if nic.bridge && !is_bridge
- entry += "|BRIDGE=breth0" if !nic.bridge && !is_bridge
- entry += "|TYPE=bridge" if is_bridge
end
entry += "|ONBOOT=yes"
end
--
1.6.0.6
More information about the ovirt-devel
mailing list