Class: FlowEntry
- Inherits:
-
Object
- Object
- FlowEntry
- Defined in:
- lib/openflowdev/flow_entry.rb
Overview
Class for creating and interacting with OpenFlow flows
Instance Attribute Summary collapse
-
#barrier ⇒ Object
readonly
boolean: Boolean flag used to enforce OpenFlow switch to do ordered message processing.
-
#buffer_id ⇒ Object
readonly
Buffered packet to apply to, or OFP_NO_BUFFER.
-
#cookie ⇒ Object
readonly
integer: Opaque Controller-issued identifier.
-
#cookie_mask ⇒ Object
readonly
integer: Mask used to restrict the cookie bits that must match when the command is OFPFC_MODIFY* or OFPFC_DELETE*.
-
#flags ⇒ Object
readonly
integer: Bitmap of OpenFlow flags (OFPFF_* from OpenFlow spec).
-
#hard_timeout ⇒ Object
readonly
integer: Max time before discarding (seconds).
-
#id ⇒ Object
readonly
integer: Unique identifier of this FlowEntry in the Controller’s data store.
-
#idle_timeout ⇒ Object
readonly
integer: Idle time before discarding (seconds).
-
#install_hw ⇒ Object
readonly
internal Controller’s inventory attribute.
-
#instructions ⇒ Object
readonly
list of Instruction: Instructions to be executed when a flow matches this entry flow match fields.
-
#match ⇒ Object
readonly
Match: Flow match fields.
-
#name ⇒ Object
readonly
string: FlowEntry name in the FlowTable (internal Controller’s inventory attribute).
-
#out_group ⇒ Object
readonly
integer: For delete commands, require matching entries to include this as an output group.
-
#out_port ⇒ Object
readonly
integer: For delete commands, require matching entries to include this as an output port.
-
#priority ⇒ Object
readonly
integer: Priority level of flow entry.
-
#strict ⇒ Object
readonly
boolean: Modify/Delete entry strictly matching wildcards and priority.
-
#table_id ⇒ Object
readonly
string: ID of the table to put the flow in.
Instance Method Summary collapse
-
#add_instruction(instruction) ⇒ Object
Add an Instruction to the flow entry.
-
#add_match(match) ⇒ Object
Add a match rule to the flow entry.
-
#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
:nodoc:.
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.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/openflowdev/flow_entry.rb', line 109 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 @barrier = @cookie = @cookie_mask = @instructions = [] @out_port = out_port @out_group = out_group @flags = flags @buffer_id = buffer_id end |
Instance Attribute Details
#barrier ⇒ Object (readonly)
boolean: Boolean flag used to enforce OpenFlow switch to do ordered message processing. Barrier request/reply messages are used by the controller to ensure message dependencies have been met or to receive notifications for completed operations. When the controller wants to ensure message dependencies have been met or wants to receive notifications for completed operations, it may use an OFPT_BARRIER_REQUEST message. This message has no body. Upon receipt, the switch must finish processing all previously-received messages, including sending corresponding reply or error messages, before executing any messages beyond the Barrier Request.
58 59 60 |
# File 'lib/openflowdev/flow_entry.rb', line 58 def @barrier end |
#buffer_id ⇒ Object (readonly)
Buffered packet to apply to, or OFP_NO_BUFFER. Not meaningful for delete
79 80 81 |
# File 'lib/openflowdev/flow_entry.rb', line 79 def buffer_id @buffer_id end |
#cookie ⇒ Object (readonly)
integer: Opaque Controller-issued identifier
60 61 62 |
# File 'lib/openflowdev/flow_entry.rb', line 60 def @cookie end |
#cookie_mask ⇒ Object (readonly)
integer: Mask used to restrict the cookie bits that must match when the command is OFPFC_MODIFY* or OFPFC_DELETE*. A value of 0 indicates no restriction
63 64 65 |
# File 'lib/openflowdev/flow_entry.rb', line 63 def @cookie_mask end |
#flags ⇒ Object (readonly)
integer: Bitmap of OpenFlow flags (OFPFF_* from OpenFlow spec)
77 78 79 |
# File 'lib/openflowdev/flow_entry.rb', line 77 def flags @flags end |
#hard_timeout ⇒ Object (readonly)
integer: Max time before discarding (seconds)
45 46 47 |
# File 'lib/openflowdev/flow_entry.rb', line 45 def hard_timeout @hard_timeout end |
#id ⇒ Object (readonly)
integer: Unique identifier of this FlowEntry in the Controller’s data store
39 40 41 |
# File 'lib/openflowdev/flow_entry.rb', line 39 def id @id end |
#idle_timeout ⇒ Object (readonly)
integer: Idle time before discarding (seconds)
43 44 45 |
# File 'lib/openflowdev/flow_entry.rb', line 43 def idle_timeout @idle_timeout end |
#install_hw ⇒ Object (readonly)
internal Controller’s inventory attribute
49 50 51 |
# File 'lib/openflowdev/flow_entry.rb', line 49 def install_hw @install_hw end |
#instructions ⇒ Object (readonly)
list of Instruction: Instructions to be executed when a flow matches this entry flow match fields
67 68 69 |
# File 'lib/openflowdev/flow_entry.rb', line 67 def instructions @instructions end |
#match ⇒ Object (readonly)
Match: Flow match fields
69 70 71 |
# File 'lib/openflowdev/flow_entry.rb', line 69 def match @match end |
#name ⇒ Object (readonly)
string: FlowEntry name in the FlowTable (internal Controller’s inventory attribute)
65 66 67 |
# File 'lib/openflowdev/flow_entry.rb', line 65 def name @name end |
#out_group ⇒ Object (readonly)
integer: For delete commands, require matching entries to include this as an output group. A value of OFPG_ANY indicates no restriction
75 76 77 |
# File 'lib/openflowdev/flow_entry.rb', line 75 def out_group @out_group end |
#out_port ⇒ Object (readonly)
integer: For delete commands, require matching entries to include this as an output port. A value of OFPP_ANY indicates no restriction.
72 73 74 |
# File 'lib/openflowdev/flow_entry.rb', line 72 def out_port @out_port end |
#priority ⇒ Object (readonly)
integer: Priority level of flow entry
41 42 43 |
# File 'lib/openflowdev/flow_entry.rb', line 41 def priority @priority end |
#strict ⇒ Object (readonly)
boolean: Modify/Delete entry strictly matching wildcards and priority
47 48 49 |
# File 'lib/openflowdev/flow_entry.rb', line 47 def strict @strict end |
#table_id ⇒ Object (readonly)
string: ID of the table to put the flow in
37 38 39 |
# File 'lib/openflowdev/flow_entry.rb', line 37 def table_id @table_id end |
Instance Method Details
#add_instruction(instruction) ⇒ Object
Add an Instruction to the flow entry.
Parameters
instruction-
Instruction : Instruction to add to the flow entry.
139 140 141 142 |
# File 'lib/openflowdev/flow_entry.rb', line 139 def add_instruction(instruction) raise ArgumentError, "Instruction must be of type 'Instruction'" unless instruction.is_a?(Instruction) @instructions << instruction end |
#add_match(match) ⇒ Object
Add a match rule to the flow entry.
Parameters
match-
Match : Match to add to the flow entry.
149 150 151 152 |
# File 'lib/openflowdev/flow_entry.rb', line 149 def add_match(match) raise ArgumentError, "Match must be of type 'Match'" unless match.is_a?(Match) @match = match end |
#to_hash ⇒ Object
:nodoc:
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/openflowdev/flow_entry.rb', line 154 def to_hash #:nodoc: instructions_hash = [] @instructions.each do |instruction| instructions_hash << instruction.to_hash end hash = {'flow-node-inventory:flow' => {:barrier => @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, :cookie_mask => @cookie_mask, 'flow-name' => @name, :instructions => {:instruction => instructions_hash}}} hash = hash.compact hash end |