enfcli 3.12.0.pre.alpha → 3.13.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/Gemfile.lock +1 -1
- data/lib/enfapi.rb +0 -2
- data/lib/enfcli/commands/xiam.rb +29 -77
- data/lib/enfcli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 522440e411980f0f45893f8e062e68dbfe53e0f1c322cc6dcd3b41a4b37b1546
|
|
4
|
+
data.tar.gz: a29c99ae3bada808e496be1da3c27746fa5e53d01c8fbe02796a97c62220c680
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4890b71f648e7a082f63f0861e36c11147d5c863767d49e69f3bb4e11c6ba9fe1928f32932a53a71a87f81c3371fbc8981a463f9044865a086107efc5cf3f50f
|
|
7
|
+
data.tar.gz: b814bcef370608ad93f4248eacca7254be81f0e9a93855fd6bd4bade190eb828bca7b016ccfb3996fa7c5e03158bf08370d221d9f120b6a9ffec27c9d1cfd44a
|
data/Gemfile.lock
CHANGED
data/lib/enfapi.rb
CHANGED
|
@@ -17,7 +17,6 @@ require 'rest-client'
|
|
|
17
17
|
require 'singleton'
|
|
18
18
|
require 'json'
|
|
19
19
|
require 'date'
|
|
20
|
-
require 'base64'
|
|
21
20
|
require 'cgi'
|
|
22
21
|
|
|
23
22
|
#
|
|
@@ -588,7 +587,6 @@ module EnfApi
|
|
|
588
587
|
def api_error_msg(err)
|
|
589
588
|
if err.key?(:xiam_error)
|
|
590
589
|
reason = err[:reason]
|
|
591
|
-
reason = Base64.decode64(reason)
|
|
592
590
|
"#{reason}"
|
|
593
591
|
elsif err.key?(:error)
|
|
594
592
|
code = err[:error][:code]
|
data/lib/enfcli/commands/xiam.rb
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
#
|
|
16
16
|
require 'enfthor'
|
|
17
17
|
require 'enfapi'
|
|
18
|
-
require 'base64'
|
|
19
18
|
require 'digest'
|
|
20
19
|
require 'openssl'
|
|
21
20
|
require 'ipaddr'
|
|
@@ -101,14 +100,13 @@ module EnfCli
|
|
|
101
100
|
|
|
102
101
|
def display_groups groups
|
|
103
102
|
headings = ['DAA Group', 'Base Name', 'Provisioned', 'Onboarded', 'Default Network', 'Domain' ]
|
|
104
|
-
say groups
|
|
105
103
|
rows = groups.map{ |hash|
|
|
106
|
-
[
|
|
107
|
-
|
|
104
|
+
[ hash[:gid],
|
|
105
|
+
hash[:basename],
|
|
108
106
|
hash[:provisioned_count],
|
|
109
107
|
hash[:onboarded_count],
|
|
110
|
-
hash[:default_network] ?
|
|
111
|
-
|
|
108
|
+
hash[:default_network] ? hash[:default_network] : '<not set>',
|
|
109
|
+
hash[:domain],
|
|
112
110
|
]
|
|
113
111
|
}
|
|
114
112
|
render_table(headings, rows)
|
|
@@ -116,8 +114,7 @@ module EnfCli
|
|
|
116
114
|
|
|
117
115
|
def provision_endpoint(ipv6_address, pub)
|
|
118
116
|
# encode public key
|
|
119
|
-
|
|
120
|
-
pubkey = Base64.strict_encode64([hex].pack("H*"))
|
|
117
|
+
pubkey = pub.to_bn.to_s(16)
|
|
121
118
|
|
|
122
119
|
# create NEW_CREDENTIAL_ECDSA
|
|
123
120
|
new_credential = {
|
|
@@ -132,7 +129,7 @@ module EnfCli
|
|
|
132
129
|
:ecdsa_credential => new_credential,
|
|
133
130
|
:address_request => {
|
|
134
131
|
:address_request_oneof => {
|
|
135
|
-
:address =>
|
|
132
|
+
:address => ipv6_address.to_s
|
|
136
133
|
}
|
|
137
134
|
}
|
|
138
135
|
}
|
|
@@ -141,18 +138,16 @@ module EnfCli
|
|
|
141
138
|
|
|
142
139
|
data = EnfApi::Iam.instance.provision_endpoint new_endpoint
|
|
143
140
|
provisioned_ip = data[:address]
|
|
144
|
-
provisioned_ip = EnfCli::IPV6::ntoh Base64.decode64(provisioned_ip)
|
|
145
141
|
|
|
146
142
|
# Make sure provisioned ip is same as the requested ip
|
|
147
|
-
raise EnfCli::ERROR, "
|
|
143
|
+
raise EnfCli::ERROR, "Provisioned IPv6 address not the same as requested" unless provisioned_ip.eql?( ipv6_address.to_s )
|
|
148
144
|
|
|
149
145
|
say "Created new ipv6 endpoint #{provisioned_ip}", :green
|
|
150
146
|
end
|
|
151
147
|
|
|
152
148
|
def update_endpoint_credentials(ipv6_address, pub)
|
|
153
149
|
# encode public key
|
|
154
|
-
|
|
155
|
-
pubkey = Base64.strict_encode64([hex].pack("H*"))
|
|
150
|
+
pubkey = pub.to_bn.to_s(16)
|
|
156
151
|
|
|
157
152
|
# create NEW_CREDENTIAL_ECDSA
|
|
158
153
|
new_credential = {
|
|
@@ -187,10 +182,7 @@ module EnfCli
|
|
|
187
182
|
gid = scan_gid
|
|
188
183
|
end
|
|
189
184
|
|
|
190
|
-
|
|
191
|
-
enc_gid = Base64.urlsafe_encode64([gid].pack("H*"))
|
|
192
|
-
|
|
193
|
-
data = EnfApi::Iam.instance.get_group enc_gid
|
|
185
|
+
data = EnfApi::Iam.instance.get_group gid
|
|
194
186
|
groups = [data]
|
|
195
187
|
|
|
196
188
|
# display data
|
|
@@ -230,7 +222,7 @@ module EnfCli
|
|
|
230
222
|
method_option *option_gid
|
|
231
223
|
def set_group_default_network
|
|
232
224
|
try_with_rescue_in_session do
|
|
233
|
-
network = EnfCli::IPV6Cidr.new
|
|
225
|
+
network = EnfCli::IPV6Cidr.new(options[:network]).to_s
|
|
234
226
|
|
|
235
227
|
# scan if gid not in options
|
|
236
228
|
if options[:gid]
|
|
@@ -239,23 +231,14 @@ module EnfCli
|
|
|
239
231
|
gid = scan_gid
|
|
240
232
|
end
|
|
241
233
|
|
|
242
|
-
# create IPV6_NETWORK
|
|
243
|
-
ipv6_network = {
|
|
244
|
-
:prefix => Base64.strict_encode64( network.prefix_bytes ),
|
|
245
|
-
:prefix_length => network.prefix_len
|
|
246
|
-
}
|
|
247
|
-
|
|
248
234
|
# create MODIFIED_GROUP
|
|
249
235
|
modified_group = {
|
|
250
|
-
:gid =>
|
|
251
|
-
:default_network =>
|
|
236
|
+
:gid => gid,
|
|
237
|
+
:default_network => network
|
|
252
238
|
}
|
|
253
239
|
|
|
254
|
-
# url safe encode gid
|
|
255
|
-
enc_gid = Base64.urlsafe_encode64([gid].pack("H*"))
|
|
256
|
-
|
|
257
240
|
# Post to server
|
|
258
|
-
EnfApi::Iam.instance.update_group
|
|
241
|
+
EnfApi::Iam.instance.update_group gid, modified_group
|
|
259
242
|
|
|
260
243
|
say "Set #{network} as default network for group #{gid}", :green
|
|
261
244
|
end
|
|
@@ -266,7 +249,7 @@ module EnfCli
|
|
|
266
249
|
method_option *option_gid
|
|
267
250
|
def set_group_domain
|
|
268
251
|
try_with_rescue_in_session do
|
|
269
|
-
|
|
252
|
+
domain = EnfCli::IPV6Cidr.new(options[:domain]).to_s
|
|
270
253
|
|
|
271
254
|
# scan if gid not in options
|
|
272
255
|
if options[:gid]
|
|
@@ -275,25 +258,16 @@ module EnfCli
|
|
|
275
258
|
gid = scan_gid
|
|
276
259
|
end
|
|
277
260
|
|
|
278
|
-
# create IPV6_NETWORK
|
|
279
|
-
ipv6_network = {
|
|
280
|
-
:prefix => Base64.strict_encode64( domain_network.prefix_bytes ),
|
|
281
|
-
:prefix_length => domain_network.prefix_len
|
|
282
|
-
}
|
|
283
|
-
|
|
284
261
|
# create MODIFIED_GROUP
|
|
285
262
|
modified_group = {
|
|
286
|
-
:gid =>
|
|
287
|
-
:domain =>
|
|
263
|
+
:gid => gid,
|
|
264
|
+
:domain => domain
|
|
288
265
|
}
|
|
289
266
|
|
|
290
|
-
# url safe encode gid
|
|
291
|
-
enc_gid = Base64.urlsafe_encode64([gid].pack("H*"))
|
|
292
|
-
|
|
293
267
|
# Post to server
|
|
294
|
-
EnfApi::Iam.instance.update_group
|
|
268
|
+
EnfApi::Iam.instance.update_group gid, modified_group
|
|
295
269
|
|
|
296
|
-
say "Associated group #{gid} with #{
|
|
270
|
+
say "Associated group #{gid} with #{domain}", :green
|
|
297
271
|
end
|
|
298
272
|
end
|
|
299
273
|
|
|
@@ -303,7 +277,7 @@ module EnfCli
|
|
|
303
277
|
method_option :'set_as_default', :type => :boolean, default: false, desc: "Set the network as the default for this group"
|
|
304
278
|
def add_group_to_network
|
|
305
279
|
try_with_rescue_in_session do
|
|
306
|
-
network = EnfCli::IPV6Cidr.new
|
|
280
|
+
network = EnfCli::IPV6Cidr.new(options[:network]).to_s
|
|
307
281
|
|
|
308
282
|
# scan if gid not in options
|
|
309
283
|
if options[:gid]
|
|
@@ -312,25 +286,16 @@ module EnfCli
|
|
|
312
286
|
gid = scan_gid
|
|
313
287
|
end
|
|
314
288
|
|
|
315
|
-
# create IPV6_NETWORK
|
|
316
|
-
ipv6_network = {
|
|
317
|
-
:prefix => Base64.strict_encode64( network.prefix_bytes ),
|
|
318
|
-
:prefix_length => network.prefix_len
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
# url safe encode gid
|
|
322
|
-
enc_gid = Base64.urlsafe_encode64([gid].pack("H*"))
|
|
323
|
-
|
|
324
289
|
if options[:set_as_default]
|
|
325
290
|
modified_group = {
|
|
326
|
-
:gid =>
|
|
327
|
-
:default_network =>
|
|
291
|
+
:gid => gid,
|
|
292
|
+
:default_network => network
|
|
328
293
|
}
|
|
329
294
|
|
|
330
|
-
EnfApi::Iam.instance.update_group
|
|
295
|
+
EnfApi::Iam.instance.update_group gid, modified_group
|
|
331
296
|
say "Associated group #{gid} with #{network} as default network", :green
|
|
332
297
|
else
|
|
333
|
-
EnfApi::Iam.instance.add_group_to_network
|
|
298
|
+
EnfApi::Iam.instance.add_group_to_network gid, network
|
|
334
299
|
say "Associated group #{gid} with #{network}", :green
|
|
335
300
|
end
|
|
336
301
|
end
|
|
@@ -355,22 +320,17 @@ module EnfCli
|
|
|
355
320
|
operator = options.operator.join(" ").gsub(/\A"+(.*?)"+\Z/m, '\1')
|
|
356
321
|
quantity = options[:'device-count']
|
|
357
322
|
|
|
358
|
-
# base64 encode all binary data: basename, gpk, gid
|
|
359
|
-
enc_basename = Base64.strict_encode64([basename].pack("H*"))
|
|
360
|
-
enc_gpk = Base64.strict_encode64([gpk].pack("H*"))
|
|
361
|
-
enc_gid = Base64.strict_encode64([gid].pack("H*"))
|
|
362
|
-
|
|
363
323
|
# create NEW_PROVISIONING
|
|
364
324
|
new_provisioning = {
|
|
365
|
-
:group_id =>
|
|
325
|
+
:group_id => gid,
|
|
366
326
|
:quantity => quantity,
|
|
367
327
|
:operator => operator
|
|
368
328
|
}
|
|
369
329
|
|
|
370
330
|
# create NEW_GROUP
|
|
371
331
|
new_group = {
|
|
372
|
-
:group_public_key =>
|
|
373
|
-
:basename =>
|
|
332
|
+
:group_public_key => gpk,
|
|
333
|
+
:basename => basename,
|
|
374
334
|
:provisionings => [ new_provisioning ]
|
|
375
335
|
}
|
|
376
336
|
|
|
@@ -432,7 +392,7 @@ module EnfCli
|
|
|
432
392
|
def create_endpoint_in_network
|
|
433
393
|
try_with_rescue_in_session do
|
|
434
394
|
# Read options
|
|
435
|
-
network = EnfCli::IPV6Cidr.new
|
|
395
|
+
network = EnfCli::IPV6Cidr.new(options[:network]).to_s
|
|
436
396
|
keyfile = EnfCli::expand_path(options['public-key-in-file'])
|
|
437
397
|
|
|
438
398
|
# read keyfile
|
|
@@ -440,8 +400,7 @@ module EnfCli
|
|
|
440
400
|
|
|
441
401
|
# encode public key
|
|
442
402
|
pub = key.public_key
|
|
443
|
-
|
|
444
|
-
pubkey = Base64.strict_encode64([hex].pack("H*"))
|
|
403
|
+
pubkey = pub.to_bn.to_s(16)
|
|
445
404
|
|
|
446
405
|
# create NEW_CREDENTIAL_ECDSA
|
|
447
406
|
new_credential = {
|
|
@@ -449,12 +408,6 @@ module EnfCli
|
|
|
449
408
|
:key => pubkey
|
|
450
409
|
}
|
|
451
410
|
|
|
452
|
-
# create IPV6_NETWORK
|
|
453
|
-
ipv6_network = {
|
|
454
|
-
:prefix => Base64.strict_encode64( network.prefix_bytes ),
|
|
455
|
-
:prefix_length => network.prefix_len
|
|
456
|
-
}
|
|
457
|
-
|
|
458
411
|
# create NEW_ENDPOINT_AUTH
|
|
459
412
|
new_endpoint = {
|
|
460
413
|
:cred_oneof => {
|
|
@@ -462,7 +415,7 @@ module EnfCli
|
|
|
462
415
|
:ecdsa_credential => new_credential,
|
|
463
416
|
:address_request => {
|
|
464
417
|
:address_request_oneof => {
|
|
465
|
-
:network =>
|
|
418
|
+
:network => network
|
|
466
419
|
}
|
|
467
420
|
}
|
|
468
421
|
}
|
|
@@ -471,7 +424,6 @@ module EnfCli
|
|
|
471
424
|
|
|
472
425
|
data = EnfApi::Iam.instance.provision_endpoint new_endpoint
|
|
473
426
|
provisioned_ip = data[:address]
|
|
474
|
-
provisioned_ip = EnfCli::IPV6::ntoh Base64.decode64(provisioned_ip)
|
|
475
427
|
|
|
476
428
|
say "Created new ipv6 endpoint #{provisioned_ip}", :green
|
|
477
429
|
end
|
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: 3.
|
|
4
|
+
version: 3.13.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: 2019-
|
|
11
|
+
date: 2019-12-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|