rubybvc 0.3.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/controller/controller.rb +189 -3
- data/lib/controller/netconf_node.rb +27 -3
- data/lib/controller/node.rb +7 -0
- data/lib/controller/openflow_node.rb +3 -1
- data/lib/netconfdev/vrouter/firewall.rb +6 -1
- data/lib/netconfdev/vrouter/rule.rb +16 -3
- data/lib/netconfdev/vrouter/rules.rb +18 -2
- data/lib/netconfdev/vrouter/vrouter5600.rb +123 -16
- data/lib/openflowdev/action_output.rb +37 -3
- data/lib/openflowdev/actions/action.rb +1 -0
- data/lib/openflowdev/actions/copy_ttl_inwards_action.rb +4 -0
- data/lib/openflowdev/actions/copy_ttl_outwards_action.rb +4 -0
- data/lib/openflowdev/actions/dec_mpls_ttl_action.rb +4 -0
- data/lib/openflowdev/actions/dec_nw_ttl_action.rb +4 -0
- data/lib/openflowdev/actions/drop_action.rb +1 -0
- data/lib/openflowdev/actions/flood_action.rb +4 -0
- data/lib/openflowdev/actions/flood_all_action.rb +4 -0
- data/lib/openflowdev/actions/group_action.rb +7 -1
- data/lib/openflowdev/actions/hw_path_action.rb +3 -0
- data/lib/openflowdev/actions/loopback_action.rb +5 -1
- data/lib/openflowdev/actions/output_action.rb +10 -1
- data/lib/openflowdev/actions/pop_mpls_header_action.rb +6 -1
- data/lib/openflowdev/actions/pop_pbb_header_action.rb +5 -1
- data/lib/openflowdev/actions/pop_vlan_header_action.rb +5 -1
- data/lib/openflowdev/actions/push_mpls_header_action.rb +6 -1
- data/lib/openflowdev/actions/push_pbb_header_action.rb +6 -1
- data/lib/openflowdev/actions/push_vlan_header_action.rb +11 -1
- data/lib/openflowdev/actions/set_dl_dst_action.rb +6 -1
- data/lib/openflowdev/actions/set_dl_src_action.rb +6 -1
- data/lib/openflowdev/actions/set_field_action.rb +7 -1
- data/lib/openflowdev/actions/set_mpls_ttl_action.rb +6 -1
- data/lib/openflowdev/actions/set_nw_dst_action.rb +6 -1
- data/lib/openflowdev/actions/set_nw_src_action.rb +6 -1
- data/lib/openflowdev/actions/set_nw_ttl_action.rb +6 -1
- data/lib/openflowdev/actions/set_queue_action.rb +7 -1
- data/lib/openflowdev/actions/set_tp_dst_action.rb +6 -1
- data/lib/openflowdev/actions/set_tp_src_action.rb +6 -1
- data/lib/openflowdev/actions/set_vlan_cfi_action.rb +6 -1
- data/lib/openflowdev/actions/set_vlan_id_action.rb +6 -1
- data/lib/openflowdev/actions/set_vlan_pcp_action.rb +6 -1
- data/lib/openflowdev/actions/strip_vlan_action.rb +2 -1
- data/lib/openflowdev/actions/sw_path_action.rb +5 -1
- data/lib/openflowdev/flow_entry.rb +86 -6
- data/lib/openflowdev/instruction.rb +12 -1
- data/lib/openflowdev/match.rb +119 -9
- data/lib/openflowdev/of_switch.rb +94 -3
- data/lib/utils/hash_with_compact.rb +1 -1
- data/lib/utils/netconf_response.rb +9 -1
- data/lib/utils/netconf_response_status.rb +1 -0
- data/lib/utils/rest_agent.rb +1 -1
- data/lib/utils/utilities.rb +2 -2
- metadata +2 -2
@@ -29,19 +29,33 @@
|
|
29
29
|
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
|
31
31
|
require 'controller/openflow_node'
|
32
|
+
|
33
|
+
# Class that represents an instance of 'OpenFlow Switch' (OpenFlow capable device).
|
32
34
|
class OFSwitch < OpenflowNode
|
33
35
|
require 'json'
|
34
36
|
require 'controller/controller'
|
35
37
|
require 'openflowdev/flow_entry'
|
36
38
|
require 'openflowdev/action_output'
|
37
39
|
|
40
|
+
# String: name of the controller node.
|
38
41
|
attr_reader :name
|
39
42
|
|
43
|
+
# _Parameters_
|
44
|
+
# * +controller+:: Controller : Controller object through which the OpenFlow switch is to be controlled.
|
45
|
+
# * +name+:: String : Node name of the OpenFlow node.
|
46
|
+
# * +dpid+:: String : The OpenFlow datapath identifier for the OpenFlow device I. e.g. admin
|
47
|
+
|
40
48
|
def initialize(controller: nil, name: nil, dpid: nil)
|
41
49
|
super(controller: controller, name: name)
|
42
50
|
@dpid = dpid
|
43
51
|
end
|
44
|
-
|
52
|
+
|
53
|
+
|
54
|
+
##
|
55
|
+
# Return info about the OpenFlow switch.
|
56
|
+
#
|
57
|
+
# _Return_ _Value_
|
58
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and info about the OpenFlow switch.
|
45
59
|
def get_switch_info
|
46
60
|
get_uri = @controller.get_node_operational_uri(self)
|
47
61
|
response = @controller.rest_agent.get_request(get_uri)
|
@@ -71,6 +85,11 @@ class OFSwitch < OpenflowNode
|
|
71
85
|
end
|
72
86
|
end
|
73
87
|
|
88
|
+
##
|
89
|
+
# Return a list of OpenFlow features supported by the OpenFlow switch.
|
90
|
+
#
|
91
|
+
# _Return_ _Value_
|
92
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and supported features.
|
74
93
|
def get_features_info
|
75
94
|
get_uri = @controller.get_node_operational_uri(self)
|
76
95
|
response = @controller.rest_agent.get_request(get_uri)
|
@@ -92,6 +111,11 @@ class OFSwitch < OpenflowNode
|
|
92
111
|
end
|
93
112
|
end
|
94
113
|
|
114
|
+
##
|
115
|
+
# Return a list of ports for the OpenFlow switch.
|
116
|
+
#
|
117
|
+
# _Return_ _Value_
|
118
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and list of ports.
|
95
119
|
def get_ports_list
|
96
120
|
get_uri = @controller.get_node_operational_uri(self)
|
97
121
|
response = @controller.rest_agent.get_request(get_uri)
|
@@ -109,6 +133,11 @@ class OFSwitch < OpenflowNode
|
|
109
133
|
end
|
110
134
|
end
|
111
135
|
|
136
|
+
##
|
137
|
+
# Return a brief set of information about each port on the OpenFlow switch.
|
138
|
+
#
|
139
|
+
# _Return_ _Value_
|
140
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and list of ports with brief info for each.
|
112
141
|
def get_ports_brief_info
|
113
142
|
get_uri = @controller.get_node_operational_uri(self)
|
114
143
|
response = @controller.rest_agent.get_request(get_uri)
|
@@ -131,6 +160,13 @@ class OFSwitch < OpenflowNode
|
|
131
160
|
end
|
132
161
|
end
|
133
162
|
|
163
|
+
##
|
164
|
+
# Return detailed information about a specific port.
|
165
|
+
#
|
166
|
+
# _Parameters_
|
167
|
+
# * +port+:: Integer : number for the port from the #get_ports_brief_info
|
168
|
+
# _Return_ _Value_
|
169
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and detailed information about the requested port.
|
134
170
|
def get_port_detail_info(port)
|
135
171
|
get_uri = "#{@controller.get_node_operational_uri(self)}/node-connector/"\
|
136
172
|
"#{self.name}:#{port}"
|
@@ -145,6 +181,13 @@ class OFSwitch < OpenflowNode
|
|
145
181
|
end
|
146
182
|
end
|
147
183
|
|
184
|
+
##
|
185
|
+
# Add a new flow or modify an existing one.
|
186
|
+
#
|
187
|
+
# _Parameters_
|
188
|
+
# * +flow+:: FlowEntry : the flow definition
|
189
|
+
# _Return_ _Value_
|
190
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and error details (if Status indicates an error).
|
148
191
|
def add_modify_flow(flow)
|
149
192
|
put_uri = "#{@controller.get_node_config_uri(self)}/table/#{flow.table_id}/"\
|
150
193
|
"flow/#{flow.id}"
|
@@ -157,6 +200,14 @@ class OFSwitch < OpenflowNode
|
|
157
200
|
end
|
158
201
|
end
|
159
202
|
|
203
|
+
##
|
204
|
+
# Return details of a specific flow.
|
205
|
+
#
|
206
|
+
# _Parameters_
|
207
|
+
# * +table_id+:: String : the identifier for the OpenFlow table from which to retrieve the flow
|
208
|
+
# * +flow_id+:: String : the identifier for the flow to retrieve.
|
209
|
+
# _Return_ _Value_
|
210
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and details about the requested flow.
|
160
211
|
def get_configured_flow(table_id: nil, flow_id: nil)
|
161
212
|
raise ArgumentError, "Table ID (table_id) required" unless table_id
|
162
213
|
raise ArgumentError, "Flow ID (flow_id) required" unless flow_id
|
@@ -168,6 +219,14 @@ class OFSwitch < OpenflowNode
|
|
168
219
|
end
|
169
220
|
end
|
170
221
|
|
222
|
+
##
|
223
|
+
# Remove a flow.
|
224
|
+
#
|
225
|
+
# _Parameters_
|
226
|
+
# * +table_id+:: String : the identifier for the OpenFlow table from which to remove the flow
|
227
|
+
# * +flow_id+:: String : the identifier for the flow to remove.
|
228
|
+
# _Return_ _Value_
|
229
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and details on error (if Status indicates an error).
|
171
230
|
def delete_flow(table_id: nil, flow_id: nil)
|
172
231
|
raise ArgumentError, "Table ID (table_id) required" unless table_id
|
173
232
|
raise ArgumentError, "Flow ID (flow_id) required" unless flow_id
|
@@ -181,16 +240,38 @@ class OFSwitch < OpenflowNode
|
|
181
240
|
end
|
182
241
|
end
|
183
242
|
|
243
|
+
##
|
244
|
+
# Return a list of flows in the controller's operational data store for the OpenFlow switch. These are the flows that are in the switch.
|
245
|
+
#
|
246
|
+
# _Parameters_
|
247
|
+
# * +table_id+:: String : the identifier for the OpenFlow table from which to retrieve the flows
|
248
|
+
# _Return_ _Value_
|
249
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and list of flows.
|
184
250
|
def get_operational_flows(table_id: nil)
|
185
251
|
raise ArgumentError, "Table ID (table_id) required" unless table_id
|
186
252
|
get_flows(table_id: table_id)
|
187
253
|
end
|
188
254
|
|
255
|
+
##
|
256
|
+
# Return a list of flows in the controller's configuration data store for the OpenFlow switch. These are the flows that the controller is supposed to program into the OpenFlow switch.
|
257
|
+
#
|
258
|
+
# _Parameters_
|
259
|
+
# * +table_id+:: String : the identifier for the OpenFlow table from which to retrieve the flows
|
260
|
+
# _Return_ _Value_
|
261
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and list of flows.
|
189
262
|
def get_configured_flows(table_id: nil)
|
190
263
|
raise ArgumentError, "Table ID (table_id) required" unless table_id
|
191
264
|
get_flows(table_id: table_id, is_operational: false)
|
192
265
|
end
|
193
266
|
|
267
|
+
##
|
268
|
+
# Return a list of flows in the controller's operational data store for the OpenFlow switch. These are the flows that are in the switch.
|
269
|
+
# These flows will be returned in Open Vswitch (OVS) format.
|
270
|
+
#
|
271
|
+
# _Parameters_
|
272
|
+
# * +table_id+:: String : the identifier for the OpenFlow table from which to retrieve the flows
|
273
|
+
# _Return_ _Value_
|
274
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and list of flows in Open VSwitch format.
|
194
275
|
def get_operational_flows_ovs_syntax(table_id: nil, sort: false)
|
195
276
|
raise ArgumentError, "Table ID (table_id) required" unless table_id
|
196
277
|
response = get_operational_flows(table_id: table_id)
|
@@ -206,6 +287,16 @@ class OFSwitch < OpenflowNode
|
|
206
287
|
end
|
207
288
|
end
|
208
289
|
|
290
|
+
|
291
|
+
##
|
292
|
+
# Return a list of flows in the controller's configured data store for the OpenFlow switch.
|
293
|
+
# These are the flows that the controller is to program into the OpenFlow switch.
|
294
|
+
# These flows will be returned in Open Vswitch (OVS) format.
|
295
|
+
#
|
296
|
+
# _Parameters_
|
297
|
+
# * +table_id+:: String : the identifier for the OpenFlow table from which to retrieve the flows
|
298
|
+
# _Return_ _Value_
|
299
|
+
# * NetconfResponse : Status ( NetconfResponseStatus ) and list of flows in Open VSwitch format.
|
209
300
|
def get_configured_flows_ovs_syntax(table_id: nil, sort: false)
|
210
301
|
raise ArgumentError, "Table ID (table_id) required" unless table_id
|
211
302
|
response = get_configured_flows(table_id: table_id)
|
@@ -223,7 +314,7 @@ class OFSwitch < OpenflowNode
|
|
223
314
|
|
224
315
|
private
|
225
316
|
|
226
|
-
def get_flows(table_id: nil, is_operational: true)
|
317
|
+
def get_flows(table_id: nil, is_operational: true) #:nodoc:
|
227
318
|
if is_operational
|
228
319
|
get_uri = "#{@controller.get_node_operational_uri(self)}/"\
|
229
320
|
"flow-node-inventory:table/#{table_id}"
|
@@ -246,7 +337,7 @@ class OFSwitch < OpenflowNode
|
|
246
337
|
end
|
247
338
|
end
|
248
339
|
|
249
|
-
def odl_to_ovs_flow_syntax(odl_flow)
|
340
|
+
def odl_to_ovs_flow_syntax(odl_flow) #:nodoc:
|
250
341
|
ovs_flow = {}
|
251
342
|
if odl_flow.has_key?('cookie')
|
252
343
|
ovs_flow['cookie'] = "0x#{odl_flow['cookie'].to_s(16)}"
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
# borrowing from rails implementation
|
32
32
|
# https://github.com/rails/rails/blob/c0357d789b4323da64f1f9f82fa720ec9bac17cf/activesupport/lib/active_support/core_ext/hash/compact.rb#L8
|
33
|
-
class Hash
|
33
|
+
class Hash #:nodoc: all
|
34
34
|
def compact
|
35
35
|
self.select { |_, value| value.is_a?(Hash) ? !value.compact_and_check_if_empty : !value.nil? }
|
36
36
|
end
|
@@ -28,17 +28,25 @@
|
|
28
28
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
29
|
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
|
31
|
+
#Class defining response to most requests made in rubybvc.
|
31
32
|
class NetconfResponse
|
32
33
|
require 'utils/netconf_response_status'
|
33
34
|
|
35
|
+
# integer: success or failure status of request
|
34
36
|
attr_accessor :status
|
37
|
+
# <variable>: the response from the request or more information about failure
|
35
38
|
attr_accessor :body
|
36
39
|
|
37
|
-
def initialize(netconf_response_status = nil, json_body = nil)
|
40
|
+
def initialize(netconf_response_status = nil, json_body = nil) #:nodoc:
|
38
41
|
@status = netconf_response_status
|
39
42
|
@body = json_body
|
40
43
|
end
|
41
44
|
|
45
|
+
##
|
46
|
+
# Return a string for the status.
|
47
|
+
#
|
48
|
+
# _Return_ _Value_
|
49
|
+
# * string : A string describing the status of the response (success or reason for failure).
|
42
50
|
def message
|
43
51
|
case(@status)
|
44
52
|
when NetconfResponseStatus::OK
|
@@ -28,6 +28,7 @@
|
|
28
28
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
29
|
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
|
31
|
+
#Class defining the numeric status that may be returned from making a request to rubybvc
|
31
32
|
class NetconfResponseStatus
|
32
33
|
OK = 200
|
33
34
|
NODE_CONNECTED = 210
|
data/lib/utils/rest_agent.rb
CHANGED
data/lib/utils/utilities.rb
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
29
|
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
|
31
|
-
def check_response_for_success(response)
|
31
|
+
def check_response_for_success(response) #:nodoc:
|
32
32
|
netconf_response = nil
|
33
33
|
if response && ((response.body && response.code.to_i < 204) || (response.code.to_i == 204 && !response.body))
|
34
34
|
parsed_body = response.body ? JSON.parse(response.body) : nil
|
@@ -39,7 +39,7 @@ def check_response_for_success(response)
|
|
39
39
|
netconf_response
|
40
40
|
end
|
41
41
|
|
42
|
-
def handle_error_response(response)
|
42
|
+
def handle_error_response(response) #:nodoc:
|
43
43
|
if response && response.body.nil? && response.code.to_i < 204
|
44
44
|
netconf_response = NetconfResponse.new(NetconfResponseStatus::CTRL_INTERNAL_ERROR)
|
45
45
|
elsif response && response.code.to_i > 204
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubybvc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sarah Dempsey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|