enfcli 4.2.2.pre.alpha → 5.0.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/lib/enfapi.rb +36 -168
- 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 +51 -24
- data/lib/enfcli/commands/user.rb +198 -153
- data/lib/enfcli/commands/xcr.rb +67 -48
- data/lib/enfcli/commands/xdns.rb +17 -10
- data/lib/enfcli/commands/xfw.rb +1 -1
- data/lib/enfcli/version.rb +1 -1
- metadata +5 -2
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.
|
@@ -26,8 +26,8 @@ module EnfCli
|
|
26
26
|
[hash[:ipv6],
|
27
27
|
hash[:name],
|
28
28
|
hash[:state],
|
29
|
-
hash[:state] == "OFFLINE" ? "" : hash[:
|
30
|
-
hash[:state] == "OFFLINE" ? "" : hash[:
|
29
|
+
hash[:state] == "OFFLINE" ? "" : hash[:last_event][:asn_org],
|
30
|
+
hash[:state] == "OFFLINE" ? "" : hash[:last_event][:remote_ip]]
|
31
31
|
}
|
32
32
|
render_table(headings, rows, options.file)
|
33
33
|
end
|
@@ -41,23 +41,23 @@ module EnfCli
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def display_domains(domains)
|
44
|
-
headings = ["Name", "
|
44
|
+
headings = ["Name", "Cidr", "Status"]
|
45
45
|
rows = domains.map { |hash|
|
46
|
-
[hash[:name], hash[:
|
46
|
+
[hash[:name], hash[:cidr], hash[:status]]
|
47
47
|
}
|
48
48
|
render_table(headings, rows)
|
49
49
|
end
|
50
50
|
|
51
51
|
def display_networks(networks)
|
52
|
-
headings = ["Name", "
|
52
|
+
headings = ["Name", "Cidr", "Description", "Status"]
|
53
53
|
rows = networks.map { |hash|
|
54
|
-
[hash[:name], hash[:
|
54
|
+
[hash[:name], hash[:cidr], hash[:description], hash[:status]]
|
55
55
|
}
|
56
56
|
render_table(headings, rows)
|
57
57
|
end
|
58
58
|
|
59
59
|
def display_network(network)
|
60
|
-
network_cidr = network[:
|
60
|
+
network_cidr = network[:cidr]
|
61
61
|
name = network[:name] || ""
|
62
62
|
description = network[:description] || ""
|
63
63
|
status = network[:status] || ""
|
@@ -104,13 +104,26 @@ module EnfCli
|
|
104
104
|
}
|
105
105
|
|
106
106
|
desc "list-networks", "List all virtual networks in domain"
|
107
|
+
method_option :domain, type: :string, default: nil, banner: "/48 CIDR",
|
108
|
+
aliases: "-d"
|
107
109
|
|
108
110
|
def list_networks
|
109
111
|
try_with_rescue_in_session do
|
110
|
-
|
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
|
111
124
|
|
112
125
|
# Call the api
|
113
|
-
data = EnfApi::API.instance.list_domain_nws
|
126
|
+
data = EnfApi::API.instance.list_domain_nws domain
|
114
127
|
networks = data[:data]
|
115
128
|
|
116
129
|
# display table
|
@@ -120,13 +133,24 @@ module EnfCli
|
|
120
133
|
|
121
134
|
desc "provision-network", "Provision a Network"
|
122
135
|
method_option :name, :type => :array, :required => true, :banner => "NAME"
|
136
|
+
method_option :domain, type: :string, default: nil, banner: "/48 CIDR",
|
137
|
+
aliases: "-d"
|
123
138
|
method_option :description, :type => :array, :banner => "DESCRIPTION"
|
124
139
|
|
125
140
|
def provision_network
|
126
141
|
try_with_rescue_in_session do
|
127
|
-
#
|
128
|
-
|
129
|
-
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
|
130
154
|
|
131
155
|
# Get options
|
132
156
|
description = ""
|
@@ -136,10 +160,9 @@ module EnfCli
|
|
136
160
|
# Call the api
|
137
161
|
hash = {
|
138
162
|
:name => network_name,
|
139
|
-
:domain_id => domain_id,
|
140
163
|
:description => description,
|
141
164
|
}
|
142
|
-
data = EnfApi::API.instance.create_nw hash
|
165
|
+
data = EnfApi::API.instance.create_nw domain, hash
|
143
166
|
networks = data[:data]
|
144
167
|
|
145
168
|
# display table
|
@@ -211,10 +234,10 @@ module EnfCli
|
|
211
234
|
|
212
235
|
# call api
|
213
236
|
data = { :data => [] }
|
214
|
-
|
215
|
-
|
237
|
+
|
238
|
+
if EnfCli::CTX.instance.xaptum_admin?
|
216
239
|
data = EnfApi::API.instance.list_domains
|
217
|
-
|
240
|
+
elsif EnfCli::CTX.instance.has_role?("DOMAIN_ADMIN")
|
218
241
|
data = EnfApi::API.instance.get_domain session[:domain_id]
|
219
242
|
end
|
220
243
|
|
@@ -252,13 +275,13 @@ module EnfCli
|
|
252
275
|
end
|
253
276
|
|
254
277
|
desc "list-domain-rate-limits", "List domain rate limits"
|
255
|
-
method_option :
|
278
|
+
method_option :domain, :type => :string, :required => true, :banner => "/48 CIDR"
|
256
279
|
method_option :filter, :type => :string, :enum => ["default", "max"]
|
257
280
|
|
258
281
|
def list_domain_rate_limits
|
259
282
|
try_with_rescue_in_session do
|
260
283
|
# Call the api
|
261
|
-
data = EnfApi::API.instance.get_domain_rate_limits options[:
|
284
|
+
data = EnfApi::API.instance.get_domain_rate_limits options[:domain], options[:filter]
|
262
285
|
|
263
286
|
# Get the limits
|
264
287
|
limits = data[:data][0]
|
@@ -274,7 +297,7 @@ module EnfCli
|
|
274
297
|
end
|
275
298
|
|
276
299
|
desc "list-network-rate-limits", "List network rate limits"
|
277
|
-
method_option :network, :type => :string, :required => true
|
300
|
+
method_option :network, :type => :string, :required => true, :banner => "/64 CIDR"
|
278
301
|
method_option :filter, :type => :string, :enum => ["default", "max"]
|
279
302
|
|
280
303
|
def list_network_rate_limits
|
@@ -318,12 +341,12 @@ module EnfCli
|
|
318
341
|
end
|
319
342
|
|
320
343
|
desc "activate-domain", "Activate a customer's /48 domain"
|
321
|
-
method_option :
|
344
|
+
method_option :domain, :type => :string, :required => true, banner: "/48 CIDR"
|
322
345
|
|
323
346
|
def activate_domain
|
324
347
|
try_with_rescue_in_session do
|
325
348
|
# Call api
|
326
|
-
data = EnfApi::API.instance.update_domain_status options[:
|
349
|
+
data = EnfApi::API.instance.update_domain_status options[:domain], { :status => "ACTIVE" }
|
327
350
|
domains = data[:data]
|
328
351
|
|
329
352
|
# Display the data
|
@@ -333,12 +356,12 @@ module EnfCli
|
|
333
356
|
end
|
334
357
|
|
335
358
|
desc "deactivate-domain", "Deactivate a customer's /48 domain"
|
336
|
-
method_option :
|
359
|
+
method_option :domain, :type => :string, :required => true, banner: "/48 CIDR"
|
337
360
|
|
338
361
|
def deactivate_domain
|
339
362
|
try_with_rescue_in_session do
|
340
363
|
# Call api
|
341
|
-
data = EnfApi::API.instance.update_domain_status options[:
|
364
|
+
data = EnfApi::API.instance.update_domain_status options[:domain], { :status => "READY" }
|
342
365
|
domains = data[:data]
|
343
366
|
|
344
367
|
# Display the data
|
@@ -348,12 +371,12 @@ module EnfCli
|
|
348
371
|
end
|
349
372
|
|
350
373
|
desc "set-domain-rate-limits", "Update a customer /48 domain's endpoint rate limits"
|
351
|
-
method_option :
|
374
|
+
method_option :domain, :type => :string, :required => true, banner: "/48 CIDR"
|
352
375
|
method_option :limit, :type => :string, :enum => ["default", "max"], :required => true
|
353
|
-
method_option :'packets-per-second', :type => :numeric, :required => true
|
354
|
-
method_option :'packets-burst-size', :type => :numeric, :required => true
|
355
|
-
method_option :'bytes-per-second', :type => :numeric, :required => true
|
356
|
-
method_option :'bytes-burst-size', :type => :numeric, :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"
|
357
380
|
|
358
381
|
def set_domain_rate_limits
|
359
382
|
try_with_rescue_in_session do
|
@@ -364,7 +387,7 @@ module EnfCli
|
|
364
387
|
:bytes_per_second => options["bytes-per-second"],
|
365
388
|
:bytes_burst_size => options["bytes-burst-size"],
|
366
389
|
}
|
367
|
-
data = EnfApi::API.instance.update_domain_rate_limits options[:
|
390
|
+
data = EnfApi::API.instance.update_domain_rate_limits options[:domain], options[:limit], hash
|
368
391
|
limits = data[:data][0]
|
369
392
|
|
370
393
|
# The Api returns only the rate limits object. Have to add type explicitly to display
|
@@ -378,10 +401,10 @@ module EnfCli
|
|
378
401
|
desc "set-network-rate-limits", "Update a customer /64 network's endpoint rate limits"
|
379
402
|
method_option :network, :type => :string, :required => true
|
380
403
|
method_option :limit, :type => :string, :enum => ["default", "max"], :required => true
|
381
|
-
method_option :'packets-per-second', :type => :numeric, :required => true
|
382
|
-
method_option :'packets-burst-size', :type => :numeric, :required => true
|
383
|
-
method_option :'bytes-per-second', :type => :numeric, :required => true
|
384
|
-
method_option :'bytes-burst-size', :type => :numeric, :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"
|
385
408
|
|
386
409
|
def set_network_rate_limits
|
387
410
|
try_with_rescue_in_session do
|
@@ -427,10 +450,10 @@ module EnfCli
|
|
427
450
|
desc "set-endpoint-rate-limits", "Update an ipv6 endpoint rate limits"
|
428
451
|
method_option :ipv6, :type => :string, :required => true
|
429
452
|
method_option :limit, :type => :string, :enum => ["current", "max"], :required => true
|
430
|
-
method_option :'packets-per-second', :type => :numeric, :required => true
|
431
|
-
method_option :'packets-burst-size', :type => :numeric, :required => true
|
432
|
-
method_option :'bytes-per-second', :type => :numeric, :required => true
|
433
|
-
method_option :'bytes-burst-size', :type => :numeric, :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"
|
434
457
|
|
435
458
|
def set_endpoint_rate_limits
|
436
459
|
try_with_rescue_in_session do
|
@@ -474,17 +497,13 @@ module EnfCli
|
|
474
497
|
end
|
475
498
|
|
476
499
|
desc "list-endpoints", "List all connections in a network"
|
477
|
-
method_option :network, :type => :string, :required => true
|
500
|
+
method_option :network, :type => :string, :required => true, banner: "/48 CIDR"
|
478
501
|
method_option :file, :type => :string, :aliases => "-f"
|
479
502
|
|
480
503
|
def list_endpoints
|
481
504
|
try_with_rescue_in_session do
|
482
|
-
# verify domain context is set
|
483
|
-
domain_id = EnfCli::CTX.instance.session[:domain_id]
|
484
|
-
raise EnfCli::ERROR, "User's domain not available!" if !domain_id || domain_id < 0
|
485
|
-
|
486
505
|
# call api
|
487
|
-
data = EnfApi::API.instance.list_nw_connections
|
506
|
+
data = EnfApi::API.instance.list_nw_connections options.network
|
488
507
|
cxns = data[:data]
|
489
508
|
|
490
509
|
# display table
|
@@ -550,15 +569,15 @@ module EnfCli
|
|
550
569
|
end
|
551
570
|
|
552
571
|
desc "activate-enf-network", "Active a /34 enf network"
|
553
|
-
method_option :
|
572
|
+
method_option :cidr, :type => :string, :required => true
|
554
573
|
|
555
574
|
def activate_enfnw
|
556
575
|
try_with_rescue_in_session do
|
557
576
|
# Call the api
|
558
|
-
EnfApi::API.instance.activate_enfnw options.
|
577
|
+
EnfApi::API.instance.activate_enfnw options.cidr
|
559
578
|
|
560
579
|
# Print success
|
561
|
-
say "Activated Enf Network #{options.
|
580
|
+
say "Activated Enf Network #{options.cidr}!", :green
|
562
581
|
end
|
563
582
|
end
|
564
583
|
end # class
|
data/lib/enfcli/commands/xdns.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright 2019 Xaptum,Inc
|
2
|
+
# Copyright 2019-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.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
require "enfthor"
|
17
|
-
require "enfapi"
|
17
|
+
require "enfapi/dns"
|
18
18
|
|
19
19
|
module EnfCli
|
20
20
|
module Cmd
|
@@ -46,9 +46,9 @@ module EnfCli
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def display_zones_table(zones)
|
49
|
-
headings = ["Id", "Zone", "Description", "Enf Domain"]
|
49
|
+
headings = ["Id", "Zone", "Description", "Privileged", "Enf Domain"]
|
50
50
|
rows = zones.map { |hash|
|
51
|
-
[hash[:id], hash[:zone_domain_name], hash[:description], hash[:enf_domain]]
|
51
|
+
[hash[:id], hash[:zone_domain_name], hash[:description], hash[:privileged], hash[:enf_domain]]
|
52
52
|
}
|
53
53
|
render_table(headings, rows)
|
54
54
|
end
|
@@ -82,6 +82,7 @@ module EnfCli
|
|
82
82
|
method_option :'zone-domain-name', :type => :string, :required => true
|
83
83
|
method_option :description, :type => :array, :banner => "DESCRIPTION"
|
84
84
|
method_option :'enf-domain', :type => :string, :banner => "/48 Enf Domain"
|
85
|
+
method_option :'enf-network', :type => :string, :banner => "/64 Enf Network"
|
85
86
|
|
86
87
|
def create_zone
|
87
88
|
try_with_rescue_in_session do
|
@@ -91,12 +92,16 @@ module EnfCli
|
|
91
92
|
## Gather parameters
|
92
93
|
zone_domain_name = options["zone-domain-name"]
|
93
94
|
description = array_option_to_string(options.description) if options.description
|
94
|
-
|
95
|
-
when "XAPTUM_ADMIN"
|
95
|
+
if EnfCli::CTX.instance.xaptum_admin?
|
96
96
|
enf_domain = options["enf-domain"]
|
97
97
|
raise "No value provided for required options '--enf-domain'" unless enf_domain
|
98
98
|
else
|
99
|
-
enf_domain = session[:
|
99
|
+
enf_domain = session[:domain]
|
100
|
+
end
|
101
|
+
|
102
|
+
enf_network = options["enf-network"]
|
103
|
+
unless EnfCli::CTX.instance.edit_domain_role?
|
104
|
+
raise "No value provided for required option '--enf-network'" unless enf_network
|
100
105
|
end
|
101
106
|
|
102
107
|
## create request hash
|
@@ -106,6 +111,9 @@ module EnfCli
|
|
106
111
|
:enf_domain => enf_domain,
|
107
112
|
}
|
108
113
|
|
114
|
+
## add enf_network to request if present
|
115
|
+
new_zone[:enf_network] = enf_network if enf_network
|
116
|
+
|
109
117
|
## call api
|
110
118
|
data = EnfApi::Dns.instance.create_dns_zone new_zone
|
111
119
|
zones = data[:data]
|
@@ -125,12 +133,11 @@ module EnfCli
|
|
125
133
|
## session
|
126
134
|
session = EnfCli::CTX.instance.session
|
127
135
|
|
128
|
-
|
129
|
-
when "XAPTUM_ADMIN"
|
136
|
+
if EnfCli::CTX.instance.xaptum_admin?
|
130
137
|
enf_domain = options["enf-domain"]
|
131
138
|
raise "No value provided for required options '--enf-domain'" unless enf_domain
|
132
139
|
else
|
133
|
-
enf_domain = session[:
|
140
|
+
enf_domain = session[:domain]
|
134
141
|
end
|
135
142
|
|
136
143
|
## call api
|
data/lib/enfcli/commands/xfw.rb
CHANGED
data/lib/enfcli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enfcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Venkatakumar Srinivasan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -243,6 +243,9 @@ files:
|
|
243
243
|
- enfcli.gemspec
|
244
244
|
- format.sh
|
245
245
|
- lib/enfapi.rb
|
246
|
+
- lib/enfapi/dns.rb
|
247
|
+
- lib/enfapi/firewall.rb
|
248
|
+
- lib/enfapi/user.rb
|
246
249
|
- lib/enfcli.rb
|
247
250
|
- lib/enfcli/commands/captive.rb
|
248
251
|
- lib/enfcli/commands/user.rb
|