Class: ActionOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/openflowdev/action_output.rb

Overview

OpenFlow ‘Output’ action type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port: nil, length: nil, order: nil) ⇒ ActionOutput

  • order

    integer : order



52
53
54
55
56
57
# File 'lib/openflowdev/action_output.rb', line 52

def initialize(port: nil, length: nil, order: nil)
  @type = 'output'
  @order = order
  @port = port
  @length = length
end

Instance Attribute Details

#lengthObject (readonly)

integer : When the ’port’ is the controller, this indicates the max number of bytes to send. A value of zero means no bytes of the packet should be sent. A value of OFPCML_NO_BUFFER (0xffff) means that the packet is not buffered and the complete packet is to be sent to the controller.



43
44
45
# File 'lib/openflowdev/action_output.rb', line 43

def length
  @length
end

#orderObject (readonly)

integer : order



36
37
38
# File 'lib/openflowdev/action_output.rb', line 36

def order
  @order
end

#portObject (readonly)

integer : port to output



38
39
40
# File 'lib/openflowdev/action_output.rb', line 38

def port
  @port
end

#typeObject (readonly)

string : type of action.



34
35
36
# File 'lib/openflowdev/action_output.rb', line 34

def type
  @type
end

Instance Method Details

#to_sObject



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/openflowdev/action_output.rb', line 94

def to_s
  if @port && @length
    if @port == "CONTROLLER"
      "#{@port}:#{@length}"
    else
      "#{@type}:#{@port}"
    end
  else
    ""
  end
end

#update(port: nil, length: nil, order: nil) ⇒ Object

Return a list of YANG schemas for the node.

Parameters

  • port

    integer : the port to target for output

  • length

    integer : When the ’port’ is the controller, this indicates the max number of

bytes to send. A value of zero means no bytes of the packet should be sent. A value of OFPCML_NO_BUFFER (0xffff) means that the packet is not buffered and the complete packet is to be sent to the controller.

  • order

    integer : order



70
71
72
73
74
# File 'lib/openflowdev/action_output.rb', line 70

def update(port: nil, length: nil, order: nil)
  @order = order unless order.nil?
  @port = port unless port.nil?
  @length = length unless length.nil?
end

#update_from_object(action_object) ⇒ Object

Update from an existing Action .

Parameters

  • action_object

    Action : Update this action from an existing Action.



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/openflowdev/action_output.rb', line 81

def update_from_object(action_object)
  @order = action_object['order']
  if action_object.has_key?('output-action')
    if action_object['output-action'].has_key?('output-node-connector')
      @port = action_object['output-action']['output-node-connector']
    end
    
    if action_object['output-action'].has_key?('max-length')
      @length = action_object['output-action']['max-length']
    end
  end
end