Changeset 182

Show
Ignore:
Timestamp:
07/30/08 15:38:08 (4 months ago)
Author:
pwh
Message:
  • test/unit/application_common_functions_test.rb: Create tests for
    purify_mac_address
  • app/controllers/application.rb: Add parse_stp_root_bridge_address and
    validate_stp_root_bridge address functions. Test for
    parse_stp_root_bridge are still to be written.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nethorus/app/controllers/application.rb

    r150 r182  
    6565  end 
    6666 
     67 
     68  # Split an STP root bridge in to bridge priority and bridge address 
     69   
     70  def parse_stp_root_bridge_address(stp_root) 
     71   
     72    root_fields = stp_root.upcase.match(/(.{4})(.{12})/) 
     73 
     74    return root_fields 
     75   
     76  end 
     77   
     78   
     79  # Return true if the specified STP root bridge address is valid, or false 
     80  # otherwise 
     81   
     82  def validate_stp_root_bridge_address(stp_root) 
     83   
     84    root_fields = parse_stp_root_bridge_address(stp_root) 
     85 
     86    if root_fields[1].match(/[0-9A-F]{4}/) and root_fields[2].match(/[0-9A-F]{12}/) 
     87      return :true 
     88    else 
     89      return :false 
     90    end 
     91 
     92  end 
     93 
    6794end