lmcadm 0.13.0 → 0.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4ec85a8b1a7d9fe63c2f27ec1016310c0e029f878ab430063cdf8305d84b56e
4
- data.tar.gz: 4538b2bb9b9c212e3e58cf13badc5720b7480622eb3b02006c60e8c5a61d5f65
3
+ metadata.gz: '0925f20d360b3e8e6740c298a99c12b67474ae9d8d0c1ff6a426109cc9810ef7'
4
+ data.tar.gz: a3be3188b433d777bce80b5807c497ca41d15c9fa65037eaec5421abd2c6490b
5
5
  SHA512:
6
- metadata.gz: 81cf76346a7cb4e017f0db92ba785a3805b348bfb9d041d28361a63ba7dffd87a8363c9cc4c937b9e1f62b514780b81227c4e5b2a61f99ed8c2658f66013b77e
7
- data.tar.gz: b361f098338b6827a2ef76ba3d3680afade12ea06c8dcb00d3f04f5b86dff10110a59288517b0a829f3859fb4bd8a8b8654ab6bcc316af566e1d67b92e96514f
6
+ metadata.gz: 1958b20290dcad4adcddfbb87de3e0352f9e6efa8f5ddd8e343bf1bb3ac5b757ec6cffb61081402fdff986a7d454210ad64d1662f4ac8519e3b9c406e53b5a08
7
+ data.tar.gz: 3398cb285de12bb7a2211a609fea72cd7f421827e45133c751482f072fa370509d860707c94a7ff1042d2a243ebe0553086cb09da316e24b837b4a46e3a80b15
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ #wrapper script
3
+ #set -x
4
+ LMCADM_PATH_DEP=1 GLI_DEBUG=false bundle exec exe/lmcadm "$@"
@@ -29,9 +29,9 @@ module LMCAdm
29
29
  accounts.sort {|a, b| a["name"] <=> b["name"]}.each do |account|
30
30
  puts account.inspect if global_options[:v]
31
31
  if options[:l]
32
- puts account["name"] + " (" + account["type"] + ") ID: " + account["id"]
32
+ puts account.summary
33
33
  else
34
- puts account["name"] + " (" + account["type"] + ")"
34
+ puts "\"#{account}\" (#{account["type"]})"
35
35
  end
36
36
  end
37
37
  puts accounts.length.to_s + " Accounts found"
@@ -27,6 +27,7 @@ module LMCAdm
27
27
  }}
28
28
  tp backstage_infos
29
29
  puts '---'
30
+ puts "Base URL: #{cloud.build_url}"
30
31
  puts "Principal: #{LMC::Principal.get_self(cloud)}"
31
32
 
32
33
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LMCAdm #:nodoc:
4
+ desc 'Manipulate preferences'
5
+ command :preferences do |preferences|
6
+ preferences.desc 'Get last account data'
7
+ preferences.arg_name 'accounts'
8
+ preferences.command :lastaccounts do |la|
9
+ la.action do |g, _o, args|
10
+ cloud = LMC::Cloud.new(g[:cloud_host], g[:user], g[:password])
11
+ self_ui = cloud.preferences [:principals, :self, :ui]
12
+ if args.empty?
13
+ ids = self_ui.get 'lastAccountIds'
14
+ accounts = ids.map do |id|
15
+ LMC::Account.get id
16
+ end
17
+ accounts.each { |a|
18
+ puts a.summary
19
+ }
20
+ else
21
+ account_ids = args.map { |arg|
22
+ LMC::Account.get_by_uuid_or_name(arg).id
23
+ }
24
+ puts account_ids
25
+ puts self_ui.put 'lastAccountIds', account_ids
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -50,8 +50,8 @@ module LMCAdm
50
50
  begin
51
51
  EventMachine.epoll
52
52
  EventMachine.run do
53
- trap("TERM") { stop g[:debug]}
54
- trap("INT") { stop g[:debug]}
53
+ trap("TERM") { stop g[:debug] }
54
+ trap("INT") { stop g[:debug] }
55
55
  IO.console.raw!
56
56
  EventMachine.open_keyboard(LMCAdm::KeyboardHandler)
57
57
  @ws = WebSocket::EventMachine::Client.connect({uri: url, headers: headers_hash})
@@ -59,19 +59,27 @@ module LMCAdm
59
59
 
60
60
  @ws.onopen do
61
61
  print "Connected to #{device.name} (#{device.id}):\r\n"
62
+ remaining_args = args.drop(1)
63
+ if remaining_args.length > 0
64
+ @ws.send '1' + remaining_args.join(' ') + "\r", type: 'binary'
65
+ end
62
66
  end
63
67
 
64
68
  @ws.onmessage do |msg, type|
65
69
  print "##{msg.length}##{msg.inspect}#" if g[:debug]
70
+ # respond to custom keepalive
71
+ if msg.start_with? '0'
72
+ @ws.send '0', type: 'binary'
73
+ end
66
74
  if msg.start_with? "1"
67
- print msg[1..-1].gsub("\n","\r\n")
75
+ print msg[1..-1].gsub("\n", "\r\n")
68
76
  else
69
77
  print msg if g[:debug]
70
78
  end
71
79
  print DateTime.now.to_s if g[:debug]
72
80
  if msg.include? "\n\nGoodbye\n\n"
73
81
  stop g[:debug]
74
- closing = true
82
+ closing = true
75
83
  end
76
84
  end
77
85
 
@@ -93,7 +101,7 @@ module LMCAdm
93
101
  puts "Received pong: #{msg}" if g[:verbose]
94
102
  end
95
103
 
96
- def stop(debug=false)
104
+ def stop(debug = false)
97
105
  print DateTime.now.to_s if debug
98
106
  print "Terminating connection\r\n"
99
107
  EventMachine.stop
@@ -102,9 +110,9 @@ module LMCAdm
102
110
  ensure
103
111
  IO.console.cooked!
104
112
  end
105
- # disabled, getting 401 anyways
106
- #account.cloud.auth_for_account account
107
- #account.cloud.delete ['cloud-service-devicetunnel', 'accounts', account.id, "terminal?ids=#{sessionInfo.body.first['id']}"]
113
+ # disabled, getting 401 anyways
114
+ #account.cloud.auth_for_account account
115
+ #account.cloud.delete ['cloud-service-devicetunnel', 'accounts', account.id, "terminal?ids=#{sessionInfo.body.first['id']}"]
108
116
  end
109
117
  end
110
118
  end
@@ -1,3 +1,3 @@
1
1
  module LMCAdm
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.0'
3
3
  end
@@ -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.11.0'
27
+ spec.add_runtime_dependency 'lmc', '~> 0.12.0'
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.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - erpel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-03 00:00:00.000000000 Z
11
+ date: 2020-06-20 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.11.0
75
+ version: 0.12.0
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.11.0
82
+ version: 0.12.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: gli
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +155,7 @@ files:
155
155
  - Rakefile
156
156
  - bin/console
157
157
  - bin/setup
158
+ - dev_lmcadm
158
159
  - exe/lmcadm
159
160
  - lib/lmcadm.rb
160
161
  - lib/lmcadm/ColoredProgressVisualizer.rb
@@ -167,6 +168,7 @@ files:
167
168
  - lib/lmcadm/commands/completion.rb
168
169
  - lib/lmcadm/commands/maintenance.rb
169
170
  - lib/lmcadm/commands/monitor.rb
171
+ - lib/lmcadm/commands/preferences.rb
170
172
  - lib/lmcadm/commands/principal.rb
171
173
  - lib/lmcadm/commands/privatecloud.rb
172
174
  - lib/lmcadm/commands/rights.rb