rubybvc 0.3.1
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 +7 -0
- data/lib/controller/controller.rb +445 -0
- data/lib/controller/netconf_node.rb +55 -0
- data/lib/controller/node.rb +41 -0
- data/lib/controller/openflow_node.rb +33 -0
- data/lib/netconfdev/vrouter/dataplane_firewall.rb +53 -0
- data/lib/netconfdev/vrouter/firewall.rb +44 -0
- data/lib/netconfdev/vrouter/rule.rb +53 -0
- data/lib/netconfdev/vrouter/rules.rb +53 -0
- data/lib/netconfdev/vrouter/vrouter5600.rb +242 -0
- data/lib/openflowdev/action_output.rb +71 -0
- data/lib/openflowdev/actions/action.rb +39 -0
- data/lib/openflowdev/actions/actions.rb +63 -0
- data/lib/openflowdev/actions/copy_ttl_inwards_action.rb +39 -0
- data/lib/openflowdev/actions/copy_ttl_outwards_action.rb +39 -0
- data/lib/openflowdev/actions/dec_mpls_ttl_action.rb +39 -0
- data/lib/openflowdev/actions/dec_nw_ttl_action.rb +39 -0
- data/lib/openflowdev/actions/drop_action.rb +37 -0
- data/lib/openflowdev/actions/flood_action.rb +39 -0
- data/lib/openflowdev/actions/flood_all_action.rb +39 -0
- data/lib/openflowdev/actions/group_action.rb +44 -0
- data/lib/openflowdev/actions/hw_path_action.rb +39 -0
- data/lib/openflowdev/actions/loopback_action.rb +39 -0
- data/lib/openflowdev/actions/output_action.rb +43 -0
- data/lib/openflowdev/actions/pop_mpls_header_action.rb +41 -0
- data/lib/openflowdev/actions/pop_pbb_header_action.rb +39 -0
- data/lib/openflowdev/actions/pop_vlan_header_action.rb +39 -0
- data/lib/openflowdev/actions/push_mpls_header_action.rb +41 -0
- data/lib/openflowdev/actions/push_pbb_header_action.rb +40 -0
- data/lib/openflowdev/actions/push_vlan_header_action.rb +46 -0
- data/lib/openflowdev/actions/set_dl_dst_action.rb +41 -0
- data/lib/openflowdev/actions/set_dl_src_action.rb +41 -0
- data/lib/openflowdev/actions/set_field_action.rb +43 -0
- data/lib/openflowdev/actions/set_mpls_ttl_action.rb +41 -0
- data/lib/openflowdev/actions/set_nw_dst_action.rb +41 -0
- data/lib/openflowdev/actions/set_nw_src_action.rb +41 -0
- data/lib/openflowdev/actions/set_nw_ttl_action.rb +41 -0
- data/lib/openflowdev/actions/set_queue_action.rb +44 -0
- data/lib/openflowdev/actions/set_tp_dst_action.rb +41 -0
- data/lib/openflowdev/actions/set_tp_src_action.rb +41 -0
- data/lib/openflowdev/actions/set_vlan_cfi_action.rb +41 -0
- data/lib/openflowdev/actions/set_vlan_id_action.rb +41 -0
- data/lib/openflowdev/actions/set_vlan_pcp_action.rb +41 -0
- data/lib/openflowdev/actions/strip_vlan_action.rb +35 -0
- data/lib/openflowdev/actions/sw_path_action.rb +39 -0
- data/lib/openflowdev/flow_entry.rb +91 -0
- data/lib/openflowdev/instruction.rb +53 -0
- data/lib/openflowdev/match.rb +121 -0
- data/lib/openflowdev/of_switch.rb +374 -0
- data/lib/rubybvc.rb +52 -0
- data/lib/utils/hash_with_compact.rb +46 -0
- data/lib/utils/netconf_response.rb +67 -0
- data/lib/utils/netconf_response_status.rb +41 -0
- data/lib/utils/rest_agent.rb +103 -0
- data/lib/utils/utilities.rb +51 -0
- metadata +111 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class Rule
|
32
|
+
attr_reader :number, :action, :src_address
|
33
|
+
|
34
|
+
def initialize(rule_number: nil, action: nil, source_address: nil,
|
35
|
+
icmp_typename: nil)
|
36
|
+
raise ArgumentError, "Rule number (rule_number) required" unless rule_number
|
37
|
+
raise ArgumentError, "Action (action) required" unless action
|
38
|
+
# either of the other two required? at least one required?
|
39
|
+
|
40
|
+
@number = rule_number
|
41
|
+
@action = action
|
42
|
+
@src_address = source_address
|
43
|
+
@icmp_typename = icmp_typename
|
44
|
+
@protocol = "icmp" if icmp_typename
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_hash
|
48
|
+
hash = {:action => @action, :source => {:address => @src_address},
|
49
|
+
:tagnode => @number, :protocol => @protocol, :icmp =>
|
50
|
+
{'type-name' => @icmp_typename}}
|
51
|
+
hash.compact
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class Rules
|
32
|
+
attr_reader :name, :rules
|
33
|
+
|
34
|
+
def initialize(name: nil)
|
35
|
+
raise ArgumentError, "Name (name) required" unless name
|
36
|
+
|
37
|
+
@name = name
|
38
|
+
@rules = []
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_rule(rule)
|
42
|
+
raise ArgumentError, "Rule must be instance of 'Rule'" unless rule.is_a?(Rule)
|
43
|
+
@rules << rule
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_hash
|
47
|
+
rules_hash = []
|
48
|
+
@rules.each do |rule|
|
49
|
+
rules_hash << rule.to_hash
|
50
|
+
end
|
51
|
+
{:rule => rules_hash, :tagnode => @name}
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,242 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class VRouter5600 < NetconfNode
|
32
|
+
require 'netconfdev/vrouter/firewall'
|
33
|
+
require 'netconfdev/vrouter/rules'
|
34
|
+
require 'netconfdev/vrouter/rule'
|
35
|
+
require 'netconfdev/vrouter/dataplane_firewall'
|
36
|
+
|
37
|
+
def get_schemas
|
38
|
+
@controller.get_schemas(@name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_schema(id: nil, version: nil)
|
42
|
+
raise ArgumentError, "Identifier (id) required" unless id
|
43
|
+
raise ArgumentError, "Version (version) required" unless version
|
44
|
+
|
45
|
+
@controller.get_schema(@name, id: id, version: version)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_cfg
|
49
|
+
get_uri = @controller.get_ext_mount_config_uri(self)
|
50
|
+
response = @controller.rest_agent.get_request(get_uri)
|
51
|
+
check_response_for_success(response) do |body|
|
52
|
+
NetconfResponse.new(NetconfResponseStatus::OK, body)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_firewalls_cfg
|
57
|
+
get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
58
|
+
"vyatta-security:security/vyatta-security-firewall:firewall"
|
59
|
+
response = @controller.rest_agent.get_request(get_uri)
|
60
|
+
check_response_for_success(response) do |body|
|
61
|
+
NetconfResponse.new(NetconfResponseStatus::OK, body)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_firewall_instance_cfg(firewall_or_name)
|
66
|
+
firewall_name = firewall_or_name.is_a?(Firewall) ? firewall_or_name.rules.name :
|
67
|
+
firewall_or_name
|
68
|
+
get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
69
|
+
"vyatta-security:security/vyatta-security-firewall:firewall/name/"\
|
70
|
+
"#{firewall_name}"
|
71
|
+
response = @controller.rest_agent.get_request(get_uri)
|
72
|
+
check_response_for_success(response) do |body|
|
73
|
+
NetconfResponse.new(NetconfResponseStatus::OK, body)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_firewall_instance(firewall)
|
78
|
+
raise ArgumentError, "Firewall must be instance of 'Firewall'" unless firewall.is_a?(Firewall)
|
79
|
+
post_uri = @controller.get_ext_mount_config_uri(self)
|
80
|
+
response = @controller.rest_agent.post_request(post_uri, firewall.to_hash,
|
81
|
+
headers: {'Content-Type' => 'application/yang.data+json'})
|
82
|
+
check_response_for_success(response) do
|
83
|
+
NetconfResponse.new(NetconfResponseStatus::OK)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def delete_firewall_instance(firewall_or_name)
|
88
|
+
firewall_name = firewall_or_name.is_a?(Firewall) ? firewall_or_name.rules.name :
|
89
|
+
firewall_or_name
|
90
|
+
delete_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
91
|
+
"vyatta-security:security/vyatta-security-firewall:firewall/name/"\
|
92
|
+
"#{firewall_name}"
|
93
|
+
response = @controller.rest_agent.delete_request(delete_uri)
|
94
|
+
if response.code.to_i == 200
|
95
|
+
NetconfResponse.new(NetconfResponseStatus::OK)
|
96
|
+
else
|
97
|
+
handle_error_response(response)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_dataplane_interfaces_list
|
102
|
+
response = get_interfaces_config
|
103
|
+
check_response_for_success(response) do |body|
|
104
|
+
if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
|
105
|
+
body['interfaces'].has_key?('vyatta-interfaces-dataplane:dataplane')
|
106
|
+
dp_interface_list = []
|
107
|
+
body['interfaces']['vyatta-interfaces-dataplane:dataplane'].each do |interface|
|
108
|
+
dp_interface_list << interface['tagnode']
|
109
|
+
end
|
110
|
+
NetconfResponse.new(NetconfResponseStatus::OK, dp_interface_list)
|
111
|
+
else
|
112
|
+
NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_dataplane_interfaces_cfg
|
118
|
+
response = get_interfaces_config
|
119
|
+
check_response_for_success(response) do |body|
|
120
|
+
if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
|
121
|
+
body['interfaces'].has_key?('vyatta-interfaces-dataplane:dataplane')
|
122
|
+
NetconfResponse.new(NetconfResponseStatus::OK,
|
123
|
+
body['interfaces']['vyatta-interfaces-dataplane:dataplane'])
|
124
|
+
else
|
125
|
+
NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_dataplane_interface_cfg(interface_name)
|
131
|
+
get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
132
|
+
"vyatta-interfaces:interfaces/vyatta-interfaces-dataplane:dataplane/"\
|
133
|
+
"#{interface_name}"
|
134
|
+
response = @controller.rest_agent.get_request(get_uri)
|
135
|
+
check_response_for_success(response) do |body|
|
136
|
+
NetconfResponse.new(NetconfResponseStatus::OK, body)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_loopback_interfaces_list
|
141
|
+
response = get_interfaces_config
|
142
|
+
check_response_for_success(response) do |body|
|
143
|
+
if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
|
144
|
+
body['interfaces'].has_key?('vyatta-interfaces-loopback:loopback')
|
145
|
+
lb_interface_list = []
|
146
|
+
body['interfaces']['vyatta-interfaces-loopback:loopback'].each do |interface|
|
147
|
+
lb_interface_list << interface['tagnode']
|
148
|
+
end
|
149
|
+
NetconfResponse.new(NetconfResponseStatus::OK, lb_interface_list)
|
150
|
+
else
|
151
|
+
NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def get_loopback_interfaces_cfg
|
157
|
+
response = get_interfaces_config
|
158
|
+
check_response_for_success(response) do |body|
|
159
|
+
if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
|
160
|
+
body['interfaces'].has_key?('vyatta-interfaces-loopback:loopback')
|
161
|
+
NetconfResponse.new(NetconfResponseStatus::OK,
|
162
|
+
body['interfaces']['vyatta-interfaces-loopback:loopback'])
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def get_loopback_interface_cfg(interface_name)
|
168
|
+
get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
169
|
+
"vyatta-interfaces:interfaces/vyatta-interfaces-loopback:loopback/"\
|
170
|
+
"#{interface_name}"
|
171
|
+
response = @controller.rest_agent.get_request(get_uri)
|
172
|
+
check_response_for_success(response) do |body|
|
173
|
+
NetconfResponse.new(NetconfResponseStatus::OK, body)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def set_dataplane_interface_firewall(interface_name,
|
178
|
+
inbound_firewall_name: nil, outbound_firewall_name: nil)
|
179
|
+
raise ArgumentError, "At least one firewall (inbound_firewall_name, "\
|
180
|
+
"outbound_firewall_name) required" unless inbound_firewall_name || outbound_firewall_name
|
181
|
+
dpif = DataplaneFirewall.new(interface_name: interface_name,
|
182
|
+
in_firewall_name: inbound_firewall_name,
|
183
|
+
out_firewall_name: outbound_firewall_name)
|
184
|
+
|
185
|
+
put_uri = "#{@controller.get_ext_mount_config_uri(self)}/#{dpif.get_uri}"
|
186
|
+
response = @controller.rest_agent.put_request(put_uri, dpif.to_hash,
|
187
|
+
headers: {'Content-Type' => 'application/yang.data+json'})
|
188
|
+
if response.code.to_i == 200
|
189
|
+
NetconfResponse.new(NetconfResponseStatus::OK)
|
190
|
+
else
|
191
|
+
handle_error_response(response)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def delete_dataplane_interface_firewall(interface_name)
|
196
|
+
delete_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
197
|
+
"vyatta-interfaces:interfaces/vyatta-interfaces-dataplane:dataplane/"\
|
198
|
+
"#{interface_name}/vyatta-security-firewall:firewall"
|
199
|
+
response = @controller.rest_agent.delete_request(delete_uri)
|
200
|
+
if response.code.to_i == 200
|
201
|
+
NetconfResponse.new(NetconfResponseStatus::OK)
|
202
|
+
else
|
203
|
+
handle_error_response(response)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def get_interfaces_list
|
208
|
+
response = get_interfaces_config
|
209
|
+
check_response_for_success(response) do |body|
|
210
|
+
if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash)
|
211
|
+
if_list = []
|
212
|
+
body['interfaces'].each do |if_name, interfaces|
|
213
|
+
interfaces.each do |interface|
|
214
|
+
if_list << interface['tagnode']
|
215
|
+
end
|
216
|
+
end
|
217
|
+
NetconfResponse.new(NetconfResponseStatus::OK, if_list)
|
218
|
+
else
|
219
|
+
NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def get_interfaces_cfg
|
225
|
+
response = get_interfaces_config
|
226
|
+
check_response_for_success(response) do |body|
|
227
|
+
if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash)
|
228
|
+
NetconfResponse.new(NetconfResponseStatus::OK, body)
|
229
|
+
else
|
230
|
+
NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
private
|
236
|
+
|
237
|
+
def get_interfaces_config
|
238
|
+
get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
|
239
|
+
"vyatta-interfaces:interfaces"
|
240
|
+
@controller.rest_agent.get_request(get_uri)
|
241
|
+
end
|
242
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class ActionOutput
|
32
|
+
attr_reader :type, :order, :port, :length
|
33
|
+
|
34
|
+
def initialize(port: nil, length: nil, order: nil)
|
35
|
+
@type = 'output'
|
36
|
+
@order = order
|
37
|
+
@port = port
|
38
|
+
@length = length
|
39
|
+
end
|
40
|
+
|
41
|
+
def update(port: nil, length: nil, order: nil)
|
42
|
+
@order = order unless order.nil?
|
43
|
+
@port = port unless port.nil?
|
44
|
+
@length = length unless length.nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_from_object(action_object)
|
48
|
+
@order = action_object['order']
|
49
|
+
if action_object.has_key?('output-action')
|
50
|
+
if action_object['output-action'].has_key?('output-node-connector')
|
51
|
+
@port = action_object['output-action']['output-node-connector']
|
52
|
+
end
|
53
|
+
|
54
|
+
if action_object['output-action'].has_key?('max-length')
|
55
|
+
@length = action_object['output-action']['max-length']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_s
|
61
|
+
if @port && @length
|
62
|
+
if @port == "CONTROLLER"
|
63
|
+
"#{@port}:#{@length}"
|
64
|
+
else
|
65
|
+
"#{@type}:#{@port}"
|
66
|
+
end
|
67
|
+
else
|
68
|
+
""
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class Action
|
32
|
+
attr_accessor :order
|
33
|
+
|
34
|
+
def initialize(order: nil)
|
35
|
+
raise ArgumentError, "Order (order) required" unless order
|
36
|
+
|
37
|
+
@order = order
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
require 'openflowdev/actions/action'
|
32
|
+
require 'openflowdev/actions/copy_ttl_inwards_action'
|
33
|
+
require 'openflowdev/actions/copy_ttl_outwards_action'
|
34
|
+
require 'openflowdev/actions/dec_mpls_ttl_action'
|
35
|
+
require 'openflowdev/actions/dec_nw_ttl_action'
|
36
|
+
require 'openflowdev/actions/drop_action'
|
37
|
+
require 'openflowdev/actions/flood_action'
|
38
|
+
require 'openflowdev/actions/flood_all_action'
|
39
|
+
require 'openflowdev/actions/group_action'
|
40
|
+
require 'openflowdev/actions/hw_path_action'
|
41
|
+
require 'openflowdev/actions/loopback_action'
|
42
|
+
require 'openflowdev/actions/output_action'
|
43
|
+
require 'openflowdev/actions/pop_mpls_header_action'
|
44
|
+
require 'openflowdev/actions/pop_pbb_header_action'
|
45
|
+
require 'openflowdev/actions/pop_vlan_header_action'
|
46
|
+
require 'openflowdev/actions/push_mpls_header_action'
|
47
|
+
require 'openflowdev/actions/push_pbb_header_action'
|
48
|
+
require 'openflowdev/actions/push_vlan_header_action'
|
49
|
+
require 'openflowdev/actions/set_dl_dst_action'
|
50
|
+
require 'openflowdev/actions/set_dl_src_action'
|
51
|
+
require 'openflowdev/actions/set_field_action'
|
52
|
+
require 'openflowdev/actions/set_mpls_ttl_action'
|
53
|
+
require 'openflowdev/actions/set_nw_dst_action'
|
54
|
+
require 'openflowdev/actions/set_nw_src_action'
|
55
|
+
require 'openflowdev/actions/set_nw_ttl_action'
|
56
|
+
require 'openflowdev/actions/set_queue_action'
|
57
|
+
require 'openflowdev/actions/set_tp_dst_action'
|
58
|
+
require 'openflowdev/actions/set_tp_src_action'
|
59
|
+
require 'openflowdev/actions/set_vlan_cfi_action'
|
60
|
+
require 'openflowdev/actions/set_vlan_id_action'
|
61
|
+
require 'openflowdev/actions/set_vlan_pcp_action'
|
62
|
+
require 'openflowdev/actions/strip_vlan_action'
|
63
|
+
require 'openflowdev/actions/sw_path_action'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class CopyTTLInwardsAction < Action
|
32
|
+
def initialize(order: 0)
|
33
|
+
super(order: order)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_hash
|
37
|
+
{:order => @order, 'copy-ttl-in' => {}}
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class CopyTTLOutwardsAction < Action
|
32
|
+
def initialize(order: 0)
|
33
|
+
super(order: order)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_hash
|
37
|
+
{:order => @order, 'copy-ttl-out' => {}}
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
# list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
29
|
+
# THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
class DecMplsTTLAction < Action
|
32
|
+
def initialize(order: 0)
|
33
|
+
super(order: order)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_hash
|
37
|
+
{:order => @order, 'dec-mpls-ttl' => {}}
|
38
|
+
end
|
39
|
+
end
|