Class: Morpheus::Cli::License
- Inherits:
-
Object
- Object
- Morpheus::Cli::License
show all
- Includes:
- CliCommand
- Defined in:
- lib/morpheus/cli/license.rb
Instance Attribute Summary
Attributes included from CliCommand
#no_prompt
Instance Method Summary
collapse
Methods included from CliCommand
#build_common_options, #build_option_type_options, #command_name, #default_subcommand, #establish_remote_appliance_connection, #handle_subcommand, included, #interactive?, #noninteractive, #print_usage, #subcommand_aliases, #subcommand_usage, #subcommands, #usage, #verify_access_token!
Constructor Details
Returns a new instance of License.
13
14
15
|
# File 'lib/morpheus/cli/license.rb', line 13
def initialize()
end
|
Instance Method Details
#apply(args) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/morpheus/cli/license.rb', line 66
def apply(args)
options = {}
account_name = nil
optparse = OptionParser.new do|opts|
opts.banner = subcommand_usage("[key]")
build_common_options(opts, options, [:json, :dry_run, :remote])
end
optparse.parse!(args)
connect(options)
begin
if args[0]
key = args[0]
else
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'licenseKey', 'fieldLabel' => 'License Key', 'type' => 'text', 'required' => true}], options[:options])
instance_name = v_prompt['licenseKey'] || ''
end
if options[:dry_run]
print_dry_run @license_interface.dry.apply(key)
return
end
license_results = @license_interface.apply(key)
if options[:json]
puts JSON.pretty_generate(license_results)
else
puts "License applied successfully!"
end
rescue RestClient::Exception => e
print_rest_exception(e, options)
return false
end
end
|
#connect(opts) ⇒ Object
17
18
19
20
21
|
# File 'lib/morpheus/cli/license.rb', line 17
def connect(opts)
@api_client = establish_remote_appliance_connection(opts)
@api_client = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url)
@license_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).license
end
|
#get(args) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/morpheus/cli/license.rb', line 27
def get(args)
options = {}
optparse = OptionParser.new do|opts|
opts.banner = subcommand_usage()
build_common_options(opts, options, [:json, :dry_run, :remote])
end
optparse.parse!(args)
connect(options)
begin
if options[:dry_run]
print_dry_run @license_interface.dry.get()
return
end
license = @license_interface.get()
if options[:json]
puts JSON.pretty_generate(license)
else
if license['license'].nil?
puts "No License Currently Applied to the appliance."
exit 1
else
print "\n", cyan, "License\n=======\n"
max_memory = Filesize.from("#{license['license']['maxMemory']} B").pretty
max_storage = Filesize.from("#{license['license']['maxStorage']} B").pretty
used_memory = Filesize.from("#{license['usedMemory']} B").pretty
puts "Account: #{license['license']['accountName']}"
puts "Start Date: #{license['license']['startDate']}"
puts "End Date: #{license['license']['endDate']}"
puts "Memory: #{used_memory} / #{max_memory}"
puts "Max Storage: #{max_storage}"
end
print reset,"\n"
end
rescue RestClient::Exception => e
print_rest_exception(e, options)
return false
end
end
|
#handle(args) ⇒ Object
23
24
25
|
# File 'lib/morpheus/cli/license.rb', line 23
def handle(args)
handle_subcommand(args)
end
|