Class: MistApi::NetworkTemplate

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

Overview

Network Template

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(acl_policies = SKIP, acl_tags = SKIP, additional_config_cmds = SKIP, bgp_config = SKIP, created_time = SKIP, dhcp_snooping = SKIP, dns_servers = SKIP, dns_suffix = SKIP, extra_routes = SKIP, extra_routes6 = SKIP, id = SKIP, import_org_networks = SKIP, mist_nac = SKIP, modified_time = SKIP, name = SKIP, networks = SKIP, ntp_servers = SKIP, org_id = SKIP, ospf_areas = SKIP, port_mirroring = SKIP, port_usages = SKIP, radius_config = SKIP, remote_syslog = SKIP, remove_existing_configs = false, routing_policies = SKIP, snmp_config = SKIP, switch_matching = SKIP, switch_mgmt = SKIP, vrf_config = SKIP, vrf_instances = SKIP, additional_properties = nil) ⇒ NetworkTemplate

Returns a new instance of NetworkTemplate.



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
# File 'lib/mist_api/models/network_template.rb', line 223

def initialize(acl_policies = SKIP, acl_tags = SKIP,
               additional_config_cmds = SKIP, bgp_config = SKIP,
               created_time = SKIP, dhcp_snooping = SKIP,
               dns_servers = SKIP, dns_suffix = SKIP, extra_routes = SKIP,
               extra_routes6 = SKIP, id = SKIP, import_org_networks = SKIP,
               mist_nac = SKIP, modified_time = SKIP, name = SKIP,
               networks = SKIP, ntp_servers = SKIP, org_id = SKIP,
               ospf_areas = SKIP, port_mirroring = SKIP, port_usages = SKIP,
               radius_config = SKIP, remote_syslog = SKIP,
               remove_existing_configs = false, routing_policies = SKIP,
               snmp_config = SKIP, switch_matching = SKIP,
               switch_mgmt = SKIP, vrf_config = SKIP, vrf_instances = SKIP,
               additional_properties = nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @acl_policies = acl_policies unless acl_policies == SKIP
  @acl_tags = acl_tags unless acl_tags == SKIP
  @additional_config_cmds = additional_config_cmds unless additional_config_cmds == SKIP
  @bgp_config = bgp_config unless bgp_config == SKIP
  @created_time = created_time unless created_time == SKIP
  @dhcp_snooping = dhcp_snooping unless dhcp_snooping == SKIP
  @dns_servers = dns_servers unless dns_servers == SKIP
  @dns_suffix = dns_suffix unless dns_suffix == SKIP
  @extra_routes = extra_routes unless extra_routes == SKIP
  @extra_routes6 = extra_routes6 unless extra_routes6 == SKIP
  @id = id unless id == SKIP
  @import_org_networks = import_org_networks unless import_org_networks == SKIP
  @mist_nac = mist_nac unless mist_nac == SKIP
  @modified_time = modified_time unless modified_time == SKIP
  @name = name unless name == SKIP
  @networks = networks unless networks == SKIP
  @ntp_servers = ntp_servers unless ntp_servers == SKIP
  @org_id = org_id unless org_id == SKIP
  @ospf_areas = ospf_areas unless ospf_areas == SKIP
  @port_mirroring = port_mirroring unless port_mirroring == SKIP
  @port_usages = port_usages unless port_usages == SKIP
  @radius_config = radius_config unless radius_config == SKIP
  @remote_syslog = remote_syslog unless remote_syslog == SKIP
  @remove_existing_configs = remove_existing_configs unless remove_existing_configs == SKIP
  @routing_policies = routing_policies unless routing_policies == SKIP
  @snmp_config = snmp_config unless snmp_config == SKIP
  @switch_matching = switch_matching unless switch_matching == SKIP
  @switch_mgmt = switch_mgmt unless switch_mgmt == SKIP
  @vrf_config = vrf_config unless vrf_config == SKIP
  @vrf_instances = vrf_instances unless vrf_instances == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#acl_policiesArray[AclPolicy]

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/mist_api/models/network_template.rb', line 14

def acl_policies
  @acl_policies
end

#acl_tagsHash[String, AclTag]

ACL Tags to identify traffic source or destination. Key name is the tag name

Returns:

  • (Hash[String, AclTag])


19
20
21
# File 'lib/mist_api/models/network_template.rb', line 19

def acl_tags
  @acl_tags
end

#additional_config_cmdsArray[String]

additional CLI commands to append to the generated Junos config. Note: no check is done

Returns:

  • (Array[String])


24
25
26
# File 'lib/mist_api/models/network_template.rb', line 24

def additional_config_cmds
  @additional_config_cmds
end

#bgp_configHash[String, SwitchBgpConfig]

additional CLI commands to append to the generated Junos config. Note: no check is done

Returns:



29
30
31
# File 'lib/mist_api/models/network_template.rb', line 29

def bgp_config
  @bgp_config
end

#created_timeFloat

When the object has been created, in epoch

Returns:

  • (Float)


33
34
35
# File 'lib/mist_api/models/network_template.rb', line 33

def created_time
  @created_time
end

#dhcp_snoopingDhcpSnooping

When the object has been created, in epoch

Returns:



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

def dhcp_snooping
  @dhcp_snooping
end

#dns_serversArray[String]

Global dns settings. To keep compatibility, dns settings in ‘ip_config` and `oob_ip_config` will overwrite this setting

Returns:

  • (Array[String])


42
43
44
# File 'lib/mist_api/models/network_template.rb', line 42

def dns_servers
  @dns_servers
end

#dns_suffixArray[String]

Global dns settings. To keep compatibility, dns settings in ‘ip_config` and `oob_ip_config` will overwrite this setting

Returns:

  • (Array[String])


47
48
49
# File 'lib/mist_api/models/network_template.rb', line 47

def dns_suffix
  @dns_suffix
end

#extra_routesHash[String, ExtraRoute]

Property key is the destination CIDR (e.g. “10.0.0.0/8”)

Returns:



51
52
53
# File 'lib/mist_api/models/network_template.rb', line 51

def extra_routes
  @extra_routes
end

#extra_routes6Hash[String, ExtraRoute6]

Property key is the destination CIDR (e.g. “2a02:1234:420a:10c9::/64”)

Returns:



55
56
57
# File 'lib/mist_api/models/network_template.rb', line 55

def extra_routes6
  @extra_routes6
end

#idUUID | String

Unique ID of the object instance in the Mist Organization

Returns:

  • (UUID | String)


59
60
61
# File 'lib/mist_api/models/network_template.rb', line 59

def id
  @id
end

#import_org_networksArray[String]

Org Networks that we’d like to import

Returns:

  • (Array[String])


63
64
65
# File 'lib/mist_api/models/network_template.rb', line 63

def import_org_networks
  @import_org_networks
end

#mist_nacSwitchMistNac

Enable mist_nac to use RadSec

Returns:



67
68
69
# File 'lib/mist_api/models/network_template.rb', line 67

def mist_nac
  @mist_nac
end

#modified_timeFloat

When the object has been modified for the last time, in epoch

Returns:

  • (Float)


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

def modified_time
  @modified_time
end

#nameString

When the object has been modified for the last time, in epoch

Returns:

  • (String)


75
76
77
# File 'lib/mist_api/models/network_template.rb', line 75

def name
  @name
end

#networksHash[String, SwitchNetwork]

Property key is network name

Returns:



79
80
81
# File 'lib/mist_api/models/network_template.rb', line 79

def networks
  @networks
end

#ntp_serversArray[String]

List of NTP servers specific to this device. By default, those in Site Settings will be used

Returns:

  • (Array[String])


84
85
86
# File 'lib/mist_api/models/network_template.rb', line 84

def ntp_servers
  @ntp_servers
end

#org_idUUID | String

List of NTP servers specific to this device. By default, those in Site Settings will be used

Returns:

  • (UUID | String)


89
90
91
# File 'lib/mist_api/models/network_template.rb', line 89

def org_id
  @org_id
end

#ospf_areasHash[String, OspfArea]

Junos OSPF areas. Property key is the OSPF Area (Area should be a number (0-255) / IP address)

Returns:



94
95
96
# File 'lib/mist_api/models/network_template.rb', line 94

def ospf_areas
  @ospf_areas
end

#port_mirroringHash[String, SwitchPortMirroringProperty]

Property key is the port mirroring instance name. ‘port_mirroring` can be added under device/site settings. It takes interface and ports as input for ingress, interface as input for egress and can take interface and port as output. A maximum 4 mirroring ports is allowed

Returns:



101
102
103
# File 'lib/mist_api/models/network_template.rb', line 101

def port_mirroring
  @port_mirroring
end

#port_usagesHash[String, SwitchPortUsage]

Property key is the port usage name. Defines the profiles of port configuration configured on the switch

Returns:



106
107
108
# File 'lib/mist_api/models/network_template.rb', line 106

def port_usages
  @port_usages
end

#radius_configSwitchRadiusConfig

Junos Radius config

Returns:



110
111
112
# File 'lib/mist_api/models/network_template.rb', line 110

def radius_config
  @radius_config
end

#remote_syslogRemoteSyslog

Junos Radius config

Returns:



114
115
116
# File 'lib/mist_api/models/network_template.rb', line 114

def remote_syslog
  @remote_syslog
end

#remove_existing_configsTrueClass | FalseClass

By default, only the configuration generated by Mist is cleaned up during the configuration process. If ‘true`, all the existing configuration will be removed.

Returns:

  • (TrueClass | FalseClass)


120
121
122
# File 'lib/mist_api/models/network_template.rb', line 120

def remove_existing_configs
  @remove_existing_configs
end

#routing_policiesHash[String, SwRoutingPolicy]

Property key is the routing policy name

Returns:



124
125
126
# File 'lib/mist_api/models/network_template.rb', line 124

def routing_policies
  @routing_policies
end

#snmp_configSnmpConfig

Property key is the routing policy name

Returns:



128
129
130
# File 'lib/mist_api/models/network_template.rb', line 128

def snmp_config
  @snmp_config
end

#switch_matchingSwitchMatching

Defines custom switch configuration based on different criteria

Returns:



132
133
134
# File 'lib/mist_api/models/network_template.rb', line 132

def switch_matching
  @switch_matching
end

#switch_mgmtSwitchMgmt

Switch Management settings

Returns:



136
137
138
# File 'lib/mist_api/models/network_template.rb', line 136

def switch_mgmt
  @switch_mgmt
end

#vrf_configVrfConfig

Switch Management settings

Returns:



140
141
142
# File 'lib/mist_api/models/network_template.rb', line 140

def vrf_config
  @vrf_config
end

#vrf_instancesHash[String, SwitchVrfInstance]

Property key is the network name

Returns:



144
145
146
# File 'lib/mist_api/models/network_template.rb', line 144

def vrf_instances
  @vrf_instances
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/mist_api/models/network_template.rb', line 273

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  acl_policies = nil
  unless hash['acl_policies'].nil?
    acl_policies = []
    hash['acl_policies'].each do |structure|
      acl_policies << (AclPolicy.from_hash(structure) if structure)
    end
  end

  acl_policies = SKIP unless hash.key?('acl_policies')
  acl_tags = AclTag.from_hash(hash['acl_tags']) if hash['acl_tags']

  acl_tags = SKIP unless hash.key?('acl_tags')
  additional_config_cmds =
    hash.key?('additional_config_cmds') ? hash['additional_config_cmds'] : SKIP
  bgp_config = SwitchBgpConfig.from_hash(hash['bgp_config']) if hash['bgp_config']

  bgp_config = SKIP unless hash.key?('bgp_config')
  created_time = hash.key?('created_time') ? hash['created_time'] : SKIP
  dhcp_snooping = DhcpSnooping.from_hash(hash['dhcp_snooping']) if hash['dhcp_snooping']
  dns_servers = hash.key?('dns_servers') ? hash['dns_servers'] : SKIP
  dns_suffix = hash.key?('dns_suffix') ? hash['dns_suffix'] : SKIP
  extra_routes = ExtraRoute.from_hash(hash['extra_routes']) if hash['extra_routes']

  extra_routes = SKIP unless hash.key?('extra_routes')
  extra_routes6 = ExtraRoute6.from_hash(hash['extra_routes6']) if hash['extra_routes6']

  extra_routes6 = SKIP unless hash.key?('extra_routes6')
  id = hash.key?('id') ? hash['id'] : SKIP
  import_org_networks =
    hash.key?('import_org_networks') ? hash['import_org_networks'] : SKIP
  mist_nac = SwitchMistNac.from_hash(hash['mist_nac']) if hash['mist_nac']
  modified_time = hash.key?('modified_time') ? hash['modified_time'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  networks = SwitchNetwork.from_hash(hash['networks']) if hash['networks']

  networks = SKIP unless hash.key?('networks')
  ntp_servers = hash.key?('ntp_servers') ? hash['ntp_servers'] : SKIP
  org_id = hash.key?('org_id') ? hash['org_id'] : SKIP
  ospf_areas = OspfArea.from_hash(hash['ospf_areas']) if hash['ospf_areas']

  ospf_areas = SKIP unless hash.key?('ospf_areas')
  port_mirroring = SwitchPortMirroringProperty.from_hash(hash['port_mirroring']) if
    hash['port_mirroring']

  port_mirroring = SKIP unless hash.key?('port_mirroring')
  port_usages = SwitchPortUsage.from_hash(hash['port_usages']) if hash['port_usages']

  port_usages = SKIP unless hash.key?('port_usages')
  radius_config = SwitchRadiusConfig.from_hash(hash['radius_config']) if hash['radius_config']
  remote_syslog = RemoteSyslog.from_hash(hash['remote_syslog']) if hash['remote_syslog']
  remove_existing_configs = hash['remove_existing_configs'] ||= false
  routing_policies = SwRoutingPolicy.from_hash(hash['routing_policies']) if
    hash['routing_policies']

  routing_policies = SKIP unless hash.key?('routing_policies')
  snmp_config = SnmpConfig.from_hash(hash['snmp_config']) if hash['snmp_config']
  switch_matching = SwitchMatching.from_hash(hash['switch_matching']) if
    hash['switch_matching']
  switch_mgmt = SwitchMgmt.from_hash(hash['switch_mgmt']) if hash['switch_mgmt']
  vrf_config = VrfConfig.from_hash(hash['vrf_config']) if hash['vrf_config']
  vrf_instances = SwitchVrfInstance.from_hash(hash['vrf_instances']) if hash['vrf_instances']

  vrf_instances = SKIP unless hash.key?('vrf_instances')

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  NetworkTemplate.new(acl_policies,
                      acl_tags,
                      additional_config_cmds,
                      bgp_config,
                      created_time,
                      dhcp_snooping,
                      dns_servers,
                      dns_suffix,
                      extra_routes,
                      extra_routes6,
                      id,
                      import_org_networks,
                      mist_nac,
                      modified_time,
                      name,
                      networks,
                      ntp_servers,
                      org_id,
                      ospf_areas,
                      port_mirroring,
                      port_usages,
                      radius_config,
                      remote_syslog,
                      remove_existing_configs,
                      routing_policies,
                      snmp_config,
                      switch_matching,
                      switch_mgmt,
                      vrf_config,
                      vrf_instances,
                      additional_properties)
end

.namesObject

A mapping from model property names to API property names.



147
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
173
174
175
176
177
178
179
180
# File 'lib/mist_api/models/network_template.rb', line 147

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['acl_policies'] = 'acl_policies'
  @_hash['acl_tags'] = 'acl_tags'
  @_hash['additional_config_cmds'] = 'additional_config_cmds'
  @_hash['bgp_config'] = 'bgp_config'
  @_hash['created_time'] = 'created_time'
  @_hash['dhcp_snooping'] = 'dhcp_snooping'
  @_hash['dns_servers'] = 'dns_servers'
  @_hash['dns_suffix'] = 'dns_suffix'
  @_hash['extra_routes'] = 'extra_routes'
  @_hash['extra_routes6'] = 'extra_routes6'
  @_hash['id'] = 'id'
  @_hash['import_org_networks'] = 'import_org_networks'
  @_hash['mist_nac'] = 'mist_nac'
  @_hash['modified_time'] = 'modified_time'
  @_hash['name'] = 'name'
  @_hash['networks'] = 'networks'
  @_hash['ntp_servers'] = 'ntp_servers'
  @_hash['org_id'] = 'org_id'
  @_hash['ospf_areas'] = 'ospf_areas'
  @_hash['port_mirroring'] = 'port_mirroring'
  @_hash['port_usages'] = 'port_usages'
  @_hash['radius_config'] = 'radius_config'
  @_hash['remote_syslog'] = 'remote_syslog'
  @_hash['remove_existing_configs'] = 'remove_existing_configs'
  @_hash['routing_policies'] = 'routing_policies'
  @_hash['snmp_config'] = 'snmp_config'
  @_hash['switch_matching'] = 'switch_matching'
  @_hash['switch_mgmt'] = 'switch_mgmt'
  @_hash['vrf_config'] = 'vrf_config'
  @_hash['vrf_instances'] = 'vrf_instances'
  @_hash
end

.nullablesObject

An array for nullable fields



219
220
221
# File 'lib/mist_api/models/network_template.rb', line 219

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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/network_template.rb', line 183

def self.optionals
  %w[
    acl_policies
    acl_tags
    additional_config_cmds
    bgp_config
    created_time
    dhcp_snooping
    dns_servers
    dns_suffix
    extra_routes
    extra_routes6
    id
    import_org_networks
    mist_nac
    modified_time
    name
    networks
    ntp_servers
    org_id
    ospf_areas
    port_mirroring
    port_usages
    radius_config
    remote_syslog
    remove_existing_configs
    routing_policies
    snmp_config
    switch_matching
    switch_mgmt
    vrf_config
    vrf_instances
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/mist_api/models/network_template.rb', line 402

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} acl_policies: #{@acl_policies.inspect}, acl_tags: #{@acl_tags.inspect},"\
  " additional_config_cmds: #{@additional_config_cmds.inspect}, bgp_config:"\
  " #{@bgp_config.inspect}, created_time: #{@created_time.inspect}, dhcp_snooping:"\
  " #{@dhcp_snooping.inspect}, dns_servers: #{@dns_servers.inspect}, dns_suffix:"\
  " #{@dns_suffix.inspect}, extra_routes: #{@extra_routes.inspect}, extra_routes6:"\
  " #{@extra_routes6.inspect}, id: #{@id.inspect}, import_org_networks:"\
  " #{@import_org_networks.inspect}, mist_nac: #{@mist_nac.inspect}, modified_time:"\
  " #{@modified_time.inspect}, name: #{@name.inspect}, networks: #{@networks.inspect},"\
  " ntp_servers: #{@ntp_servers.inspect}, org_id: #{@org_id.inspect}, ospf_areas:"\
  " #{@ospf_areas.inspect}, port_mirroring: #{@port_mirroring.inspect}, port_usages:"\
  " #{@port_usages.inspect}, radius_config: #{@radius_config.inspect}, remote_syslog:"\
  " #{@remote_syslog.inspect}, remove_existing_configs: #{@remove_existing_configs.inspect},"\
  " routing_policies: #{@routing_policies.inspect}, snmp_config: #{@snmp_config.inspect},"\
  " switch_matching: #{@switch_matching.inspect}, switch_mgmt: #{@switch_mgmt.inspect},"\
  " vrf_config: #{@vrf_config.inspect}, vrf_instances: #{@vrf_instances.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/mist_api/models/network_template.rb', line 384

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} acl_policies: #{@acl_policies}, acl_tags: #{@acl_tags},"\
  " additional_config_cmds: #{@additional_config_cmds}, bgp_config: #{@bgp_config},"\
  " created_time: #{@created_time}, dhcp_snooping: #{@dhcp_snooping}, dns_servers:"\
  " #{@dns_servers}, dns_suffix: #{@dns_suffix}, extra_routes: #{@extra_routes},"\
  " extra_routes6: #{@extra_routes6}, id: #{@id}, import_org_networks:"\
  " #{@import_org_networks}, mist_nac: #{@mist_nac}, modified_time: #{@modified_time}, name:"\
  " #{@name}, networks: #{@networks}, ntp_servers: #{@ntp_servers}, org_id: #{@org_id},"\
  " ospf_areas: #{@ospf_areas}, port_mirroring: #{@port_mirroring}, port_usages:"\
  " #{@port_usages}, radius_config: #{@radius_config}, remote_syslog: #{@remote_syslog},"\
  " remove_existing_configs: #{@remove_existing_configs}, routing_policies:"\
  " #{@routing_policies}, snmp_config: #{@snmp_config}, switch_matching: #{@switch_matching},"\
  " switch_mgmt: #{@switch_mgmt}, vrf_config: #{@vrf_config}, vrf_instances:"\
  " #{@vrf_instances}, additional_properties: #{@additional_properties}>"
end