| 41 | | 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 => 0..2147483647, :message => "must be in the range 0-2147483647" |
|---|
| 43 | | validates_inclusion_of :dot1d_stp_max_age, :in => 1..2147483647, :message => "must be in the range 1-2147483647" |
|---|
| 44 | | validates_inclusion_of :dot1d_stp_hello_time, :in => 1..2147483647, :message => "must be in the range 1-2147483647" |
|---|
| 45 | | validates_inclusion_of :dot1d_stp_hold_time, :in => 1..2147483647, :message => "must be in the range 1-2147483647" |
|---|
| 46 | | validates_inclusion_of :dot1d_stp_forward_delay, :in => 1..2147483647, :message => "must be in the range 1-2147483647" |
|---|
| 47 | | validates_inclusion_of :dot1d_stp_bridge_max_age, :in => 600..4000, :message => "must be in the range 600-4000" |
|---|
| 48 | | validates_inclusion_of :dot1d_stp_bridge_hello_time, :in => 100..1000, :message => "must be in the range 100-1000" |
|---|
| | 45 | validates_numericality_of :dot1d_base_num_ports, |
|---|
| | 46 | :message => "must be a number" |
|---|
| | 47 | |
|---|
| | 48 | validates_inclusion_of :dot1d_base_type, |
|---|
| | 49 | :in => %w( transparent-only ), |
|---|
| | 50 | :message => "is not a valid type" |
|---|
| | 51 | |
|---|
| | 52 | validates_inclusion_of :dot1d_stp_protocol_specification, |
|---|
| | 53 | :in => %w( ieee8021d ), |
|---|
| | 54 | :message => "is not a valid protocol" |
|---|
| | 55 | |
|---|
| | 56 | validates_inclusion_of :dot1d_stp_priority, |
|---|
| | 57 | :in => 1..65535, |
|---|
| | 58 | :message => "must be in the range 1-65535" |
|---|
| | 59 | |
|---|
| | 60 | validates_format_of :dot1d_stp_designated_root, |
|---|
| | 61 | :with => /\d{4}[0-9A-F]{12}/, |
|---|
| | 62 | :message => "must be a priority and a 12-character hexadecimal string" |
|---|
| | 63 | |
|---|
| | 64 | validates_numericality_of :dot1d_stp_root_cost, |
|---|
| | 65 | :greater_than_or_equal_to => 0, |
|---|
| | 66 | :less_than_or_equal_to => 2147483647, |
|---|
| | 67 | :message => "must be in the range 0-2147483647" |
|---|
| | 68 | |
|---|
| | 69 | validates_numericality_of :dot1d_stp_max_age, |
|---|
| | 70 | :greater_than_or_equal_to => 1, |
|---|
| | 71 | :less_than_or_equal_to => 2147483647, |
|---|
| | 72 | :message => "must be in the range 1-2147483647" |
|---|
| | 73 | |
|---|
| | 74 | validates_numericality_of :dot1d_stp_hello_time, |
|---|
| | 75 | :greater_than_or_equal_to => 1, |
|---|
| | 76 | :less_than_or_equal_to => 2147483647, |
|---|
| | 77 | :message => "must be in the range 1-2147483647" |
|---|
| | 78 | |
|---|
| | 79 | validates_numericality_of :dot1d_stp_hold_time, |
|---|
| | 80 | :greater_than_or_equal_to => 1, |
|---|
| | 81 | :less_than_or_equal_to => 2147483647, |
|---|
| | 82 | :message => "must be in the range 1-2147483647" |
|---|
| | 83 | |
|---|
| | 84 | validates_numericality_of :dot1d_stp_forward_delay, |
|---|
| | 85 | :greater_than_or_equal_to => 1, |
|---|
| | 86 | :less_than_or_equal_to => 2147483647, |
|---|
| | 87 | :message => "must be in the range 1-2147483647" |
|---|
| | 88 | |
|---|
| | 89 | validates_numericality_of :dot1d_stp_bridge_max_age, |
|---|
| | 90 | :greater_than_or_equal_to => 600, |
|---|
| | 91 | :less_than_or_equal_to => 4000, |
|---|
| | 92 | :message => "must be in the range 600-4000" |
|---|
| | 93 | |
|---|
| | 94 | validates_numericality_of :dot1d_stp_bridge_hello_time, |
|---|
| | 95 | :greater_than_or_equal_to => 100, |
|---|
| | 96 | :less_than_or_equal_to => 1000, |
|---|
| | 97 | :message => "must be in the range 100-1000" |
|---|
| | 98 | |
|---|
| | 99 | |
|---|
| | 100 | # TODO: Some bridges set the timer values to seconds, not centi-seconds |
|---|
| | 101 | # (1/100th of a second). This is a hack to get around this problem. |
|---|
| | 102 | |
|---|
| | 103 | def before_validation |
|---|
| | 104 | |
|---|
| | 105 | if !self.dot1d_stp_max_age.nil? && self.dot1d_stp_max_age <= 99 |
|---|
| | 106 | logger.warn "dot1d_stp_max_age is #{self.dot1d_stp_max_age} - multiplying by 100" |
|---|
| | 107 | self.dot1d_stp_max_age = self.dot1d_stp_max_age * 100 |
|---|
| | 108 | end |
|---|
| | 109 | |
|---|
| | 110 | if !self.dot1d_stp_hello_time.nil? && self.dot1d_stp_hello_time <= 99 |
|---|
| | 111 | self.dot1d_stp_hello_time = self.dot1d_stp_hello_time * 100 |
|---|
| | 112 | end |
|---|
| | 113 | |
|---|
| | 114 | if !self.dot1d_stp_hold_time.nil? && self.dot1d_stp_hold_time <= 99 |
|---|
| | 115 | self.dot1d_stp_hold_time = self.dot1d_stp_hold_time * 100 |
|---|
| | 116 | end |
|---|
| | 117 | |
|---|
| | 118 | if !self.dot1d_stp_forward_delay.nil? && self.dot1d_stp_forward_delay <= 99 |
|---|
| | 119 | self.dot1d_stp_forward_delay = self.dot1d_stp_forward_delay * 100 |
|---|
| | 120 | end |
|---|
| | 121 | |
|---|
| | 122 | if !self.dot1d_stp_bridge_max_age.nil? && self.dot1d_stp_bridge_max_age <= 99 |
|---|
| | 123 | self.dot1d_stp_bridge_max_age = self.dot1d_stp_bridge_max_age * 100 |
|---|
| | 124 | end |
|---|
| | 125 | |
|---|
| | 126 | if !self.dot1d_stp_bridge_hello_time.nil? && self.dot1d_stp_bridge_hello_time <= 99 |
|---|
| | 127 | self.dot1d_stp_bridge_hello_time = self.dot1d_stp_bridge_hello_time * 100 |
|---|
| | 128 | end |
|---|
| | 129 | |
|---|
| | 130 | if !self.dot1d_stp_bridge_forward_delay.nil? && self.dot1d_stp_bridge_forward_delay <= 99 |
|---|
| | 131 | self.dot1d_stp_bridge_forward_delay = self.dot1d_stp_bridge_forward_delay * 100 |
|---|
| | 132 | end |
|---|
| | 133 | |
|---|
| | 134 | end |
|---|