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
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'morpheus/cli/cli_registry'
|
2
|
+
require 'morpheus/cli/mixins/print_helper'
|
2
3
|
|
3
4
|
module Morpheus
|
4
5
|
module Cli
|
@@ -7,19 +8,24 @@ module Morpheus
|
|
7
8
|
|
8
9
|
def self.included(klass)
|
9
10
|
Morpheus::Cli::CliRegistry.add(klass)
|
11
|
+
klass.include Morpheus::Cli::PrintHelper
|
10
12
|
klass.extend ClassMethods
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
def build_common_options(opts, options, includes=[])
|
16
|
+
includes = includes.clone
|
17
|
+
while (option_key = includes.shift) do
|
18
|
+
case option_key.to_sym
|
19
|
+
|
20
|
+
when :account
|
21
|
+
opts.on('-a','--account ACCOUNT', "Account Name") do |val|
|
22
|
+
options[:account_name] = val
|
23
|
+
end
|
24
|
+
opts.on('-A','--account-id ID', "Account ID") do |val|
|
25
|
+
options[:account_id] = val
|
26
|
+
end
|
21
27
|
|
22
|
-
|
28
|
+
when :options
|
23
29
|
opts.on( '-O', '--option OPTION', "Option" ) do |option|
|
24
30
|
custom_option_args = option.split('=')
|
25
31
|
custom_options = options[:options] || {}
|
@@ -40,19 +46,14 @@ module Morpheus
|
|
40
46
|
|
41
47
|
options[:options] = custom_options
|
42
48
|
end
|
43
|
-
opts.on('-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
exit
|
49
|
-
end
|
50
|
-
opts.on('-j','--json', "JSON Output") do |json|
|
51
|
-
options[:json] = true
|
52
|
-
end
|
53
|
-
opts.on( '-y', '--yes', "Auto Confirm" ) do
|
54
|
-
options[:yes] = true
|
49
|
+
opts.on('-N','--no-prompt', "Skip prompts. Use default values for all optional fields.") do |val|
|
50
|
+
options[:no_prompt] = true
|
51
|
+
# ew, stored in here for now because options[:options] is what is passed into OptionTypes.prompt() everywhere!
|
52
|
+
options[:options] ||= {}
|
53
|
+
options[:options][:no_prompt] = true
|
55
54
|
end
|
55
|
+
when :list
|
56
|
+
|
56
57
|
opts.on( '-m', '--max MAX', "Max Results" ) do |max|
|
57
58
|
options[:max] = max.to_i
|
58
59
|
end
|
@@ -61,6 +62,19 @@ module Morpheus
|
|
61
62
|
options[:offset] = offset.to_i
|
62
63
|
end
|
63
64
|
|
65
|
+
opts.on( '-s', '--search PHRASE', "Search Phrase" ) do |phrase|
|
66
|
+
options[:phrase] = phrase
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.on( '-S', '--sort ORDER', "Sort Order" ) do |v|
|
70
|
+
options[:sort] = v
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on( '-D', '--desc', "Reverse Sort Order" ) do |v|
|
74
|
+
options[:direction] = "desc"
|
75
|
+
end
|
76
|
+
|
77
|
+
when :remote
|
64
78
|
opts.on( '-r', '--remote REMOTE', "Remote Appliance" ) do |remote|
|
65
79
|
options[:remote] = remote
|
66
80
|
end
|
@@ -80,18 +94,31 @@ module Morpheus
|
|
80
94
|
opts.on( '-T', '--token ACCESS_TOKEN', "Access Token" ) do |remote|
|
81
95
|
options[:remote_token] = remote
|
82
96
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
97
|
+
|
98
|
+
when :auto_confirm
|
99
|
+
opts.on( '-y', '--yes', "Auto Confirm" ) do
|
100
|
+
options[:yes] = true
|
86
101
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
102
|
+
|
103
|
+
when :json
|
104
|
+
opts.on('-j','--json', "JSON Output") do |json|
|
105
|
+
options[:json] = true
|
90
106
|
end
|
107
|
+
|
108
|
+
else
|
109
|
+
raise "Unknown common_option key: #{option_key}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# options that are always included
|
114
|
+
opts.on('-C','--nocolor', "ANSI") do
|
115
|
+
Term::ANSIColor::coloring = false
|
116
|
+
end
|
117
|
+
opts.on('-h', '--help', "Prints this help" ) do
|
118
|
+
puts opts
|
119
|
+
exit
|
120
|
+
end
|
91
121
|
|
92
|
-
opts.on( '', '--desc', "Reverse Sort Order" ) do |v|
|
93
|
-
options[:direction] = "desc"
|
94
|
-
end
|
95
122
|
end
|
96
123
|
|
97
124
|
|
data/lib/morpheus/cli/clouds.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
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 'morpheus/cli/cli_command'
|
7
6
|
require 'morpheus/cli/option_types'
|
@@ -9,7 +8,7 @@ require 'json'
|
|
9
8
|
|
10
9
|
class Morpheus::Cli::Clouds
|
11
10
|
include Morpheus::Cli::CliCommand
|
12
|
-
|
11
|
+
|
13
12
|
def initialize()
|
14
13
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
15
14
|
|
@@ -29,7 +28,7 @@ class Morpheus::Cli::Clouds
|
|
29
28
|
@groups_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).groups
|
30
29
|
@cloud_types = @clouds_interface.cloud_types['zoneTypes']
|
31
30
|
if @access_token.empty?
|
32
|
-
|
31
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
33
32
|
return 1
|
34
33
|
end
|
35
34
|
end
|
@@ -63,13 +62,10 @@ class Morpheus::Cli::Clouds
|
|
63
62
|
end
|
64
63
|
|
65
64
|
def add(args)
|
66
|
-
if args.count < 1
|
67
|
-
puts "\nUsage: morpheus clouds add [name] --group GROUP --type TYPE\n\n"
|
68
|
-
exit 1
|
69
|
-
end
|
70
65
|
options = {}
|
71
66
|
params = {zone_type: 'standard'}
|
72
67
|
optparse = OptionParser.new do|opts|
|
68
|
+
opts.banner = "Usage: morpheus clouds add [name] --group GROUP --type TYPE"
|
73
69
|
opts.on( '-g', '--group GROUP', "Group Name" ) do |group|
|
74
70
|
params[:group] = group
|
75
71
|
end
|
@@ -79,9 +75,15 @@ class Morpheus::Cli::Clouds
|
|
79
75
|
opts.on( '-d', '--description DESCRIPTION', "Description (optional)" ) do |desc|
|
80
76
|
params[:description] = desc
|
81
77
|
end
|
82
|
-
|
78
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
83
79
|
end
|
84
80
|
optparse.parse!(args)
|
81
|
+
|
82
|
+
if args.count < 1
|
83
|
+
puts "\n#{optparse.banner}\n\n"
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
|
85
87
|
connect(options)
|
86
88
|
zone = {name: args[0], description: params[:description]}
|
87
89
|
if !params[:group].nil?
|
@@ -98,44 +100,42 @@ class Morpheus::Cli::Clouds
|
|
98
100
|
|
99
101
|
begin
|
100
102
|
zone.merge!(Morpheus::Cli::OptionTypes.prompt(cloud_type['optionTypes'],options[:options],@api_client))
|
101
|
-
@clouds_interface.create(zone)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
if options[:json]
|
106
|
-
print JSON.pretty_generate(error)
|
107
|
-
else
|
108
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
109
|
-
end
|
103
|
+
json_response = @clouds_interface.create(zone)
|
104
|
+
if options[:json]
|
105
|
+
print JSON.pretty_generate(json_response)
|
106
|
+
print "\n"
|
110
107
|
else
|
111
|
-
|
108
|
+
list([])
|
112
109
|
end
|
110
|
+
rescue RestClient::Exception => e
|
111
|
+
print_rest_exception(e, options)
|
113
112
|
exit 1
|
114
113
|
end
|
115
|
-
list([])
|
116
114
|
end
|
117
115
|
|
118
116
|
def remove(args)
|
119
|
-
|
120
|
-
puts "\nUsage: morpheus clouds remove [name] --group GROUP\n\n"
|
121
|
-
return
|
122
|
-
end
|
123
|
-
|
124
|
-
params = {}
|
117
|
+
options = {}
|
125
118
|
optparse = OptionParser.new do|opts|
|
119
|
+
opts.banner = "Usage: morpheus clouds remove [name] --group GROUP"
|
126
120
|
opts.on( '-g', '--group GROUP', "Group Name" ) do |group|
|
127
|
-
|
121
|
+
options[:group] = group
|
128
122
|
end
|
129
|
-
|
123
|
+
build_common_options(opts, options, [:auto_confirm, :json, :remote])
|
130
124
|
end
|
131
125
|
optparse.parse(args)
|
132
|
-
|
133
|
-
if
|
134
|
-
|
126
|
+
|
127
|
+
if args.count < 2
|
128
|
+
puts "\n#{optparse.banner}\n\n"
|
129
|
+
return
|
130
|
+
end
|
131
|
+
|
132
|
+
connect(options)
|
133
|
+
if !options[:group].nil?
|
134
|
+
group = find_group_by_name(options[:group])
|
135
135
|
if !group.nil?
|
136
|
-
|
136
|
+
options[:groupId] = group['id']
|
137
137
|
else
|
138
|
-
puts "\nGroup #{
|
138
|
+
puts "\nGroup #{options[:group]} not found!"
|
139
139
|
exit 1
|
140
140
|
end
|
141
141
|
end
|
@@ -147,15 +147,19 @@ class Morpheus::Cli::Clouds
|
|
147
147
|
puts "Zone not found by name #{args[0]}"
|
148
148
|
exit 1
|
149
149
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
150
|
+
cloud = zone_results['zones'][0]
|
151
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the cloud #{cloud['name']}?")
|
152
|
+
exit
|
153
|
+
end
|
154
|
+
json_response = @clouds_interface.destroy(cloud['id'])
|
155
|
+
if options[:json]
|
156
|
+
print JSON.pretty_generate(json_response)
|
157
|
+
print "\n"
|
156
158
|
else
|
157
|
-
|
159
|
+
list([])
|
158
160
|
end
|
161
|
+
rescue RestClient::Exception => e
|
162
|
+
print_rest_exception(e, options)
|
159
163
|
exit 1
|
160
164
|
end
|
161
165
|
end
|
@@ -163,10 +167,11 @@ class Morpheus::Cli::Clouds
|
|
163
167
|
def list(args)
|
164
168
|
options={}
|
165
169
|
optparse = OptionParser.new do|opts|
|
170
|
+
opts.banner = "Usage: morpheus clouds list"
|
166
171
|
opts.on( '-g', '--group GROUP', "Group Name" ) do |group|
|
167
172
|
options[:group] = group
|
168
173
|
end
|
169
|
-
|
174
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
170
175
|
end
|
171
176
|
optparse.parse(args)
|
172
177
|
connect(options)
|
@@ -199,7 +204,7 @@ class Morpheus::Cli::Clouds
|
|
199
204
|
status = "#{red}#{cloud['status'] ? cloud['status'].upcase : 'N/A'}#{cloud['statusMessage'] ? "#{cyan} - #{cloud['statusMessage']}" : ''}#{cyan}"
|
200
205
|
end
|
201
206
|
{id: cloud['id'], name: cloud['name'], type: cloud_type_for_id(cloud['zoneTypeId']), location: cloud['location'], status: status}
|
202
|
-
# print
|
207
|
+
# print cyan, "= [#{server['id']}] #{server['name']} - #{server['computeServerType'] ? server['computeServerType']['name'] : 'unmanaged'} (#{server['status']}) Power: ", power_state, "\n"
|
203
208
|
end
|
204
209
|
print cyan
|
205
210
|
tp clouds_table, :id, :name, :type, :location, :status
|
@@ -229,12 +234,7 @@ class Morpheus::Cli::Clouds
|
|
229
234
|
@clouds_interface.firewall_disable(zone_results['zones'][0]['id'])
|
230
235
|
security_groups([args[0]])
|
231
236
|
rescue RestClient::Exception => e
|
232
|
-
|
233
|
-
error = JSON.parse(e.response.to_s)
|
234
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
235
|
-
else
|
236
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
237
|
-
end
|
237
|
+
print_rest_exception(e, options)
|
238
238
|
exit 1
|
239
239
|
end
|
240
240
|
end
|
@@ -253,12 +253,7 @@ class Morpheus::Cli::Clouds
|
|
253
253
|
@clouds_interface.firewall_enable(zone_results['zones'][0]['id'])
|
254
254
|
security_groups([args[0]])
|
255
255
|
rescue RestClient::Exception => e
|
256
|
-
|
257
|
-
error = JSON.parse(e.response.to_s)
|
258
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
259
|
-
else
|
260
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
261
|
-
end
|
256
|
+
print_rest_exception(e, options)
|
262
257
|
exit 1
|
263
258
|
end
|
264
259
|
end
|
@@ -291,12 +286,7 @@ class Morpheus::Cli::Clouds
|
|
291
286
|
print reset,"\n\n"
|
292
287
|
|
293
288
|
rescue RestClient::Exception => e
|
294
|
-
|
295
|
-
error = JSON.parse(e.response.to_s)
|
296
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
297
|
-
else
|
298
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
299
|
-
end
|
289
|
+
print_rest_exception(e, options)
|
300
290
|
exit 1
|
301
291
|
end
|
302
292
|
end
|
@@ -344,12 +334,7 @@ EOF
|
|
344
334
|
@clouds_interface.apply_security_groups(zone_results['zones'][0]['id'], options)
|
345
335
|
security_groups([args[0]])
|
346
336
|
rescue RestClient::Exception => e
|
347
|
-
|
348
|
-
error = JSON.parse(e.response.to_s)
|
349
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
350
|
-
else
|
351
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
352
|
-
end
|
337
|
+
print_rest_exception(e, options)
|
353
338
|
exit 1
|
354
339
|
end
|
355
340
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
# require 'yaml'
|
2
1
|
require 'io/console'
|
3
2
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
3
|
require 'optparse'
|
6
4
|
require 'table_print'
|
7
5
|
require 'morpheus/cli/cli_command'
|
8
6
|
|
9
7
|
class Morpheus::Cli::Deployments
|
10
8
|
include Morpheus::Cli::CliCommand
|
11
|
-
|
9
|
+
|
12
10
|
def initialize()
|
13
11
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
14
12
|
end
|
@@ -24,7 +22,7 @@ class Morpheus::Cli::Deployments
|
|
24
22
|
@api_client = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url)
|
25
23
|
@deployments_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).deployments
|
26
24
|
if @access_token.empty?
|
27
|
-
|
25
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
28
26
|
exit 1
|
29
27
|
end
|
30
28
|
end
|
@@ -57,7 +55,7 @@ class Morpheus::Cli::Deployments
|
|
57
55
|
options = {}
|
58
56
|
optparse = OptionParser.new do|opts|
|
59
57
|
opts.banner = "Usage: morpheus deployments list [-s] [-o] [-m]"
|
60
|
-
|
58
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
61
59
|
end
|
62
60
|
optparse.parse(args)
|
63
61
|
connect(options)
|
@@ -86,7 +84,7 @@ class Morpheus::Cli::Deployments
|
|
86
84
|
|
87
85
|
|
88
86
|
rescue RestClient::Exception => e
|
89
|
-
|
87
|
+
print_rest_exception(e, options)
|
90
88
|
exit 1
|
91
89
|
end
|
92
90
|
end
|
@@ -95,7 +93,7 @@ class Morpheus::Cli::Deployments
|
|
95
93
|
options = {}
|
96
94
|
optparse = OptionParser.new do|opts|
|
97
95
|
opts.banner = "Usage: morpheus deployments versions [deployment] [-s] [-o] [-m]"
|
98
|
-
|
96
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
99
97
|
end
|
100
98
|
optparse.parse(args)
|
101
99
|
if args.count < 1
|
@@ -130,7 +128,7 @@ class Morpheus::Cli::Deployments
|
|
130
128
|
print reset,"\n\n"
|
131
129
|
end
|
132
130
|
rescue RestClient::Exception => e
|
133
|
-
|
131
|
+
print_rest_exception(e, options)
|
134
132
|
exit 1
|
135
133
|
end
|
136
134
|
end
|
@@ -141,7 +139,7 @@ class Morpheus::Cli::Deployments
|
|
141
139
|
account_name = nil
|
142
140
|
optparse = OptionParser.new do|opts|
|
143
141
|
opts.banner = "Usage: morpheus deployments update [deployment] [options]"
|
144
|
-
|
142
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
145
143
|
end
|
146
144
|
if args.count < 1
|
147
145
|
puts "\n#{optparse.banner}\n\n"
|
@@ -185,12 +183,7 @@ class Morpheus::Cli::Deployments
|
|
185
183
|
print "\n", cyan, "Deployment #{response['deployment']['name']} updated", reset, "\n\n"
|
186
184
|
end
|
187
185
|
rescue RestClient::Exception => e
|
188
|
-
|
189
|
-
error = JSON.parse(e.response.to_s)
|
190
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
191
|
-
else
|
192
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
193
|
-
end
|
186
|
+
print_rest_exception(e, options)
|
194
187
|
exit 1
|
195
188
|
end
|
196
189
|
end
|
@@ -203,7 +196,7 @@ class Morpheus::Cli::Deployments
|
|
203
196
|
opts.on( '-d', '--description DESCRIPTION', "Description" ) do |val|
|
204
197
|
options[:description] = val
|
205
198
|
end
|
206
|
-
|
199
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
207
200
|
end
|
208
201
|
if args.count < 1
|
209
202
|
puts "\n#{optparse.banner}\n\n"
|
@@ -221,12 +214,7 @@ class Morpheus::Cli::Deployments
|
|
221
214
|
print "\n", cyan, "Deployment #{json_response['deployment']['name']} created successfully", reset, "\n\n"
|
222
215
|
end
|
223
216
|
rescue RestClient::Exception => e
|
224
|
-
|
225
|
-
error = JSON.parse(e.response.to_s)
|
226
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
227
|
-
else
|
228
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
229
|
-
end
|
217
|
+
print_rest_exception(e, options)
|
230
218
|
exit 1
|
231
219
|
end
|
232
220
|
end
|
@@ -236,7 +224,7 @@ class Morpheus::Cli::Deployments
|
|
236
224
|
options = {}
|
237
225
|
optparse = OptionParser.new do|opts|
|
238
226
|
opts.banner = "Usage: morpheus deployments remove [deployment]"
|
239
|
-
|
227
|
+
build_common_options(opts, options, [:auto_confirm, :json, :remote])
|
240
228
|
end
|
241
229
|
if args.count < 1
|
242
230
|
puts "\n#{optparse.banner}\n\n"
|
@@ -247,7 +235,9 @@ class Morpheus::Cli::Deployments
|
|
247
235
|
begin
|
248
236
|
deployment = find_deployment_by_name_or_code_or_id(deployment_name)
|
249
237
|
exit 1 if deployment.nil?
|
250
|
-
|
238
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the deployment #{deployment['name']}?")
|
239
|
+
exit
|
240
|
+
end
|
251
241
|
json_response = @deployments_interface.destroy(deployment['id'])
|
252
242
|
if options[:json]
|
253
243
|
print JSON.pretty_generate(json_response)
|
@@ -255,12 +245,7 @@ class Morpheus::Cli::Deployments
|
|
255
245
|
print "\n", cyan, "Deployment #{deployment['name']} removed", reset, "\n\n"
|
256
246
|
end
|
257
247
|
rescue RestClient::Exception => e
|
258
|
-
|
259
|
-
error = JSON.parse(e.response.to_s)
|
260
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
261
|
-
else
|
262
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
263
|
-
end
|
248
|
+
print_rest_exception(e, options)
|
264
249
|
exit 1
|
265
250
|
end
|
266
251
|
end
|
@@ -278,7 +263,7 @@ private
|
|
278
263
|
result = results['deployment']
|
279
264
|
end
|
280
265
|
if result.nil?
|
281
|
-
|
266
|
+
print_red_alert "Deployment not found by '#{val}'"
|
282
267
|
return nil
|
283
268
|
end
|
284
269
|
return result
|
@@ -295,7 +280,7 @@ private
|
|
295
280
|
result = results['deploymentType']
|
296
281
|
end
|
297
282
|
if result.nil?
|
298
|
-
|
283
|
+
print_red_alert "Deployment Type not found by '#{val}'"
|
299
284
|
return nil
|
300
285
|
end
|
301
286
|
return result
|
@@ -307,4 +292,4 @@ private
|
|
307
292
|
{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'displayOrder' => 1}
|
308
293
|
]
|
309
294
|
end
|
310
|
-
end
|
295
|
+
end
|