Class: MistApi::CaptureMxedge

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

Overview

Initiate a Mist Edge Packet Capture

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(duration = 600, format = CaptureMxedgeFormatEnum::STREAM, max_pkt_len = 512, mxedges = SKIP, num_packets = 1024, tcpdump_expression = SKIP, tzsp_host = SKIP, tzsp_port = 37008) ⇒ CaptureMxedge

Returns a new instance of CaptureMxedge.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/mist_api/models/capture_mxedge.rb', line 94

def initialize(duration = 600, format = CaptureMxedgeFormatEnum::STREAM,
               max_pkt_len = 512, mxedges = SKIP, num_packets = 1024,
               tcpdump_expression = SKIP, tzsp_host = SKIP,
               tzsp_port = 37008)
  @duration = duration unless duration == SKIP
  @format = format unless format == SKIP
  @max_pkt_len = max_pkt_len unless max_pkt_len == SKIP
  @mxedges = mxedges unless mxedges == SKIP
  @num_packets = num_packets unless num_packets == SKIP
  @tcpdump_expression = tcpdump_expression unless tcpdump_expression == SKIP
  @type = 'mxedge'
  @tzsp_host = tzsp_host unless tzsp_host == SKIP
  @tzsp_port = tzsp_port unless tzsp_port == SKIP
end

Instance Attribute Details

#durationInteger

Duration of the capture, in seconds. Default is 600, minimum is 60 and maximum is 10800 (3h)

Returns:

  • (Integer)


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

def duration
  @duration
end

#formatCaptureMxedgeFormatEnum

PCAP format. enum:

* `stream`: to Mist cloud
* `tzsp`: stream packets (over UDP as TZSP packets) to a remote host

(typically running Wireshark)



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

def format
  @format
end

#max_pkt_lenInteger

Max_len of each packet to capture. Default is 512, minimum is 64 and maximum is 2048

Returns:

  • (Integer)


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

def max_pkt_len
  @max_pkt_len
end

#mxedgesHash[String, CaptureMxedgeMxedges]

Dict of Mist Edges to capture on, property key is the Mist Edge ID. Property value is a dict of interfaces to capture for the given mxedge (e.g. port1, kni0, lacp0, ipsec, drop, oobm)

Returns:



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

def mxedges
  @mxedges
end

#num_packetsInteger

Number of packets to capture. Default is 1024, maximum is 10000, minimum 1, or 0 for unlimited (local/remote streaming only)

Returns:

  • (Integer)


38
39
40
# File 'lib/mist_api/models/capture_mxedge.rb', line 38

def num_packets
  @num_packets
end

#tcpdump_expressionString

tcpdump expression, applicable across all interfaces if specified at top level. An interface-specific value (under the ‘interfaces` dict) overrides this top-level value.

Returns:

  • (String)


44
45
46
# File 'lib/mist_api/models/capture_mxedge.rb', line 44

def tcpdump_expression
  @tcpdump_expression
end

#typeString (readonly)

enum: ‘mxedge`

Returns:

  • (String)


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

def type
  @type
end

#tzsp_hostString

Required if ‘format`==`tzsp`. Remote host accessible to mxedges over the network for receiving the captured packets

Returns:

  • (String)


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

def tzsp_host
  @tzsp_host
end

#tzsp_portInteger

Optional port on remote host for receiving the captured packets. Default is 37008 (TZSP)

Returns:

  • (Integer)


58
59
60
# File 'lib/mist_api/models/capture_mxedge.rb', line 58

def tzsp_port
  @tzsp_port
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/mist_api/models/capture_mxedge.rb', line 110

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  duration = hash['duration'] ||= 600
  format = hash['format'] ||= CaptureMxedgeFormatEnum::STREAM
  max_pkt_len = hash['max_pkt_len'] ||= 512
  mxedges = CaptureMxedgeMxedges.from_hash(hash['mxedges']) if hash['mxedges']

  mxedges = SKIP unless hash.key?('mxedges')
  num_packets = hash['num_packets'] ||= 1024
  tcpdump_expression =
    hash.key?('tcpdump_expression') ? hash['tcpdump_expression'] : SKIP
  tzsp_host = hash.key?('tzsp_host') ? hash['tzsp_host'] : SKIP
  tzsp_port = hash['tzsp_port'] ||= 37008

  # Create object from extracted values.
  CaptureMxedge.new(duration,
                    format,
                    max_pkt_len,
                    mxedges,
                    num_packets,
                    tcpdump_expression,
                    tzsp_host,
                    tzsp_port)
end

.namesObject

A mapping from model property names to API property names.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/mist_api/models/capture_mxedge.rb', line 61

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['duration'] = 'duration'
  @_hash['format'] = 'format'
  @_hash['max_pkt_len'] = 'max_pkt_len'
  @_hash['mxedges'] = 'mxedges'
  @_hash['num_packets'] = 'num_packets'
  @_hash['tcpdump_expression'] = 'tcpdump_expression'
  @_hash['type'] = 'type'
  @_hash['tzsp_host'] = 'tzsp_host'
  @_hash['tzsp_port'] = 'tzsp_port'
  @_hash
end

.nullablesObject

An array for nullable fields



90
91
92
# File 'lib/mist_api/models/capture_mxedge.rb', line 90

def self.nullables
  []
end

.optionalsObject

An array for optional fields



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/mist_api/models/capture_mxedge.rb', line 76

def self.optionals
  %w[
    duration
    format
    max_pkt_len
    mxedges
    num_packets
    tcpdump_expression
    tzsp_host
    tzsp_port
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



147
148
149
150
151
152
153
# File 'lib/mist_api/models/capture_mxedge.rb', line 147

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} duration: #{@duration.inspect}, format: #{@format.inspect}, max_pkt_len:"\
  " #{@max_pkt_len.inspect}, mxedges: #{@mxedges.inspect}, num_packets:"\
  " #{@num_packets.inspect}, tcpdump_expression: #{@tcpdump_expression.inspect}, type:"\
  " #{@type.inspect}, tzsp_host: #{@tzsp_host.inspect}, tzsp_port: #{@tzsp_port.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



138
139
140
141
142
143
144
# File 'lib/mist_api/models/capture_mxedge.rb', line 138

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} duration: #{@duration}, format: #{@format}, max_pkt_len: #{@max_pkt_len},"\
  " mxedges: #{@mxedges}, num_packets: #{@num_packets}, tcpdump_expression:"\
  " #{@tcpdump_expression}, type: #{@type}, tzsp_host: #{@tzsp_host}, tzsp_port:"\
  " #{@tzsp_port}>"
end