morpheus-cli 0.9.10 → 2.9.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/morpheus +48 -33
- data/lib/morpheus/api/api_client.rb +12 -0
- data/lib/morpheus/api/custom_instance_types.rb +55 -0
- data/lib/morpheus/api/custom_instance_types_interface.rb +133 -0
- data/lib/morpheus/api/dashboard_interface.rb +37 -0
- data/lib/morpheus/api/users_interface.rb +17 -0
- data/lib/morpheus/api/whoami_interface.rb +20 -0
- data/lib/morpheus/cli.rb +13 -1
- data/lib/morpheus/cli/app_templates.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +22 -1
- data/lib/morpheus/cli/cli_registry.rb +1 -1
- data/lib/morpheus/cli/credentials.rb +33 -11
- data/lib/morpheus/cli/dashboard_command.rb +74 -0
- data/lib/morpheus/cli/instance_types.rb +4 -2
- data/lib/morpheus/cli/key_pairs.rb +1 -1
- data/lib/morpheus/cli/library.rb +539 -0
- data/lib/morpheus/cli/login.rb +57 -0
- data/lib/morpheus/cli/logout.rb +61 -0
- data/lib/morpheus/cli/mixins/accounts_helper.rb +52 -10
- data/lib/morpheus/cli/mixins/print_helper.rb +23 -16
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/whoami_helper.rb +34 -0
- data/lib/morpheus/cli/option_types.rb +15 -1
- data/lib/morpheus/cli/recent_activity_command.rb +83 -0
- data/lib/morpheus/cli/remote.rb +71 -28
- data/lib/morpheus/cli/roles.rb +89 -24
- data/lib/morpheus/cli/shell.rb +24 -11
- data/lib/morpheus/cli/users.rb +166 -24
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/version_command.rb +45 -0
- data/lib/morpheus/cli/whoami.rb +139 -0
- data/lib/morpheus/logging.rb +78 -0
- metadata +15 -2
data/lib/morpheus/cli/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# a command for printing this client version
|
2
|
+
require 'morpheus/cli/cli_command'
|
3
|
+
|
4
|
+
class Morpheus::Cli::VersionCommand
|
5
|
+
include Morpheus::Cli::CliCommand
|
6
|
+
|
7
|
+
cli_command_name :version
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage
|
13
|
+
"morpheus version"
|
14
|
+
end
|
15
|
+
|
16
|
+
def handle(args)
|
17
|
+
options = {}
|
18
|
+
optparse = OptionParser.new do|opts|
|
19
|
+
opts.banner = usage
|
20
|
+
opts.on('-v','--short', "Print only the client version number") do |val|
|
21
|
+
options[:short] = true
|
22
|
+
end
|
23
|
+
build_common_options(opts, options)
|
24
|
+
end
|
25
|
+
optparse.parse(args)
|
26
|
+
|
27
|
+
client_version = Morpheus::Cli::VERSION
|
28
|
+
if options[:short]
|
29
|
+
puts client_version
|
30
|
+
else
|
31
|
+
print cyan
|
32
|
+
banner = "" +
|
33
|
+
" __ ___ __ \n" +
|
34
|
+
" / |/ /__ _______ / / ___ __ _____\n" +
|
35
|
+
" / /|_/ / _ \\/ __/ _ \\/ _ \\/ -_) // (_-<\n" +
|
36
|
+
"/_/ /_/\\___/_/ / .__/_//_/\\__/\\_,_/___/\n" +
|
37
|
+
"****************************************"
|
38
|
+
puts(banner)
|
39
|
+
puts(" Client Version: #{client_version}")
|
40
|
+
puts("****************************************")
|
41
|
+
print reset
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# require 'yaml'
|
2
|
+
require 'io/console'
|
3
|
+
require 'rest_client'
|
4
|
+
require 'optparse'
|
5
|
+
require 'morpheus/cli/cli_command'
|
6
|
+
require 'morpheus/cli/mixins/whoami_helper'
|
7
|
+
require 'morpheus/cli/mixins/accounts_helper'
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
class Morpheus::Cli::Whoami
|
11
|
+
include Morpheus::Cli::CliCommand
|
12
|
+
include Morpheus::Cli::WhoamiHelper
|
13
|
+
include Morpheus::Cli::AccountsHelper
|
14
|
+
|
15
|
+
def initialize()
|
16
|
+
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
17
|
+
@active_groups = ::Morpheus::Cli::Groups.load_group_file
|
18
|
+
end
|
19
|
+
|
20
|
+
def connect(opts)
|
21
|
+
@access_token = Morpheus::Cli::Credentials.new(@appliance_name,@appliance_url).load_saved_credentials()
|
22
|
+
# always try this.. it will 401
|
23
|
+
# if @access_token.empty?
|
24
|
+
# print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
25
|
+
# exit 1
|
26
|
+
# end
|
27
|
+
@api_client = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url)
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def usage
|
33
|
+
"Usage: morpheus whoami"
|
34
|
+
end
|
35
|
+
|
36
|
+
def handle(args)
|
37
|
+
show(args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def show(args)
|
41
|
+
options = {}
|
42
|
+
optparse = OptionParser.new do|opts|
|
43
|
+
opts.banner = usage
|
44
|
+
opts.on(nil,'--feature-access', "Display Feature Access") do |val|
|
45
|
+
options[:include_feature_access] = true
|
46
|
+
end
|
47
|
+
# opts.on(nil,'--group-access', "Display Group Access") do
|
48
|
+
# options[:include_group_access] = true
|
49
|
+
# end
|
50
|
+
# opts.on(nil,'--cloud-access', "Display Cloud Access") do
|
51
|
+
# options[:include_cloud_access] = true
|
52
|
+
# end
|
53
|
+
# opts.on(nil,'--instance-type-access', "Display Instance Type Access") do
|
54
|
+
# options[:include_instance_type_access] = true
|
55
|
+
# end
|
56
|
+
opts.on(nil,'--all-access', "Display All Access Lists") do
|
57
|
+
options[:include_feature_access] = true
|
58
|
+
options[:include_group_access] = true
|
59
|
+
options[:include_cloud_access] = true
|
60
|
+
options[:include_instance_type_access] = true
|
61
|
+
end
|
62
|
+
build_common_options(opts, options, [:json]) # todo: support :remote too
|
63
|
+
end
|
64
|
+
optparse.parse(args)
|
65
|
+
|
66
|
+
connect(options)
|
67
|
+
begin
|
68
|
+
|
69
|
+
json_response = load_whoami()
|
70
|
+
|
71
|
+
if options[:json]
|
72
|
+
print JSON.pretty_generate(json_response)
|
73
|
+
print "\n"
|
74
|
+
else
|
75
|
+
user = @current_user
|
76
|
+
if !user
|
77
|
+
puts yellow,"No active session. Please login",reset
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
|
81
|
+
# todo: impersonate command and show that info here
|
82
|
+
|
83
|
+
print "\n" ,cyan, bold, "Current User\n","==================", reset, "\n\n"
|
84
|
+
print cyan
|
85
|
+
# if @is_master_account
|
86
|
+
puts "ID: #{user['id']}"
|
87
|
+
puts "Account: #{user['account'] ? user['account']['name'] : nil}" + (@is_master_account ? " (Master Account)" : "")
|
88
|
+
# end
|
89
|
+
puts "First Name: #{user['firstName']}"
|
90
|
+
puts "Last Name: #{user['lastName']}"
|
91
|
+
puts "Username: #{user['username']}"
|
92
|
+
puts "Email: #{user['email']}"
|
93
|
+
puts "Role: #{format_user_role_names(user)}"
|
94
|
+
# puts "Date Created: #{format_local_dt(user['dateCreated'])}"
|
95
|
+
# puts "Last Updated: #{format_local_dt(user['lastUpdated'])}"
|
96
|
+
# print "\n" ,cyan, bold, "User Instance Limits\n","==================", reset, "\n\n"
|
97
|
+
# print cyan
|
98
|
+
# puts "Max Storage (bytes): #{user['instanceLimits'] ? user['instanceLimits']['maxStorage'] : 0}"
|
99
|
+
# puts "Max Memory (bytes): #{user['instanceLimits'] ? user['instanceLimits']['maxMemory'] : 0}"
|
100
|
+
# puts "CPU Count: #{user['instanceLimits'] ? user['instanceLimits']['maxCpu'] : 0}"
|
101
|
+
|
102
|
+
if options[:include_feature_access]
|
103
|
+
if @user_permissions
|
104
|
+
print "\n" ,cyan, bold, "Feature Permissions\n","==================", reset, "\n\n"
|
105
|
+
print cyan
|
106
|
+
rows = @user_permissions.collect do |code, access|
|
107
|
+
{code: code, access: get_access_string(access) }
|
108
|
+
end
|
109
|
+
tp rows, [:code, :access]
|
110
|
+
else
|
111
|
+
puts yellow,"No permissions found.",reset
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
print "\n" ,cyan, bold, "Remote Appliance\n","==================", reset, "\n\n"
|
116
|
+
print cyan
|
117
|
+
if @appliance_name
|
118
|
+
puts "Name: #{@appliance_name}"
|
119
|
+
end
|
120
|
+
if @appliance_url
|
121
|
+
puts "Url: #{@appliance_url}"
|
122
|
+
end
|
123
|
+
if @appliance_build_verison
|
124
|
+
puts "Build Version: #{@appliance_build_verison}"
|
125
|
+
end
|
126
|
+
print cyan
|
127
|
+
|
128
|
+
print reset,"\n"
|
129
|
+
|
130
|
+
end
|
131
|
+
rescue RestClient::Exception => e
|
132
|
+
print_rest_exception(e, options)
|
133
|
+
exit 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
# Provides global Logging behavior
|
4
|
+
# By default, Morpheus::Logging.logger is set to STDOUT with level INFO
|
5
|
+
#
|
6
|
+
module Morpheus::Logging
|
7
|
+
|
8
|
+
DEFAULT_LOG_LEVEL = ENV['DEBUG'] ? Logger::DEBUG : Logger::INFO
|
9
|
+
|
10
|
+
@@log_level = DEFAULT_LOG_LEVEL
|
11
|
+
@@logger = nil
|
12
|
+
|
13
|
+
# Morpheus::Logging::Logger looks just like a typical Logger
|
14
|
+
class Logger < ::Logger
|
15
|
+
end
|
16
|
+
|
17
|
+
# Mixin for any class that need a logger instance
|
18
|
+
module HasLogger
|
19
|
+
|
20
|
+
def logger
|
21
|
+
@logger ||= Morpheus::Logging.logger
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# global methods
|
28
|
+
|
29
|
+
|
30
|
+
# get the global logger instance
|
31
|
+
def self.logger
|
32
|
+
if !@@logger
|
33
|
+
set_logger(STDOUT, @@log_level)
|
34
|
+
end
|
35
|
+
@@logger
|
36
|
+
end
|
37
|
+
|
38
|
+
# set the global logger to another logger or filename
|
39
|
+
def self.set_logger(logdev, log_level = @@log_level)
|
40
|
+
@@logger = logdev.is_a?(Logger) ? logdev : Logger.new(logdev)
|
41
|
+
@@logger.level = log_level || DEFAULT_LOG_LEVEL
|
42
|
+
@@logger.formatter = proc do |severity, datetime, progname, msg|
|
43
|
+
"#{msg}\n"
|
44
|
+
end
|
45
|
+
@@logger
|
46
|
+
end
|
47
|
+
|
48
|
+
# set the global log level
|
49
|
+
def self.log_level
|
50
|
+
@@log_level
|
51
|
+
end
|
52
|
+
|
53
|
+
# set the global log level
|
54
|
+
def self.set_log_level(level)
|
55
|
+
@@log_level = level.to_i
|
56
|
+
if @@logger
|
57
|
+
@@logger.level = @@log_level
|
58
|
+
end
|
59
|
+
@@log_level
|
60
|
+
end
|
61
|
+
|
62
|
+
# alias for set_log_level(level)
|
63
|
+
# def self.log_level=(level)
|
64
|
+
# self.set_log_level(level)
|
65
|
+
# end
|
66
|
+
|
67
|
+
# is log level debug?
|
68
|
+
def self.debug?
|
69
|
+
# self.log_level && self.log_level <= Logger::DEBUG
|
70
|
+
self.logger.debug?
|
71
|
+
end
|
72
|
+
|
73
|
+
# whether or not to print stack traces
|
74
|
+
def self.print_stacktrace?
|
75
|
+
self.debug?
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -144,6 +144,9 @@ files:
|
|
144
144
|
- lib/morpheus/api/app_templates_interface.rb
|
145
145
|
- lib/morpheus/api/apps_interface.rb
|
146
146
|
- lib/morpheus/api/clouds_interface.rb
|
147
|
+
- lib/morpheus/api/custom_instance_types.rb
|
148
|
+
- lib/morpheus/api/custom_instance_types_interface.rb
|
149
|
+
- lib/morpheus/api/dashboard_interface.rb
|
147
150
|
- lib/morpheus/api/deploy_interface.rb
|
148
151
|
- lib/morpheus/api/deployments_interface.rb
|
149
152
|
- lib/morpheus/api/groups_interface.rb
|
@@ -163,6 +166,7 @@ files:
|
|
163
166
|
- lib/morpheus/api/tasks_interface.rb
|
164
167
|
- lib/morpheus/api/users_interface.rb
|
165
168
|
- lib/morpheus/api/virtual_images_interface.rb
|
169
|
+
- lib/morpheus/api/whoami_interface.rb
|
166
170
|
- lib/morpheus/cli.rb
|
167
171
|
- lib/morpheus/cli/accounts.rb
|
168
172
|
- lib/morpheus/cli/app_templates.rb
|
@@ -171,6 +175,7 @@ files:
|
|
171
175
|
- lib/morpheus/cli/cli_registry.rb
|
172
176
|
- lib/morpheus/cli/clouds.rb
|
173
177
|
- lib/morpheus/cli/credentials.rb
|
178
|
+
- lib/morpheus/cli/dashboard_command.rb
|
174
179
|
- lib/morpheus/cli/deployments.rb
|
175
180
|
- lib/morpheus/cli/deploys.rb
|
176
181
|
- lib/morpheus/cli/groups.rb
|
@@ -178,12 +183,17 @@ files:
|
|
178
183
|
- lib/morpheus/cli/instance_types.rb
|
179
184
|
- lib/morpheus/cli/instances.rb
|
180
185
|
- lib/morpheus/cli/key_pairs.rb
|
186
|
+
- lib/morpheus/cli/library.rb
|
181
187
|
- lib/morpheus/cli/license.rb
|
182
188
|
- lib/morpheus/cli/load_balancers.rb
|
189
|
+
- lib/morpheus/cli/login.rb
|
190
|
+
- lib/morpheus/cli/logout.rb
|
183
191
|
- lib/morpheus/cli/mixins/accounts_helper.rb
|
184
192
|
- lib/morpheus/cli/mixins/print_helper.rb
|
185
193
|
- lib/morpheus/cli/mixins/provisioning_helper.rb
|
194
|
+
- lib/morpheus/cli/mixins/whoami_helper.rb
|
186
195
|
- lib/morpheus/cli/option_types.rb
|
196
|
+
- lib/morpheus/cli/recent_activity_command.rb
|
187
197
|
- lib/morpheus/cli/remote.rb
|
188
198
|
- lib/morpheus/cli/roles.rb
|
189
199
|
- lib/morpheus/cli/security_group_rules.rb
|
@@ -192,10 +202,13 @@ files:
|
|
192
202
|
- lib/morpheus/cli/tasks.rb
|
193
203
|
- lib/morpheus/cli/users.rb
|
194
204
|
- lib/morpheus/cli/version.rb
|
205
|
+
- lib/morpheus/cli/version_command.rb
|
195
206
|
- lib/morpheus/cli/virtual_images.rb
|
207
|
+
- lib/morpheus/cli/whoami.rb
|
196
208
|
- lib/morpheus/cli/workflows.rb
|
197
209
|
- lib/morpheus/ext/nil_class.rb
|
198
210
|
- lib/morpheus/formatters.rb
|
211
|
+
- lib/morpheus/logging.rb
|
199
212
|
- lib/morpheus/rest_client.rb
|
200
213
|
- morpheus-cli.gemspec
|
201
214
|
homepage: http://www.morpheusdata.com
|