[Ovirt-devel] [PATCH] Added additional fields to the nic table.

Perry N. Myers pmyers at redhat.com
Sat Sep 13 15:09:24 UTC 2008


Darryl L. Pierce wrote:
> The new fields are netmask and broadcast.
> 
> You will need to run a migration with this patch.

I'm not the right one to give ACKs on object model changes in the DB, but 
this looks ok with one question...

How does the administrator indicate that a given NIC should be configured 
via DHCP?  Is this done by explicitly setting the IP_ADDRESS field?

One of the things I'd like to get back from the host along with broadcast 
and netmask is the actual IP.  In the case of a host that is statically 
configured this IP will be the same as the admin configured IP.  But in 
the case of a NIC using DHCP this will be useful info for the administrator.

If IP_ADDRESS is used to determine whether the NIC is DHCP or not, we 
can't just simply add IP_ADDRESS to the list of data that is sent back via 
the node identify process.  Since that would overwrite the empty field and 
switch the NIC from DHCP to static.

We either need a field in the NIC table that indicates what mode the NIC 
is in (DHCP, bootp, static) or we need a second IP_ADDRESS field that is 
the ACTUAL_IP_ADDRESS instead of the configured IP_ADDRESS.  There is a 
field in the nics table right now called USAGE_TYPE.  If that is the 
intent of this field, then just ignore my comments :)

Perry

> Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
> ---
>  src/db/migrate/018_add_netmask_to_nics.rb |   11 +++++++++++
>  src/host-browser/host-browser.rb          |   18 ++++++++++++++++--
>  2 files changed, 27 insertions(+), 2 deletions(-)
>  create mode 100644 src/db/migrate/018_add_netmask_to_nics.rb
> 
> diff --git a/src/db/migrate/018_add_netmask_to_nics.rb b/src/db/migrate/018_add_netmask_to_nics.rb
> new file mode 100644
> index 0000000..a006109
> --- /dev/null
> +++ b/src/db/migrate/018_add_netmask_to_nics.rb
> @@ -0,0 +1,11 @@
> +class AddNetmaskToNics < ActiveRecord::Migration
> +  def self.up
> +    add_column :nics, :netmask,   :string, :limit => 16
> +    add_column :nics, :broadcast, :string, :limit => 16
> +  end
> +
> +  def self.down
> +    remove_column :nics, :netmask
> +    remove_column :nics, :broadcast
> +  end
> +end
> diff --git a/src/host-browser/host-browser.rb b/src/host-browser/host-browser.rb
> index a9fc9c7..debd78f 100755
> --- a/src/host-browser/host-browser.rb
> +++ b/src/host-browser/host-browser.rb
> @@ -170,7 +170,7 @@ class HostBrowser
>  
>              break if info == "ENDNIC"
>  
> -            raise Exception.new("ERRINFO! Excepted key=value : #{info}\n") unless info =~ /[\w]+[\s]*=[\w]/
> +            raise Exception.new("ERRINFO! Excepted key=value : #{info}\n") unless info =~ /[\w]+[\s]*=[\w]*/
>  
>              key, value = info.split("=")
>  
> @@ -275,6 +275,17 @@ class HostBrowser
>                  # the received data to avoid creating a dupe later
>                  if detail['MAC'] == nic.mac
>                      nic_info.delete(detail)
> +                    
> +                    updated_nic = Nic.find_by_id(nic.id)
> +            
> +                    updated_nic.bandwidth = detail['BANDWIDTH']
> +                    updated_nic.ip_addr   = detail['IP_ADDRESS']
> +                    updated_nic.netmask   = detail['NETMASK']
> +                    updated_nic.broadcast = detail['BROADCAST']
> +                  
> +                    updated_nic.save!
> +                    found=true
> +                    nic_info.delete detail
>                  end
>              end
>  
> @@ -292,7 +303,10 @@ class HostBrowser
>              detail = Nic.new(
>                  'mac'        => nic['MAC'],
>                  'bandwidth'  => nic['BANDWIDTH'],
> -                'usage_type' => 1)
> +                'usage_type' => 1,
> +                'ip_addr'    => nic['IP_ADDRESS'],
> +                'netmask'    => nic['NETMASK'],
> +                'broadcast'  => nic['BROADCAST'])
>  
>              host.nics << detail
>          end

-- 
|=-        Red Hat, Engineering, Emerging Technologies, Boston        -=|
|=-                     Email: pmyers at redhat.com                      -=|
|=-         Office: +1 412 474 3552   Mobile: +1 703 362 9622         -=|
|=- GnuPG: E65E4F3D 88F9 F1C9 C2F3 1303 01FE 817C C5D2 8B91 E65E 4F3D -=|




More information about the ovirt-devel mailing list