lmcadm 0.9.2 → 0.10.0
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/exe/lmcadm +1 -1
- data/lib/lmcadm/account_commands.rb +15 -150
- data/lib/lmcadm/commands/principal.rb +1 -11
- data/lib/lmcadm/device_commands.rb +25 -14
- data/lib/lmcadm/version.rb +1 -1
- data/lmcadm.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 938d019f4b6505f37a438e3067e6a6e1dcf7fea9
|
4
|
+
data.tar.gz: a95c69c72ba3a0c9a49662bd234cedfaf7b40528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebdf152550d92de31951c1dc9cd01275bf82463fc483e995804042429a4e0b067396d2c6231e02193fa94644f961c8bb274ae209acce85627dc1848ec506839e
|
7
|
+
data.tar.gz: 7a9a3f51b97d8a6c8396e4ad247880087dcb7f8829c1e9f6ae61599fa2ec810de60d9685a4cc4876c1b681230af9050e57f66d80c4685070736f07139a02b6ae
|
data/exe/lmcadm
CHANGED
@@ -60,7 +60,7 @@ module LMCAdm
|
|
60
60
|
# chosen command
|
61
61
|
# Use skips_pre before a command to skip this block
|
62
62
|
# on that command only
|
63
|
-
if global[:password] == ""
|
63
|
+
if command.name != :completion && global[:password] == ""
|
64
64
|
global[:password] = Helpers::read_pw "Enter password for #{global[:user]}:"
|
65
65
|
end
|
66
66
|
::LMC::Cloud.cloud_host = global[:cloud_host]
|
@@ -82,9 +82,9 @@ module LMCAdm
|
|
82
82
|
account_create.action do |global_options, options, args|
|
83
83
|
parent = LMC::Account.get_by_uuid_or_name options[:p]
|
84
84
|
t = ProgressVisualizer.new "Creating object"
|
85
|
-
a = LMC::Account.new({
|
86
|
-
|
87
|
-
|
85
|
+
a = LMC::Account.new(LMC::Cloud.instance, {"name" => args.first,
|
86
|
+
"type" => options[GLI::Command::PARENT][:account_type],
|
87
|
+
"parent" => parent.id})
|
88
88
|
t.done
|
89
89
|
t = ProgressVisualizer.new "Saving #{a.name}"
|
90
90
|
result = a.save
|
@@ -159,126 +159,26 @@ module LMCAdm
|
|
159
159
|
memberlist.action do |global_options, options, args|
|
160
160
|
account = LMC::Account.get_by_uuid_or_name args.first
|
161
161
|
members = account.members
|
162
|
-
tp members, [{
|
163
|
-
:authorities => {
|
162
|
+
tp members, [{:id => {:width => 36}}, :name, :type, :state, :invitationState, :principalState,
|
163
|
+
:authorities => {:display_method => lambda {|m|
|
164
164
|
m.authorities.map {|a|
|
165
165
|
a['name']
|
166
166
|
}.join(',')
|
167
|
-
}, :width => 128
|
167
|
+
}, :width => 128}]
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
# Commented out due to bad quality at the moment.
|
172
|
-
# This code is untested after the gem split.
|
173
|
-
=begin
|
174
|
-
c.desc 'Modify account members'
|
175
|
-
c.command :memberupdate do |memberupdate|
|
176
|
-
memberupdate.desc 'Account UUID'
|
177
|
-
memberupdate.flag :a, "account-uuid", :required => true
|
178
|
-
|
179
|
-
memberupdate.desc 'Principal UUID'
|
180
|
-
memberupdate.flag :u, :uuid, :required => true
|
181
|
-
|
182
|
-
memberupdate.desc 'Authority'
|
183
|
-
memberupdate.flag :authority
|
184
|
-
|
185
|
-
memberupdate.action do |global_options, options, args|
|
186
|
-
account = LMCAccount.get options[:a]
|
187
|
-
|
188
|
-
account_authorities = account.authorities
|
189
|
-
puts account_authorities.inspect if global_options[:debug]
|
190
|
-
authority = account_authorities.find {|auth| auth["name"] == options[:authority]}
|
191
|
-
puts authority if global_options[:debug]
|
192
|
-
puts "authority id: #{authority["id"]}" if global_options[:debug]
|
193
|
-
|
194
|
-
resp = account.update_member options[:u], {:authorities => [authority["id"]]}
|
195
|
-
puts "response: #{resp.inspect}"
|
196
|
-
if resp.code == 200
|
197
|
-
puts "Updated success"
|
198
|
-
|
199
|
-
else
|
200
|
-
loggerr.error "ERROR: #{resp.code} #{resp.body.message}"
|
201
|
-
end
|
202
|
-
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
c.arg_name "email address", [:optional, :multiple]
|
207
|
-
c.desc 'Invite members, requires an account type'
|
208
|
-
c.command :invite do |account_invite|
|
209
|
-
|
210
|
-
account_invite.desc "File with email addresses; one address per line"
|
211
|
-
account_invite.flag :file
|
212
|
-
#account_invite.desc "Email address to invite"
|
213
|
-
#account_invite.flag :
|
214
|
-
account_invite.desc 'Account name'
|
215
|
-
account_invite.flag :account_name, :A, :required => true
|
216
|
-
|
217
|
-
account_invite.desc 'Member type'
|
218
|
-
account_invite.default_value "MEMBER"
|
219
|
-
account_invite.flag :member_type
|
220
|
-
|
221
|
-
account_invite.desc 'Authority'
|
222
|
-
account_invite.default_value "PROJECT_VIEWER"
|
223
|
-
account_invite.flag :authority
|
224
|
-
|
225
|
-
account_invite.desc 'Do not make changes'
|
226
|
-
account_invite.switch :n, :dry
|
227
|
-
|
228
|
-
account_invite.desc "Send emails (deprecated)"
|
229
|
-
account_invite.default_value false
|
230
|
-
account_invite.switch :e, "send-mail", "send-email"
|
231
|
-
|
232
|
-
account_invite.default_value false
|
233
|
-
account_invite.switch "show-csv"
|
234
|
-
|
235
|
-
account_invite.action do |global_options, options, args|
|
236
|
-
|
237
|
-
puts "ARGS:" + args.inspect if global_options[:debug]
|
238
|
-
lmcen = Cloud.new(global_options[:cloud_host], global_options[:user], global_options[:password])
|
239
|
-
t = ProgressVisualizer.new "Getting account"
|
240
|
-
account = lmcen.get_account options[:account_name], options[GLI::Command::PARENT][:account_type]
|
241
|
-
t.done
|
242
|
-
|
243
|
-
am = AccountManager.new(options, global_options)
|
244
|
-
if options[:file]
|
245
|
-
t = ProgressVisualizer.new "Inviting from file"
|
246
|
-
File.foreach(options[:file]) do |line|
|
247
|
-
if nil != am.invite(lmcen, account, line, options[:member_type], options[:authority])
|
248
|
-
t.dot
|
249
|
-
else
|
250
|
-
t.X
|
251
|
-
end
|
252
|
-
end
|
253
|
-
t.done
|
254
|
-
end
|
255
|
-
if not args.empty?
|
256
|
-
t = ProgressVisualizer.new "Inviting from arguments"
|
257
|
-
args.each do |line|
|
258
|
-
if nil != am.invite(lmcen, account, line, options[:member_type], options[:authority])
|
259
|
-
t.dot
|
260
|
-
else
|
261
|
-
t.X
|
262
|
-
end
|
263
|
-
end
|
264
|
-
t.done
|
265
|
-
end
|
266
|
-
loggerr.info am.errors unless am.errors.empty?
|
267
|
-
|
268
|
-
end
|
269
|
-
end
|
270
|
-
=end
|
271
171
|
c.arg_name '"Account name"|UUID', [:required]
|
272
172
|
c.desc 'List authorities'
|
273
173
|
c.command :authorities do |auth|
|
274
|
-
|
275
|
-
auth.action do |g, o, args|
|
174
|
+
auth.action do |_g, _o, args|
|
276
175
|
account = LMC::Account.get_by_uuid_or_name args.first
|
277
176
|
authorities = account.authorities
|
278
177
|
max = Helpers::longest_in_collection(authorities.map {|a| a.name})
|
279
|
-
tp authorities, [{
|
178
|
+
tp authorities, [{:id => {:width => 36}}, {:name => {:width => max}}, :visibility, :type]
|
280
179
|
end
|
281
180
|
end
|
181
|
+
|
282
182
|
c.desc 'Manage authorities'
|
283
183
|
c.command :authority do |auth|
|
284
184
|
auth.arg_name 'Authority name', [:required]
|
@@ -287,7 +187,7 @@ module LMCAdm
|
|
287
187
|
create.flag :A, :required => true
|
288
188
|
create.action do |_global_options, options, _args|
|
289
189
|
account = LMC::Account.get_by_uuid_or_name options[:A]
|
290
|
-
auth = LMC::Authority.new({
|
190
|
+
auth = LMC::Authority.new({'name' => _args.first, 'visibility' => 'PRIVATE'}, account)
|
291
191
|
puts auth.save
|
292
192
|
end
|
293
193
|
end
|
@@ -307,13 +207,12 @@ module LMCAdm
|
|
307
207
|
cloud.invite_user_to_account email, account.id, options[:type], chosen_authorities
|
308
208
|
end
|
309
209
|
end
|
310
|
-
|
311
210
|
end
|
312
211
|
|
313
212
|
c.desc 'Leave account'
|
314
213
|
c.arg_name "Account id"
|
315
214
|
c.command :leave do |leave|
|
316
|
-
leave.action do |
|
215
|
+
leave.action do |_global_options, _options, args|
|
317
216
|
account = LMC::Account.get_by_uuid(args[0])
|
318
217
|
puts "Leave account \"#{account.name}\""
|
319
218
|
puts account.remove_membership_self
|
@@ -324,7 +223,7 @@ module LMCAdm
|
|
324
223
|
c.desc 'Add Member'
|
325
224
|
c.command :memberadd do |ma|
|
326
225
|
ma.flag :A, :account, :required => true
|
327
|
-
ma.action do |
|
226
|
+
ma.action do |_global_options, options, args|
|
328
227
|
target_account = LMC::Account.get_by_uuid_or_name options[:account]
|
329
228
|
membership = LMC::Membership.new
|
330
229
|
membership.name = args.first
|
@@ -343,7 +242,7 @@ module LMCAdm
|
|
343
242
|
c.desc 'Remove member from account'
|
344
243
|
c.command :memberremove do |memberremove|
|
345
244
|
memberremove.flag :A, :account, :required => true
|
346
|
-
memberremove.action do |
|
245
|
+
memberremove.action do |_global_options, options, args|
|
347
246
|
account = LMC::Account.get_by_uuid_or_name(options[:account])
|
348
247
|
membership = account.find_member_by_name args.first
|
349
248
|
puts "Leave account \"#{account.name}\""
|
@@ -357,7 +256,7 @@ module LMCAdm
|
|
357
256
|
update.flag :A, :account, :required => true
|
358
257
|
update.desc 'authority id'
|
359
258
|
update.flag 'add-authority'
|
360
|
-
update.action do |
|
259
|
+
update.action do |_global_options, options, args|
|
361
260
|
account = LMC::Account.get_by_uuid_or_name(options[:account])
|
362
261
|
membership = account.find_member_by_name args.first
|
363
262
|
puts membership
|
@@ -376,22 +275,13 @@ module LMCAdm
|
|
376
275
|
# POST /accounts/{accountId}/members/{principalId}
|
377
276
|
cloud = LMC::Cloud.instance
|
378
277
|
cloud.auth_for_account account
|
379
|
-
res = cloud.post ['cloud-service-auth', 'accounts', account.id, 'members', membership.id], {
|
278
|
+
res = cloud.post ['cloud-service-auth', 'accounts', account.id, 'members', membership.id], {'authorities' => authority_ids}
|
380
279
|
puts res
|
381
280
|
end
|
382
281
|
end
|
383
282
|
end
|
384
283
|
|
385
284
|
|
386
|
-
# IF the special flag is set, do weird license magic for ninden
|
387
|
-
# * Für alle unterliegenden Organisationen
|
388
|
-
# -> POST /accounts/{accountId}/conditions/device-operation
|
389
|
-
# -> "templateAllowTestAllocation": true,
|
390
|
-
# -> "templateTestDuration": 30
|
391
|
-
# * Für alle unterliegenden Projekte
|
392
|
-
# -> POST /accounts/{accountId}/conditions/device-operation
|
393
|
-
# -> "allowTestAllocation": true,
|
394
|
-
# -> "testDuration": 30
|
395
285
|
c.desc 'List account children'
|
396
286
|
c.arg_name 'UUID|Name'
|
397
287
|
c.command :children do |children|
|
@@ -400,31 +290,6 @@ module LMCAdm
|
|
400
290
|
account = LMC::Account.get_by_uuid_or_name args.first
|
401
291
|
cloud = LMC::Cloud.instance
|
402
292
|
|
403
|
-
# def recurse_print_children(root_acc, account, options, cloud)
|
404
|
-
# children = root_acc.children_for_account_id account.id
|
405
|
-
# children.each do |child|
|
406
|
-
# puts "\n#{child["name"]} #{child["id"]} #{child["type"]}"
|
407
|
-
# if options[:special] == "read"
|
408
|
-
# puts cloud.get ["cloud-service-licenses", "accounts", child["id"], "conditions"]
|
409
|
-
# end
|
410
|
-
# if options[:special] == "write"
|
411
|
-
# if child["type"] == "ORGANIZATION"
|
412
|
-
# #puts cloud.get ["cloud-service-licenses", "accounts", child["id"], "conditions", "device-operation"]
|
413
|
-
# puts cloud.post ["cloud-service-licenses", "accounts", child["id"], "conditions", "device-operation"], {"templateAllowTestAllocation" => true, "templateTestDuration": 30}
|
414
|
-
# end
|
415
|
-
# if child["type"] == "PROJECT"
|
416
|
-
# #puts cloud.get ["cloud-service-licenses", "accounts", child["id"], "conditions", "device-operation"]
|
417
|
-
# puts cloud.post ["cloud-service-licenses", "accounts", child["id"], "conditions", "device-operation"], {"allowTestAllocation" => true, "testDuration": 30}
|
418
|
-
# end
|
419
|
-
#
|
420
|
-
# end
|
421
|
-
# end
|
422
|
-
# children.each do |child|
|
423
|
-
# childacc = LMCAccount.new(child)
|
424
|
-
# recurse_print_children(childacc, childacc, options, cloud)
|
425
|
-
# end
|
426
|
-
# end
|
427
|
-
#recurse_print_children(account, account, options, cloud)
|
428
293
|
def recurse_childen account, indent_level
|
429
294
|
children = account.children
|
430
295
|
children.each do |child|
|
@@ -10,16 +10,7 @@ module LMCAdm
|
|
10
10
|
cloud.auth_for_account root_account
|
11
11
|
pw = Helpers::read_pw "Enter new password for #{args.first}:"
|
12
12
|
principal = LMC::Principal.new({ 'name' => args.first, 'password' => pw, 'type' => options[:type] })
|
13
|
-
puts principal.save
|
14
|
-
begin
|
15
|
-
rescue Exception => e
|
16
|
-
puts e.inspect
|
17
|
-
puts e.message.inspect
|
18
|
-
puts e.response
|
19
|
-
puts e.response.message
|
20
|
-
end
|
21
|
-
|
22
|
-
|
13
|
+
puts principal.save
|
23
14
|
end
|
24
15
|
end
|
25
16
|
|
@@ -40,7 +31,6 @@ module LMCAdm
|
|
40
31
|
c = LMC::Cloud.instance
|
41
32
|
c.auth_for_account LMC::Account.get LMC::Account::ROOT_ACCOUNT_UUID
|
42
33
|
c.delete ['cloud-service-auth', 'principals', args.first]
|
43
|
-
|
44
34
|
end
|
45
35
|
end
|
46
36
|
end
|
@@ -33,45 +33,56 @@ module LMCAdm
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
c.arg_name "device uuid", [:multiple]
|
36
|
+
c.arg_name "<device uuid|name>", [:multiple, :required]
|
37
37
|
c.desc 'Show device config'
|
38
38
|
c.command :config do |device_config|
|
39
39
|
device_config.desc 'Account UUID|Name'
|
40
40
|
device_config.flag :A, :account
|
41
41
|
|
42
|
+
device_config.desc 'Output descriptive identifiers, overrides filter oid and lcf format'
|
43
|
+
device_config.switch :d, :descriptive
|
44
|
+
|
45
|
+
device_config.desc 'Output lcf file, overrides filter oid'
|
46
|
+
device_config.switch :lcf
|
47
|
+
|
42
48
|
device_config.desc 'Write to files'
|
43
49
|
device_config.switch :w
|
50
|
+
|
44
51
|
device_config.desc 'Prefix for files'
|
45
52
|
device_config.default_value 'config'
|
46
53
|
device_config.flag :p, :prefix
|
47
54
|
|
48
|
-
device_config.desc "Filter OID"
|
55
|
+
device_config.desc "Filter OID, incompatible with descriptive identifiers"
|
49
56
|
device_config.flag :filter_oid, "filter-oid"
|
50
57
|
|
51
58
|
device_config.action do |global_options, options, args|
|
59
|
+
raise "No devices specified" if args.length < 1
|
52
60
|
account = LMC::Account.get_by_uuid_or_name options[:account]
|
53
61
|
all_devices = LMC::Device.get_for_account(account)
|
54
62
|
devices = all_devices.select do |device|
|
55
|
-
args.include? device.id
|
63
|
+
(args.include? device.id) || (args.include? device.name)
|
56
64
|
end
|
65
|
+
file_extension = 'json'
|
57
66
|
devices.each do |device|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
67
|
+
config = device.config
|
68
|
+
if options[:descriptive]
|
69
|
+
result_config = config.descriptive_confighash
|
70
|
+
elsif options[:lcf]
|
71
|
+
pretty = config.lcf
|
72
|
+
file_extension = 'lcf'
|
73
|
+
elsif options[:filter_oid]
|
74
|
+
puts config.confighash
|
75
|
+
result_config = config.confighash[options[:filter_oid]]
|
76
|
+
else
|
77
|
+
result_config = config.confighash
|
64
78
|
end
|
65
|
-
|
66
|
-
puts "result_config class: " + result_config.body_object.class.to_s if global_options[:debug]
|
67
|
-
pretty = JSON.pretty_generate(result_config)
|
79
|
+
pretty ||= JSON.pretty_generate(result_config)
|
68
80
|
if options[:w]
|
69
|
-
IO.write(options[:prefix]
|
81
|
+
IO.write("#{options[:prefix]}-#{device.name}-#{device.id}.#{file_extension}", pretty)
|
70
82
|
else
|
71
83
|
puts pretty
|
72
84
|
end
|
73
85
|
end
|
74
|
-
|
75
86
|
end
|
76
87
|
|
77
88
|
end
|
data/lib/lmcadm/version.rb
CHANGED
data/lmcadm.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "minitest", "~> 5.0"
|
25
25
|
spec.add_development_dependency "pry-nav", "0.2.4"
|
26
26
|
|
27
|
-
spec.add_runtime_dependency 'lmc', '~> 0.
|
27
|
+
spec.add_runtime_dependency 'lmc', '~> 0.10.1'
|
28
28
|
spec.add_runtime_dependency 'gli', '~> 2.17'
|
29
29
|
spec.add_runtime_dependency 'table_print', '~> 1.5'
|
30
30
|
spec.add_runtime_dependency 'colorize', '~> 0.8'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lmcadm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- erpel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.10.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.10.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: gli
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|