Class: FlowEntry

Inherits:
Object
  • Object
show all
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:

  1. Redistributions of source code must retain the above copyright notice, this

list of conditions and the following disclaimer.

  1. 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.

  1. 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

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


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
  @barrier = barrier
  @cookie = cookie
  @cookie_mask = cookie_mask
  @instructions = []
  @out_port = out_port
  @out_group = out_group
  @flags = flags
  @buffer_id = buffer_id
end

Instance Attribute Details

#barrierObject (readonly)

Returns the value of attribute barrier.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def barrier
  @barrier
end

#buffer_idObject (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

Returns the value of attribute cookie.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def cookie
  @cookie
end

Returns the value of attribute cookie_mask.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def cookie_mask
  @cookie_mask
end

#flagsObject (readonly)

Returns the value of attribute flags.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def flags
  @flags
end

#hard_timeoutObject (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

#idObject (readonly)

Returns the value of attribute id.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def id
  @id
end

#idle_timeoutObject (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_hwObject (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

#instructionsObject (readonly)

Returns the value of attribute instructions.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def instructions
  @instructions
end

#matchObject (readonly)

Returns the value of attribute match.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def match
  @match
end

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def name
  @name
end

#out_groupObject (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_portObject (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

#priorityObject (readonly)

Returns the value of attribute priority.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def priority
  @priority
end

#strictObject (readonly)

Returns the value of attribute strict.



35
36
37
# File 'lib/openflowdev/flow_entry.rb', line 35

def strict
  @strict
end

#table_idObject (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

Raises:

  • (ArgumentError)


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

Raises:

  • (ArgumentError)


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_hashObject



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 => @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