opennebula-cli 7.0.2 → 7.2.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/bin/oneacct +1 -1
- data/bin/oneacl +1 -1
- data/bin/onebackupjob +1 -1
- data/bin/onecluster +1 -1
- data/bin/onedatastore +1 -1
- data/bin/oneflow +1 -1
- data/bin/oneflow-template +1 -1
- data/bin/oneform +150 -0
- data/bin/onegroup +1 -1
- data/bin/onehook +1 -1
- data/bin/onehost +1 -1
- data/bin/oneimage +1 -1
- data/bin/oneirb +1 -1
- data/bin/onelog +1 -1
- data/bin/onemarket +1 -1
- data/bin/onemarketapp +4 -1
- data/bin/onesecgroup +1 -1
- data/bin/oneshowback +1 -1
- data/bin/onetemplate +16 -5
- data/bin/oneuser +3 -2
- data/bin/onevdc +1 -1
- data/bin/onevm +51 -6
- data/bin/onevmgroup +1 -1
- data/bin/onevnet +1 -1
- data/bin/onevntemplate +3 -2
- data/bin/onevrouter +1 -1
- data/bin/onezone +12 -6
- data/lib/cli_helper.rb +153 -1
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper/oneacct_helper.rb +3 -1
- data/lib/one_helper/oneacl_helper.rb +3 -1
- data/lib/one_helper/onebackupjob_helper.rb +3 -1
- data/lib/one_helper/onecluster_helper.rb +4 -1
- data/lib/one_helper/onedatastore_helper.rb +4 -1
- data/lib/one_helper/oneflow_helper.rb +1 -1
- data/lib/one_helper/oneflowtemplate_helper.rb +1 -1
- data/lib/one_helper/oneform_helper.rb +255 -0
- data/lib/one_helper/onegroup_helper.rb +133 -98
- data/lib/one_helper/onehook_helper.rb +5 -2
- data/lib/one_helper/onehost_helper.rb +6 -3
- data/lib/one_helper/oneimage_helper.rb +3 -1
- data/lib/one_helper/onemarket_helper.rb +3 -1
- data/lib/one_helper/onemarketapp_helper.rb +4 -1
- data/lib/one_helper/onequota_helper.rb +105 -22
- data/lib/one_helper/onesecgroup_helper.rb +3 -1
- data/lib/one_helper/onetemplate_helper.rb +3 -2
- data/lib/one_helper/oneuser_helper.rb +165 -156
- data/lib/one_helper/onevdc_helper.rb +3 -1
- data/lib/one_helper/onevm_helper.rb +6 -2
- data/lib/one_helper/onevmgroup_helper.rb +3 -1
- data/lib/one_helper/onevnet_helper.rb +16 -5
- data/lib/one_helper/onevntemplate_helper.rb +3 -2
- data/lib/one_helper/onevrouter_helper.rb +3 -1
- data/lib/one_helper/onezone_helper.rb +16 -5
- data/lib/one_helper.rb +53 -18
- data/share/schemas/xsd/group.xsd +8 -0
- data/share/schemas/xsd/group_pool.xsd +8 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +6 -10
- data/share/schemas/xsd/shared.xsd +8 -0
- data/share/schemas/xsd/user.xsd +8 -0
- data/share/schemas/xsd/user_pool.xsd +8 -0
- data/share/schemas/xsd/vm.xsd +20 -0
- data/share/schemas/xsd/vnet.xsd +2 -1
- data/share/schemas/xsd/vnet_pool.xsd +1 -0
- metadata +7 -4
data/lib/cli_helper.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -265,6 +265,158 @@ module CLIHelper
|
|
|
265
265
|
exit(-1)
|
|
266
266
|
end
|
|
267
267
|
|
|
268
|
+
# Render a small HTML subset for terminal output
|
|
269
|
+
# Supports: p, br, ul/ol/li, strong/b, em/i, code, a[href]
|
|
270
|
+
def self.render_html(text)
|
|
271
|
+
return '' if text.nil? || text.empty?
|
|
272
|
+
|
|
273
|
+
use_ansi = $stdout.tty?
|
|
274
|
+
|
|
275
|
+
bold_on = use_ansi ? "\33[1m" : ''
|
|
276
|
+
faint_on = use_ansi ? "\33[2m" : ''
|
|
277
|
+
reset = use_ansi ? "\33[0m" : ''
|
|
278
|
+
mono_on = use_ansi ? "\33[36m" : ''
|
|
279
|
+
bullet = use_ansi ? '•' : '*'
|
|
280
|
+
|
|
281
|
+
# OSC 8 hyperlink escape (clickable links)
|
|
282
|
+
osc8_link = lambda do |label, url|
|
|
283
|
+
return "#{label} (#{url})" unless use_ansi
|
|
284
|
+
|
|
285
|
+
"\e]8;;#{url}\a#{label}\e]8;;\a"
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
s = text.to_s.gsub("\r\n", "\n")
|
|
289
|
+
|
|
290
|
+
# Block tags -> newlines
|
|
291
|
+
s = s.gsub(%r{<\s*br\s*/?\s*>}i, "\n")
|
|
292
|
+
s = s.gsub(%r{<\s*/\s*p\s*>}i, "\n")
|
|
293
|
+
s = s.gsub(/<\s*p\b[^>]*>/i, '')
|
|
294
|
+
s = s.gsub(%r{<\s*/\s*(div|section|article)\s*>}i, "\n\n")
|
|
295
|
+
s = s.gsub(/<\s*(div|section|article)\b[^>]*>/i, '')
|
|
296
|
+
|
|
297
|
+
# Links: <a href="url">label</a>
|
|
298
|
+
s = s.gsub(%r{<\s*a\b[^>]*href\s*=\s*["']([^"']+)["'][^>]*>(.*?)<\s*/\s*a\s*>}im) do
|
|
299
|
+
url = Regexp.last_match(1).strip
|
|
300
|
+
label = Regexp.last_match(2).to_s
|
|
301
|
+
osc8_link.call(label, url)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# Lists
|
|
305
|
+
s = s.gsub(/<\s*li\b[^>]*>/i, "#{bullet} ")
|
|
306
|
+
|
|
307
|
+
# Inline formatting
|
|
308
|
+
if use_ansi
|
|
309
|
+
s = s.gsub(%r{<\s*/\s*(strong|b)\s*>}i, reset)
|
|
310
|
+
s = s.gsub(/<\s*(strong|b)\b[^>]*>/i, bold_on)
|
|
311
|
+
|
|
312
|
+
s = s.gsub(%r{<\s*/\s*(em|i)\s*>}i, reset)
|
|
313
|
+
s = s.gsub(/<\s*(em|i)\b[^>]*>/i, faint_on)
|
|
314
|
+
|
|
315
|
+
# <code>
|
|
316
|
+
s = s.gsub(%r{<\s*code\b[^>]*>(.*?)<\s*/\s*code\s*>}im) do
|
|
317
|
+
"#{faint_on}#{mono_on}#{Regexp.last_match(1)}#{reset}"
|
|
318
|
+
end
|
|
319
|
+
else
|
|
320
|
+
s = s.gsub(%r{<\s*/?\s*(strong|b|em|i|code)\b[^>]*>}i, '')
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Remove any remaining tags
|
|
324
|
+
s = s.gsub(/<[^>]+>/, '')
|
|
325
|
+
|
|
326
|
+
# Decode minimal HTML entities
|
|
327
|
+
s = s.gsub('&', '&')
|
|
328
|
+
.gsub('<', '<')
|
|
329
|
+
.gsub('>', '>')
|
|
330
|
+
.gsub('"', '"')
|
|
331
|
+
.gsub(''', "'")
|
|
332
|
+
.gsub(' ', ' ')
|
|
333
|
+
|
|
334
|
+
# Normalize whitespace
|
|
335
|
+
s = s.lines.map(&:rstrip).join("\n")
|
|
336
|
+
s.gsub(/\n{3,}/, "\n\n").strip
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# Render a small Markdown subset for terminal output. Supports headings,
|
|
340
|
+
# bold, italic, inline code, and unordered lists.
|
|
341
|
+
def self.render_md(text)
|
|
342
|
+
return '' if text.nil? || text.empty?
|
|
343
|
+
|
|
344
|
+
use_ansi = $stdout.tty?
|
|
345
|
+
|
|
346
|
+
bold_on = use_ansi ? "\33[1m" : ''
|
|
347
|
+
reset = use_ansi ? "\33[0m" : ''
|
|
348
|
+
faint_on = use_ansi ? "\33[2m" : ''
|
|
349
|
+
mono_on = use_ansi ? "\33[36m" : ''
|
|
350
|
+
bullet = use_ansi ? '•' : '*'
|
|
351
|
+
|
|
352
|
+
# OSC 8 hyperlink sequences
|
|
353
|
+
osc8_link = lambda do |label, url|
|
|
354
|
+
return "#{label} (#{url})" unless use_ansi
|
|
355
|
+
|
|
356
|
+
"\e]8;;#{url}\a#{label}\e]8;;\a"
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
lines = text.to_s.gsub("\r\n", "\n").split("\n", -1)
|
|
360
|
+
|
|
361
|
+
out = lines.map do |line|
|
|
362
|
+
# Preserve empty lines
|
|
363
|
+
if line.strip.empty?
|
|
364
|
+
''
|
|
365
|
+
# Headings (#, ##, ###)
|
|
366
|
+
elsif (m = line.match(/\A\s{0,3}(\#{1,3})\s+(.*)\z/))
|
|
367
|
+
title = m[2].strip
|
|
368
|
+
"#{bold_on}#{title}#{reset}"
|
|
369
|
+
# Unordered list items (*, -, +)
|
|
370
|
+
elsif (m = line.match(/\A(\s*)[*+-]\s+(.*)\z/))
|
|
371
|
+
indent = m[1]
|
|
372
|
+
item = m[2]
|
|
373
|
+
"#{indent}#{bullet} #{item}"
|
|
374
|
+
else
|
|
375
|
+
line
|
|
376
|
+
end
|
|
377
|
+
end.join("\n")
|
|
378
|
+
|
|
379
|
+
# Links [label](url)
|
|
380
|
+
out = out.gsub(/\[([^\]]+)\]\(([^)]+)\)/) do
|
|
381
|
+
label = Regexp.last_match(1)
|
|
382
|
+
url = Regexp.last_match(2).strip
|
|
383
|
+
osc8_link.call(label, url)
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
# Autolinks <https://example.com>
|
|
387
|
+
out = out.gsub(/<((?:https?|mailto):[^>\s]+)>/) do
|
|
388
|
+
url = Regexp.last_match(1)
|
|
389
|
+
osc8_link.call(url, url)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
# Inline formatting (simple, non-nested)
|
|
393
|
+
if use_ansi
|
|
394
|
+
# Inline code: `code`
|
|
395
|
+
out = out.gsub(/`([^`]+)`/) do
|
|
396
|
+
m = Regexp.last_match(1)
|
|
397
|
+
"#{faint_on}#{mono_on}#{m}#{reset}"
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
# Bold: **text**
|
|
401
|
+
out = out.gsub(/\*\*([^\*]+)\*\*/) do
|
|
402
|
+
m = Regexp.last_match(1)
|
|
403
|
+
"#{bold_on}#{m}#{reset}"
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
# Italic: *text*
|
|
407
|
+
out = out.gsub(/(^|[^*])\*([^*\n]+)\*(?!\*)/) do
|
|
408
|
+
m1 = Regexp.last_match(1)
|
|
409
|
+
m2 = Regexp.last_match(2)
|
|
410
|
+
"#{m1}#{faint_on}#{m2}#{reset}"
|
|
411
|
+
end
|
|
412
|
+
else
|
|
413
|
+
# Non-tty, keep markdown mostly as-is, but normalize list bullets
|
|
414
|
+
out = out.gsub(/\A(\s*)[*+-]\s+/m, "\\1#{bullet} ")
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
out
|
|
418
|
+
end
|
|
419
|
+
|
|
268
420
|
# Check if value is in base64
|
|
269
421
|
#
|
|
270
422
|
# @param value [String] Value to check
|
data/lib/command_parser.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
require 'one_helper'
|
|
18
18
|
require 'optparse/time'
|
|
19
|
+
require 'opennebula/virtual_machine'
|
|
20
|
+
require 'opennebula/virtual_machine_pool'
|
|
19
21
|
|
|
20
22
|
class AcctHelper < OpenNebulaHelper::OneHelper
|
|
21
23
|
TIME_ZONE_CUR = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
17
|
require 'one_helper'
|
|
18
|
+
require 'opennebula/acl'
|
|
19
|
+
require 'opennebula/acl_pool'
|
|
18
20
|
|
|
19
21
|
# Helper for oneacl command
|
|
20
22
|
class OneAclHelper < OpenNebulaHelper::OneHelper
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
17
|
require 'one_helper'
|
|
18
|
+
require 'opennebula/backupjob'
|
|
19
|
+
require 'opennebula/backupjob_pool'
|
|
18
20
|
|
|
19
21
|
# Helper for onebackupjob command
|
|
20
22
|
class OneBackupJobHelper < OpenNebulaHelper::OneHelper
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
17
|
require 'one_helper'
|
|
18
|
+
require 'opennebula/cluster'
|
|
19
|
+
require 'opennebula/cluster_pool'
|
|
20
|
+
require 'opennebula/host'
|
|
18
21
|
|
|
19
22
|
# OneCluster CLI command helper
|
|
20
23
|
class OneClusterHelper < OpenNebulaHelper::OneHelper
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
17
|
require 'one_helper'
|
|
18
|
+
require 'opennebula/datastore'
|
|
19
|
+
require 'opennebula/datastore_pool'
|
|
20
|
+
require 'opennebula/image'
|
|
18
21
|
|
|
19
22
|
class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
|
20
23
|
DATASTORE = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
|
2
|
+
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
3
|
+
# #
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
|
6
|
+
# a copy of the License at #
|
|
7
|
+
# #
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
9
|
+
# #
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
13
|
+
# See the License for the specific language governing permissions and #
|
|
14
|
+
# limitations under the License. #
|
|
15
|
+
#--------------------------------------------------------------------------- #
|
|
16
|
+
|
|
17
|
+
require 'one_helper'
|
|
18
|
+
|
|
19
|
+
# Oneflow Template command helper
|
|
20
|
+
class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
21
|
+
|
|
22
|
+
# Configuration file
|
|
23
|
+
def self.conf_file
|
|
24
|
+
'oneform.yaml'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Get client to make request
|
|
28
|
+
#
|
|
29
|
+
# @options [Hash] CLI options
|
|
30
|
+
def client(options)
|
|
31
|
+
OneForm::Client.new(
|
|
32
|
+
:username => options[:username],
|
|
33
|
+
:password => options[:password],
|
|
34
|
+
:url => options[:server],
|
|
35
|
+
:api_version => options[:api_version],
|
|
36
|
+
:user_agent => USER_AGENT
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def format_driver_pool
|
|
41
|
+
config_file = self.class.table_conf
|
|
42
|
+
|
|
43
|
+
CLIHelper::ShowTable.new(config_file, self) do
|
|
44
|
+
column :NAME, 'NAME', :left, :size => 15 do |d|
|
|
45
|
+
File.basename(d[:system_path])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
column :DEPLOYMENTS, 'DEPLOYMENTS', :left, :expand => true do |d|
|
|
49
|
+
if d[:deployment_confs].nil? || d[:deployment_confs].empty?
|
|
50
|
+
'--'
|
|
51
|
+
else
|
|
52
|
+
d[:deployment_confs].map {|conf| conf[:inventory] || '--' }.join(', ')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
column :STATE, 'Group', :left, :size => 10 do |d|
|
|
57
|
+
d[:state]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
default :NAME, :DEPLOYMENTS, :STATE
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# List drivers pool
|
|
65
|
+
#
|
|
66
|
+
# @param client [OneForm::Client] Petition client
|
|
67
|
+
# @param options [Hash] CLI options
|
|
68
|
+
def list_driver_pool(client, options, params = {})
|
|
69
|
+
response = client.list_drivers(params)
|
|
70
|
+
|
|
71
|
+
if CloudClient.is_error?(response)
|
|
72
|
+
[response[:err_code], response[:message]]
|
|
73
|
+
else
|
|
74
|
+
if options[:json]
|
|
75
|
+
[0, JSON.pretty_generate(response)]
|
|
76
|
+
elsif options[:yaml]
|
|
77
|
+
[0, response.to_yaml(:indent => 4)]
|
|
78
|
+
else
|
|
79
|
+
table = format_driver_pool
|
|
80
|
+
|
|
81
|
+
table.show(response, options)
|
|
82
|
+
table.describe_columns if options[:describe]
|
|
83
|
+
|
|
84
|
+
0
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# List driver pool continiously
|
|
90
|
+
#
|
|
91
|
+
# @param client [OneForm::Client] Petition client
|
|
92
|
+
# @param options [Hash] CLI options
|
|
93
|
+
def top_driver_pool(client, options, params = {})
|
|
94
|
+
options[:delay] ? delay = options[:delay] : delay = 4
|
|
95
|
+
|
|
96
|
+
begin
|
|
97
|
+
loop do
|
|
98
|
+
CLIHelper.scr_cls
|
|
99
|
+
CLIHelper.scr_move(0, 0)
|
|
100
|
+
|
|
101
|
+
list_driver_pool(client, options, params)
|
|
102
|
+
|
|
103
|
+
sleep delay
|
|
104
|
+
end
|
|
105
|
+
rescue StandardError => e
|
|
106
|
+
STDERR.puts e.message
|
|
107
|
+
exit(-1)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
0
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Show driver detailed information
|
|
114
|
+
#
|
|
115
|
+
# @param client [OneForm::Client] Petition client
|
|
116
|
+
# @param driver_name [String] driver name
|
|
117
|
+
# @param options [Hash] CLI options
|
|
118
|
+
def format_resource(client, driver_name, options)
|
|
119
|
+
response = client.get_driver(driver_name)
|
|
120
|
+
|
|
121
|
+
if CloudClient.is_error?(response)
|
|
122
|
+
[response[:err_code], response[:message]]
|
|
123
|
+
else
|
|
124
|
+
if options[:json]
|
|
125
|
+
[0, JSON.pretty_generate(response)]
|
|
126
|
+
elsif options[:yaml]
|
|
127
|
+
[0, response.to_yaml(:indent => 4)]
|
|
128
|
+
else
|
|
129
|
+
str = '%-20s: %-20s'
|
|
130
|
+
str_h1 = '%-80s'
|
|
131
|
+
|
|
132
|
+
driver_name = File.basename(response[:system_path])
|
|
133
|
+
CLIHelper.print_header(str_h1 % "#{driver_name.upcase} ONEFORM DRIVER INFORMATION")
|
|
134
|
+
|
|
135
|
+
puts Kernel.format str, 'NAME', response[:name]
|
|
136
|
+
puts Kernel.format str, 'DESCRIPTION', response[:description]
|
|
137
|
+
puts Kernel.format str, 'STATE', response[:state]
|
|
138
|
+
puts Kernel.format str, 'SOURCE', response[:registry]
|
|
139
|
+
puts Kernel.format str, 'VERSION', response[:version]
|
|
140
|
+
|
|
141
|
+
puts
|
|
142
|
+
|
|
143
|
+
connection_inputs = response[:connection] || {}
|
|
144
|
+
|
|
145
|
+
CLIHelper.print_header(str_h1 % 'CONNECTION INPUTS', false)
|
|
146
|
+
CLIHelper::ShowTable.new(nil, self) do
|
|
147
|
+
column :NAME, '', :left, :size => 25, :adjust => true do |input|
|
|
148
|
+
input[:name] || '--'
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
column :TYPE, '', :left, :size => 15 do |input|
|
|
152
|
+
input[:type] || '--'
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
column :DEFAULT, '', :left, :size => 30 do |input|
|
|
156
|
+
if input[:default].is_a?(Hash) || input[:default].is_a?(Array)
|
|
157
|
+
input[:default].to_json
|
|
158
|
+
else
|
|
159
|
+
input[:default] || '--'
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
default :NAME, :TYPE, :DEFAULT
|
|
164
|
+
end.show(connection_inputs, {})
|
|
165
|
+
|
|
166
|
+
puts
|
|
167
|
+
|
|
168
|
+
user_inputs = response[:user_inputs] || {}
|
|
169
|
+
|
|
170
|
+
CLIHelper.print_header(str_h1 % 'PROVISIONING INPUTS', false)
|
|
171
|
+
CLIHelper::ShowTable.new(nil, self) do
|
|
172
|
+
column :NAME, '', :left, :size => 25, :adjust => true do |input|
|
|
173
|
+
input[:name] || '--'
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
column :TYPE, '', :left, :size => 15 do |input|
|
|
177
|
+
input[:type] || '--'
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
column :DEFAULT, '', :left, :size => 30 do |input|
|
|
181
|
+
if input[:default].is_a?(Hash) || input[:default].is_a?(Array)
|
|
182
|
+
input[:default].to_json
|
|
183
|
+
else
|
|
184
|
+
input[:default] || '--'
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
default :NAME, :TYPE, :DEFAULT
|
|
189
|
+
end.show(user_inputs, {})
|
|
190
|
+
|
|
191
|
+
puts
|
|
192
|
+
|
|
193
|
+
CLIHelper.print_header(str_h1 % 'DEPLOYMENT CONFIGURATIONS', true)
|
|
194
|
+
puts
|
|
195
|
+
|
|
196
|
+
configs = response[:deployment_confs] || []
|
|
197
|
+
|
|
198
|
+
configs.each do |conf|
|
|
199
|
+
CLIHelper.print_header(str_h1 % conf[:name].upcase, false)
|
|
200
|
+
|
|
201
|
+
puts conf[:description].nil? ? '--' : CLIHelper.render_html(conf[:description])
|
|
202
|
+
puts
|
|
203
|
+
|
|
204
|
+
next unless conf[:user_inputs] && !conf[:user_inputs].empty?
|
|
205
|
+
|
|
206
|
+
CLIHelper.print_header("#{conf[:inventory].upcase} CONFIGURATION INPUTS", false)
|
|
207
|
+
CLIHelper::ShowTable.new(nil, self) do
|
|
208
|
+
column :NAME, '', :left, :size => 25, :adjust => true do |input|
|
|
209
|
+
input[:name] || '--'
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
column :TYPE, '', :left, :size => 15 do |input|
|
|
213
|
+
input[:type] || '--'
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
column :DEFAULT, '', :left, :size => 30 do |input|
|
|
217
|
+
if input[:default].is_a?(Hash) || input[:default].is_a?(Array)
|
|
218
|
+
input[:default].to_json
|
|
219
|
+
else
|
|
220
|
+
input[:default] || '--'
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
default :NAME, :TYPE, :DEFAULT
|
|
225
|
+
end.show(conf[:user_inputs], {})
|
|
226
|
+
|
|
227
|
+
puts
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
remaining = response.reject do |k, _|
|
|
231
|
+
[
|
|
232
|
+
:name,
|
|
233
|
+
:description,
|
|
234
|
+
:version,
|
|
235
|
+
:registry,
|
|
236
|
+
:state,
|
|
237
|
+
:fireedge,
|
|
238
|
+
:connection,
|
|
239
|
+
:user_inputs,
|
|
240
|
+
:deployment_confs,
|
|
241
|
+
:system_path
|
|
242
|
+
].include?(k)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
if remaining.any?
|
|
246
|
+
CLIHelper.print_header('USER TEMPLATE', false)
|
|
247
|
+
puts JSON.pretty_generate(remaining)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
0
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
end
|