enfcli 4.0.0 → 5.0.0.pre.alpha
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 +4 -4
- data/.circleci/Dockerfile +2 -2
- data/.circleci/config.yml +5 -0
- data/Gemfile.lock +38 -26
- data/Makefile +7 -0
- data/README.md +52 -7
- data/enfcli.gemspec +28 -26
- data/format.sh +9 -0
- data/lib/enfapi.rb +184 -237
- data/lib/enfapi/dns.rb +95 -0
- data/lib/enfapi/firewall.rb +37 -0
- data/lib/enfapi/user.rb +75 -0
- data/lib/enfcli.rb +211 -111
- data/lib/enfcli/commands/captive.rb +518 -157
- data/lib/enfcli/commands/user.rb +208 -160
- data/lib/enfcli/commands/xcr.rb +151 -119
- data/lib/enfcli/commands/xdns.rb +65 -55
- data/lib/enfcli/commands/xfw.rb +37 -37
- data/lib/enfcli/commands/xiam.rb +87 -80
- data/lib/enfcli/version.rb +2 -2
- data/lib/enfthor.rb +38 -14
- metadata +65 -5
data/lib/enfcli/commands/xcr.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright 2018 Xaptum,Inc
|
2
|
+
# Copyright 2018-2020 Xaptum,Inc
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -13,56 +13,51 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
-
require
|
17
|
-
require
|
16
|
+
require "enfthor"
|
17
|
+
require "enfapi"
|
18
18
|
|
19
19
|
module EnfCli
|
20
|
-
|
21
20
|
module Cmd
|
22
|
-
|
23
21
|
class Xcr < EnfThor
|
24
22
|
no_commands {
|
25
|
-
def display_endpoints
|
26
|
-
headings = [
|
27
|
-
rows = eps.map{ |hash|
|
28
|
-
[
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
]
|
23
|
+
def display_endpoints(eps)
|
24
|
+
headings = ["IPV6", "Name", "State", "Network", "Remote IP"]
|
25
|
+
rows = eps.map { |hash|
|
26
|
+
[hash[:ipv6],
|
27
|
+
hash[:name],
|
28
|
+
hash[:state],
|
29
|
+
hash[:state] == "OFFLINE" ? "" : hash[:last_event][:asn_org],
|
30
|
+
hash[:state] == "OFFLINE" ? "" : hash[:last_event][:remote_ip]]
|
34
31
|
}
|
35
32
|
render_table(headings, rows, options.file)
|
36
33
|
end
|
37
34
|
|
38
|
-
def display_endpoint_events
|
39
|
-
headings = [
|
40
|
-
rows = events.map{ |hash|
|
41
|
-
[
|
35
|
+
def display_endpoint_events(events)
|
36
|
+
headings = ["Time", "IPV6", "Source", "Event", "Network", "Remote IP"]
|
37
|
+
rows = events.map { |hash|
|
38
|
+
[hash[:inserted_date], hash[:ipv6_text], hash[:source], hash[:type], hash[:asn_org], hash[:remote_ip]]
|
42
39
|
}
|
43
40
|
render_table(headings, rows)
|
44
41
|
end
|
45
42
|
|
46
|
-
def display_domains
|
47
|
-
headings = [
|
48
|
-
rows = domains.map{ |hash|
|
49
|
-
[
|
50
|
-
]
|
43
|
+
def display_domains(domains)
|
44
|
+
headings = ["Name", "Cidr", "Status"]
|
45
|
+
rows = domains.map { |hash|
|
46
|
+
[hash[:name], hash[:cidr], hash[:status]]
|
51
47
|
}
|
52
48
|
render_table(headings, rows)
|
53
49
|
end
|
54
50
|
|
55
|
-
def display_networks
|
56
|
-
headings = [
|
57
|
-
rows = networks.map{ |hash|
|
58
|
-
[
|
59
|
-
]
|
51
|
+
def display_networks(networks)
|
52
|
+
headings = ["Name", "Cidr", "Description", "Status"]
|
53
|
+
rows = networks.map { |hash|
|
54
|
+
[hash[:name], hash[:cidr], hash[:description], hash[:status]]
|
60
55
|
}
|
61
56
|
render_table(headings, rows)
|
62
57
|
end
|
63
58
|
|
64
|
-
def display_network
|
65
|
-
network_cidr = network[:
|
59
|
+
def display_network(network)
|
60
|
+
network_cidr = network[:cidr]
|
66
61
|
name = network[:name] || ""
|
67
62
|
description = network[:description] || ""
|
68
63
|
status = network[:status] || ""
|
@@ -79,27 +74,27 @@ module EnfCli
|
|
79
74
|
say "Modified At: #{modified_at}\n", nil, true
|
80
75
|
end
|
81
76
|
|
82
|
-
def display_limits
|
77
|
+
def display_limits(limits)
|
83
78
|
# Extract default limits
|
84
79
|
default_limits = limits[:default]
|
85
80
|
current_limits = limits[:current]
|
86
81
|
max_limits = limits[:max]
|
87
82
|
|
88
83
|
# add type to the limits hash
|
89
|
-
default_limits[:limit] =
|
90
|
-
max_limits[:limit] =
|
91
|
-
current_limits[:limit] =
|
84
|
+
default_limits[:limit] = "DEFAULT" if default_limits
|
85
|
+
max_limits[:limit] = "MAX" if max_limits
|
86
|
+
current_limits[:limit] = "CURRENT" if current_limits
|
92
87
|
|
93
88
|
limits_array = []
|
94
89
|
limits_array.push default_limits if default_limits
|
95
90
|
limits_array.push current_limits if current_limits
|
96
91
|
limits_array.push max_limits if max_limits
|
97
92
|
|
98
|
-
headings = [
|
99
|
-
headings <<
|
93
|
+
headings = ["Limit", "Pkts/Sec", "Pkts Burst Size", "Bytes/Sec", "Bytes Burst Size"]
|
94
|
+
headings << "Inherited" if limits_array.reduce(false) { |acc, hash| acc or hash.member?(:inherit) }
|
100
95
|
|
101
|
-
rows = limits_array.map{ |hash|
|
102
|
-
row = [
|
96
|
+
rows = limits_array.map { |hash|
|
97
|
+
row = [hash[:limit], hash[:packets_per_second], hash[:packets_burst_size], hash[:bytes_per_second], hash[:bytes_burst_size]]
|
103
98
|
row << hash[:inherit] ? "Y" : "N" if hash.member?(:inherit)
|
104
99
|
row
|
105
100
|
}
|
@@ -109,12 +104,26 @@ module EnfCli
|
|
109
104
|
}
|
110
105
|
|
111
106
|
desc "list-networks", "List all virtual networks in domain"
|
107
|
+
method_option :domain, type: :string, default: nil, banner: "/48 CIDR",
|
108
|
+
aliases: "-d"
|
109
|
+
|
112
110
|
def list_networks
|
113
111
|
try_with_rescue_in_session do
|
114
|
-
|
112
|
+
# get correct domain
|
113
|
+
domain = EnfCli::CTX.instance.session[:domain]
|
114
|
+
raise EnfCli::ERROR, "User not in a valid domain!" unless domain
|
115
|
+
|
116
|
+
# check if admin
|
117
|
+
if EnfCli::CTX.instance.xaptum_admin?
|
118
|
+
raise EnfCli::ERROR, "--domain is required" unless options[:domain]
|
119
|
+
|
120
|
+
domain = options[:domain]
|
121
|
+
elsif options[:domain]
|
122
|
+
say "Warning: Ignoring command option --domain #{options[:domain]}", :yellow
|
123
|
+
end
|
115
124
|
|
116
125
|
# Call the api
|
117
|
-
data = EnfApi::API.instance.list_domain_nws
|
126
|
+
data = EnfApi::API.instance.list_domain_nws domain
|
118
127
|
networks = data[:data]
|
119
128
|
|
120
129
|
# display table
|
@@ -124,12 +133,24 @@ module EnfCli
|
|
124
133
|
|
125
134
|
desc "provision-network", "Provision a Network"
|
126
135
|
method_option :name, :type => :array, :required => true, :banner => "NAME"
|
136
|
+
method_option :domain, type: :string, default: nil, banner: "/48 CIDR",
|
137
|
+
aliases: "-d"
|
127
138
|
method_option :description, :type => :array, :banner => "DESCRIPTION"
|
139
|
+
|
128
140
|
def provision_network
|
129
141
|
try_with_rescue_in_session do
|
130
|
-
#
|
131
|
-
|
132
|
-
raise EnfCli::ERROR, "User
|
142
|
+
# get correct domain
|
143
|
+
domain = EnfCli::CTX.instance.session[:domain]
|
144
|
+
raise EnfCli::ERROR, "User not in a valid domain!" unless domain
|
145
|
+
|
146
|
+
# check if admin
|
147
|
+
if EnfCli::CTX.instance.xaptum_admin?
|
148
|
+
raise EnfCli::ERROR, "--domain is required" unless options[:domain]
|
149
|
+
|
150
|
+
domain = options[:domain]
|
151
|
+
elsif options[:domain]
|
152
|
+
say "Warning: Ignoring command option --domain #{options[:domain]}", :yellow
|
153
|
+
end
|
133
154
|
|
134
155
|
# Get options
|
135
156
|
description = ""
|
@@ -139,10 +160,9 @@ module EnfCli
|
|
139
160
|
# Call the api
|
140
161
|
hash = {
|
141
162
|
:name => network_name,
|
142
|
-
:
|
143
|
-
:description => description
|
163
|
+
:description => description,
|
144
164
|
}
|
145
|
-
data = EnfApi::API.instance.create_nw hash
|
165
|
+
data = EnfApi::API.instance.create_nw domain, hash
|
146
166
|
networks = data[:data]
|
147
167
|
|
148
168
|
# display table
|
@@ -153,6 +173,7 @@ module EnfCli
|
|
153
173
|
|
154
174
|
desc "get-network", "Display network details"
|
155
175
|
method_option :network, :type => :string, :required => true
|
176
|
+
|
156
177
|
def get_network
|
157
178
|
try_with_rescue_in_session do
|
158
179
|
# call the api
|
@@ -168,6 +189,7 @@ module EnfCli
|
|
168
189
|
method_option :network, :type => :string, :required => true
|
169
190
|
method_option :name, :type => :array, :required => false, :banner => "NAME"
|
170
191
|
method_option :description, :type => :array, :required => false, :banner => "DESCRIPTION"
|
192
|
+
|
171
193
|
def update_network
|
172
194
|
try_with_rescue_in_session do
|
173
195
|
# Get options
|
@@ -188,6 +210,7 @@ module EnfCli
|
|
188
210
|
end
|
189
211
|
|
190
212
|
desc "list-enf-networks", "List enf /34 networks"
|
213
|
+
|
191
214
|
def list_enf_networks
|
192
215
|
try_with_rescue_in_session do
|
193
216
|
# Call the api
|
@@ -195,27 +218,26 @@ module EnfCli
|
|
195
218
|
networks = data[:data]
|
196
219
|
|
197
220
|
# Display the data
|
198
|
-
headings = [
|
199
|
-
rows = networks.map{ |hash|
|
200
|
-
[
|
221
|
+
headings = ["Id", "Parent", "Network", "Notes", "Status", "Type"]
|
222
|
+
rows = networks.map { |hash|
|
223
|
+
[hash[:id], hash[:parent], hash[:network], hash[:notes], hash[:status], hash[:type]]
|
201
224
|
}
|
202
225
|
render_table(headings, rows)
|
203
|
-
|
204
226
|
end
|
205
227
|
end
|
206
228
|
|
207
229
|
desc "list-domains", "List all domains"
|
230
|
+
|
208
231
|
def list_domains
|
209
232
|
try_with_rescue_in_session do
|
210
233
|
session = EnfCli::CTX.instance.session
|
211
234
|
|
212
235
|
# call api
|
213
|
-
data = {:data => []}
|
214
|
-
case session[:type]
|
215
|
-
when 'XAPTUM_ADMIN'
|
216
|
-
data = EnfApi::API.instance.list_domains
|
236
|
+
data = { :data => [] }
|
217
237
|
|
218
|
-
|
238
|
+
if EnfCli::CTX.instance.xaptum_admin?
|
239
|
+
data = EnfApi::API.instance.list_domains
|
240
|
+
elsif EnfCli::CTX.instance.has_role?("DOMAIN_ADMIN")
|
219
241
|
data = EnfApi::API.instance.get_domain session[:domain_id]
|
220
242
|
end
|
221
243
|
|
@@ -229,6 +251,7 @@ module EnfCli
|
|
229
251
|
method_option :name, :type => :string, :required => true
|
230
252
|
method_option :'admin-name', :type => :array, :required => true, :banner => "ADMIN_NAME"
|
231
253
|
method_option :'admin-email', :type => :string, :required => true, :banner => "EMAIL"
|
254
|
+
|
232
255
|
def provision_domain
|
233
256
|
try_with_rescue_in_session do
|
234
257
|
# Get cli params
|
@@ -241,7 +264,7 @@ module EnfCli
|
|
241
264
|
:admin_name => admin_name,
|
242
265
|
:admin_email => admin_email,
|
243
266
|
:name => domain_name,
|
244
|
-
:type =>
|
267
|
+
:type => "CUSTOMER_SOURCE",
|
245
268
|
}
|
246
269
|
data = EnfApi::API.instance.create_domain hash
|
247
270
|
|
@@ -252,19 +275,20 @@ module EnfCli
|
|
252
275
|
end
|
253
276
|
|
254
277
|
desc "list-domain-rate-limits", "List domain rate limits"
|
255
|
-
method_option :
|
256
|
-
method_option :filter, :type => :string, :enum => [
|
278
|
+
method_option :domain, :type => :string, :required => true, :banner => "/48 CIDR"
|
279
|
+
method_option :filter, :type => :string, :enum => ["default", "max"]
|
280
|
+
|
257
281
|
def list_domain_rate_limits
|
258
282
|
try_with_rescue_in_session do
|
259
283
|
# Call the api
|
260
|
-
data = EnfApi::API.instance.get_domain_rate_limits options[:
|
284
|
+
data = EnfApi::API.instance.get_domain_rate_limits options[:domain], options[:filter]
|
261
285
|
|
262
286
|
# Get the limits
|
263
287
|
limits = data[:data][0]
|
264
288
|
|
265
289
|
# if the Api returns only the rate limits object, have to add type explicitly to display
|
266
290
|
limits = {
|
267
|
-
options[:filter].to_sym => limits
|
291
|
+
options[:filter].to_sym => limits,
|
268
292
|
} if options[:filter]
|
269
293
|
|
270
294
|
# Display limits
|
@@ -273,8 +297,9 @@ module EnfCli
|
|
273
297
|
end
|
274
298
|
|
275
299
|
desc "list-network-rate-limits", "List network rate limits"
|
276
|
-
method_option :network, :type => :string, :required => true
|
277
|
-
method_option :filter, :type => :string, :enum => [
|
300
|
+
method_option :network, :type => :string, :required => true, :banner => "/64 CIDR"
|
301
|
+
method_option :filter, :type => :string, :enum => ["default", "max"]
|
302
|
+
|
278
303
|
def list_network_rate_limits
|
279
304
|
try_with_rescue_in_session do
|
280
305
|
# Call the api
|
@@ -285,7 +310,7 @@ module EnfCli
|
|
285
310
|
|
286
311
|
# if the Api returns only the rate limits object, have to add type explicitly to display
|
287
312
|
limits = {
|
288
|
-
options[:filter].to_sym => limits
|
313
|
+
options[:filter].to_sym => limits,
|
289
314
|
} if options[:filter]
|
290
315
|
|
291
316
|
# Display limits
|
@@ -295,7 +320,8 @@ module EnfCli
|
|
295
320
|
|
296
321
|
desc "list-endpoint-rate-limits", "List endpoints rate limits"
|
297
322
|
method_option :ipv6, :type => :string, :required => true
|
298
|
-
method_option :filter, :type => :string, :enum => [
|
323
|
+
method_option :filter, :type => :string, :enum => ["current", "max"]
|
324
|
+
|
299
325
|
def list_endpoint_rate_limits
|
300
326
|
try_with_rescue_in_session do
|
301
327
|
# Call the api
|
@@ -306,21 +332,21 @@ module EnfCli
|
|
306
332
|
|
307
333
|
# if the Api returns only the rate limits object, have to add type explicitly to display
|
308
334
|
limits = {
|
309
|
-
options[:filter].to_sym => limits
|
335
|
+
options[:filter].to_sym => limits,
|
310
336
|
} if options[:filter]
|
311
337
|
|
312
|
-
|
313
338
|
# Display limits
|
314
339
|
display_limits limits
|
315
340
|
end
|
316
341
|
end
|
317
342
|
|
318
343
|
desc "activate-domain", "Activate a customer's /48 domain"
|
319
|
-
method_option :
|
344
|
+
method_option :domain, :type => :string, :required => true, banner: "/48 CIDR"
|
345
|
+
|
320
346
|
def activate_domain
|
321
347
|
try_with_rescue_in_session do
|
322
348
|
# Call api
|
323
|
-
data = EnfApi::API.instance.update_domain_status options[:
|
349
|
+
data = EnfApi::API.instance.update_domain_status options[:domain], { :status => "ACTIVE" }
|
324
350
|
domains = data[:data]
|
325
351
|
|
326
352
|
# Display the data
|
@@ -330,11 +356,12 @@ module EnfCli
|
|
330
356
|
end
|
331
357
|
|
332
358
|
desc "deactivate-domain", "Deactivate a customer's /48 domain"
|
333
|
-
method_option :
|
359
|
+
method_option :domain, :type => :string, :required => true, banner: "/48 CIDR"
|
360
|
+
|
334
361
|
def deactivate_domain
|
335
362
|
try_with_rescue_in_session do
|
336
363
|
# Call api
|
337
|
-
data = EnfApi::API.instance.update_domain_status options[:
|
364
|
+
data = EnfApi::API.instance.update_domain_status options[:domain], { :status => "READY" }
|
338
365
|
domains = data[:data]
|
339
366
|
|
340
367
|
# Display the data
|
@@ -344,27 +371,28 @@ module EnfCli
|
|
344
371
|
end
|
345
372
|
|
346
373
|
desc "set-domain-rate-limits", "Update a customer /48 domain's endpoint rate limits"
|
347
|
-
method_option :
|
348
|
-
method_option :limit, :type => :string, :enum => [
|
349
|
-
method_option :'packets-per-second', :type => :numeric, :required => true
|
350
|
-
method_option :'packets-burst-size', :type => :numeric, :required => true
|
351
|
-
method_option :'bytes-per-second', :type => :numeric, :required => true
|
352
|
-
method_option :'bytes-burst-size', :type => :numeric, :required => true
|
374
|
+
method_option :domain, :type => :string, :required => true, banner: "/48 CIDR"
|
375
|
+
method_option :limit, :type => :string, :enum => ["default", "max"], :required => true
|
376
|
+
method_option :'packets-per-second', :type => :numeric, :required => true, aliases: "-p"
|
377
|
+
method_option :'packets-burst-size', :type => :numeric, :required => true, aliases: "-P"
|
378
|
+
method_option :'bytes-per-second', :type => :numeric, :required => true, aliases: "-b"
|
379
|
+
method_option :'bytes-burst-size', :type => :numeric, :required => true, aliases: "-B"
|
380
|
+
|
353
381
|
def set_domain_rate_limits
|
354
382
|
try_with_rescue_in_session do
|
355
383
|
# Call api
|
356
384
|
hash = {
|
357
|
-
:packets_per_second => options[
|
358
|
-
:packets_burst_size => options[
|
359
|
-
:bytes_per_second => options[
|
360
|
-
:bytes_burst_size => options[
|
385
|
+
:packets_per_second => options["packets-per-second"],
|
386
|
+
:packets_burst_size => options["packets-burst-size"],
|
387
|
+
:bytes_per_second => options["bytes-per-second"],
|
388
|
+
:bytes_burst_size => options["bytes-burst-size"],
|
361
389
|
}
|
362
|
-
data = EnfApi::API.instance.update_domain_rate_limits options[:
|
390
|
+
data = EnfApi::API.instance.update_domain_rate_limits options[:domain], options[:limit], hash
|
363
391
|
limits = data[:data][0]
|
364
392
|
|
365
393
|
# The Api returns only the rate limits object. Have to add type explicitly to display
|
366
394
|
limits_hash = {
|
367
|
-
options[:limit].to_sym => limits
|
395
|
+
options[:limit].to_sym => limits,
|
368
396
|
}
|
369
397
|
display_limits limits_hash
|
370
398
|
end
|
@@ -372,26 +400,27 @@ module EnfCli
|
|
372
400
|
|
373
401
|
desc "set-network-rate-limits", "Update a customer /64 network's endpoint rate limits"
|
374
402
|
method_option :network, :type => :string, :required => true
|
375
|
-
method_option :limit, :type => :string, :enum => [
|
376
|
-
method_option :'packets-per-second', :type => :numeric, :required => true
|
377
|
-
method_option :'packets-burst-size', :type => :numeric, :required => true
|
378
|
-
method_option :'bytes-per-second', :type => :numeric, :required => true
|
379
|
-
method_option :'bytes-burst-size', :type => :numeric, :required => true
|
403
|
+
method_option :limit, :type => :string, :enum => ["default", "max"], :required => true
|
404
|
+
method_option :'packets-per-second', :type => :numeric, :required => true, aliases: "-p"
|
405
|
+
method_option :'packets-burst-size', :type => :numeric, :required => true, aliases: "-P"
|
406
|
+
method_option :'bytes-per-second', :type => :numeric, :required => true, aliases: "-b"
|
407
|
+
method_option :'bytes-burst-size', :type => :numeric, :required => true, aliases: "-B"
|
408
|
+
|
380
409
|
def set_network_rate_limits
|
381
410
|
try_with_rescue_in_session do
|
382
411
|
# Call api
|
383
412
|
hash = {
|
384
|
-
:packets_per_second => options[
|
385
|
-
:packets_burst_size => options[
|
386
|
-
:bytes_per_second => options[
|
387
|
-
:bytes_burst_size => options[
|
413
|
+
:packets_per_second => options["packets-per-second"],
|
414
|
+
:packets_burst_size => options["packets-burst-size"],
|
415
|
+
:bytes_per_second => options["bytes-per-second"],
|
416
|
+
:bytes_burst_size => options["bytes-burst-size"],
|
388
417
|
}
|
389
418
|
data = EnfApi::API.instance.update_network_rate_limits options[:network], options[:limit], hash
|
390
419
|
limits = data[:data][0]
|
391
420
|
|
392
421
|
# The Api returns only the rate limits object. Have to add type explicitly to display
|
393
422
|
limits_hash = {
|
394
|
-
options[:limit].to_sym => limits
|
423
|
+
options[:limit].to_sym => limits,
|
395
424
|
}
|
396
425
|
display_limits limits_hash
|
397
426
|
end
|
@@ -399,19 +428,20 @@ module EnfCli
|
|
399
428
|
|
400
429
|
desc "reset-network-rate-limits", "Reset customer /64 network's endpoint rate limits to domains rate limits"
|
401
430
|
method_option :network, :type => :string, :required => true
|
402
|
-
method_option :limit, :type => :string, :enum => [
|
431
|
+
method_option :limit, :type => :string, :enum => ["default", "max"], :required => true
|
432
|
+
|
403
433
|
def reset_network_rate_limits
|
404
434
|
try_with_rescue_in_session do
|
405
435
|
# Call api
|
406
436
|
hash = {
|
407
|
-
:inherit => true
|
437
|
+
:inherit => true,
|
408
438
|
}
|
409
439
|
data = EnfApi::API.instance.update_network_rate_limits options[:network], options[:limit], hash
|
410
440
|
limits = data[:data][0]
|
411
441
|
|
412
442
|
# The Api returns only the rate limits object. Have to add type explicitly to display
|
413
443
|
limits_hash = {
|
414
|
-
options[:limit].to_sym => limits
|
444
|
+
options[:limit].to_sym => limits,
|
415
445
|
}
|
416
446
|
display_limits limits_hash
|
417
447
|
end
|
@@ -419,26 +449,27 @@ module EnfCli
|
|
419
449
|
|
420
450
|
desc "set-endpoint-rate-limits", "Update an ipv6 endpoint rate limits"
|
421
451
|
method_option :ipv6, :type => :string, :required => true
|
422
|
-
method_option :limit, :type => :string, :enum => [
|
423
|
-
method_option :'packets-per-second', :type => :numeric, :required => true
|
424
|
-
method_option :'packets-burst-size', :type => :numeric, :required => true
|
425
|
-
method_option :'bytes-per-second', :type => :numeric, :required => true
|
426
|
-
method_option :'bytes-burst-size', :type => :numeric, :required => true
|
452
|
+
method_option :limit, :type => :string, :enum => ["current", "max"], :required => true
|
453
|
+
method_option :'packets-per-second', :type => :numeric, :required => true, aliases: "-p"
|
454
|
+
method_option :'packets-burst-size', :type => :numeric, :required => true, aliases: "-P"
|
455
|
+
method_option :'bytes-per-second', :type => :numeric, :required => true, aliases: "-b"
|
456
|
+
method_option :'bytes-burst-size', :type => :numeric, :required => true, aliases: "-B"
|
457
|
+
|
427
458
|
def set_endpoint_rate_limits
|
428
459
|
try_with_rescue_in_session do
|
429
460
|
# Call api
|
430
461
|
hash = {
|
431
|
-
:packets_per_second => options[
|
432
|
-
:packets_burst_size => options[
|
433
|
-
:bytes_per_second => options[
|
434
|
-
:bytes_burst_size => options[
|
462
|
+
:packets_per_second => options["packets-per-second"],
|
463
|
+
:packets_burst_size => options["packets-burst-size"],
|
464
|
+
:bytes_per_second => options["bytes-per-second"],
|
465
|
+
:bytes_burst_size => options["bytes-burst-size"],
|
435
466
|
}
|
436
467
|
data = EnfApi::API.instance.update_ep_rate_limits options[:ipv6], options[:limit], hash
|
437
468
|
limits = data[:data][0]
|
438
469
|
|
439
470
|
# The Api returns only the rate limits object. Have to add type explicitly to display
|
440
471
|
limits_hash = {
|
441
|
-
options[:limit].to_sym => limits
|
472
|
+
options[:limit].to_sym => limits,
|
442
473
|
}
|
443
474
|
display_limits limits_hash
|
444
475
|
end
|
@@ -446,35 +477,33 @@ module EnfCli
|
|
446
477
|
|
447
478
|
desc "reset-endpoint-rate-limits", "Reset an ipv6 endpoint rate limits to network's rate limits"
|
448
479
|
method_option :ipv6, :type => :string, :required => true
|
449
|
-
method_option :limit, :type => :string, :enum => [
|
480
|
+
method_option :limit, :type => :string, :enum => ["current", "max"], :required => true
|
481
|
+
|
450
482
|
def reset_endpoint_rate_limits
|
451
483
|
try_with_rescue_in_session do
|
452
484
|
# Call api
|
453
485
|
hash = {
|
454
|
-
:inherit => true
|
486
|
+
:inherit => true,
|
455
487
|
}
|
456
488
|
data = EnfApi::API.instance.update_ep_rate_limits options[:ipv6], options[:limit], hash
|
457
489
|
limits = data[:data][0]
|
458
490
|
|
459
491
|
# The Api returns only the rate limits object. Have to add type explicitly to display
|
460
492
|
limits_hash = {
|
461
|
-
options[:limit].to_sym => limits
|
493
|
+
options[:limit].to_sym => limits,
|
462
494
|
}
|
463
495
|
display_limits limits_hash
|
464
496
|
end
|
465
497
|
end
|
466
498
|
|
467
499
|
desc "list-endpoints", "List all connections in a network"
|
468
|
-
method_option :network, :type => :string, :required => true
|
500
|
+
method_option :network, :type => :string, :required => true, banner: "/48 CIDR"
|
469
501
|
method_option :file, :type => :string, :aliases => "-f"
|
502
|
+
|
470
503
|
def list_endpoints
|
471
504
|
try_with_rescue_in_session do
|
472
|
-
# verify domain context is set
|
473
|
-
domain_id = EnfCli::CTX.instance.session[:domain_id]
|
474
|
-
raise EnfCli::ERROR, "User's domain not available!" if !domain_id || domain_id < 0
|
475
|
-
|
476
505
|
# call api
|
477
|
-
data = EnfApi::API.instance.list_nw_connections
|
506
|
+
data = EnfApi::API.instance.list_nw_connections options.network
|
478
507
|
cxns = data[:data]
|
479
508
|
|
480
509
|
# display table
|
@@ -484,6 +513,7 @@ module EnfCli
|
|
484
513
|
|
485
514
|
desc "list-endpoint-events", "List connect/disconnect events for an ipv6 endpoint"
|
486
515
|
method_option :ipv6, :type => :string, :required => true
|
516
|
+
|
487
517
|
def list_endpoint_events
|
488
518
|
try_with_rescue_in_session do
|
489
519
|
# call the api
|
@@ -492,12 +522,12 @@ module EnfCli
|
|
492
522
|
|
493
523
|
# display data
|
494
524
|
display_endpoint_events events
|
495
|
-
|
496
525
|
end
|
497
526
|
end
|
498
527
|
|
499
528
|
desc "list-network-events", "List connect/disconnect events of ipv6 endpoints in a network"
|
500
529
|
method_option :network, :type => :string, :required => true
|
530
|
+
|
501
531
|
def list_network_events
|
502
532
|
try_with_rescue_in_session do
|
503
533
|
# call the api
|
@@ -511,6 +541,7 @@ module EnfCli
|
|
511
541
|
|
512
542
|
desc "get-endpoint", "Display an ipv6 endpoint's information"
|
513
543
|
method_option :ipv6, :type => :string, :required => true
|
544
|
+
|
514
545
|
def get_endpoint
|
515
546
|
try_with_rescue_in_session do
|
516
547
|
# call the api
|
@@ -525,6 +556,7 @@ module EnfCli
|
|
525
556
|
desc "update-endpoint", "Update an ipv6 endpoint's name"
|
526
557
|
method_option :ipv6, :type => :string, :required => true
|
527
558
|
method_option :name, :type => :array, :required => true, :banner => "NAME"
|
559
|
+
|
528
560
|
def update_endpoint
|
529
561
|
try_with_rescue_in_session do
|
530
562
|
# Call the api
|
@@ -537,17 +569,17 @@ module EnfCli
|
|
537
569
|
end
|
538
570
|
|
539
571
|
desc "activate-enf-network", "Active a /34 enf network"
|
540
|
-
method_option :
|
572
|
+
method_option :cidr, :type => :string, :required => true
|
573
|
+
|
541
574
|
def activate_enfnw
|
542
575
|
try_with_rescue_in_session do
|
543
576
|
# Call the api
|
544
|
-
EnfApi::API.instance.activate_enfnw options.
|
577
|
+
EnfApi::API.instance.activate_enfnw options.cidr
|
545
578
|
|
546
579
|
# Print success
|
547
|
-
say "Activated Enf Network #{options.
|
580
|
+
say "Activated Enf Network #{options.cidr}!", :green
|
548
581
|
end
|
549
582
|
end
|
550
|
-
|
551
583
|
end # class
|
552
584
|
end # module Cmd
|
553
585
|
end # module EnfCli
|