28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/rightscale_selfservice/cli/operation.rb', line 28
def create(operation_name, execution_id_or_href)
execution_id = execution_id_or_href.split("/").last
client = get_api_client()
params = {:execution_id => execution_id, :name => operation_name}
if @options["options_file"]
options_filepath = File.expand_path(@options["options_file"], Dir.pwd)
options_str = File.open(File.expand_path(options_filepath), 'r') { |f| f.read }
params["options"] = options_str
end
begin
response = client.manager.operation.create(params)
logger.info("Successfully started operation \"#{operation_name}\" on execution id \"#{execution_id}\". Href: #{response.[:location]}")
rescue RestClient::ExceptionWithResponse => e
shell = Thor::Shell::Color.new
message = "Failed to create operation \"#{operation_name}\" on execution id \"#{execution_id}\"\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
logger.error(shell.set_color message, :red)
end
end
|