enfcli 3.8.6.pre.alpha → 3.9.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd44dc015e746db79cdd90f494cc2e468ec3c4e8ce778de93d6ebf890d32cbca
4
- data.tar.gz: 0a93e319fa5e5efad44626abaa07a12f2e9339fa49479be5f5731ac31c99fd90
3
+ metadata.gz: f5a105c81c7f42c28b274f00d6bf3899db3eb4d339bbd9fb013b46b2efbc189e
4
+ data.tar.gz: 7e3c5c91683c9f414d1b35da725fee523ab9c5497c1f00aa7645cc0609114b6e
5
5
  SHA512:
6
- metadata.gz: 8fffba329c28bb08c2f058b50d349880047af1778bdbdea9107547d0e4fd0ef10c4c5f38bc699b99ea80ae1886004ee47d3288987df55473e9cc0c8d691955ab
7
- data.tar.gz: 12911e5091de82ff4605a24afbacff93da59ea11b7ed3f4d057ce58acfd8e5aadfab49f114639fb8b19a06cb4f65f3d7b76436c8c4de7742ddaee37957af17a2
6
+ metadata.gz: 2a6746f422f5f694ca03934c834fc524f51d355b45645e0c01a13b3fa4ef1ccbc5861b5743225d9d0f4c86689956df23ca91f4235daf39c9f3e5843d319b1b79
7
+ data.tar.gz: f602019955f342a70e5890b1a461eb89233a63986e558b0740680411d6cf84cd26f692c981e45ecd7e5ea815607f9b12e978881ef1d778a1d8fa40cc20ecd0b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enfcli (3.8.6.pre.alpha)
4
+ enfcli (3.9.0.pre.alpha)
5
5
  rest-client (~> 2.0)
6
6
  terminal-table
7
7
  thor (~> 0.20.0)
@@ -24,9 +24,9 @@ GEM
24
24
  http-accept (1.7.0)
25
25
  http-cookie (1.0.3)
26
26
  domain_name (~> 0.5)
27
- mime-types (3.2.2)
27
+ mime-types (3.3)
28
28
  mime-types-data (~> 3.2015)
29
- mime-types-data (3.2019.0331)
29
+ mime-types-data (3.2019.0904)
30
30
  netrc (0.11.0)
31
31
  public_suffix (3.0.3)
32
32
  rake (10.5.0)
data/lib/enfapi.rb CHANGED
@@ -167,10 +167,17 @@ module EnfApi
167
167
  end
168
168
 
169
169
  ## NO_TEST
170
- def list_group(gid)
170
+ def get_group(gid)
171
171
  EnfApi::API.instance.get "/api/xiam/v1/groups/#{gid}"
172
172
  end
173
173
 
174
+ ## NO_TEST
175
+ def list_groups(network = nil)
176
+ url = "/api/xiam/v1/groups"
177
+ url = "#{url}?network=#{network}" if network
178
+ EnfApi::API.instance.get url
179
+ end
180
+
174
181
  ## NO_TEST
175
182
  def provision_endpoint(new_endpoint)
176
183
  json = EnfApi::to_json(new_endpoint)
@@ -32,14 +32,14 @@ module EnfCli
32
32
  # Write to file
33
33
  if write_to_file keyfile, data
34
34
  say "Created #{keyfile}", :green
35
- end
35
+ end
36
36
  end
37
-
37
+
38
38
  def write_to_file filename, data
39
39
  begin
40
40
  # check if file exists
41
- filename = EnfCli::expand_path(filename)
42
- if File.exists?( filename )
41
+ filename = EnfCli::expand_path(filename)
42
+ if File.exists?( filename )
43
43
  proceed = ask("Overwrite #{filename}(type 'yes' to continue...)?")
44
44
  return nil unless (proceed.downcase == 'yes')
45
45
  end
@@ -76,6 +76,18 @@ module EnfCli
76
76
  gpk_info
77
77
  end
78
78
 
79
+ def scan_gid()
80
+ qr_code_info = scan_group_qr_code()
81
+
82
+ # Extract gpk and basename
83
+ gpk_info = qr_code_info.split(",")
84
+ basename = gpk_info[0]
85
+ gpk = gpk_info[1]
86
+
87
+ # Calculate gid
88
+ calculate_gid basename, gpk
89
+ end
90
+
79
91
  def read_ec_key_file(keyfile)
80
92
  # expand path
81
93
  keyfile = EnfCli::expand_path(keyfile)
@@ -157,52 +169,72 @@ module EnfCli
157
169
  end
158
170
  }
159
171
 
160
- desc "list-group", "List DAA Group Information"
161
- def list_group
162
- try_with_rescue_in_session do
163
- qr_code_info = scan_group_qr_code()
172
+ option_gid = [:gid, {default: nil, type: :string, banner: 'GID',
173
+ desc: 'The group to get. If not specified, scan the group QR code'}]
164
174
 
165
- # Extract gpk and basename
166
- gpk_info = qr_code_info.split(",")
167
- basename = gpk_info[0]
168
- gpk = gpk_info[1]
169
-
170
- # Calculate gid
171
- gid = calculate_gid basename, gpk
175
+ desc "get-group", "Get DAA Group Information"
176
+ method_option *option_gid
177
+ def get_group
178
+ try_with_rescue_in_session do
179
+ # scan if gid not in options
180
+ if options[:gid]
181
+ gid = options[:gid]
182
+ else
183
+ gid = scan_gid
184
+ end
172
185
 
173
186
  # url safe encode gid
174
187
  enc_gid = Base64.urlsafe_encode64([gid].pack("H*"))
175
188
 
176
- data = EnfApi::Iam.instance.list_group enc_gid
189
+ data = EnfApi::Iam.instance.get_group enc_gid
177
190
  groups = [data]
178
-
191
+
179
192
  # display data
180
193
  display_groups groups
181
194
  end
182
195
  end
183
196
 
197
+ desc "list-groups", "List DAA Groups Information"
198
+ method_option :'network', default: nil, type: :string, banner: 'NETWORK',
199
+ desc: 'List only groups in this network'
200
+ def list_groups
201
+ try_with_rescue_in_session do
202
+ # The xiam API doesn't properly support the 'network' query
203
+ # parameter for listing groups. Until that is fixed, use the
204
+ # /network/N/groups resource instead.
205
+ #
206
+ # See https://github.com/xaptum/xiam/issues/54
207
+ #
208
+ if options[:network]
209
+ # validate network
210
+ network = EnfCli::IPV6Cidr.new options[:network]
211
+
212
+ # call the api
213
+ data = EnfApi::Iam.instance.list_network_groups network.to_s
214
+ else
215
+ # call the api
216
+ data = EnfApi::Iam.instance.list_groups
217
+ end
218
+
219
+ groups = data[:body]
220
+ display_groups groups
221
+ end
222
+ end
223
+
184
224
  desc "set-group-default-network", "Set /64 network as default for the DAA group"
185
225
  method_option :'network', :type => :string, :required => true
186
- method_option :'gid', :type => :string
226
+ method_option *option_gid
187
227
  def set_group_default_network
188
228
  try_with_rescue_in_session do
189
229
  network = EnfCli::IPV6Cidr.new options[:network]
190
230
 
191
231
  # scan if gid not in options
192
- if options[:gid]
232
+ if options[:gid]
193
233
  gid = options[:gid]
194
234
  else
195
- qr_code_info = scan_group_qr_code()
196
-
197
- # Extract gpk and basename
198
- gpk_info = qr_code_info.split(",")
199
- basename = gpk_info[0]
200
- gpk = gpk_info[1]
201
-
202
- # Calculate gid
203
- gid = calculate_gid basename, gpk
235
+ gid = scan_gid
204
236
  end
205
-
237
+
206
238
  # create IPV6_NETWORK
207
239
  ipv6_network = {
208
240
  :prefix => Base64.strict_encode64( network.prefix_bytes ),
@@ -223,30 +255,22 @@ module EnfCli
223
255
 
224
256
  say "Set #{network} as default network for group #{gid}", :green
225
257
  end
226
- end
258
+ end
227
259
 
228
260
  desc "set-group-domain", "Set /48 domain for the DAA group"
229
261
  method_option :'domain', :type => :string, :required => true
230
- method_option :'gid', :type => :string
262
+ method_option *option_gid
231
263
  def set_group_domain
232
264
  try_with_rescue_in_session do
233
265
  domain_network = EnfCli::IPV6Cidr.new options[:domain]
234
266
 
235
267
  # scan if gid not in options
236
- if options[:gid]
268
+ if options[:gid]
237
269
  gid = options[:gid]
238
270
  else
239
- qr_code_info = scan_group_qr_code()
240
-
241
- # Extract gpk and basename
242
- gpk_info = qr_code_info.split(",")
243
- basename = gpk_info[0]
244
- gpk = gpk_info[1]
245
-
246
- # Calculate gid
247
- gid = calculate_gid basename, gpk
271
+ gid = scan_gid
248
272
  end
249
-
273
+
250
274
  # create IPV6_NETWORK
251
275
  ipv6_network = {
252
276
  :prefix => Base64.strict_encode64( domain_network.prefix_bytes ),
@@ -271,26 +295,18 @@ module EnfCli
271
295
 
272
296
  desc "add-group-to-network", "Associate a DAA Group with /64 network"
273
297
  method_option :'network', :type => :string, :required => true
274
- method_option :'gid', :type => :string
298
+ method_option *option_gid
275
299
  def add_group_to_network
276
300
  try_with_rescue_in_session do
277
301
  network = EnfCli::IPV6Cidr.new options[:network]
278
302
 
279
303
  # scan if gid not in options
280
- if options[:gid]
304
+ if options[:gid]
281
305
  gid = options[:gid]
282
306
  else
283
- qr_code_info = scan_group_qr_code()
284
-
285
- # Extract gpk and basename
286
- gpk_info = qr_code_info.split(",")
287
- basename = gpk_info[0]
288
- gpk = gpk_info[1]
289
-
290
- # Calculate gid
291
- gid = calculate_gid basename, gpk
307
+ gid = scan_gid
292
308
  end
293
-
309
+
294
310
  # create IPV6_NETWORK
295
311
  ipv6_network = {
296
312
  :prefix => Base64.strict_encode64( network.prefix_bytes ),
@@ -329,7 +345,7 @@ module EnfCli
329
345
  # base64 encode all binary data: basename, gpk, gid
330
346
  enc_basename = Base64.strict_encode64([basename].pack("H*"))
331
347
  enc_gpk = Base64.strict_encode64([gpk].pack("H*"))
332
- enc_gid = Base64.strict_encode64([gid].pack("H*"))
348
+ enc_gid = Base64.strict_encode64([gid].pack("H*"))
333
349
 
334
350
  # create NEW_PROVISIONING
335
351
  new_provisioning = {
@@ -353,22 +369,6 @@ module EnfCli
353
369
  end
354
370
  end
355
371
 
356
- desc "list-network-groups", "List all DAA groups associated with a /64 network"
357
- method_option :'network', :type => :string, :required => true
358
- def list_network_groups
359
- try_with_rescue_in_session do
360
- # validate network
361
- network = EnfCli::IPV6Cidr.new options[:network]
362
-
363
- # call the api
364
- data = EnfApi::Iam.instance.list_network_groups network.to_s
365
- groups = data[:body]
366
-
367
- # display data
368
- display_groups groups
369
- end
370
- end
371
-
372
372
  desc "create-endpoint-key", "Generate a pem encoded EC key pair"
373
373
  method_option :'key-out-file', :type => :string, :required => true, :banner => '<file>'
374
374
  method_option :'public-key-out-file', :type => :string, :required => true, :banner => '<file>'
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module EnfCli
17
- VERSION = '3.8.6-alpha'
17
+ VERSION = '3.9.0-alpha'
18
18
  end
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.8.6.pre.alpha
4
+ version: 3.9.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-09-04 00:00:00.000000000 Z
11
+ date: 2019-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor