lmcadm 0.15.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-win.yaml +35 -0
- data/.gitignore +2 -0
- data/README.md +59 -0
- data/exe/lmcadm +6 -0
- data/lib/lmcadm/account_commands.rb +42 -37
- data/lib/lmcadm/cloud_commands.rb +1 -0
- data/lib/lmcadm/commands/monitor.rb +59 -1
- data/lib/lmcadm/commands/rights.rb +27 -2
- data/lib/lmcadm/helpers/find_helpers.rb +18 -0
- data/lib/lmcadm/helpers/string_helpers.rb +10 -0
- data/lib/lmcadm/version.rb +1 -1
- data/lmcadm.gemspec +2 -1
- data/makeocragemfile.rb +15 -0
- data/ocra.sh +2 -0
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca0dd10565f531737baa49a5fbfef88cd87428354379bfea56479b695f6a9447
|
4
|
+
data.tar.gz: 057bef12dff7c5b8ec69b6f833343789c4682595b6bd99f4dbce64b1a740b6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4d94f44775a0c2bea6b8e0c7376af6e7b21268670f0bc119e83d1ea2de670e8477012e717eb52df18651af18c51186551e4c71f10bd1d78bf5b4838df486f4f
|
7
|
+
data.tar.gz: f45285b9223ada9c9213f99e351335f59aff2e6f9ee0038b12efe14cec3e8f0bdc6564f87db76082efce72d36128de84e45d2d50ae4414a10170f779fa6edb91
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: build-win
|
2
|
+
on:
|
3
|
+
release:
|
4
|
+
types:
|
5
|
+
- published
|
6
|
+
|
7
|
+
# push:
|
8
|
+
# tags:
|
9
|
+
# - 'v*.*.*'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
runs-on: windows-latest
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- uses: ruby/setup-ruby@v1
|
17
|
+
- run: gem install eventmachine --platform ruby
|
18
|
+
- run: gem install ocra lmcadm
|
19
|
+
- run: ruby makeocragemfile.rb
|
20
|
+
- run: ocra --gemfile ocra_gemfile --gem-full exe/lmcadm
|
21
|
+
- name: Setup tmate session
|
22
|
+
uses: mxschmitt/action-tmate@v3
|
23
|
+
if: false
|
24
|
+
- run: ./lmcadm.exe --version
|
25
|
+
- uses: papeloto/action-zip@v1
|
26
|
+
with:
|
27
|
+
files: lmcadm.exe LICENSE.txt
|
28
|
+
dest: lmcadm-${{ github.event.release.tag_name }}-win.zip
|
29
|
+
- name: Release
|
30
|
+
uses: softprops/action-gh-release@v1
|
31
|
+
with:
|
32
|
+
files: lmcadm-${{ github.event.release.tag_name }}-win.zip
|
33
|
+
env:
|
34
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
35
|
+
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -14,6 +14,25 @@ These can usually be installed the same way ruby was installed.
|
|
14
14
|
|
15
15
|
On Ubuntu for example, installing the `ruby-dev` via the package manager is sufficient.
|
16
16
|
|
17
|
+
### Windows
|
18
|
+
|
19
|
+
Lmcadm works with https://rubyinstaller.org/downloads/, use the recommended version with Devkit and choose the default options during install.
|
20
|
+
Installation can continue with rubygems.
|
21
|
+
|
22
|
+
#### Known issues
|
23
|
+
*Installing lmcadm fails with `ERROR: Failed to build gem native extension.`*
|
24
|
+
|
25
|
+
Ruby headers and some tools to build software (C compiler, make) are needed.
|
26
|
+
On Ubuntu for example, the packages `ruby-dev` and `build-essential` should be enough.
|
27
|
+
apt install ruby-dev build-essential
|
28
|
+
|
29
|
+
*Unable to load the EventMachine C extension ; To use the pure-ruby reactor, require 'em/pure_ruby'*
|
30
|
+
|
31
|
+
Workaround: Reinstall eventmachine with --platform ruby.
|
32
|
+
|
33
|
+
gem uninstall eventmachine (select all versions if prompted)
|
34
|
+
gem install eventmachine --platform ruby
|
35
|
+
|
17
36
|
## Usage
|
18
37
|
|
19
38
|
The primary usage documentation is in the help output of lmcadm:
|
@@ -32,6 +51,11 @@ Set the environment variable LMCADM\_PATH\_DEP to 1 to use the _lmc_ gem from ..
|
|
32
51
|
Example:
|
33
52
|
$ LMCADM_PATH_DEP=1 bundle exec lmcadm --version
|
34
53
|
|
54
|
+
### Building an exe for windows using ocra
|
55
|
+
|
56
|
+
* Apply workaround reinstalling eventmachine (see above)
|
57
|
+
* run ocra.sh
|
58
|
+
|
35
59
|
## Contributing
|
36
60
|
|
37
61
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lmcadm.
|
@@ -40,3 +64,38 @@ The sentence above is patently wrong currently.
|
|
40
64
|
## License
|
41
65
|
|
42
66
|
The gem is available as open source under the terms of the BSD 3-Clause License.
|
67
|
+
|
68
|
+
# Advanced usage or experimental features
|
69
|
+
|
70
|
+
## Using lmcadm to query monitoring data
|
71
|
+
|
72
|
+
Example use:
|
73
|
+
|
74
|
+
lmcadm monitor -A "ExampleProject" raw device_info cloud_rtt 42adf60b-0fe7-4187-af4f-9ee97669bfb0
|
75
|
+
|
76
|
+
### --type scalar (default)
|
77
|
+
|
78
|
+
When specifying a period longer than MINUTE1, the name must be suffixed with a dot, followed by an aggregation type.
|
79
|
+
Available types are
|
80
|
+
* .min
|
81
|
+
* .max
|
82
|
+
* .avg
|
83
|
+
|
84
|
+
Example use:
|
85
|
+
|
86
|
+
lmcadm monitor -A "ExampleProject" raw --type scalar --period MINUTE10 \
|
87
|
+
device_info cloud_rtt.max 3e19ada7-86fa-4809-a14e-7174b018603d
|
88
|
+
|
89
|
+
|
90
|
+
### --type json
|
91
|
+
|
92
|
+
This dumps the raw values response as json.
|
93
|
+
To further extract data, use something that can parse json, like `jq`[1].
|
94
|
+
|
95
|
+
Example use:
|
96
|
+
|
97
|
+
lmcadm monitor -A "SDN-DEMO (LANCOM Visitor)" raw --type json --period MINUTE1 \
|
98
|
+
wan_info_json interfaces a6871a81-84f3-4c57-a20e-c3410b47e895 | jq ' .[]["DSL-CH-1"].rxRate'
|
99
|
+
|
100
|
+
# Footnotes
|
101
|
+
[1] https://stedolan.github.io/jq/manual/
|
data/exe/lmcadm
CHANGED
@@ -85,6 +85,9 @@ module LMCAdm
|
|
85
85
|
::LMC::Cloud.verify_tls = global["verify-tls"]
|
86
86
|
::LMC::Cloud.use_tls = global["use-tls"]
|
87
87
|
LMCAdm::ProgressVisualizer.take_time = global["take-time"]
|
88
|
+
# let table_print print wide columns
|
89
|
+
tp.set :max_width, 50
|
90
|
+
|
88
91
|
true
|
89
92
|
end
|
90
93
|
|
@@ -106,5 +109,8 @@ module LMCAdm
|
|
106
109
|
true
|
107
110
|
end
|
108
111
|
|
112
|
+
if Encoding.find('locale') != 'UTF-8'
|
113
|
+
STDIN.set_encoding(Encoding.find('locale'),'UTF-8')
|
114
|
+
end
|
109
115
|
exit run(ARGV)
|
110
116
|
end
|
@@ -26,7 +26,7 @@ module LMCAdm
|
|
26
26
|
a["type"] == options[:account_type]
|
27
27
|
end
|
28
28
|
end
|
29
|
-
accounts.sort {|a, b| a["name"] <=> b["name"]}.each do |account|
|
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
32
|
puts account.summary
|
@@ -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(LMC::Cloud.instance, {"name" => args.first,
|
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
|
@@ -106,13 +106,13 @@ module LMCAdm
|
|
106
106
|
t = ProgressVisualizer.new "Getting accounts"
|
107
107
|
if options[:e]
|
108
108
|
accounts = LMC::Cloud.instance.get_accounts_objects
|
109
|
-
matched_accounts = accounts.select {|account| /#{args.first}/.match(account.name)}
|
109
|
+
matched_accounts = accounts.select { |account| /#{args.first}/.match(account.name) }
|
110
110
|
else
|
111
111
|
matched_accounts = [LMC::Account.get_by_uuid_or_name(args.first)]
|
112
112
|
end
|
113
113
|
t.done
|
114
114
|
puts 'Accounts to delete:'
|
115
|
-
puts matched_accounts.map {|a| "#{a.id} - #{a.name}"}.join("\n")
|
115
|
+
puts matched_accounts.map { |a| "#{a.id} - #{a.name}" }.join("\n")
|
116
116
|
print('Type yes to confirm: ')
|
117
117
|
exit unless STDIN.gets.chomp == 'yes'
|
118
118
|
t = ProgressVisualizer.new "Deleting accounts"
|
@@ -159,12 +159,12 @@ 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, [{:id => {:width => 36}}, :name, :type, :state, :invitationState, :principalState,
|
163
|
-
:authorities => {:display_method => lambda {|m|
|
164
|
-
m.authorities.map {|a|
|
162
|
+
tp members, [{ :id => { :width => 36 } }, :name, :type, :state, :invitationState, :principalState,
|
163
|
+
:authorities => { :display_method => lambda { |m|
|
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
|
|
@@ -174,8 +174,8 @@ module LMCAdm
|
|
174
174
|
auth.action do |_g, _o, args|
|
175
175
|
account = LMC::Account.get_by_uuid_or_name args.first
|
176
176
|
authorities = account.authorities
|
177
|
-
max = Helpers::longest_in_collection(authorities.map {|a| a.name})
|
178
|
-
tp authorities, [{:id => {:width => 36}}, {:name => {:width => max}}, :visibility, :type]
|
177
|
+
max = Helpers::longest_in_collection(authorities.map { |a| a.name })
|
178
|
+
tp authorities, [{ :id => { :width => 36 } }, { :name => { :width => max } }, :visibility, :type]
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
@@ -187,7 +187,7 @@ module LMCAdm
|
|
187
187
|
create.flag :A, :required => true
|
188
188
|
create.action do |_global_options, options, _args|
|
189
189
|
account = LMC::Account.get_by_uuid_or_name options[:A]
|
190
|
-
auth = LMC::Authority.new({'name' => _args.first, 'visibility' => 'PRIVATE'}, account)
|
190
|
+
auth = LMC::Authority.new({ 'name' => _args.first, 'visibility' => 'PRIVATE' }, account)
|
191
191
|
puts auth.save
|
192
192
|
end
|
193
193
|
end
|
@@ -202,7 +202,7 @@ module LMCAdm
|
|
202
202
|
account_invite.action do |global_options, options, args|
|
203
203
|
account = LMC::Account.get_by_uuid_or_name options[:account]
|
204
204
|
cloud = LMC::Cloud.instance
|
205
|
-
chosen_authorities = account.authorities.select {|auth| auth.name == options[:role]}
|
205
|
+
chosen_authorities = account.authorities.select { |auth| auth.name == options[:role] }
|
206
206
|
args.each do |email|
|
207
207
|
cloud.invite_user_to_account email, account.id, options[:type], chosen_authorities
|
208
208
|
end
|
@@ -256,28 +256,37 @@ module LMCAdm
|
|
256
256
|
update.flag :A, :account, :required => true
|
257
257
|
update.desc 'authority id'
|
258
258
|
update.flag 'add-authority'
|
259
|
-
update.
|
259
|
+
update.desc 'authority name|id'
|
260
|
+
update.flag 'remove-authority'
|
261
|
+
update.action do |global_options, options, args|
|
260
262
|
account = LMC::Account.get_by_uuid_or_name(options[:account])
|
263
|
+
account.cloud.auth_for_account account
|
261
264
|
membership = account.find_member_by_name args.first
|
262
|
-
|
265
|
+
if global_options[:verbose]
|
266
|
+
puts "membership class: #{membership.class}"
|
267
|
+
puts "membership.authorities first class: #{membership.authorities.first.class}"
|
268
|
+
puts membership
|
269
|
+
end
|
270
|
+
authority_ids = membership.authorities.map do |a|
|
271
|
+
a.id
|
272
|
+
end
|
273
|
+
puts "Existing authority ids: #{authority_ids}"
|
263
274
|
if options['add-authority']
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
puts
|
268
|
-
puts membership.authorities.class
|
269
|
-
authority_ids = membership.authorities.map do |a|
|
270
|
-
a['id']
|
271
|
-
end
|
272
|
-
puts authority_ids
|
273
|
-
authority_ids = authority_ids.concat [options['add-authority']]
|
274
|
-
puts authority_ids
|
275
|
-
# POST /accounts/{accountId}/members/{principalId}
|
276
|
-
cloud = LMC::Cloud.instance
|
277
|
-
cloud.auth_for_account account
|
278
|
-
res = cloud.post ['cloud-service-auth', 'accounts', account.id, 'members', membership.id], {'authorities' => authority_ids}
|
279
|
-
puts res
|
275
|
+
add_str = options['add-authority']
|
276
|
+
new_authority = Helpers::find_by_id_or_name account.authorities, add_str
|
277
|
+
authority_ids = authority_ids.concat [new_authority.id]
|
278
|
+
puts "Adding #{authority_ids}"
|
280
279
|
end
|
280
|
+
if options['remove-authority']
|
281
|
+
remove_str = options['remove-authority']
|
282
|
+
deleting_authority = Helpers.find_by_id_or_name account.authorities, remove_str
|
283
|
+
puts "Removing #{deleting_authority}"
|
284
|
+
authority_ids = authority_ids - [deleting_authority.id]
|
285
|
+
end
|
286
|
+
puts "New authority ids: #{authority_ids}"
|
287
|
+
# POST /accounts/{accountId}/members/{principalId}
|
288
|
+
res = account.cloud.post ['cloud-service-auth', 'accounts', account.id, 'members', membership.id], { 'authorities' => authority_ids }
|
289
|
+
puts res
|
281
290
|
end
|
282
291
|
end
|
283
292
|
|
@@ -288,16 +297,12 @@ module LMCAdm
|
|
288
297
|
children.flag :special
|
289
298
|
children.action do |global_options, options, args|
|
290
299
|
account = LMC::Account.get_by_uuid_or_name args.first
|
291
|
-
cloud = LMC::Cloud.instance
|
292
300
|
|
293
301
|
def recurse_childen account, indent_level
|
294
302
|
children = account.children
|
295
303
|
children.each do |child|
|
296
304
|
puts ' ' * indent_level + child.to_s
|
297
|
-
|
298
|
-
recurse_childen child, indent_level + 1
|
299
|
-
rescue RestClient::Forbidden => e
|
300
|
-
end
|
305
|
+
recurse_childen child, indent_level + 1
|
301
306
|
end
|
302
307
|
end
|
303
308
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'chronic'
|
2
3
|
|
3
4
|
module LMCAdm #:nodoc:
|
4
5
|
desc 'Retrieve montoring data'
|
@@ -15,7 +16,7 @@ module LMCAdm #:nodoc:
|
|
15
16
|
monitor_device.action do |_g, options, args|
|
16
17
|
record_name = args.shift
|
17
18
|
account = LMC::Account.get_by_uuid_or_name options[GLI::Command::PARENT][:account]
|
18
|
-
device = account.devices.find {|d| d.name == options[:device]}
|
19
|
+
device = account.devices.find { |d| d.name == options[:device] }
|
19
20
|
record = device.record record_name
|
20
21
|
|
21
22
|
options[:scalar].each do |datapoint|
|
@@ -48,5 +49,62 @@ module LMCAdm #:nodoc:
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
52
|
+
|
53
|
+
monitor.desc 'Make raw monitoring requests'
|
54
|
+
monitor.arg_name '<record> <name> <id>'
|
55
|
+
monitor.command :raw do |raw|
|
56
|
+
raw.flag :t, :type, default_value: 'scalar'
|
57
|
+
raw.flag :g, :group, default_value: 'DEVICE'
|
58
|
+
raw.flag :p, :period, default_value: 'MINUTE1'
|
59
|
+
raw.desc 'Start time'
|
60
|
+
raw.flag :start, default_value: 'one hour ago'
|
61
|
+
raw.flag :end, default_value: 'now'
|
62
|
+
raw.action do |_g, options, args|
|
63
|
+
record = args.shift
|
64
|
+
name = args.shift
|
65
|
+
groupId = args.shift
|
66
|
+
account = LMC::Account.get_by_uuid_or_name options[GLI::Command::PARENT][:account]
|
67
|
+
account.cloud.auth_for_account account
|
68
|
+
|
69
|
+
startTime = Chronic.parse(options[:start])
|
70
|
+
puts "Start time: #{startTime}" if _g[:verbose]
|
71
|
+
endTime = Chronic.parse(options[:end])
|
72
|
+
puts "End time: #{endTime}" if _g[:verbose]
|
73
|
+
|
74
|
+
# https://cloud.lancom.de/cloud-service-monitoring/accounts/399bc33a-7f53-4757-a6bd-cac3cbb6ebdd/records/wlan_info_json?type=scalar&name=stations&group=ACCOUNT&groupId=399bc33a-7f53-4757-a6bd-cac3cbb6ebdd&period=MINUTE1&start=1623417748&end=1623421348
|
75
|
+
# https://cloud.lancom.de/cloud-service-monitoring/accounts/399bc33a-7f53-4757-a6bd-cac3cbb6ebdd/records/device_info?type=scalar&name=cloud_rtt&group=DEVICE&groupId=efec12e1-ac4d-459d-bb5d-a9b6c1410eb5&period=MINUTE1&start=1623419874&end=1623423474
|
76
|
+
# https://cloud.lancom.de/cloud-service-monitoring/accounts/399bc33a-7f53-4757-a6bd-cac3cbb6ebdd/records/device_info?type=scalar&name=cloud_rtt&group=DEVICE&group_id=efec12e1-ac4d-459d-bb5d-a9b6c1410eb5&period=MINUTE1&start=1623419874&end=1623423474
|
77
|
+
result = account.cloud.get ['cloud-service-monitoring', 'accounts', account.id, 'records', record], {
|
78
|
+
type: options[:type],
|
79
|
+
name: name,
|
80
|
+
group: options[:group],
|
81
|
+
groupId: groupId,
|
82
|
+
period: options[:period],
|
83
|
+
start: startTime.to_i,
|
84
|
+
end: endTime.to_i,
|
85
|
+
}
|
86
|
+
monitordata = result.body.items[name]
|
87
|
+
puts result.body.inspect if _g[:debug]
|
88
|
+
if options[:type] == 'scalar'
|
89
|
+
puts monitordata.values
|
90
|
+
elsif options[:type] == 'json'
|
91
|
+
puts JSON.pretty_generate monitordata.to_h[:values]
|
92
|
+
elsif options[:type] == 'table'
|
93
|
+
table_data = monitordata.values.map { |v|
|
94
|
+
row = v.first
|
95
|
+
hash = {}
|
96
|
+
monitordata.keys.each_with_index { |k, index|
|
97
|
+
unless row[index].nil?
|
98
|
+
hash[k] = v.first[index]
|
99
|
+
end
|
100
|
+
}
|
101
|
+
hash
|
102
|
+
}
|
103
|
+
tp table_data
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
51
109
|
end
|
52
110
|
end
|
@@ -15,7 +15,7 @@ module LMCAdm
|
|
15
15
|
end
|
16
16
|
rights.arg_name "rights"
|
17
17
|
rights.command :assign do |assign|
|
18
|
-
assign.flag :A
|
18
|
+
assign.flag :A, :account
|
19
19
|
assign.flag :authority
|
20
20
|
assign.flag :service
|
21
21
|
assign.action do |_g, o, a |
|
@@ -23,9 +23,34 @@ module LMCAdm
|
|
23
23
|
account = LMC::Account.get_by_uuid_or_name o[:A]
|
24
24
|
c = LMC::Cloud.instance
|
25
25
|
c.auth_for_account account
|
26
|
-
|
26
|
+
service_name = Helpers.complete_service_name o[:service]
|
27
|
+
c.post [service_name, "accounts", account.id, 'authorities', o[:authority], 'rights' ], a
|
27
28
|
|
28
29
|
end
|
29
30
|
end
|
31
|
+
rights.arg_name 'servicename account'
|
32
|
+
rights.desc 'example: lmcadm rights authorities messaging myproject'
|
33
|
+
rights.command :authorities do |authorities|
|
34
|
+
authorities.action do |_g, _o, a |
|
35
|
+
account = LMC::Account.get_by_uuid_or_name a[1]
|
36
|
+
account.cloud.auth_for_account account
|
37
|
+
authorities = account.cloud.get [Helpers.complete_service_name(a[0]), 'accounts', account.id, 'authorities']
|
38
|
+
tp authorities.body, [:name , :visibility, :type, :id]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
rights.arg_name '<servicename> <account> <authority_id>'
|
43
|
+
rights.desc 'example: lmcadm rights show service-messaging myproject 5c244078-c937-4ff9-bb33-351f5253fe53'
|
44
|
+
rights.command :show do |show|
|
45
|
+
show.action do |_g, _o, a|
|
46
|
+
account = LMC::Account.get_by_uuid_or_name a[1]
|
47
|
+
account.cloud.auth_for_account account
|
48
|
+
service_name = Helpers.complete_service_name a[0]
|
49
|
+
authority = account.cloud.get([service_name, 'accounts', account.id, 'authorities', a[2]]).body
|
50
|
+
puts authority.to_h.to_s
|
51
|
+
rights = account.cloud.get([service_name, 'accounts', account.id, 'authorities', a[2], 'rights']).body
|
52
|
+
puts rights
|
53
|
+
end
|
54
|
+
end
|
30
55
|
end
|
31
56
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module LMCAdm
|
3
|
+
module Helpers
|
4
|
+
def self.find_by_id_or_name(list, search)
|
5
|
+
found = []
|
6
|
+
found += list.select do |item|
|
7
|
+
item.id == search
|
8
|
+
end
|
9
|
+
found += list.select do |item|
|
10
|
+
item.name == search
|
11
|
+
end
|
12
|
+
puts "More than one item found for: #{search}" if found.length > 1
|
13
|
+
raise "Not found: #{search}" if found.length < 1
|
14
|
+
return found.first
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -7,5 +7,15 @@ module LMCAdm
|
|
7
7
|
end
|
8
8
|
return max
|
9
9
|
end
|
10
|
+
|
11
|
+
def self.complete_service_name(name)
|
12
|
+
if name.start_with? 'cloud-service-'
|
13
|
+
return name
|
14
|
+
end
|
15
|
+
if name.start_with? 'service-'
|
16
|
+
return 'cloud-' + name
|
17
|
+
end
|
18
|
+
return'cloud-service-' + name
|
19
|
+
end
|
10
20
|
end
|
11
21
|
end
|
data/lib/lmcadm/version.rb
CHANGED
data/lmcadm.gemspec
CHANGED
@@ -24,9 +24,10 @@ 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.14.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'
|
31
31
|
spec.add_runtime_dependency 'websocket-eventmachine-client', '~> 1.3.0'
|
32
|
+
spec.add_runtime_dependency 'chronic', '~> 0.10.2'
|
32
33
|
end
|
data/makeocragemfile.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Temporary gemfile to be used by OCRA.
|
2
|
+
GEMFILE = 'ocra_gemfile'
|
3
|
+
|
4
|
+
# Add gems from gemspec.
|
5
|
+
ocra_gemfile = File.new(GEMFILE, 'w')
|
6
|
+
File.open("lmcadm.gemspec",'r') do |file|
|
7
|
+
file.each { |line| ocra_gemfile.write "gem #{$1}\n" if line =~ /spec.add_runtime_dependency (.+)/ }
|
8
|
+
end
|
9
|
+
ocra_gemfile.close
|
10
|
+
|
11
|
+
# Execute OCRA
|
12
|
+
#system("ocra --gemfile #{GEMFILE} --console script_name")
|
13
|
+
|
14
|
+
# Cleanup
|
15
|
+
#FileUtils.rm Dir.glob(GEMFILE)
|
data/ocra.sh
ADDED
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.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- erpel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-09 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.14.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.
|
82
|
+
version: 0.14.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: gli
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.3.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: chronic
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.10.2
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.10.2
|
139
153
|
description:
|
140
154
|
email:
|
141
155
|
- philipp@copythat.de
|
@@ -144,6 +158,7 @@ executables:
|
|
144
158
|
extensions: []
|
145
159
|
extra_rdoc_files: []
|
146
160
|
files:
|
161
|
+
- ".github/workflows/build-win.yaml"
|
147
162
|
- ".gitignore"
|
148
163
|
- ".idea/encodings.xml"
|
149
164
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
@@ -177,11 +192,14 @@ files:
|
|
177
192
|
- lib/lmcadm/device_commands.rb
|
178
193
|
- lib/lmcadm/helpers/args_helpers.rb
|
179
194
|
- lib/lmcadm/helpers/device_helpers.rb
|
195
|
+
- lib/lmcadm/helpers/find_helpers.rb
|
180
196
|
- lib/lmcadm/helpers/password_helper.rb
|
181
197
|
- lib/lmcadm/helpers/string_helpers.rb
|
182
198
|
- lib/lmcadm/version.rb
|
183
199
|
- lmcadm
|
184
200
|
- lmcadm.gemspec
|
201
|
+
- makeocragemfile.rb
|
202
|
+
- ocra.sh
|
185
203
|
homepage:
|
186
204
|
licenses:
|
187
205
|
- BSD-3-Clause
|