598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
# File 'lib/morpheus/cli/commands/library_instance_types_command.rb', line 598
def remove(args)
options = {}
optparse = Morpheus::Cli::OptionParser.new do|opts|
opts.banner = subcommand_usage("[name]")
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
opts. = "Delete an instance type."
end
optparse.parse!(args)
if args.count < 1
puts optparse
exit 1
end
connect(options)
begin
instance_type = find_instance_type_by_name_or_id(args[0])
exit 1 if instance_type.nil?
unless Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the instance type #{instance_type['name']}?", options)
exit
end
@library_instance_types_interface.setopts(options)
if options[:dry_run]
print_dry_run @library_instance_types_interface.dry.destroy(instance_type['id'])
return
end
json_response = @library_instance_types_interface.destroy(instance_type['id'])
if options[:json]
print JSON.pretty_generate(json_response), "\n"
return
end
print_green_success "Removed Instance Type #{instance_type['name']}"
rescue RestClient::Exception => e
print_rest_exception(e, options)
exit 1
end
end
|