aeolus-image 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ module Aeolus
4
+ module Image
5
+ describe ConfigParser do
6
+ it "should parse the specified command" do
7
+ config_parser = ConfigParser.new(%w(list --images))
8
+ config_parser.process
9
+ config_parser.command.should == 'list'
10
+ end
11
+
12
+ it "should exit gracefully when a required subcommand is not provided" do
13
+ begin
14
+ silence_stream(STDOUT) do
15
+ config_parser = ConfigParser.new(%w(list))
16
+ config_parser.process
17
+ config_parser.should_receive(:exit).with(1)
18
+ end
19
+ rescue SystemExit => e
20
+ e.status.should == 1
21
+ end
22
+ end
23
+
24
+ it "should notify the user of an invalid command" do
25
+ config_parser = ConfigParser.new(%w(sparkle))
26
+ config_parser.should_receive(:exit).with(0)
27
+ silence_stream(STDOUT) do
28
+ config_parser.process
29
+ end
30
+ end
31
+
32
+ it "should exit gracefully with bad params" do
33
+ begin
34
+ silence_stream(STDOUT) do
35
+ ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1)
36
+ end
37
+ rescue SystemExit => e
38
+ e.status.should == 1
39
+ end
40
+ end
41
+
42
+ it "should set options hash for valid general options" do
43
+ config_parser = ConfigParser.new(%w(list --user joe --password cloud --images))
44
+ config_parser.options[:user].should == 'joe'
45
+ config_parser.options[:password].should == 'cloud'
46
+ config_parser.options[:subcommand].should == :images
47
+ end
48
+
49
+ it "should set options hash for valid list options" do
50
+ config_parser = ConfigParser.new(%w(list --builds 12345))
51
+ config_parser.options[:subcommand].should == :builds
52
+ config_parser.options[:id].should == '12345'
53
+ end
54
+
55
+ it "should set options hash for valid build options" do
56
+ config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345 --template my.tmpl))
57
+ config_parser.options[:target].should == ['ec2','rackspace']
58
+ config_parser.options[:image].should == '12345'
59
+ config_parser.options[:template].should == 'my.tmpl'
60
+ end
61
+
62
+ it "should set options hash for valid push options" do
63
+ config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345))
64
+ config_parser.options[:provider].should == ['ec2-us-east1']
65
+ config_parser.options[:id].should == '12345'
66
+ end
67
+
68
+ it "should set options hash for valid delete options" do
69
+ config_parser = ConfigParser.new(%w(delete --build 12345))
70
+ config_parser.options[:build].should == '12345'
71
+ end
72
+
73
+ it "should set options hash for valid import options" do
74
+ config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2))
75
+ config_parser.options[:provider].should == ['ec2-us-east-1a']
76
+ config_parser.options[:target].should == ['ec2']
77
+ config_parser.options[:description].should == '/path/to/file'
78
+ config_parser.options[:id].should == 'ami-123456'
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,18 @@
1
+ <bad_template>
2
+ <name>tmpl1</name>
3
+ <description>foo</description>
4
+ <os>
5
+ <name>Fedora</name>
6
+ <arch>x86_64</arch>
7
+ <version>14</version>
8
+ <install type="url">
9
+ <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86_64/os/</url>
10
+ </install>
11
+ </os>
12
+ <bad_repositories>
13
+ <repository name="custom">
14
+ <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
15
+ <signed>false</signed>
16
+ </repository>
17
+ </bad_repositories>
18
+ </bad_template>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <name>tmpl1</name>
3
+ <description>foo</description>
4
+ <os>
5
+ <name>Fedora</name>
6
+ <arch>x86_64</arch>
7
+ <version>14</version>
8
+ <install type="url">
9
+ <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86_64/os/</url>
10
+ </install>
11
+ </os>
12
+ <repositories>
13
+ <repository name="custom">
14
+ <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
15
+ <signed>false</signed>
16
+ </repository>
17
+ </repositories>
18
+ </template>
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ module Aeolus
4
+ module Image
5
+ describe ImportCommand do
6
+ before(:each) do
7
+ @options[:id] = "ami-test"
8
+ @options[:target] = "ec2"
9
+ @options[:provider] = "ec2-us-east-1"
10
+ end
11
+
12
+ describe "#import_image" do
13
+ it "should import an image with default description values" do
14
+ importc = ImportCommand.new(@options)
15
+ begin
16
+ importc.import_image
17
+ rescue SystemExit => e
18
+ e.status.should == 0
19
+ end
20
+ $stdout.string.should include("Image:")
21
+ $stdout.string.should include("Target Image:")
22
+ $stdout.string.should include("Build:")
23
+ $stdout.string.should include("Provider Image:")
24
+ end
25
+
26
+ it "should import an image with file description" do
27
+ @options[:description] = 'spec/sample_data/image_description.xml'
28
+ importc = ImportCommand.new(@options)
29
+ begin
30
+ importc.import_image
31
+ rescue SystemExit => e
32
+ e.status.should == 0
33
+ end
34
+ $stdout.string.should include("Image:")
35
+ $stdout.string.should include("Target Image:")
36
+ $stdout.string.should include("Build:")
37
+ $stdout.string.should include("Provider Image:")
38
+ #TODO: Add test to check that file was uploaded properly (when we have implemented a show/view image command)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ module Aeolus
4
+ module Image
5
+ describe ListCommand do
6
+ it "should return a list of images" do
7
+ regexp = Regexp.new('[uuid:\s][\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
8
+ listc = ListCommand.new(:subcommand => 'images')
9
+ images = listc.images
10
+ images.each do |image|
11
+ regexp.match(image.to_s).should_not == nil
12
+ end
13
+ end
14
+ it "should return not implemented for unimplemented subcommands" do
15
+ l = ListCommand.new()
16
+ r = l.targets
17
+ r.should eql("This option or combination is not yet implemented")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ module Aeolus
4
+ module Image
5
+ describe PushCommand do
6
+
7
+ before(:each) do
8
+ @options[:provider] = ['mock']
9
+ @options[:user] = 'admin'
10
+ @options[:password] = 'password'
11
+ end
12
+
13
+ describe "#run" do
14
+ before(:each) do
15
+ options = {}
16
+ options[:target] = ['mock','ec2']
17
+ options[:template] = "#{File.dirname(__FILE__)}" + "/../examples/custom_repo.tdl"
18
+ b = BuildCommand.new(options)
19
+ sleep(5)
20
+ tmpl_str = b.send(:read_file, options[:template])
21
+ b.console.build(tmpl_str, ['mock','ec2']).each do |adaptor|
22
+ @build_id = adaptor.image
23
+ end
24
+ b.console.shutdown
25
+ @options[:id] = @build_id
26
+ end
27
+
28
+ it "should push an image with valid options" do
29
+ p = PushCommand.new(@options, @output)
30
+ begin
31
+ p.run
32
+ rescue SystemExit => e
33
+ e.status.should == 0
34
+ end
35
+ $stdout.string.should include("Image:")
36
+ $stdout.string.should include("Provider Image:")
37
+ $stdout.string.should include("Build:")
38
+ end
39
+ end
40
+
41
+ describe "#combo_implemented?" do
42
+ it "should give useful feedback if no template or target is specified" do
43
+ @options.delete(:id)
44
+ @options.delete(:provider)
45
+ b = PushCommand.new(@options, @output)
46
+ begin
47
+ b.combo_implemented?
48
+ rescue SystemExit => e
49
+ e.status.should == 1
50
+ end
51
+ $stdout.string.should include("This combination of parameters is not currently supported")
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format specdoc
3
+ --diff
@@ -0,0 +1,52 @@
1
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
2
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "."))
3
+ require 'rubygems'
4
+ require 'config_parser'
5
+ require 'stringio'
6
+ require 'base_command'
7
+ require 'list_command'
8
+ require 'build_command'
9
+ require 'push_command'
10
+ require 'import_command'
11
+ require 'delete_command'
12
+
13
+
14
+ module Helpers
15
+ # Silences any stream for the duration of the block.
16
+ #
17
+ # silence_stream(STDOUT) do
18
+ # puts 'This will never be seen'
19
+ # end
20
+ #
21
+ # puts 'But this will'
22
+ #
23
+ # (Taken from ActiveSupport)
24
+ def silence_stream(stream)
25
+ old_stream = stream.dup
26
+ stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
27
+ stream.sync = true
28
+ yield
29
+ ensure
30
+ stream.reopen(old_stream)
31
+ end
32
+ end
33
+
34
+ Spec::Runner.configure do |config|
35
+ config.include Helpers
36
+ config.before(:all) do
37
+ Aeolus::Image::BaseCommand.class_eval do
38
+ def load_config
39
+ YAML::load(File.open(File.join(File.dirname(__FILE__), "/../examples/aeolus-cli")))
40
+ end
41
+ end
42
+ end
43
+ config.before(:each) do
44
+ @output = double('output')
45
+ @stdout_orig = $stdout
46
+ $stdout = StringIO.new
47
+ @options = {}
48
+ end
49
+ config.after(:each) do
50
+ $stdout = @stdout_orig
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aeolus-image
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jason Guiditta, Martyn Taylor
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-22 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 0
32
+ - 4
33
+ - 0
34
+ version: 0.4.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rest-client
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: imagefactory-console
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 15
60
+ segments:
61
+ - 0
62
+ - 4
63
+ - 0
64
+ version: 0.4.0
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 27
76
+ segments:
77
+ - 1
78
+ - 3
79
+ - 0
80
+ version: 1.3.0
81
+ type: :development
82
+ version_requirements: *id004
83
+ description: Commandline interface for working with the aeolus cloud management suite
84
+ email: jguiditt@redhat.com, mtaylor@redhat.com
85
+ executables:
86
+ - aeolus-image
87
+ extensions: []
88
+
89
+ extra_rdoc_files: []
90
+
91
+ files:
92
+ - Rakefile
93
+ - bin/aeolus-image
94
+ - lib/build_command.rb
95
+ - lib/delete_command.rb
96
+ - lib/list_command.rb
97
+ - lib/base_command.rb
98
+ - lib/push_command.rb
99
+ - lib/config_parser.rb
100
+ - lib/import_command.rb
101
+ - spec/base_command_spec.rb
102
+ - spec/list_command_spec.rb
103
+ - spec/spec_helper.rb
104
+ - spec/spec.opts
105
+ - spec/fixtures/valid_template.tdl
106
+ - spec/fixtures/invalid_template.tdl
107
+ - spec/build_command_spec.rb
108
+ - spec/push_command_spec.rb
109
+ - spec/import_command_spec.rb
110
+ - spec/config_parser_spec.rb
111
+ - examples/image_description.xml
112
+ - examples/aeolus-cli
113
+ - examples/tdl.rng
114
+ - examples/custom_repo.tdl
115
+ - man/aeolus-image.1
116
+ - man/aeolus-image-push.1
117
+ - man/aeolus-image-build.1
118
+ - man/aeolus-image-import.1
119
+ - man/aeolus-image-list.1
120
+ has_rdoc: true
121
+ homepage: http://aeolusproject.org
122
+ licenses:
123
+ - GPL-2
124
+ post_install_message:
125
+ rdoc_options: []
126
+
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ hash: 3
144
+ segments:
145
+ - 0
146
+ version: "0"
147
+ requirements: []
148
+
149
+ rubyforge_project:
150
+ rubygems_version: 1.3.7
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: cli for aeolus cloud suite
154
+ test_files: []
155
+