morpheus-cli 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/api/api_client.rb +4 -0
- data/lib/morpheus/api/app_templates_interface.rb +74 -0
- data/lib/morpheus/api/instance_types_interface.rb +9 -0
- data/lib/morpheus/api/instances_interface.rb +16 -0
- data/lib/morpheus/api/roles_interface.rb +37 -1
- data/lib/morpheus/cli.rb +4 -1
- data/lib/morpheus/cli/accounts.rb +82 -58
- data/lib/morpheus/cli/app_templates.rb +908 -0
- data/lib/morpheus/cli/apps.rb +226 -187
- data/lib/morpheus/cli/cli_command.rb +57 -30
- data/lib/morpheus/cli/clouds.rb +50 -65
- data/lib/morpheus/cli/deployments.rb +18 -33
- data/lib/morpheus/cli/deploys.rb +1 -3
- data/lib/morpheus/cli/groups.rb +54 -38
- data/lib/morpheus/cli/hosts.rb +86 -80
- data/lib/morpheus/cli/instance_types.rb +42 -29
- data/lib/morpheus/cli/instances.rb +192 -69
- data/lib/morpheus/cli/key_pairs.rb +70 -87
- data/lib/morpheus/cli/license.rb +7 -9
- data/lib/morpheus/cli/load_balancers.rb +23 -53
- data/lib/morpheus/cli/mixins/accounts_helper.rb +7 -8
- data/lib/morpheus/cli/mixins/print_helper.rb +67 -0
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +461 -0
- data/lib/morpheus/cli/option_types.rb +71 -18
- data/lib/morpheus/cli/roles.rb +725 -34
- data/lib/morpheus/cli/security_group_rules.rb +50 -70
- data/lib/morpheus/cli/security_groups.rb +61 -48
- data/lib/morpheus/cli/shell.rb +123 -14
- data/lib/morpheus/cli/tasks.rb +24 -59
- data/lib/morpheus/cli/users.rb +86 -71
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +21 -51
- data/lib/morpheus/cli/workflows.rb +14 -29
- data/lib/morpheus/ext/nil_class.rb +5 -0
- data/lib/morpheus/formatters.rb +1 -0
- metadata +7 -3
- data/lib/morpheus/cli/error_handler.rb +0 -44
data/lib/morpheus/cli/version.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# require 'yaml'
|
2
2
|
require 'io/console'
|
3
3
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
4
|
require 'optparse'
|
6
5
|
require 'table_print'
|
7
6
|
require 'morpheus/cli/cli_command'
|
8
7
|
|
9
8
|
class Morpheus::Cli::VirtualImages
|
10
9
|
include Morpheus::Cli::CliCommand
|
11
|
-
|
10
|
+
|
12
11
|
def initialize()
|
13
12
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
14
13
|
end
|
@@ -25,7 +24,7 @@ class Morpheus::Cli::VirtualImages
|
|
25
24
|
@virtual_images_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).virtual_images
|
26
25
|
|
27
26
|
if @access_token.empty?
|
28
|
-
|
27
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
29
28
|
exit 1
|
30
29
|
end
|
31
30
|
end
|
@@ -73,20 +72,14 @@ class Morpheus::Cli::VirtualImages
|
|
73
72
|
opts.on( '', '--system', "System Images" ) do |val|
|
74
73
|
options[:filterType] = 'System'
|
75
74
|
end
|
76
|
-
|
75
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
77
76
|
end
|
78
77
|
optparse.parse(args)
|
79
78
|
connect(options)
|
80
79
|
begin
|
81
80
|
params = {}
|
82
|
-
|
83
|
-
params[
|
84
|
-
end
|
85
|
-
if options[:max]
|
86
|
-
params[:max] = options[:max]
|
87
|
-
end
|
88
|
-
if options[:phrase]
|
89
|
-
params[:phrase] = options[:phrase]
|
81
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
82
|
+
params[k] = options[k] unless options[k].nil?
|
90
83
|
end
|
91
84
|
if options[:imageType]
|
92
85
|
params[:imageType] = options[:imageType]
|
@@ -114,12 +107,7 @@ class Morpheus::Cli::VirtualImages
|
|
114
107
|
|
115
108
|
|
116
109
|
rescue RestClient::Exception => e
|
117
|
-
|
118
|
-
error = JSON.parse(e.response.to_s)
|
119
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
120
|
-
else
|
121
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
122
|
-
end
|
110
|
+
print_rest_exception(e, options)
|
123
111
|
exit 1
|
124
112
|
end
|
125
113
|
end
|
@@ -129,7 +117,7 @@ class Morpheus::Cli::VirtualImages
|
|
129
117
|
options = {}
|
130
118
|
optparse = OptionParser.new do|opts|
|
131
119
|
opts.banner = "Usage: morpheus virtual-images details [name]"
|
132
|
-
|
120
|
+
build_common_options(opts, options, [:json, :remote])
|
133
121
|
end
|
134
122
|
if args.count < 1
|
135
123
|
puts "\n#{optparse.banner}\n\n"
|
@@ -152,12 +140,7 @@ class Morpheus::Cli::VirtualImages
|
|
152
140
|
print reset,"\n\n"
|
153
141
|
end
|
154
142
|
rescue RestClient::Exception => e
|
155
|
-
|
156
|
-
error = JSON.parse(e.response.to_s)
|
157
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
158
|
-
else
|
159
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
160
|
-
end
|
143
|
+
print_rest_exception(e, options)
|
161
144
|
exit 1
|
162
145
|
end
|
163
146
|
end
|
@@ -168,7 +151,7 @@ class Morpheus::Cli::VirtualImages
|
|
168
151
|
account_name = nil
|
169
152
|
optparse = OptionParser.new do|opts|
|
170
153
|
opts.banner = "Usage: morpheus tasks update [task] [options]"
|
171
|
-
|
154
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
172
155
|
end
|
173
156
|
if args.count < 1
|
174
157
|
puts "\n#{optparse.banner}\n\n"
|
@@ -218,12 +201,7 @@ class Morpheus::Cli::VirtualImages
|
|
218
201
|
print "\n", cyan, "Task #{response['task']['name']} updated", reset, "\n\n"
|
219
202
|
end
|
220
203
|
rescue RestClient::Exception => e
|
221
|
-
|
222
|
-
error = JSON.parse(e.response.to_s)
|
223
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
224
|
-
else
|
225
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
226
|
-
end
|
204
|
+
print_rest_exception(e, options)
|
227
205
|
exit 1
|
228
206
|
end
|
229
207
|
end
|
@@ -233,7 +211,7 @@ class Morpheus::Cli::VirtualImages
|
|
233
211
|
options = {}
|
234
212
|
optparse = OptionParser.new do|opts|
|
235
213
|
opts.banner = "Usage: morpheus virtual-images lb-types"
|
236
|
-
|
214
|
+
build_common_options(opts, options, [:json, :remote])
|
237
215
|
end
|
238
216
|
optparse.parse(args)
|
239
217
|
connect(options)
|
@@ -258,13 +236,8 @@ class Morpheus::Cli::VirtualImages
|
|
258
236
|
end
|
259
237
|
|
260
238
|
|
261
|
-
rescue => e
|
262
|
-
|
263
|
-
error = JSON.parse(e.response.to_s)
|
264
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
265
|
-
else
|
266
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
267
|
-
end
|
239
|
+
rescue RestClient::Exception => e
|
240
|
+
print_rest_exception(e, options)
|
268
241
|
exit 1
|
269
242
|
end
|
270
243
|
end
|
@@ -278,7 +251,7 @@ class Morpheus::Cli::VirtualImages
|
|
278
251
|
opts.on( '-t', '--type LB_TYPE', "Lb Type" ) do |val|
|
279
252
|
lb_type_name = val
|
280
253
|
end
|
281
|
-
|
254
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
282
255
|
end
|
283
256
|
if args.count < 1
|
284
257
|
puts "\n#{optparse.banner}\n\n"
|
@@ -307,7 +280,7 @@ class Morpheus::Cli::VirtualImages
|
|
307
280
|
print "\n", cyan, "LB #{json_response['virtualImage']['name']} created successfully", reset, "\n\n"
|
308
281
|
end
|
309
282
|
rescue RestClient::Exception => e
|
310
|
-
|
283
|
+
print_rest_exception(e, options)
|
311
284
|
exit 1
|
312
285
|
end
|
313
286
|
end
|
@@ -317,7 +290,7 @@ class Morpheus::Cli::VirtualImages
|
|
317
290
|
options = {}
|
318
291
|
optparse = OptionParser.new do|opts|
|
319
292
|
opts.banner = "Usage: morpheus virtual-images remove [name]"
|
320
|
-
|
293
|
+
build_common_options(opts, options, [:auto_confirm, :json, :remote])
|
321
294
|
end
|
322
295
|
if args.count < 1
|
323
296
|
puts "\n#{optparse.banner}\n\n"
|
@@ -328,7 +301,9 @@ class Morpheus::Cli::VirtualImages
|
|
328
301
|
begin
|
329
302
|
image = find_image_by_name(image_name)
|
330
303
|
exit 1 if image.nil?
|
331
|
-
|
304
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the virtual image #{image['name']}?")
|
305
|
+
exit
|
306
|
+
end
|
332
307
|
json_response = @virtual_images_interface.destroy(image['id'])
|
333
308
|
if options[:json]
|
334
309
|
print JSON.pretty_generate(json_response)
|
@@ -336,12 +311,7 @@ class Morpheus::Cli::VirtualImages
|
|
336
311
|
print "\n", cyan, "Virtual Image #{image['name']} removed", reset, "\n\n"
|
337
312
|
end
|
338
313
|
rescue RestClient::Exception => e
|
339
|
-
|
340
|
-
error = JSON.parse(e.response.to_s)
|
341
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
342
|
-
else
|
343
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
344
|
-
end
|
314
|
+
print_rest_exception(e, options)
|
345
315
|
exit 1
|
346
316
|
end
|
347
317
|
end
|
@@ -382,4 +352,4 @@ private
|
|
382
352
|
return result
|
383
353
|
end
|
384
354
|
|
385
|
-
end
|
355
|
+
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# require 'yaml'
|
2
2
|
require 'io/console'
|
3
3
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
4
|
require 'optparse'
|
6
5
|
require 'table_print'
|
7
6
|
require 'morpheus/cli/cli_command'
|
8
7
|
|
9
8
|
class Morpheus::Cli::Workflows
|
10
9
|
include Morpheus::Cli::CliCommand
|
11
|
-
|
10
|
+
|
12
11
|
def initialize()
|
13
12
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
14
13
|
end
|
@@ -25,7 +24,7 @@ class Morpheus::Cli::Workflows
|
|
25
24
|
@tasks_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).tasks
|
26
25
|
@task_sets_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).task_sets
|
27
26
|
if @access_token.empty?
|
28
|
-
|
27
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
29
28
|
exit 1
|
30
29
|
end
|
31
30
|
end
|
@@ -56,20 +55,14 @@ class Morpheus::Cli::Workflows
|
|
56
55
|
options = {}
|
57
56
|
optparse = OptionParser.new do|opts|
|
58
57
|
opts.banner = "Usage: morpheus workflows list [-s] [-o] [-m]"
|
59
|
-
|
58
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
60
59
|
end
|
61
60
|
optparse.parse(args)
|
62
61
|
connect(options)
|
63
62
|
begin
|
64
63
|
params = {}
|
65
|
-
|
66
|
-
params[
|
67
|
-
end
|
68
|
-
if options[:max]
|
69
|
-
params[:max] = options[:max]
|
70
|
-
end
|
71
|
-
if options[:phrase]
|
72
|
-
params[:phrase] = options[:phrase]
|
64
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
65
|
+
params[k] = options[k] unless options[k].nil?
|
73
66
|
end
|
74
67
|
json_response = @task_sets_interface.get(params)
|
75
68
|
if options[:json]
|
@@ -89,7 +82,7 @@ class Morpheus::Cli::Workflows
|
|
89
82
|
print reset,"\n\n"
|
90
83
|
end
|
91
84
|
rescue RestClient::Exception => e
|
92
|
-
|
85
|
+
print_rest_exception(e, options)
|
93
86
|
exit 1
|
94
87
|
end
|
95
88
|
end
|
@@ -102,7 +95,7 @@ class Morpheus::Cli::Workflows
|
|
102
95
|
opts.on("--tasks x,y,z", Array, "List of tasks to run in order") do |list|
|
103
96
|
options[:task_names]= list
|
104
97
|
end
|
105
|
-
|
98
|
+
build_common_options(opts, options, [:json, :remote])
|
106
99
|
end
|
107
100
|
if args.count < 1
|
108
101
|
puts "\n#{optparse.banner}\n\n"
|
@@ -124,12 +117,7 @@ class Morpheus::Cli::Workflows
|
|
124
117
|
print "\n", cyan, "Workflow #{json_response['taskSet']['name']} created successfully", reset, "\n\n"
|
125
118
|
end
|
126
119
|
rescue RestClient::Exception => e
|
127
|
-
|
128
|
-
error = JSON.parse(e.response.to_s)
|
129
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
130
|
-
else
|
131
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
132
|
-
end
|
120
|
+
print_rest_exception(e, options)
|
133
121
|
exit 1
|
134
122
|
end
|
135
123
|
end
|
@@ -142,7 +130,7 @@ class Morpheus::Cli::Workflows
|
|
142
130
|
options = {}
|
143
131
|
optparse = OptionParser.new do|opts|
|
144
132
|
opts.banner = "Usage: morpheus workflows remove [name]"
|
145
|
-
|
133
|
+
build_common_options(opts, options, [:auto_confirm, :json, :remote])
|
146
134
|
end
|
147
135
|
if args.count < 1
|
148
136
|
puts "\n#{optparse.banner}\n\n"
|
@@ -153,7 +141,9 @@ class Morpheus::Cli::Workflows
|
|
153
141
|
begin
|
154
142
|
workflow = find_workflow_by_name_or_code_or_id(workflow_name)
|
155
143
|
exit 1 if workflow.nil?
|
156
|
-
|
144
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the workflow #{workflow['name']}?")
|
145
|
+
exit 1
|
146
|
+
end
|
157
147
|
json_response = @tasks_interface.destroy(task['id'])
|
158
148
|
if options[:json]
|
159
149
|
print JSON.pretty_generate(json_response)
|
@@ -161,12 +151,7 @@ class Morpheus::Cli::Workflows
|
|
161
151
|
print "\n", cyan, "Workflow #{workflow['name']} removed", reset, "\n\n"
|
162
152
|
end
|
163
153
|
rescue RestClient::Exception => e
|
164
|
-
|
165
|
-
error = JSON.parse(e.response.to_s)
|
166
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
167
|
-
else
|
168
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
169
|
-
end
|
154
|
+
print_rest_exception(e, options)
|
170
155
|
exit 1
|
171
156
|
end
|
172
157
|
end
|
@@ -206,4 +191,4 @@ private
|
|
206
191
|
end
|
207
192
|
return result
|
208
193
|
end
|
209
|
-
end
|
194
|
+
end
|
data/lib/morpheus/formatters.rb
CHANGED
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: 0.9.
|
4
|
+
version: 0.9.10
|
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-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- bin/morpheus
|
142
142
|
- lib/morpheus/api/accounts_interface.rb
|
143
143
|
- lib/morpheus/api/api_client.rb
|
144
|
+
- lib/morpheus/api/app_templates_interface.rb
|
144
145
|
- lib/morpheus/api/apps_interface.rb
|
145
146
|
- lib/morpheus/api/clouds_interface.rb
|
146
147
|
- lib/morpheus/api/deploy_interface.rb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- lib/morpheus/api/virtual_images_interface.rb
|
165
166
|
- lib/morpheus/cli.rb
|
166
167
|
- lib/morpheus/cli/accounts.rb
|
168
|
+
- lib/morpheus/cli/app_templates.rb
|
167
169
|
- lib/morpheus/cli/apps.rb
|
168
170
|
- lib/morpheus/cli/cli_command.rb
|
169
171
|
- lib/morpheus/cli/cli_registry.rb
|
@@ -171,7 +173,6 @@ files:
|
|
171
173
|
- lib/morpheus/cli/credentials.rb
|
172
174
|
- lib/morpheus/cli/deployments.rb
|
173
175
|
- lib/morpheus/cli/deploys.rb
|
174
|
-
- lib/morpheus/cli/error_handler.rb
|
175
176
|
- lib/morpheus/cli/groups.rb
|
176
177
|
- lib/morpheus/cli/hosts.rb
|
177
178
|
- lib/morpheus/cli/instance_types.rb
|
@@ -180,6 +181,8 @@ files:
|
|
180
181
|
- lib/morpheus/cli/license.rb
|
181
182
|
- lib/morpheus/cli/load_balancers.rb
|
182
183
|
- lib/morpheus/cli/mixins/accounts_helper.rb
|
184
|
+
- lib/morpheus/cli/mixins/print_helper.rb
|
185
|
+
- lib/morpheus/cli/mixins/provisioning_helper.rb
|
183
186
|
- lib/morpheus/cli/option_types.rb
|
184
187
|
- lib/morpheus/cli/remote.rb
|
185
188
|
- lib/morpheus/cli/roles.rb
|
@@ -191,6 +194,7 @@ files:
|
|
191
194
|
- lib/morpheus/cli/version.rb
|
192
195
|
- lib/morpheus/cli/virtual_images.rb
|
193
196
|
- lib/morpheus/cli/workflows.rb
|
197
|
+
- lib/morpheus/ext/nil_class.rb
|
194
198
|
- lib/morpheus/formatters.rb
|
195
199
|
- lib/morpheus/rest_client.rb
|
196
200
|
- morpheus-cli.gemspec
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'rest_client'
|
3
|
-
require 'term/ansicolor'
|
4
|
-
require 'optparse'
|
5
|
-
require 'json'
|
6
|
-
|
7
|
-
|
8
|
-
class Morpheus::Cli::ErrorHandler
|
9
|
-
include Term::ANSIColor
|
10
|
-
|
11
|
-
def print_errors(response, options = {})
|
12
|
-
if options[:json]
|
13
|
-
print JSON.pretty_generate(response)
|
14
|
-
else
|
15
|
-
if !response['success']
|
16
|
-
print red,bold, "\n"
|
17
|
-
if response['msg']
|
18
|
-
puts response['msg']
|
19
|
-
end
|
20
|
-
if response['errors']
|
21
|
-
response['errors'].each do |key, value|
|
22
|
-
print "* #{key}: #{value}\n"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
print reset, "\n"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def print_rest_exception(e, options={})
|
31
|
-
if e.response.code == 400
|
32
|
-
json_response = JSON.parse(e.response.to_s)
|
33
|
-
if options[:json]
|
34
|
-
print JSON.pretty_generate(json_response)
|
35
|
-
print "\n"
|
36
|
-
else
|
37
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(json_response)
|
38
|
-
end
|
39
|
-
else
|
40
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|