The bug showed that options definitions for OptionParser was duplicated. There were some options defined more than once and only last definition takes action so some parameters did not work.
OptionParser did not distinguish between commands (list, push, delete, etc.) used in aeolus-cli
Me and mzatko refactored code for parsing cli options and extended test coverage of this code.
From: Maros Zatko mzatko@redhat.com
--- lib/aeolus_cli/command/config_parser.rb | 228 +++++++++++++++++-------------- 1 files changed, 124 insertions(+), 104 deletions(-)
diff --git a/lib/aeolus_cli/command/config_parser.rb b/lib/aeolus_cli/command/config_parser.rb index 05e0ed4..f0a1748 100644 --- a/lib/aeolus_cli/command/config_parser.rb +++ b/lib/aeolus_cli/command/config_parser.rb @@ -25,7 +25,6 @@ module Aeolus @args = argv # Default options @options = {} - parse end
def process @@ -35,6 +34,7 @@ module Aeolus # Eventually get the config file from user dir if it exists. # File.expand_path("~") if COMMANDS.include?(@command) + parse(@command) self.send(@command.to_sym) else @args << "-h" @@ -44,7 +44,9 @@ module Aeolus end
private - def parse + def parse(subcommand = nil) + subcommand = subcommand.to_sym if subcommand + @optparse ||= OptionParser.new do|opts| opts.banner = "Usage: aeolus-cli [#{COMMANDS.join('|')}] [general options] [command options]"
@@ -70,114 +72,132 @@ module Aeolus exit(0) end
- opts.separator "" - opts.separator "List options:" - opts.on('-i', '--images', 'Retrieve a list of images') do - @options[:subcommand] = :images - end - opts.on('-b', '--builds ID', 'Retrieve the builds of an image') do |id| - @options[:subcommand] = :builds - @options[:id] = id - end - opts.on('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id| - @options[:subcommand] = :targetimages - @options[:id] = id - end - opts.on('-P', '--providerimages ID', 'Retrieve the provider images from a target image') do |id| - @options[:subcommand] = :providerimages - @options[:id] = id - end - opts.on('-g', '--targets', 'Retrieve the values available for the --target parameter') do - @options[:subcommand] = :targets - end - opts.on('-p', '--providers', 'Retrieve the values available for the --provider parameter') do - @options[:subcommand] = :providers - end - opts.on('-a', '--accounts', 'Retrieve the values available for the --account parameter') do - @options[:subcommand] = :accounts + if !subcommand || subcommand == :list + opts.separator "" + opts.separator "List options:" + opts.on('-i', '--images', 'Retrieve a list of images') do + @options[:subcommand] = :images + end + opts.on('-b', '--builds ID', 'Retrieve the builds of an image') do |id| + @options[:subcommand] = :builds + @options[:id] = id + end + opts.on('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id| + @options[:subcommand] = :targetimages + @options[:id] = id + end + opts.on('-P', '--providerimages ID', 'Retrieve the provider images from a target image') do |id| + @options[:subcommand] = :providerimages + @options[:id] = id + end + opts.on('-g', '--targets', 'Retrieve the values available for the --target parameter') do + @options[:subcommand] = :targets + end + opts.on('-p', '--providers', 'Retrieve the values available for the --provider parameter') do + @options[:subcommand] = :providers + end + opts.on('-a', '--accounts', 'Retrieve the values available for the --account parameter') do + @options[:subcommand] = :accounts + end end
- opts.separator "" - opts.separator "Build options:" - opts.on('-e', '--template FILE', 'path to file that contains template xml') do |file| - @options[:template] = file - end - opts.on('-z', '--no-validation', 'Do not validation the template against the TDL XML Schema') do |description| - @options[:validation] = false + if !subcommand || subcommand == :build + opts.separator "" + opts.separator "Build options:" + opts.on('-e', '--template FILE', 'path to file that contains template xml') do |file| + @options[:template] = file + end + opts.on('-z', '--no-validation', 'Do not validation the template against the TDL XML Schema') do |description| + @options[:validation] = false + end end
- opts.separator "" - opts.separator "Push options:" - opts.on('-B', '--build ID', 'push all target images for a build, to same providers as previously') do |id| - @options[:build] = id - end - opts.on('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id| - @options[:targetimage] = id - end - opts.on('-A', '--account NAME', 'name of specific provider account to use for push') do |name| - @options[:account] = name + if !subcommand || subcommand == :push + opts.separator "" + opts.separator "Push options:" + opts.on('-B', '--build ID', 'push all target images for a build, to same providers as previously') do |id| + @options[:build] = id + end + opts.on('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id| + @options[:targetimage] = id + end + opts.on('-A', '--account NAME', 'name of specific provider account to use for push') do |name| + @options[:account] = name + end end
- opts.separator "" - opts.separator "Delete options:" - opts.on('-I', '--image ID', 'delete build image and associated objects') do |id| - @options[:subcommand] = :image - @options[:image] = id - end - opts.on('-B', '--build ID', 'delete build and associated objects') do |id| - @options[:subcommand] = :build - @options[:build] = id - end - opts.on('-m', '--targetimage ID', 'delete target image and its provider images') do |id| - @options[:subcommand] = :target_image - @options[:targetimage] = id - end - opts.on('-D', '--providerimage ID', 'delete provider image') do |id| - @options[:subcommand] = :provider_image - @options[:providerimage] = id + if !subcommand || subcommand == :delete + opts.separator "" + opts.separator "Delete options:" + opts.on('-I', '--image ID', 'delete build image and associated objects') do |id| + @options[:subcommand] = :image + @options[:image] = id + end + opts.on('-B', '--build ID', 'delete build and associated objects') do |id| + @options[:subcommand] = :build + @options[:build] = id + end + opts.on('-m', '--targetimage ID', 'delete target image and its provider images') do |id| + @options[:subcommand] = :target_image + @options[:targetimage] = id + end + opts.on('-D', '--providerimage ID', 'delete provider image') do |id| + @options[:subcommand] = :provider_image + @options[:providerimage] = id + end end
opts.separator "" opts.separator "URL with credentials to Conductor are set in ~/.aeolus-cli" opts.separator "Conductor URL should point to https://<host_where_conductor_runs>/conductor/api"
- opts.separator "" - opts.separator "List Examples:" - opts.separator "aeolus-cli list --images # list available images" - opts.separator "aeolus-cli list --builds $image_id # list the builds of an image" - opts.separator "aeolus-cli list --targetimages $build_id # list the target images from a build" - opts.separator "aeolus-cli list --providerimages $target_id # list the provider images from a target image" - opts.separator "aeolus-cli list --targets # list the values available for the --target parameter" - opts.separator "aeolus-cli list --providers # list the values available for the --provider parameter" - opts.separator "aeolus-cli list --accounts # list the values available for the --account parameter" + if !subcommand || subcommand == :list + opts.separator "" + opts.separator "List Examples:" + opts.separator "aeolus-cli list --images # list available images" + opts.separator "aeolus-cli list --builds $image_id # list the builds of an image" + opts.separator "aeolus-cli list --targetimages $build_id # list the target images from a build" + opts.separator "aeolus-cli list --providerimages $target_id # list the provider images from a target image" + opts.separator "aeolus-cli list --targets # list the values available for the --target parameter" + opts.separator "aeolus-cli list --providers # list the values available for the --provider parameter" + opts.separator "aeolus-cli list --accounts # list the values available for the --account parameter" + end
- opts.separator "" - opts.separator "Build examples:" - opts.separator "aeolus-cli build --target ec2 --template my.tmpl # build a new image for ec2 from based on the given template" - opts.separator "aeolus-cli build --target ec2,rhevm --template my.tmpl # build a new image for ec2 and for rhevm based on the given template" - #opts.separator "aeolus-cli build --image $image_id # (NOT IMPLEMENTED) rebuild the image template and targets from latest build" - #opts.separator %q{aeolus-cli build --target ec2,rackspace \ # rebuild the image with a new template and set of targets - # --image $image_i \ - # --template my.tmpl} + if !subcommand || subcommand == :build + opts.separator "" + opts.separator "Build examples:" + opts.separator "aeolus-cli build --target ec2 --template my.tmpl # build a new image for ec2 from based on the given template" + opts.separator "aeolus-cli build --target ec2,rhevm --template my.tmpl # build a new image for ec2 and for rhevm based on the given template" + #opts.separator "aeolus-cli build --image $image_id # (NOT IMPLEMENTED) rebuild the image template and targets from latest build" + #opts.separator %q{aeolus-cli build --target ec2,rackspace \ # rebuild the image with a new template and set of targets + # --image $image_i \ + # --template my.tmpl} + end
- opts.separator "" - opts.separator "Push examples:" - opts.separator "aeolus-cli push --account ec2-account,ec2-account2 --targetimage $target_image_id # Push target images to each of the specified account" - opts.separator "aeolus-cli push --account ec2-account,rhevm-account --build $build_id # Push target images attached to a particular build to each of the specified accounts" - opts.separator "aeolus-cli push --account ec2-account,rhevm-account --image $image_id # Push target images attached to a particular image to each of the specified accounts" + if !subcommand || subcommand == :push + opts.separator "" + opts.separator "Push examples:" + opts.separator "aeolus-cli push --account ec2-account,ec2-account2 --targetimage $target_image_id # Push target images to each of the specified account" + opts.separator "aeolus-cli push --account ec2-account,rhevm-account --build $build_id # Push target images attached to a particular build to each of the specified accounts" + opts.separator "aeolus-cli push --account ec2-account,rhevm-account --image $image_id # Push target images attached to a particular image to each of the specified accounts" + end
- opts.separator "" - opts.separator "Import examples:" - opts.separator "aeolus-cli import --provider ec2-us-east-1 --target ec2 --id $ami_id # import an AMI from the specified provider" - opts.separator "aeolus-cli import --provider ec2-us-east-1 --target ec2 --id $ami_id --description '<image><name>My Image</name></image>' # import an AMI from the specified provider" - opts.separator "aeolus-cli import --provider ec2-us-east-1 --target ec2 --id $ami_id --description <path_to_xml_file> # import an AMI from the specified provider" + if !subcommand || subcommand == :import + opts.separator "" + opts.separator "Import examples:" + opts.separator "aeolus-cli import --provider ec2-us-east-1 --target ec2 --id $ami_id # import an AMI from the specified provider" + opts.separator "aeolus-cli import --provider ec2-us-east-1 --target ec2 --id $ami_id --description '<image><name>My Image</name></image>' # import an AMI from the specified provider" + opts.separator "aeolus-cli import --provider ec2-us-east-1 --target ec2 --id $ami_id --description <path_to_xml_file> # import an AMI from the specified provider" + end
- opts.separator "" - opts.separator "Delete examples: (DELETE CURRENTLY NOT IMPLEMENTED) " - opts.separator "aeolus-cli delete --image $image_id # deletes a image and all associated builds" - opts.separator "aeolus-cli delete --build $build_id # deletes a build and all associated targetimages" - opts.separator "aeolus-cli delete --targetimage $target_image # deletes a target image and all associated provider images" - opts.separator "aeolus-cli delete --providerimage $provider_image # deletes a provider image" + if !subcommand || subcommand == :delete + opts.separator "" + opts.separator "Delete examples: (DELETE CURRENTLY NOT IMPLEMENTED) " + opts.separator "aeolus-cli delete --image $image_id # deletes a image and all associated builds" + opts.separator "aeolus-cli delete --build $build_id # deletes a build and all associated targetimages" + opts.separator "aeolus-cli delete --targetimage $target_image # deletes a target image and all associated provider images" + opts.separator "aeolus-cli delete --providerimage $provider_image # deletes a provider image" + end end
begin
From: Petr Blaho pblaho@redhat.com
This support mzatko's patch a11b9902b9e3dbb6f13cab9c8a2cb9f6f232edfb
This is tests of solution for https://bugzilla.redhat.com/show_bug.cgi?id=754956 --- spec/command/config_parser_spec.rb | 160 ++++++++++++++++++++++++++++++------ 1 files changed, 133 insertions(+), 27 deletions(-)
diff --git a/spec/command/config_parser_spec.rb b/spec/command/config_parser_spec.rb index f4e48ec..2175b02 100644 --- a/spec/command/config_parser_spec.rb +++ b/spec/command/config_parser_spec.rb @@ -52,43 +52,149 @@ module Aeolus it "should exit gracefully with bad params" do begin silence_stream(STDOUT) do - ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1) + config_parser = ConfigParser.new(%w(delete --fred)) + config_parser.process + config_parser.should_receive(:exit).with(1) end rescue SystemExit => e e.status.should == 1 end end
- it "should set options hash for valid list options" do - config_parser = ConfigParser.new(%w(list --builds 12345)) - config_parser.options[:subcommand].should == :builds - config_parser.options[:id].should == '12345' - end + context "setting options hash" do + subject { config_parser } + let ( :parameters ) { %w{} } + let ( :config_parser ) { ConfigParser.new( parameters ) }
- it "should set options hash for valid build options" do - config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345 --template my.tmpl)) - config_parser.options[:target].should == ['ec2','rackspace'] - config_parser.options[:image].should == '12345' - config_parser.options[:template].should == 'my.tmpl' - end + before(:each) do + Aeolus::CLI::ConfigParser::COMMANDS.each do |command| + subject.stub!( command.to_sym ) + end + subject.process + end
- it "should set options hash for valid push options" do - config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345)) - config_parser.options[:provider].should == ['ec2-us-east1'] - config_parser.options[:id].should == '12345' - end + context "for list command" do + context "with --images" do + let ( :parameters ) { %w(list --images) } + let ( :options_hash ) { { :subcommand => :images } }
- it "should set options hash for valid delete options" do - config_parser = ConfigParser.new(%w(delete --build 12345)) - config_parser.options[:build].should == '12345' - end + its ( :options ) { should include( options_hash ) } + end + context "with --builds ID" do + let ( :parameters ) { %w(list --builds 12345) } + let ( :options_hash ) { { :subcommand => :builds, :id => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --targetimages ID" do + let ( :parameters ) { %w(list --targetimages 12345) } + let ( :options_hash ) { { :subcommand => :targetimages, :id => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --providerimages ID" do + let ( :parameters ) { %w(list --providerimages 12345) } + let ( :options_hash ) { { :subcommand => :providerimages, :id => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --targets" do + let ( :parameters ) { %w(list --targets) } + let ( :options_hash ) { { :subcommand => :targets } } + + its ( :options ) { should include( options_hash ) } + end + context "with --providers" do + let ( :parameters ) { %w(list --providers) } + let ( :options_hash ) { { :subcommand => :providers } } + + its ( :options ) { should include( options_hash ) } + end + context "with --accounts" do + let ( :parameters ) { %w(list --accounts) } + let ( :options_hash ) { { :subcommand => :accounts } } + + its ( :options ) { should include( options_hash ) } + end + end + + context "for build command" do + context "with --template FILE" do + let ( :parameters ) { %w(build --target ec2,rackspace --image 12345 --template my.tmpl) } + let ( :options_hash ) { { :target => ['ec2','rackspace'], :image => '12345', :template => 'my.tmpl' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --no-validation" do + let ( :parameters ) { %w(build --target ec2,rackspace --image 12345 --no-validation) } + let ( :options_hash ) { { :target => ['ec2','rackspace'], :image => '12345', :validation => false } } + + its ( :options ) { should include( options_hash ) } + end + end + + context "for push command" do + context "without other options" do + let ( :parameters ) { %w(push --provider ec2-us-east1 --id 12345) } + let ( :options_hash ) { { :provider => ['ec2-us-east1'], :id => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --build ID" do + let ( :parameters ) { %w(push --provider ec2-us-east1 --build 12345) } + let ( :options_hash ) { { :provider => ['ec2-us-east1'], :build => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --targetimage ID" do + let ( :parameters ) { %w(push --provider ec2-us-east1 --targetimage 12345) } + let ( :options_hash ) { { :provider => ['ec2-us-east1'], :targetimage => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + context "with --account NAME" do + let ( :parameters ) { %w(push --provider ec2-us-east1 --account 12345) } + let ( :options_hash ) { { :provider => ['ec2-us-east1'], :account => '12345' } } + + its ( :options ) { should include( options_hash ) } + end + end + + context "for delete command" do + context "with --image ID" do + let ( :parameters ) { %w(delete --image 12345) } + let ( :options_hash ) { { :image => '12345', :subcommand => :image } }
- it "should set options hash for valid import options" do - config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2)) - config_parser.options[:provider].should == ['ec2-us-east-1a'] - config_parser.options[:target].should == ['ec2'] - config_parser.options[:description].should == '/path/to/file' - config_parser.options[:id].should == 'ami-123456' + its ( :options ) { should include( options_hash ) } + end + context "with --build ID" do + let ( :parameters ) { %w(delete --build 12345) } + let ( :options_hash ) { { :build => '12345', :subcommand => :build } } + + its ( :options ) { should include( options_hash ) } + end + context "with --targetimage ID" do + let ( :parameters ) { %w(delete --targetimage 12345) } + let ( :options_hash ) { { :targetimage => '12345', :subcommand => :target_image } } + + its ( :options ) { should include( options_hash ) } + end + context "with --providerimage ID" do + let ( :parameters ) { %w(delete --providerimage 12345) } + let ( :options_hash ) { { :providerimage => '12345', :subcommand => :provider_image } } + + its ( :options ) { should include( options_hash ) } + end + end + + context "for import command" do + context "without other options" do + let ( :parameters ) { %w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2) } + let ( :options_hash ) { { :provider => ['ec2-us-east-1a'], :target => ['ec2'], :description => '/path/to/file', :id => 'ami-123456' } } + + its ( :options ) { should include( options_hash ) } + end + end end end end
Ack - Rebased and Pushed
Thanks
On 11/29/2011 01:51 PM, pblaho@redhat.com wrote:
From: Petr Blahopblaho@redhat.com
This support mzatko's patch a11b9902b9e3dbb6f13cab9c8a2cb9f6f232edfb
This is tests of solution for https://bugzilla.redhat.com/show_bug.cgi?id=754956
spec/command/config_parser_spec.rb | 160 ++++++++++++++++++++++++++++++------ 1 files changed, 133 insertions(+), 27 deletions(-)
diff --git a/spec/command/config_parser_spec.rb b/spec/command/config_parser_spec.rb index f4e48ec..2175b02 100644 --- a/spec/command/config_parser_spec.rb +++ b/spec/command/config_parser_spec.rb @@ -52,43 +52,149 @@ module Aeolus it "should exit gracefully with bad params" do begin silence_stream(STDOUT) do
ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1)
config_parser = ConfigParser.new(%w(delete --fred))
config_parser.process
config_parser.should_receive(:exit).with(1) end rescue SystemExit => e e.status.should == 1 end end
it "should set options hash for valid list options" do
config_parser = ConfigParser.new(%w(list --builds 12345))
config_parser.options[:subcommand].should == :builds
config_parser.options[:id].should == '12345'
end
context "setting options hash" do
subject { config_parser }
let ( :parameters ) { %w{} }
let ( :config_parser ) { ConfigParser.new( parameters ) }
it "should set options hash for valid build options" do
config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345 --template my.tmpl))
config_parser.options[:target].should == ['ec2','rackspace']
config_parser.options[:image].should == '12345'
config_parser.options[:template].should == 'my.tmpl'
end
before(:each) do
Aeolus::CLI::ConfigParser::COMMANDS.each do |command|
subject.stub!( command.to_sym )
end
subject.process
end
it "should set options hash for valid push options" do
config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345))
config_parser.options[:provider].should == ['ec2-us-east1']
config_parser.options[:id].should == '12345'
end
context "for list command" do
context "with --images" do
let ( :parameters ) { %w(list --images) }
let ( :options_hash ) { { :subcommand => :images } }
it "should set options hash for valid delete options" do
config_parser = ConfigParser.new(%w(delete --build 12345))
config_parser.options[:build].should == '12345'
end
its ( :options ) { should include( options_hash ) }
end
context "with --builds ID" do
let ( :parameters ) { %w(list --builds 12345) }
let ( :options_hash ) { { :subcommand => :builds, :id => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --targetimages ID" do
let ( :parameters ) { %w(list --targetimages 12345) }
let ( :options_hash ) { { :subcommand => :targetimages, :id => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --providerimages ID" do
let ( :parameters ) { %w(list --providerimages 12345) }
let ( :options_hash ) { { :subcommand => :providerimages, :id => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --targets" do
let ( :parameters ) { %w(list --targets) }
let ( :options_hash ) { { :subcommand => :targets } }
its ( :options ) { should include( options_hash ) }
end
context "with --providers" do
let ( :parameters ) { %w(list --providers) }
let ( :options_hash ) { { :subcommand => :providers } }
its ( :options ) { should include( options_hash ) }
end
context "with --accounts" do
let ( :parameters ) { %w(list --accounts) }
let ( :options_hash ) { { :subcommand => :accounts } }
its ( :options ) { should include( options_hash ) }
end
end
context "for build command" do
context "with --template FILE" do
let ( :parameters ) { %w(build --target ec2,rackspace --image 12345 --template my.tmpl) }
let ( :options_hash ) { { :target => ['ec2','rackspace'], :image => '12345', :template => 'my.tmpl' } }
its ( :options ) { should include( options_hash ) }
end
context "with --no-validation" do
let ( :parameters ) { %w(build --target ec2,rackspace --image 12345 --no-validation) }
let ( :options_hash ) { { :target => ['ec2','rackspace'], :image => '12345', :validation => false } }
its ( :options ) { should include( options_hash ) }
end
end
context "for push command" do
context "without other options" do
let ( :parameters ) { %w(push --provider ec2-us-east1 --id 12345) }
let ( :options_hash ) { { :provider => ['ec2-us-east1'], :id => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --build ID" do
let ( :parameters ) { %w(push --provider ec2-us-east1 --build 12345) }
let ( :options_hash ) { { :provider => ['ec2-us-east1'], :build => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --targetimage ID" do
let ( :parameters ) { %w(push --provider ec2-us-east1 --targetimage 12345) }
let ( :options_hash ) { { :provider => ['ec2-us-east1'], :targetimage => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --account NAME" do
let ( :parameters ) { %w(push --provider ec2-us-east1 --account 12345) }
let ( :options_hash ) { { :provider => ['ec2-us-east1'], :account => '12345' } }
its ( :options ) { should include( options_hash ) }
end
end
context "for delete command" do
context "with --image ID" do
let ( :parameters ) { %w(delete --image 12345) }
let ( :options_hash ) { { :image => '12345', :subcommand => :image } }
it "should set options hash for valid import options" do
config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2))
config_parser.options[:provider].should == ['ec2-us-east-1a']
config_parser.options[:target].should == ['ec2']
config_parser.options[:description].should == '/path/to/file'
config_parser.options[:id].should == 'ami-123456'
its ( :options ) { should include( options_hash ) }
end
context "with --build ID" do
let ( :parameters ) { %w(delete --build 12345) }
let ( :options_hash ) { { :build => '12345', :subcommand => :build } }
its ( :options ) { should include( options_hash ) }
end
context "with --targetimage ID" do
let ( :parameters ) { %w(delete --targetimage 12345) }
let ( :options_hash ) { { :targetimage => '12345', :subcommand => :target_image } }
its ( :options ) { should include( options_hash ) }
end
context "with --providerimage ID" do
let ( :parameters ) { %w(delete --providerimage 12345) }
let ( :options_hash ) { { :providerimage => '12345', :subcommand => :provider_image } }
its ( :options ) { should include( options_hash ) }
end
end
context "for import command" do
context "without other options" do
let ( :parameters ) { %w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2) }
let ( :options_hash ) { { :provider => ['ec2-us-east-1a'], :target => ['ec2'], :description => '/path/to/file', :id => 'ami-123456' } }
its ( :options ) { should include( options_hash ) }
end
endend end end
aeolus-devel@lists.fedorahosted.org