Changeset 183

Show
Ignore:
Timestamp:
07/30/08 15:49:27 (4 months ago)
Author:
pwh
Message:
  • app/models/bridge.rb, test/unit/bridge_test.rb: A root cost can be zero
    in the case where this bridge is the root.
  • app/models/bridge.rb: Add a method, dot1d_stp_root_port_interface, which
    will return the StpPort? associated with the root port.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nethorus/app/models/bridge.rb

    r168 r183  
    4040 
    4141  validates_inclusion_of :dot1d_stp_priority, :in => 1..65535, :message => "must be in the range 1-65535" 
    42   validates_inclusion_of :dot1d_stp_root_cost, :in => 1..2147483647, :message => "must be in the range 1-2147483647" 
     42  validates_inclusion_of :dot1d_stp_root_cost, :in => 0..2147483647, :message => "must be in the range 0-2147483647" 
    4343  validates_inclusion_of :dot1d_stp_max_age, :in => 1..2147483647, :message => "must be in the range 1-2147483647" 
    4444  validates_inclusion_of :dot1d_stp_hello_time, :in => 1..2147483647, :message => "must be in the range 1-2147483647" 
     
    4848  validates_inclusion_of :dot1d_stp_bridge_hello_time, :in => 100..1000, :message => "must be in the range 100-1000" 
    4949 
     50 
     51  # Returns the L2Interface object corresponding to the STP root port 
     52   
     53  def dot1d_stp_root_port_interface 
     54 
     55    root_port = self.dot1d_stp_root_port 
     56 
     57    root_port_interface = StpPort.find(:first, :conditions => { :dot1d_base_port => root_port, :bridge_id => self.id }) 
     58 
     59  end 
     60 
    5061end 
  • nethorus/test/unit/bridge_test.rb

    r168 r183  
    136136 
    137137    @bridge.dot1d_stp_root_cost = 0 
    138     assert(!@bridge.valid?, "A bridge should not be valid with a dot1d_stp_root_cost of 0") 
     138    assert(@bridge.valid?, "A bridge should be valid with a dot1d_stp_root_cost of 0") 
     139 
     140    @bridge.dot1d_stp_root_cost = -1 
     141    assert(!@bridge.valid?, "A bridge should not be valid with a dot1d_stp_root_cost of -1") 
    139142 
    140143    @bridge.dot1d_stp_root_cost = 2147483647 
     
    250253  end 
    251254 
     255 
     256  # Test the device/bridge relationship 
     257   
     258  def test_device_bridge_relationship 
     259   
     260  end 
     261 
    252262end