Class: MistApi::BgpConfig

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/bgp_config.rb

Overview

BFD is enabled when either bfd_minimum_interval or bfd_multiplier is configured

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(via = BgpConfigViaEnum::LAN, auth_key = SKIP, bfd_minimum_interval = 350, bfd_multiplier = 3, disable_bfd = false, export = SKIP, export_policy = SKIP, extended_v4_nexthop = SKIP, graceful_restart_time = 0, hold_time = 90, import = SKIP, import_policy = SKIP, local_as = SKIP, neighbor_as = SKIP, neighbors = SKIP, networks = SKIP, no_private_as = false, no_readvertise_to_overlay = false, tunnel_name = SKIP, type = SKIP, vpn_name = SKIP, wan_name = SKIP) ⇒ BgpConfig

Returns a new instance of BgpConfig.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/mist_api/models/bgp_config.rb', line 182

def initialize(via = BgpConfigViaEnum::LAN, auth_key = SKIP,
               bfd_minimum_interval = 350, bfd_multiplier = 3,
               disable_bfd = false, export = SKIP, export_policy = SKIP,
               extended_v4_nexthop = SKIP, graceful_restart_time = 0,
               hold_time = 90, import = SKIP, import_policy = SKIP,
               local_as = SKIP, neighbor_as = SKIP, neighbors = SKIP,
               networks = SKIP, no_private_as = false,
               no_readvertise_to_overlay = false, tunnel_name = SKIP,
               type = SKIP, vpn_name = SKIP, wan_name = SKIP)
  @auth_key = auth_key unless auth_key == SKIP
  @bfd_minimum_interval = bfd_minimum_interval unless bfd_minimum_interval == SKIP
  @bfd_multiplier = bfd_multiplier unless bfd_multiplier == SKIP
  @disable_bfd = disable_bfd unless disable_bfd == SKIP
  @export = export unless export == SKIP
  @export_policy = export_policy unless export_policy == SKIP
  @extended_v4_nexthop = extended_v4_nexthop unless extended_v4_nexthop == SKIP
  @graceful_restart_time = graceful_restart_time unless graceful_restart_time == SKIP
  @hold_time = hold_time unless hold_time == SKIP
  @import = import unless import == SKIP
  @import_policy = import_policy unless import_policy == SKIP
  @local_as = local_as unless local_as == SKIP
  @neighbor_as = neighbor_as unless neighbor_as == SKIP
  @neighbors = neighbors unless neighbors == SKIP
  @networks = networks unless networks == SKIP
  @no_private_as = no_private_as unless no_private_as == SKIP
  unless no_readvertise_to_overlay == SKIP
    @no_readvertise_to_overlay =
      no_readvertise_to_overlay
  end
  @tunnel_name = tunnel_name unless tunnel_name == SKIP
  @type = type unless type == SKIP
  @via = via
  @vpn_name = vpn_name unless vpn_name == SKIP
  @wan_name = wan_name unless wan_name == SKIP
end

Instance Attribute Details

#auth_keyString

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`

Returns:

  • (String)


15
16
17
# File 'lib/mist_api/models/bgp_config.rb', line 15

def auth_key
  @auth_key
end

#bfd_minimum_intervalInteger

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`, when bfd_multiplier is configured alone. Default:

* 1000 if `type`==`external`
* 350 `type`==`internal`

Returns:

  • (Integer)


22
23
24
# File 'lib/mist_api/models/bgp_config.rb', line 22

def bfd_minimum_interval
  @bfd_minimum_interval
end

#bfd_multiplierInteger

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`, when bfd_minimum_interval_is_configured alone

Returns:

  • (Integer)


27
28
29
# File 'lib/mist_api/models/bgp_config.rb', line 27

def bfd_multiplier
  @bfd_multiplier
end

#disable_bfdTrueClass | FalseClass

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. BFD provides faster path failure detection and is enabled by default

Returns:

  • (TrueClass | FalseClass)


32
33
34
# File 'lib/mist_api/models/bgp_config.rb', line 32

def disable_bfd
  @disable_bfd
end

#exportString

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. BFD provides faster path failure detection and is enabled by default

Returns:

  • (String)


37
38
39
# File 'lib/mist_api/models/bgp_config.rb', line 37

def export
  @export
end

#export_policyString

Default export policies if no per-neighbor policies defined

Returns:

  • (String)


41
42
43
# File 'lib/mist_api/models/bgp_config.rb', line 41

def export_policy
  @export_policy
end

#extended_v4_nexthopTrueClass | FalseClass

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. By default, either inet/net6 unicast depending on neighbor IP family (v4 or v6). For v6 neighbors, to exchange v4 nexthop, which allows dual-stack support, enable this

Returns:

  • (TrueClass | FalseClass)


48
49
50
# File 'lib/mist_api/models/bgp_config.rb', line 48

def extended_v4_nexthop
  @extended_v4_nexthop
end

#graceful_restart_timeInteger

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. `0` means disable

Returns:

  • (Integer)


53
54
55
# File 'lib/mist_api/models/bgp_config.rb', line 53

def graceful_restart_time
  @graceful_restart_time
end

#hold_timeInteger

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. Default is 90.

Returns:

  • (Integer)


57
58
59
# File 'lib/mist_api/models/bgp_config.rb', line 57

def hold_time
  @hold_time
end

#importString

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. Default is 90.

Returns:

  • (String)


61
62
63
# File 'lib/mist_api/models/bgp_config.rb', line 61

def import
  @import
end

#import_policyString

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. Default import policies if no per-neighbor policies defined

Returns:

  • (String)


66
67
68
# File 'lib/mist_api/models/bgp_config.rb', line 66

def import_policy
  @import_policy
end

#local_asObject

Required if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. BGP AS, value in range 1-4294967295

Returns:

  • (Object)


71
72
73
# File 'lib/mist_api/models/bgp_config.rb', line 71

def local_as
  @local_as
end

#neighbor_asObject

BGP AS, value in range 1-4294967294. Can be a Variable (e.g. ‘{bgp_as}` )

Returns:

  • (Object)


76
77
78
# File 'lib/mist_api/models/bgp_config.rb', line 76

def neighbor_as
  @neighbor_as
end

#neighborsHash[String, BgpConfigNeighbors]

Required if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. If per-neighbor as is desired. Property key is the neighbor address

Returns:



81
82
83
# File 'lib/mist_api/models/bgp_config.rb', line 81

def neighbors
  @neighbors
end

#networksArray[String]

Optional if ‘via`==`lan`. List of networks where we expect BGP neighbor to connect to/from

Returns:

  • (Array[String])


86
87
88
# File 'lib/mist_api/models/bgp_config.rb', line 86

def networks
  @networks
end

#no_private_asTrueClass | FalseClass

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. If true, we will not advertise private ASNs (AS 64512-65534) to this neighbor

Returns:

  • (TrueClass | FalseClass)


91
92
93
# File 'lib/mist_api/models/bgp_config.rb', line 91

def no_private_as
  @no_private_as
end

#no_readvertise_to_overlayTrueClass | FalseClass

Optional if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. By default, we’ll re-advertise all learned BGP routers toward overlay

Returns:

  • (TrueClass | FalseClass)


96
97
98
# File 'lib/mist_api/models/bgp_config.rb', line 96

def no_readvertise_to_overlay
  @no_readvertise_to_overlay
end

#tunnel_nameString

Optional if ‘via`==`tunnel`

Returns:

  • (String)


100
101
102
# File 'lib/mist_api/models/bgp_config.rb', line 100

def tunnel_name
  @tunnel_name
end

#typeBgpConfigTypeEnum

Required if ‘via`==`lan`, `via`==`tunnel` or `via`==`wan`. enum: `external`, `internal`

Returns:



105
106
107
# File 'lib/mist_api/models/bgp_config.rb', line 105

def type
  @type
end

#viaBgpConfigViaEnum

enum: ‘lan`, `tunnel`, `vpn`, `wan`

Returns:



109
110
111
# File 'lib/mist_api/models/bgp_config.rb', line 109

def via
  @via
end

#vpn_nameString

Optional if ‘via`==`vpn`

Returns:

  • (String)


113
114
115
# File 'lib/mist_api/models/bgp_config.rb', line 113

def vpn_name
  @vpn_name
end

#wan_nameString

Optional if ‘via`==`wan`

Returns:

  • (String)


117
118
119
# File 'lib/mist_api/models/bgp_config.rb', line 117

def wan_name
  @wan_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/mist_api/models/bgp_config.rb', line 219

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  via = hash['via'] ||= BgpConfigViaEnum::LAN
  auth_key = hash.key?('auth_key') ? hash['auth_key'] : SKIP
  bfd_minimum_interval = hash['bfd_minimum_interval'] ||= 350
  bfd_multiplier = hash['bfd_multiplier'] ||= 3
  disable_bfd = hash['disable_bfd'] ||= false
  export = hash.key?('export') ? hash['export'] : SKIP
  export_policy = hash.key?('export_policy') ? hash['export_policy'] : SKIP
  extended_v4_nexthop =
    hash.key?('extended_v4_nexthop') ? hash['extended_v4_nexthop'] : SKIP
  graceful_restart_time = hash['graceful_restart_time'] ||= 0
  hold_time = hash['hold_time'] ||= 90
  import = hash.key?('import') ? hash['import'] : SKIP
  import_policy = hash.key?('import_policy') ? hash['import_policy'] : SKIP
  local_as = hash.key?('local_as') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:BgpLocalAs), hash['local_as']
  ) : SKIP
  neighbor_as = hash.key?('neighbor_as') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:BgpAs), hash['neighbor_as']
  ) : SKIP
  neighbors = BgpConfigNeighbors.from_hash(hash['neighbors']) if hash['neighbors']

  neighbors = SKIP unless hash.key?('neighbors')
  networks = hash.key?('networks') ? hash['networks'] : SKIP
  no_private_as = hash['no_private_as'] ||= false
  no_readvertise_to_overlay = hash['no_readvertise_to_overlay'] ||= false
  tunnel_name = hash.key?('tunnel_name') ? hash['tunnel_name'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  vpn_name = hash.key?('vpn_name') ? hash['vpn_name'] : SKIP
  wan_name = hash.key?('wan_name') ? hash['wan_name'] : SKIP

  # Create object from extracted values.
  BgpConfig.new(via,
                auth_key,
                bfd_minimum_interval,
                bfd_multiplier,
                disable_bfd,
                export,
                export_policy,
                extended_v4_nexthop,
                graceful_restart_time,
                hold_time,
                import,
                import_policy,
                local_as,
                neighbor_as,
                neighbors,
                networks,
                no_private_as,
                no_readvertise_to_overlay,
                tunnel_name,
                type,
                vpn_name,
                wan_name)
end

.namesObject

A mapping from model property names to API property names.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/mist_api/models/bgp_config.rb', line 120

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['auth_key'] = 'auth_key'
  @_hash['bfd_minimum_interval'] = 'bfd_minimum_interval'
  @_hash['bfd_multiplier'] = 'bfd_multiplier'
  @_hash['disable_bfd'] = 'disable_bfd'
  @_hash['export'] = 'export'
  @_hash['export_policy'] = 'export_policy'
  @_hash['extended_v4_nexthop'] = 'extended_v4_nexthop'
  @_hash['graceful_restart_time'] = 'graceful_restart_time'
  @_hash['hold_time'] = 'hold_time'
  @_hash['import'] = 'import'
  @_hash['import_policy'] = 'import_policy'
  @_hash['local_as'] = 'local_as'
  @_hash['neighbor_as'] = 'neighbor_as'
  @_hash['neighbors'] = 'neighbors'
  @_hash['networks'] = 'networks'
  @_hash['no_private_as'] = 'no_private_as'
  @_hash['no_readvertise_to_overlay'] = 'no_readvertise_to_overlay'
  @_hash['tunnel_name'] = 'tunnel_name'
  @_hash['type'] = 'type'
  @_hash['via'] = 'via'
  @_hash['vpn_name'] = 'vpn_name'
  @_hash['wan_name'] = 'wan_name'
  @_hash
end

.nullablesObject

An array for nullable fields



175
176
177
178
179
180
# File 'lib/mist_api/models/bgp_config.rb', line 175

def self.nullables
  %w[
    bfd_minimum_interval
    bfd_multiplier
  ]
end

.optionalsObject

An array for optional fields



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/mist_api/models/bgp_config.rb', line 148

def self.optionals
  %w[
    auth_key
    bfd_minimum_interval
    bfd_multiplier
    disable_bfd
    export
    export_policy
    extended_v4_nexthop
    graceful_restart_time
    hold_time
    import
    import_policy
    local_as
    neighbor_as
    neighbors
    networks
    no_private_as
    no_readvertise_to_overlay
    tunnel_name
    type
    vpn_name
    wan_name
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (BgpConfig | Hash)

    value against the validation is performed.



280
281
282
283
284
285
286
287
288
289
290
# File 'lib/mist_api/models/bgp_config.rb', line 280

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.via,
                                 ->(val) { BgpConfigViaEnum.validate(val) })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['via'],
                        ->(val) { BgpConfigViaEnum.validate(val) })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/mist_api/models/bgp_config.rb', line 307

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} auth_key: #{@auth_key.inspect}, bfd_minimum_interval:"\
  " #{@bfd_minimum_interval.inspect}, bfd_multiplier: #{@bfd_multiplier.inspect}, disable_bfd:"\
  " #{@disable_bfd.inspect}, export: #{@export.inspect}, export_policy:"\
  " #{@export_policy.inspect}, extended_v4_nexthop: #{@extended_v4_nexthop.inspect},"\
  " graceful_restart_time: #{@graceful_restart_time.inspect}, hold_time:"\
  " #{@hold_time.inspect}, import: #{@import.inspect}, import_policy:"\
  " #{@import_policy.inspect}, local_as: #{@local_as.inspect}, neighbor_as:"\
  " #{@neighbor_as.inspect}, neighbors: #{@neighbors.inspect}, networks: #{@networks.inspect},"\
  " no_private_as: #{@no_private_as.inspect}, no_readvertise_to_overlay:"\
  " #{@no_readvertise_to_overlay.inspect}, tunnel_name: #{@tunnel_name.inspect}, type:"\
  " #{@type.inspect}, via: #{@via.inspect}, vpn_name: #{@vpn_name.inspect}, wan_name:"\
  " #{@wan_name.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/mist_api/models/bgp_config.rb', line 293

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} auth_key: #{@auth_key}, bfd_minimum_interval: #{@bfd_minimum_interval},"\
  " bfd_multiplier: #{@bfd_multiplier}, disable_bfd: #{@disable_bfd}, export: #{@export},"\
  " export_policy: #{@export_policy}, extended_v4_nexthop: #{@extended_v4_nexthop},"\
  " graceful_restart_time: #{@graceful_restart_time}, hold_time: #{@hold_time}, import:"\
  " #{@import}, import_policy: #{@import_policy}, local_as: #{@local_as}, neighbor_as:"\
  " #{@neighbor_as}, neighbors: #{@neighbors}, networks: #{@networks}, no_private_as:"\
  " #{@no_private_as}, no_readvertise_to_overlay: #{@no_readvertise_to_overlay}, tunnel_name:"\
  " #{@tunnel_name}, type: #{@type}, via: #{@via}, vpn_name: #{@vpn_name}, wan_name:"\
  " #{@wan_name}>"
end