2014-05-08 15:34:26 +04:00
|
|
|
require "devops-client/options/common_options"
|
|
|
|
|
|
|
|
|
|
class ImageOptions < CommonOptions
|
|
|
|
|
|
|
|
|
|
commands :create, :delete, :list, :show, :update
|
|
|
|
|
|
|
|
|
|
def initialize args, def_options
|
|
|
|
|
super(args, def_options)
|
|
|
|
|
self.header = I18n.t("headers.image")
|
|
|
|
|
self.banner_header = "image"
|
|
|
|
|
self.list_params = ["[provider]", "[ec2|openstack]"]
|
|
|
|
|
self.show_params = ["IMAGE"]
|
|
|
|
|
self.delete_params = ["IMAGE"]
|
|
|
|
|
self.update_params = ["IMAGE", "FILE"]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create_options
|
2015-04-14 12:32:20 +03:00
|
|
|
self.options do |parser, options|
|
|
|
|
|
parser.banner << self.create_banner
|
2016-01-27 15:44:59 +03:00
|
|
|
parser.resource_name = :image
|
2015-04-14 12:32:20 +03:00
|
|
|
|
2016-01-27 15:44:59 +03:00
|
|
|
parser.recognize_option_value(:provider)
|
|
|
|
|
parser.recognize_option_value(:image_id)
|
|
|
|
|
parser.recognize_option_value(:ssh_username)
|
|
|
|
|
parser.recognize_option_value(:bootstrap_template)
|
|
|
|
|
parser.recognize_option_value(:no_bootstrap_template, type: :switch, switch_value: true, default: false)
|
2014-05-08 15:34:26 +04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-14 15:29:02 +03:00
|
|
|
extend_options_method :list_options do |options|
|
|
|
|
|
if args[2] == "provider" and args[3]
|
|
|
|
|
options[:given_provider] = args[3]
|
|
|
|
|
elsif args[2]
|
|
|
|
|
options[:given_provider] = args[2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-08 15:34:26 +04:00
|
|
|
end
|