Class: Morpheus::Cli::DashboardCommand
- Inherits:
-
Object
- Object
- Morpheus::Cli::DashboardCommand
show all
- Includes:
- CliCommand
- Defined in:
- lib/morpheus/cli/dashboard_command.rb
Instance Method Summary
collapse
Methods included from CliCommand
#build_common_options, included
Constructor Details
Returns a new instance of DashboardCommand.
Instance Method Details
#connect(opts) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/morpheus/cli/dashboard_command.rb', line 15
def connect(opts)
@access_token = Morpheus::Cli::Credentials.new(@appliance_name,@appliance_url).load_saved_credentials()
if @access_token.empty?
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
exit 1
end
@api_client = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url)
@dashboard_interface = @api_client.dashboard
end
|
#handle(args) ⇒ Object
29
30
31
|
# File 'lib/morpheus/cli/dashboard_command.rb', line 29
def handle(args)
show(args)
end
|
#show(args) ⇒ Object
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
65
66
67
68
69
70
|
# File 'lib/morpheus/cli/dashboard_command.rb', line 33
def show(args)
options = {}
optparse = OptionParser.new do|opts|
opts.banner = usage
build_common_options(opts, options, [:json]) end
optparse.parse(args)
connect(options)
begin
params = {}
json_response = @dashboard_interface.get(params)
if options[:json]
print JSON.pretty_generate(json_response)
print "\n"
else
print "\n" ,cyan, bold, "Dashboard\n","==================", reset, "\n\n"
print cyan
print "\n"
puts "Coming soon.... see --json"
print "\n"
print reset,"\n"
end
rescue RestClient::Exception => e
print_rest_exception(e, options)
exit 1
end
end
|
#usage ⇒ Object
25
26
27
|
# File 'lib/morpheus/cli/dashboard_command.rb', line 25
def usage
"Usage: morpheus dashboard"
end
|