[Ovirt-devel] [PATCH server] Fixed a few bugs in o-identify-node processing.

Darryl L. Pierce dpierce at redhat.com
Tue Mar 31 15:26:06 UTC 2009


Fixed the processing of NICs to handle properly deleting a NIC that was
not identified by the node. All unidentified NICs are now deleted from
the database after o-i-node runs.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 src/host-browser/host-browser.rb |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/host-browser/host-browser.rb b/src/host-browser/host-browser.rb
index 1c5cf83..b40a73f 100755
--- a/src/host-browser/host-browser.rb
+++ b/src/host-browser/host-browser.rb
@@ -271,6 +271,7 @@ class HostBrowser
 
         puts "Updating NIC records for the node"
         nics = Array.new
+        nics_to_delete = Array.new
 
         host.nics.collect do |nic|
             found = false
@@ -278,7 +279,8 @@ 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
+                  puts "Updating details for: #{nic.interface_name} [#{nic.mac}]}"
                     nic_info.delete(detail)
 
                     updated_nic = Nic.find_by_id(nic.id)
@@ -286,7 +288,6 @@ class HostBrowser
                     updated_nic.bandwidth = detail['BANDWIDTH'].to_i
                     updated_nic.interface_name = detail['IFACE_NAME']
 
-                    updated_nic.save!
                     found=true
                     nic_info.delete detail
                 end
@@ -294,14 +295,16 @@ class HostBrowser
 
             # if the record wasn't found, then remove it from the database
             unless found
-                host.nics.delete(nic)
-                nic.destroy
+              puts "Marking NIC for removal: #{nic.interface_name} [#{nic.mac}]"
+                nics_to_delete << nic
             end
         end
 
+        nics_to_delete.each { |nic| puts "Removing NIC: #{nic.interface_name} []#{nic.mac}]"; host.nics.delete(nic) }
+
         # iterate over any nics left and create new records for them.
         nic_info.collect do |nic|
-            puts "Creating a new nic..."
+            puts "Creating a new nic: #{nic.interface_name} [#{nic.mac}]"
             detail = Nic.new(
                 'mac'          => nic['MAC'].upcase,
                 'bandwidth'    => nic['BANDWIDTH'].to_i,
-- 
1.6.0.6




More information about the ovirt-devel mailing list