Class: VRouter5600

Inherits:
NetconfNode show all
Defined in:
lib/netconfdev/vrouter/vrouter5600.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

Attributes inherited from NetconfNode

#ip, #password, #port, #tcp_only, #username

Attributes inherited from Node

#name

Instance Method Summary collapse

Methods inherited from NetconfNode

#initialize, #to_hash

Methods inherited from Node

#initialize

Constructor Details

This class inherits a constructor from NetconfNode

Instance Method Details

#create_firewall_instance(firewall) ⇒ Object

Raises:



77
78
79
80
81
82
83
84
85
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 77

def create_firewall_instance(firewall)
  raise ArgumentError, "Firewall must be instance of 'Firewall'" unless firewall.is_a?(Firewall)
  post_uri = @controller.get_ext_mount_config_uri(self)
  response = @controller.rest_agent.post_request(post_uri, firewall.to_hash,
    headers: {'Content-Type' => 'application/yang.data+json'})
  check_response_for_success(response) do
    NetconfResponse.new(NetconfResponseStatus::OK)
  end
end

#delete_dataplane_interface_firewall(interface_name) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 195

def delete_dataplane_interface_firewall(interface_name)
  delete_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
    "vyatta-interfaces:interfaces/vyatta-interfaces-dataplane:dataplane/"\
    "#{interface_name}/vyatta-security-firewall:firewall"
  response = @controller.rest_agent.delete_request(delete_uri)
  if response.code.to_i == 200
    NetconfResponse.new(NetconfResponseStatus::OK)
  else
    handle_error_response(response)
  end
end

#delete_firewall_instance(firewall_or_name) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 87

def delete_firewall_instance(firewall_or_name)
  firewall_name = firewall_or_name.is_a?(Firewall) ? firewall_or_name.rules.name :
    firewall_or_name
  delete_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
    "vyatta-security:security/vyatta-security-firewall:firewall/name/"\
    "#{firewall_name}"
  response = @controller.rest_agent.delete_request(delete_uri)
  if response.code.to_i == 200
    NetconfResponse.new(NetconfResponseStatus::OK)
  else
    handle_error_response(response)
  end
end

#get_cfgObject



48
49
50
51
52
53
54
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 48

def get_cfg
  get_uri = @controller.get_ext_mount_config_uri(self)
  response = @controller.rest_agent.get_request(get_uri)
  check_response_for_success(response) do |body|
    NetconfResponse.new(NetconfResponseStatus::OK, body)
  end
end

#get_dataplane_interface_cfg(interface_name) ⇒ Object



130
131
132
133
134
135
136
137
138
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 130

def get_dataplane_interface_cfg(interface_name)
  get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
    "vyatta-interfaces:interfaces/vyatta-interfaces-dataplane:dataplane/"\
    "#{interface_name}"
  response = @controller.rest_agent.get_request(get_uri)
  check_response_for_success(response) do |body|
    NetconfResponse.new(NetconfResponseStatus::OK, body)
  end
end

#get_dataplane_interfaces_cfgObject



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 117

def get_dataplane_interfaces_cfg
  response = get_interfaces_config
  check_response_for_success(response) do |body|
    if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
        body['interfaces'].has_key?('vyatta-interfaces-dataplane:dataplane')
      NetconfResponse.new(NetconfResponseStatus::OK,
        body['interfaces']['vyatta-interfaces-dataplane:dataplane'])
    else
      NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
    end
  end
end

#get_dataplane_interfaces_listObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 101

def get_dataplane_interfaces_list
  response = get_interfaces_config
  check_response_for_success(response) do |body|
    if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
        body['interfaces'].has_key?('vyatta-interfaces-dataplane:dataplane')
      dp_interface_list = []
      body['interfaces']['vyatta-interfaces-dataplane:dataplane'].each do |interface|
        dp_interface_list << interface['tagnode']
      end
      NetconfResponse.new(NetconfResponseStatus::OK, dp_interface_list)
    else
      NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
    end
  end
end

#get_firewall_instance_cfg(firewall_or_name) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 65

def get_firewall_instance_cfg(firewall_or_name)
  firewall_name = firewall_or_name.is_a?(Firewall) ? firewall_or_name.rules.name :
    firewall_or_name 
  get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
    "vyatta-security:security/vyatta-security-firewall:firewall/name/"\
    "#{firewall_name}"
  response = @controller.rest_agent.get_request(get_uri)
  check_response_for_success(response) do |body|
    NetconfResponse.new(NetconfResponseStatus::OK, body)
  end
end

#get_firewalls_cfgObject



56
57
58
59
60
61
62
63
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 56

def get_firewalls_cfg
  get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
    "vyatta-security:security/vyatta-security-firewall:firewall"
  response = @controller.rest_agent.get_request(get_uri)
  check_response_for_success(response) do |body|
    NetconfResponse.new(NetconfResponseStatus::OK, body)
  end
end

#get_interfaces_cfgObject



224
225
226
227
228
229
230
231
232
233
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 224

def get_interfaces_cfg
  response = get_interfaces_config
  check_response_for_success(response) do |body|
    if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash)
      NetconfResponse.new(NetconfResponseStatus::OK, body)
    else
      NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
    end
  end
end

#get_interfaces_listObject



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 207

def get_interfaces_list
  response = get_interfaces_config
  check_response_for_success(response) do |body|
    if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash)
      if_list = []
      body['interfaces'].each do |if_name, interfaces|
        interfaces.each do |interface|
          if_list << interface['tagnode']
        end
      end
      NetconfResponse.new(NetconfResponseStatus::OK, if_list)
    else
      NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
    end
  end
end

#get_loopback_interface_cfg(interface_name) ⇒ Object



167
168
169
170
171
172
173
174
175
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 167

def get_loopback_interface_cfg(interface_name)
  get_uri = "#{@controller.get_ext_mount_config_uri(self)}/"\
    "vyatta-interfaces:interfaces/vyatta-interfaces-loopback:loopback/"\
    "#{interface_name}"
  response = @controller.rest_agent.get_request(get_uri)
  check_response_for_success(response) do |body|
    NetconfResponse.new(NetconfResponseStatus::OK, body)
  end
end

#get_loopback_interfaces_cfgObject



156
157
158
159
160
161
162
163
164
165
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 156

def get_loopback_interfaces_cfg
  response = get_interfaces_config
  check_response_for_success(response) do |body|
    if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
        body['interfaces'].has_key?('vyatta-interfaces-loopback:loopback')
      NetconfResponse.new(NetconfResponseStatus::OK,
        body['interfaces']['vyatta-interfaces-loopback:loopback'])
    end
  end
end

#get_loopback_interfaces_listObject



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 140

def get_loopback_interfaces_list
  response = get_interfaces_config
  check_response_for_success(response) do |body|
    if body.has_key?('interfaces') && body['interfaces'].is_a?(Hash) &&
        body['interfaces'].has_key?('vyatta-interfaces-loopback:loopback')
      lb_interface_list = []
      body['interfaces']['vyatta-interfaces-loopback:loopback'].each do |interface|
        lb_interface_list << interface['tagnode']
      end
      NetconfResponse.new(NetconfResponseStatus::OK, lb_interface_list)
    else
      NetconfResponse.new(NetconfResponseStatus::DATA_NOT_FOUND)
    end
  end
end

#get_schema(id: nil, version: nil) ⇒ Object

Raises:



41
42
43
44
45
46
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 41

def get_schema(id: nil, version: nil)
  raise ArgumentError, "Identifier (id) required" unless id
  raise ArgumentError, "Version (version) required" unless version
  
  @controller.get_schema(@name, id: id, version: version)
end

#get_schemasObject



37
38
39
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 37

def get_schemas
  @controller.get_schemas(@name)
end

#set_dataplane_interface_firewall(interface_name, inbound_firewall_name: nil, outbound_firewall_name: nil) ⇒ Object

Raises:



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/netconfdev/vrouter/vrouter5600.rb', line 177

def set_dataplane_interface_firewall(interface_name,
    inbound_firewall_name: nil, outbound_firewall_name: nil)
  raise ArgumentError, "At least one firewall (inbound_firewall_name, "\
    "outbound_firewall_name) required" unless inbound_firewall_name || outbound_firewall_name
  dpif = DataplaneFirewall.new(interface_name: interface_name,
    in_firewall_name: inbound_firewall_name,
    out_firewall_name: outbound_firewall_name)
  
  put_uri = "#{@controller.get_ext_mount_config_uri(self)}/#{dpif.get_uri}"
  response = @controller.rest_agent.put_request(put_uri, dpif.to_hash,
    headers: {'Content-Type' => 'application/yang.data+json'})
  if response.code.to_i == 200
    NetconfResponse.new(NetconfResponseStatus::OK)
  else
    handle_error_response(response)
  end
end