173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# File 'lib/morpheus/cli/deployments.rb', line 173
def add(args)
options = {}
optparse = Morpheus::Cli::OptionParser.new do |opts|
opts.banner = subcommand_usage("[name]")
opts.on( '-d', '--description DESCRIPTION', "Description" ) do |val|
options[:description] = val
end
build_common_options(opts, options, [:options, :json, :dry_run, :remote])
end
optparse.parse!(args)
if args.count < 1
puts optparse
exit 1
end
deployment_name = args[0]
connect(options)
begin
payload = {deployment: {name: deployment_name, description: options[:description]}}
@deployments_interface.setopts(options)
if options[:dry_run]
print_dry_run @deployments_interface.dry.create(payload)
return
end
json_response = @deployments_interface.create(payload)
if options[:json]
print JSON.pretty_generate(json_response)
else
print "\n", cyan, "Deployment #{json_response['deployment']['name']} created successfully", reset, "\n\n"
end
rescue RestClient::Exception => e
print_rest_exception(e, options)
exit 1
end
end
|