[Ovirt-devel] [PATCH server] Fixed a few bugs in o-identify-node processing.
Mohammed Morsi
mmorsi at redhat.com
Tue Mar 31 22:43:30 UTC 2009
Applied this patch and haven't run it yet, but noticed a few things
Darryl L. Pierce wrote:
> 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|
>
This 'collect' should more optimally be 'each' as we're not using the
array returned by collect.
> found = false
> @@ -278,7 +279,8 @@ class HostBrowser
> nic_info.collect do |detail|
>
Same with this collect here
> # 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)
>
The 'detail' nic is being removed from the nic_info array here, and at
the end of this if block as well (see below)
>
> 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!
>
Will this work if you remove this? If I understand what your doing by
reading this, you are relying on the host.save! a little further down to
save the updated nics, but the manipulation of the nic object (eg
updating bandwidth and interface name) occurs on a nic object you
explicitly retrieve via find_by_id here. Unless I'm mistaken you will
either need this updated_nic.save! or instead of updating the nic via
the "updated_nic" object, you can simply use the "nic" object (eg the
iterator as set via the host.nics.collect{ |nic| above).
> found=true
> nic_info.delete detail
>
Here is the other place the 'detail' nic is being removed from nic_info
> 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,
>
-Mo
More information about the ovirt-devel
mailing list