Class: FlowEntry
- Inherits:
-
Object
- Object
- FlowEntry
- Defined in:
- lib/openflowdev/flow_entry.rb
Overview
Copyright © 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Instance Attribute Summary collapse
-
#barrier ⇒ Object
readonly
Returns the value of attribute barrier.
-
#buffer_id ⇒ Object
readonly
Returns the value of attribute buffer_id.
-
#cookie ⇒ Object
readonly
Returns the value of attribute cookie.
-
#cookie_mask ⇒ Object
readonly
Returns the value of attribute cookie_mask.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#hard_timeout ⇒ Object
readonly
Returns the value of attribute hard_timeout.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#idle_timeout ⇒ Object
readonly
Returns the value of attribute idle_timeout.
-
#install_hw ⇒ Object
readonly
Returns the value of attribute install_hw.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#out_group ⇒ Object
readonly
Returns the value of attribute out_group.
-
#out_port ⇒ Object
readonly
Returns the value of attribute out_port.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#strict ⇒ Object
readonly
Returns the value of attribute strict.
-
#table_id ⇒ Object
readonly
Returns the value of attribute table_id.
Instance Method Summary collapse
- #add_instruction(instruction) ⇒ Object
- #add_match(match) ⇒ Object
-
#initialize(flow_table_id: 0, flow_id: nil, flow_priority: nil, name: nil, idle_timeout: 0, hard_timeout: 0, strict: false, install_hw: false, barrier: false, cookie: nil, cookie_mask: nil, out_port: nil, out_group: nil, flags: nil, buffer_id: nil) ⇒ FlowEntry
constructor
A new instance of FlowEntry.
- #to_hash ⇒ Object
Constructor Details
#initialize(flow_table_id: 0, flow_id: nil, flow_priority: nil, name: nil, idle_timeout: 0, hard_timeout: 0, strict: false, install_hw: false, barrier: false, cookie: nil, cookie_mask: nil, out_port: nil, out_group: nil, flags: nil, buffer_id: nil) ⇒ FlowEntry
Returns a new instance of FlowEntry.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/openflowdev/flow_entry.rb', line 39 def initialize(flow_table_id: 0, flow_id: nil, flow_priority: nil, name: nil, idle_timeout: 0, hard_timeout: 0, strict: false, install_hw: false, barrier: false, cookie: nil, cookie_mask: nil, out_port: nil, out_group: nil, flags: nil, buffer_id: nil) raise ArgumentError, "Flow ID (flow_id) required" unless flow_id raise ArgumentError, "Flow Priority (flow_priority) required" unless flow_priority @table_id = flow_table_id @id = flow_id @name = name @priority = flow_priority @idle_timeout = idle_timeout @hard_timeout = hard_timeout @strict = strict @install_hw = install_hw = = = @instructions = [] @out_port = out_port @out_group = out_group @flags = flags @buffer_id = buffer_id end |
Instance Attribute Details
#barrier ⇒ Object (readonly)
Returns the value of attribute barrier.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def end |
#buffer_id ⇒ Object (readonly)
Returns the value of attribute buffer_id.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def buffer_id @buffer_id end |
#cookie ⇒ Object (readonly)
Returns the value of attribute cookie.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def end |
#cookie_mask ⇒ Object (readonly)
Returns the value of attribute cookie_mask.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def flags @flags end |
#hard_timeout ⇒ Object (readonly)
Returns the value of attribute hard_timeout.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def hard_timeout @hard_timeout end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def id @id end |
#idle_timeout ⇒ Object (readonly)
Returns the value of attribute idle_timeout.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def idle_timeout @idle_timeout end |
#install_hw ⇒ Object (readonly)
Returns the value of attribute install_hw.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def install_hw @install_hw end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def instructions @instructions end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def match @match end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def name @name end |
#out_group ⇒ Object (readonly)
Returns the value of attribute out_group.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def out_group @out_group end |
#out_port ⇒ Object (readonly)
Returns the value of attribute out_port.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def out_port @out_port end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def priority @priority end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def strict @strict end |
#table_id ⇒ Object (readonly)
Returns the value of attribute table_id.
35 36 37 |
# File 'lib/openflowdev/flow_entry.rb', line 35 def table_id @table_id end |
Instance Method Details
#add_instruction(instruction) ⇒ Object
64 65 66 67 |
# File 'lib/openflowdev/flow_entry.rb', line 64 def add_instruction(instruction) raise ArgumentError, "Instruction must be of type 'Instruction'" unless instruction.is_a?(Instruction) @instructions << instruction end |
#add_match(match) ⇒ Object
69 70 71 72 |
# File 'lib/openflowdev/flow_entry.rb', line 69 def add_match(match) raise ArgumentError, "Match must be of type 'Match'" unless match.is_a?(Match) @match = match end |
#to_hash ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/openflowdev/flow_entry.rb', line 74 def to_hash instructions_hash = [] @instructions.each do |instruction| instructions_hash << instruction.to_hash end hash = {'flow-node-inventory:flow' => {:barrier => , 'hard-timeout' => @hard_timeout, :id => @id, 'idle-timeout' => @idle_timeout, 'installHw' => @install_hw, 'out-port' => @out_port, 'out-group' => @out_group, :flags => @flags, 'buffer-id' => @buffer_id, :match => @match.to_hash, :priority => @priority, :strict => @strict, :table_id => @table_id, :cookie => , :cookie_mask => , 'flow-name' => @name, :instructions => {:instruction => instructions_hash}}} hash = hash.compact hash end |