Class: Morpheus::Cli::StorageProvidersCommand
- Inherits:
-
Object
- Object
- Morpheus::Cli::StorageProvidersCommand
- Includes:
- CliCommand, InfrastructureHelper
- Defined in:
- lib/morpheus/cli/storage_providers_command.rb
Instance Attribute Summary
Attributes included from CliCommand
Instance Method Summary collapse
- #add(args) ⇒ Object
- #connect(opts) ⇒ Object
- #get(args) ⇒ Object
- #handle(args) ⇒ Object
-
#initialize ⇒ StorageProvidersCommand
constructor
set_default_subcommand :list.
- #list(args) ⇒ Object
- #remove(args) ⇒ Object
- #update(args) ⇒ Object
Methods included from InfrastructureHelper
#cloud_type_for_id, #cloud_type_for_name, #cloud_type_for_name_or_id, #clouds_interface, #find_cloud_by_id, #find_cloud_by_name, #find_cloud_by_name_or_id, #find_group_by_id, #find_group_by_name, #find_group_by_name_or_id, #get_available_cloud_types, #groups_interface, included
Methods included from CliCommand
#build_common_options, #build_option_type_options, #command_name, #default_subcommand, #establish_remote_appliance_connection, #full_command_usage, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_id_list, #print, #print_error, #puts, #puts_error, #raise_command_error, #run_command_for_each_arg, #subcommand_aliases, #subcommand_usage, #subcommands, #usage, #verify_access_token!
Constructor Details
#initialize ⇒ StorageProvidersCommand
set_default_subcommand :list
18 19 20 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 18 def initialize() # @appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance end |
Instance Method Details
#add(args) ⇒ Object
168 169 170 171 172 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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 168 def add(args) = {} ip_range_list = nil optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage() opts.on('--name VALUE', String, "Name for this storage provider") do |val| ['name'] = val end opts.on('--type code', String, "Storage Provider Type Code") do |val| ['providerType'] = val end opts.on('--bucket-name VALUE', String, "Bucket Name") do |val| ['bucketName'] = val end opts.on('--default-backup-target [on|off]', String, "Default Backup Target") do |val| ['defaultBackupTarget'] = val.to_s == 'on' || val.to_s == 'true' end opts.on('--default-deployment-target [on|off]', String, "Default Deployment Target") do |val| ['defaultDeploymentTarget'] = val.to_s == 'on' || val.to_s == 'true' end opts.on('--default-virtual-image-target [on|off]', String, "Default Virtual Image Store") do |val| ['defaultVirtualImageTarget'] = val.to_s == 'on' || val.to_s == 'true' end opts.on('--copy-to-store [on|off]', String, "Archive Snapshots") do |val| ['copyToStore'] = val.to_s == 'on' || val.to_s == 'true' end (opts, , [:options, :payload, :json, :dry_run, :quiet, :remote]) opts. = "Create a new storage provider." + "\n" + "[name] is required and can be passed as --name instead." end optparse.parse!(args) if args.count > 1 print_error Morpheus::Terminal.angry_prompt puts_error "wrong number of arguments, expected 0-1 and got #{args.count}\n#{optparse}" return 1 end connect() begin # merge -O options into normally parsed options .deep_merge!([:options].reject {|k,v| k.is_a?(Symbol) }) if [:options] # support [name] as first argument if args[0] ['name'] = args[0] end # construct payload payload = nil if [:payload] payload = [:payload] else # prompt for storage provider options payload = { 'storageProvider' => { # 'config' => {} } } # allow arbitrary -O options payload['storageProvider'].deep_merge!([:options].reject {|k,v| k.is_a?(Symbol) }) if [:options] # Name if ['name'] payload['storageProvider']['name'] = ['name'] else v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'description' => 'Name for this storage provider.'}], ) payload['storageProvider']['name'] = v_prompt['name'] end # Storage Provider Type storage_provider_type_code = nil if ['type'] storage_provider_type_code = ['type'].to_s elsif ['providerType'] storage_provider_type_code = ['providerType'].to_s else v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'providerType', 'fieldLabel' => 'Provider Type', 'type' => 'select', 'selectOptions' => get_storage_provider_types(), 'required' => true, 'description' => 'Choose a storage provider type.'}], , @api_client, {}) storage_provider_type_code = v_prompt['providerType'] unless v_prompt['providerType'].nil? end payload['storageProvider']['providerType'] = storage_provider_type_code # Provider Type Specific Options provider_type_option_types = nil if storage_provider_type_code == 's3' # print_h2 "Amazon S3 Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'accessKey', 'fieldLabel' => 'Access Key', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'secretKey', 'fieldLabel' => 'Secret Key', 'type' => 'password', 'required' => true, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'endpoint', 'fieldLabel' => 'Endpoint URL', 'type' => 'text', 'required' => false, 'description' => 'Optional endpoint URL if pointing to an object store other than amazon that mimics the Amazon S3 APIs.'}, ] elsif storage_provider_type_code == 'azure' # print_h2 "Azure Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'storageAccount', 'fieldLabel' => 'Storage Account', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'storageKey', 'fieldLabel' => 'Storage Key', 'type' => 'password', 'required' => true, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'text', 'required' => true, 'description' => ''} ] elsif storage_provider_type_code == 'cifs' # print_h2 "CIFS Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'host', 'fieldLabel' => 'Host', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'username', 'fieldLabel' => 'Username', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'password', 'fieldLabel' => 'Password', 'type' => 'password', 'required' => true, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'text', 'required' => true, 'description' => ''} ] elsif storage_provider_type_code == 'local' # print_h2 "Local Storage Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'basePath', 'fieldLabel' => 'Storage Path', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'hidden', 'required' => true, 'description' => '', 'defaultValue' => '.'} ] elsif storage_provider_type_code == 'nfs' # print_h2 "NFSv3 Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'host', 'fieldLabel' => 'Host', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'exportFolder', 'fieldLabel' => 'Export Folder', 'type' => 'text', 'required' => false, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'hidden', 'required' => true, 'description' => '', 'defaultValue' => '/'} ] elsif storage_provider_type_code == 'openstack' # print_h2 "Openstack Swift Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'username', 'fieldLabel' => 'Username', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'apiKey', 'fieldLabel' => 'API Key', 'type' => 'password', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'region', 'fieldLabel' => 'Region', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'identityUrl', 'fieldLabel' => 'Identity URL', 'type' => 'text', 'required' => true, 'description' => ''}, ] elsif storage_provider_type_code == 'rackspace' # print_h2 "Rackspace CDN Options" provider_type_option_types = [ {'fieldContext' => 'config', 'fieldName' => 'accessKey', 'fieldLabel' => 'Access Key', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'secretKey', 'fieldLabel' => 'Secret Key', 'type' => 'password', 'required' => true, 'description' => ''}, {'fieldName' => 'bucketName', 'fieldLabel' => 'Bucket Name', 'type' => 'text', 'required' => true, 'description' => ''}, {'fieldContext' => 'config', 'fieldName' => 'endpoint', 'fieldLabel' => 'Endpoint URL', 'type' => 'text', 'required' => true, 'description' => 'Optional endpoint URL if pointing to an object store other than amazon that mimics the Amazon S3 APIs.'}, ] else puts "warning: unrecognized storage provider type: '#{storage_provider_type_code}'" end if provider_type_option_types v_prompt = Morpheus::Cli::OptionTypes.prompt(provider_type_option_types, , @api_client, {}) payload['storageProvider'].deep_merge!(v_prompt) end # Default Backup Target if ['defaultBackupTarget'] != nil payload['storageProvider']['defaultBackupTarget'] = ['defaultBackupTarget'] else v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultBackupTarget', 'fieldLabel' => 'Default Backup Target', 'type' => 'checkbox', 'required' => false, 'description' => '', 'defaultValue' => 'off'}], ) payload['storageProvider']['defaultBackupTarget'] = (v_prompt['defaultBackupTarget'].to_s == 'on') unless v_prompt['defaultBackupTarget'].nil? end # Archive Snapshots if ['copyToStore'] != nil payload['storageProvider']['copyToStore'] = ['copyToStore'] else v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'copyToStore', 'fieldLabel' => 'Archive Snapshots', 'type' => 'checkbox', 'required' => false, 'description' => '', 'defaultValue' => 'on'}], ) payload['storageProvider']['copyToStore'] = (v_prompt['copyToStore'].to_s == 'on') unless v_prompt['copyToStore'].nil? end # Default Deployment Target if ['defaultDeploymentTarget'] != nil payload['storageProvider']['defaultDeploymentTarget'] = ['defaultDeploymentTarget'] else v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultDeploymentTarget', 'fieldLabel' => 'Default Deployment Target', 'type' => 'checkbox', 'required' => false, 'description' => '', 'defaultValue' => 'off'}], ) payload['storageProvider']['defaultDeploymentTarget'] = (v_prompt['defaultDeploymentTarget'].to_s == 'on') unless v_prompt['defaultDeploymentTarget'].nil? end # Default Virtual Image Store if ['defaultVirtualImageTarget'] != nil payload['storageProvider']['defaultVirtualImageTarget'] = ['defaultVirtualImageTarget'] else v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultVirtualImageTarget', 'fieldLabel' => 'Default Virtual Image Store', 'type' => 'checkbox', 'required' => false, 'description' => '', 'defaultValue' => 'off'}], ) payload['storageProvider']['defaultVirtualImageTarget'] = (v_prompt['defaultVirtualImageTarget'].to_s == 'on') unless v_prompt['defaultVirtualImageTarget'].nil? end end if [:dry_run] print_dry_run @storage_providers_interface.dry.create(payload) return end json_response = @storage_providers_interface.create(payload) if [:json] print JSON.pretty_generate(json_response) print "\n" elsif ![:quiet] storage_provider = json_response['storageProvider'] print_green_success "Added storage provider #{storage_provider['name']}" get([storage_provider['id']]) end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#connect(opts) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 22 def connect(opts) @api_client = establish_remote_appliance_connection(opts) @storage_providers_interface = @api_client.storage_providers @clouds_interface = @api_client.clouds @options_interface = @api_client. end |
#get(args) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 105 def get(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[storage-provider]") (opts, , [:json, :yaml, :csv, :fields, :dry_run, :remote]) opts. = "Get details about a storage provider." + "\n" + "[storage-provider] is required. This is the name or id of a storage provider." end optparse.parse!(args) if args.count != 1 print_error Morpheus::Terminal.angry_prompt puts_error "#{command_name} missing argument: [storage-provider]\n#{optparse}" return 1 end connect() begin if [:dry_run] if args[0].to_s =~ /\A\d{1,}\Z/ print_dry_run @storage_providers_interface.dry.get(args[0].to_i) else print_dry_run @storage_providers_interface.dry.list({name:args[0]}) end return end storage_provider = find_storage_provider_by_name_or_id(args[0]) return 1 if storage_provider.nil? json_response = {'storageProvider' => storage_provider} # skip redundant request # json_response = @storage_providers_interface.get(storage_provider['id']) storage_provider = json_response['storageProvider'] if [:include_fields] json_response = {'storageProvider' => filter_data(storage_provider, [:include_fields]) } end if [:json] puts as_json(json_response, ) return 0 elsif [:yaml] puts as_yaml(json_response, ) return 0 elsif [:csv] puts records_as_csv([storage_provider], ) return 0 end print_h1 "Storage Provider Details" print cyan description_cols = { "ID" => 'id', "Name" => lambda {|it| it['name'] }, "Provider Type" => lambda {|it| format_storage_provider_type(it) }, "Bucket Name" => lambda {|it| format_bucket_name(it) }, "Default Backup Target" => lambda {|it| it['defaultBackupTarget'] ? 'Yes' : 'No' }, "Default Deployment Target" => lambda {|it| it['defaultDeploymentTarget'] ? 'Yes' : 'No' }, "Default Virtual Image Store" => lambda {|it| it['defaultVirtualImageTarget'] ? 'Yes' : 'No' }, "Archive Snapshots" => lambda {|it| it['copyToStore'] ? 'Yes' : 'No' } } print_description_list(description_cols, storage_provider) print reset,"\n" return 0 rescue RestClient::Exception => e print_rest_exception(e, ) return 1 end end |
#handle(args) ⇒ Object
29 30 31 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 29 def handle(args) handle_subcommand(args) end |
#list(args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 33 def list(args) = {} params = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage() (opts, , [:list, :json, :yaml, :csv, :fields, :json, :dry_run, :remote]) opts. = "List storage providers." end optparse.parse!(args) connect() begin [:phrase, :offset, :max, :sort, :direction].each do |k| params[k] = [k] unless [k].nil? end if [:dry_run] print_dry_run @storage_providers_interface.dry.list(params) return end json_response = @storage_providers_interface.list(params) storage_providers = json_response["storageProviders"] if [:include_fields] json_response = {"storageProviders" => filter_data(storage_providers, [:include_fields]) } end if [:json] puts as_json(json_response, ) return 0 elsif [:yaml] puts as_yaml(json_response, ) return 0 elsif [:csv] puts records_as_csv(storage_providers, ) return 0 end title = "Morpheus Storage Providers" subtitles = [] if params[:phrase] subtitles << "Search: #{params[:phrase]}".strip end print_h1 title, subtitles if storage_providers.empty? print cyan,"No storage providers found.",reset,"\n" else rows = storage_providers.collect {|storage_provider| row = { id: storage_provider['id'], name: storage_provider['name'], provider: format_storage_provider_type(storage_provider), bucket: format_bucket_name(storage_provider), backups: storage_provider['defaultBackupTarget'] ? 'Yes' : 'No', deployments: storage_provider['defaultDeploymentTarget'] ? 'Yes' : 'No', virtualImages: storage_provider['defaultVirtualImageTarget'] ? 'Yes' : 'No', } row } columns = [:id, :name, {:provider => {:display_name => "Provider Type".upcase} }, {:bucket => {:display_name => "Bucket Name".upcase} }, :backups, :deployments] if [:include_fields] columns = [:include_fields] rows = storage_providers end print cyan print as_pretty_table(rows, columns, ) print reset print_results_pagination(json_response, {:label => "storage provider", :n_label => "storage providers"}) end print reset,"\n" return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#remove(args) ⇒ Object
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 474 def remove(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[storage-provider]") (opts, , [:account, :auto_confirm, :json, :dry_run, :remote]) opts. = "Delete a storage provider." + "\n" + "[storage-provider] is required. This is the name or id of a storage provider." end optparse.parse!(args) if args.count < 1 print_error Morpheus::Terminal.angry_prompt puts_error "#{command_name} missing argument: [storage-provider]\n#{optparse}" return 1 end connect() begin storage_provider = find_storage_provider_by_name_or_id(args[0]) return 1 if storage_provider.nil? unless [:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the storage provider: #{storage_provider['name']}?") return 9, "aborted command" end if [:dry_run] print_dry_run @storage_providers_interface.dry.destroy(storage_provider['id']) return 0 end json_response = @storage_providers_interface.destroy(storage_provider['id']) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Removed storage provider #{storage_provider['name']}" # list([]) end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) return 1 end end |
#update(args) ⇒ Object
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/morpheus/cli/storage_providers_command.rb', line 367 def update(args) = {} ip_range_list = nil optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[storage-provider] [options]") opts.on('--name VALUE', String, "Name for this storage provider") do |val| ['name'] = val end opts.on('--type code', String, "Storage Provider Type Code") do |val| ['providerType'] = val end opts.on('--bucket-name VALUE', String, "Bucket Name") do |val| ['bucketName'] = val end opts.on('--default-backup-target [on|off]', String, "Default Backup Target") do |val| ['defaultBackupTarget'] = val.to_s == 'on' || val.to_s == 'true' end opts.on('--default-deployment-target [on|off]', String, "Default Deployment Target") do |val| ['defaultDeploymentTarget'] = val.to_s == 'on' || val.to_s == 'true' end opts.on('--default-virtual-image-target [on|off]', String, "Default Virtual Image Store") do |val| ['defaultVirtualImageTarget'] = val.to_s == 'on' || val.to_s == 'true' end opts.on('--copy-to-store [on|off]', String, "Archive Snapshots") do |val| ['copyToStore'] = val.to_s == 'on' || val.to_s == 'true' end (opts, , [:options, :payload, :json, :dry_run, :remote]) opts. = "Update a storage provider." + "\n" + "[storage-provider] is required. This is the id of a storage provider." end optparse.parse!(args) if args.count != 1 print_error Morpheus::Terminal.angry_prompt puts_error "wrong number of arguments, expected 1 and got #{args.count}\n#{optparse}" return 1 end connect() begin storage_provider = find_storage_provider_by_name_or_id(args[0]) return 1 if storage_provider.nil? # merge -O options into normally parsed options .deep_merge!([:options].reject {|k,v| k.is_a?(Symbol) }) if [:options] # construct payload payload = nil if [:payload] payload = [:payload] else # prompt for storage provider options # preserve previous config settings payload = { 'storageProvider' => { 'config' => storage_provider['config'] } } # allow arbitrary -O options payload['storageProvider'].deep_merge!([:options].reject {|k,v| k.is_a?(Symbol) }) if [:options] # Name if ['name'] payload['storageProvider']['name'] = ['name'] end # Default Backup Target if ['defaultBackupTarget'] != nil payload['storageProvider']['defaultBackupTarget'] = ['defaultBackupTarget'] end # Archive Snapshots if ['copyToStore'] != nil payload['storageProvider']['copyToStore'] = ['copyToStore'] end # Default Deployment Target if ['defaultDeploymentTarget'] != nil payload['storageProvider']['defaultDeploymentTarget'] = ['defaultDeploymentTarget'] end # Default Virtual Image Store if ['defaultVirtualImageTarget'] != nil payload['storageProvider']['defaultVirtualImageTarget'] = ['defaultVirtualImageTarget'] end end if [:dry_run] print_dry_run @storage_providers_interface.dry.update(storage_provider["id"], payload) return end json_response = @storage_providers_interface.update(storage_provider["id"], payload) if [:json] puts as_json(json_response) else storage_provider = json_response['storageProvider'] print_green_success "Updated storage provider #{storage_provider['name']}" get([storage_provider['id']]) end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) return 1 end end |