aeolus-image 0.0.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/COPYING +161 -0
  2. data/Rakefile +32 -19
  3. data/lib/aeolus_image.rb +35 -0
  4. data/lib/aeolus_image/active_resource_oauth_client.rb +62 -0
  5. data/lib/aeolus_image/import.rb +44 -0
  6. data/lib/aeolus_image/model/factory/base.rb +93 -0
  7. data/lib/aeolus_image/model/factory/build.rb +23 -0
  8. data/lib/aeolus_image/model/factory/builder.rb +46 -0
  9. data/lib/aeolus_image/model/factory/image.rb +23 -0
  10. data/lib/aeolus_image/model/factory/provider_image.rb +35 -0
  11. data/lib/aeolus_image/model/factory/target_image.rb +45 -0
  12. data/lib/aeolus_image/model/warehouse/icicle.rb +60 -0
  13. data/lib/aeolus_image/model/warehouse/image.rb +135 -0
  14. data/lib/aeolus_image/model/warehouse/image_build.rb +60 -0
  15. data/lib/aeolus_image/model/warehouse/provider_image.rb +36 -0
  16. data/lib/aeolus_image/model/warehouse/target_image.rb +53 -0
  17. data/lib/aeolus_image/model/warehouse/template.rb +35 -0
  18. data/lib/aeolus_image/model/warehouse/warehouse_client.rb +201 -0
  19. data/lib/aeolus_image/model/warehouse/warehouse_model.rb +236 -0
  20. data/spec/aeolus_image/model/factory/provider_image_spec.rb +12 -0
  21. data/spec/models/factory/base_spec.rb +94 -0
  22. data/spec/models/factory/builder_spec.rb +31 -0
  23. data/spec/models/factory/provider_image_spec.rb +21 -0
  24. data/spec/models/factory/target_image_spec.rb +21 -0
  25. data/spec/models/warehouse/image_build_spec.rb +189 -0
  26. data/spec/models/warehouse/image_spec.rb +241 -0
  27. data/spec/models/warehouse/provider_image_spec.rb +115 -0
  28. data/spec/models/warehouse/target_image_spec.rb +180 -0
  29. data/spec/models/warehouse/template_spec.rb +76 -0
  30. data/spec/models/warehouse/warehouse_client_spec.rb +445 -0
  31. data/spec/models/warehouse/warehouse_model_spec.rb +94 -0
  32. data/spec/spec_helper.rb +34 -47
  33. data/spec/vcr/cassettes/builder.yml +24 -0
  34. data/spec/vcr/cassettes/oauth.yml +80 -0
  35. data/spec/vcr/cassettes/oauth_fail_invalid.yml +30 -0
  36. data/spec/vcr/cassettes/oauth_fail_no.yml +22 -0
  37. data/spec/vcr/cassettes/oauth_success_valid.yml +30 -0
  38. data/spec/vcr_setup.rb +26 -0
  39. metadata +70 -46
  40. data/bin/aeolus-image +0 -6
  41. data/examples/aeolus-cli +0 -9
  42. data/examples/custom_repo.tdl +0 -18
  43. data/examples/image_description.xml +0 -3
  44. data/examples/tdl.rng +0 -207
  45. data/lib/base_command.rb +0 -134
  46. data/lib/build_command.rb +0 -68
  47. data/lib/config_parser.rb +0 -212
  48. data/lib/delete_command.rb +0 -9
  49. data/lib/import_command.rb +0 -44
  50. data/lib/list_command.rb +0 -141
  51. data/lib/push_command.rb +0 -72
  52. data/man/aeolus-image-build.1 +0 -36
  53. data/man/aeolus-image-import.1 +0 -57
  54. data/man/aeolus-image-list.1 +0 -80
  55. data/man/aeolus-image-push.1 +0 -40
  56. data/man/aeolus-image.1 +0 -16
  57. data/spec/base_command_spec.rb +0 -76
  58. data/spec/build_command_spec.rb +0 -63
  59. data/spec/config_parser_spec.rb +0 -82
  60. data/spec/import_command_spec.rb +0 -43
  61. data/spec/list_command_spec.rb +0 -21
  62. data/spec/push_command_spec.rb +0 -56
  63. data/spec/spec.opts +0 -3
@@ -1,36 +0,0 @@
1
- .TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
2
- .SH NAME
3
- aeolus-image build \- command for building aeolus images
4
- .SH SYNOPSIS
5
- .B aeolus-image build [\-h|--help] [\-u|--username] [\-w|--password] [\-I|--image [image-id]] [\-e|--template [path-to-template]] [\-t|--targets [targets]] [\-d|--daemon]
6
- .SH DESCRIPTION
7
- aeolus-image build command allows users to build new images based on a given TDL template file for a set of specified targets such e.g. EC2, RHEVM etc...
8
- .SH OPTIONS
9
- .TP
10
- \-u, --user <username>
11
- Conductor username
12
- .TP
13
- \-w, --password <password>
14
- Conductor password
15
- .TP
16
- \-T, --target
17
- Provide a list of targets for the build
18
- .TP
19
- \-e, --template
20
- Provide path to a TDL template file for building against
21
- .TP
22
- \-d, --daemon
23
- Run as a background process
24
- .TP
25
- Get usage information for this command and associated commmands
26
- \-h, --help
27
- .SH EXAMPLES
28
- .TP
29
- Build a new image for ec2 based on the specified template TDL file template.tdl
30
- .B aeolus-image build
31
- \--targets ec2
32
- \--template ./template.tdl
33
- .TP
34
- Martyn Taylor (mtaylor@redhat.com), Jason Guiditta (jguiditta@redhat.com)
35
- .SH SEE ALSO
36
- aeolus-image-list(1), aeolus-image-push(1), aeolus-image-import(1)
@@ -1,57 +0,0 @@
1
- .TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
2
- .SH NAME
3
- aeolus-image import \- command for importing existing provider images into aeolus
4
- .SH SYNOPSIS
5
- .B aeolus-image import [\-h|--help] [\-u|--username] [\-w|--password] [\-r|--provider [provider-name]] [\--id [provider-image-id]] [--description [path-to-file|xml string]] [\T|--target [target]] [\-d|--daemon]
6
- .SH DESCRIPTION
7
- aeolus-image import allows users to import pre-existing images that exist in cloud provders for example AMI from EC2, into aeolus.
8
- .SH OPTIONS
9
- .TP
10
- \-u, --user <username>
11
- Conductor username
12
- .TP
13
- \-w, --password <password>
14
- Conductor password
15
- .TP
16
- \-r, --provider <provider-name>
17
- The provider name as it exists in conductor from where the importing image resides
18
- .TP
19
- \--id <provider-image-id>
20
- The providers ID given to the importing image
21
- .TP
22
- \-T, --target
23
- The target type for the given provider
24
- .TP
25
- \--description <path-to-xml-description|xml string>
26
- A user defined description to associate with the importing image
27
- .TP
28
- \-d, --daemon
29
- Run as a background process
30
- .TP
31
- Get usage information for this command and associated commmands
32
- \-h, --help
33
- .SH EXAMPLES
34
- .TP
35
- Import the AMI ami-1234567 from the provider ec2-us-east-1 into aeolus
36
- .B aeolus-image import
37
- \--provider ec2-us-east-1
38
- \--target ec2
39
- \--id ami-1234567
40
- .TP
41
- Import the AMI ami-1234567 from the provider ec2-us-west-1 into aeolus with a given xml description
42
- .B aeolus-image import
43
- \--provider ec2-us-west-1
44
- \--target ec2
45
- \--id ami-1234567
46
- \--description '<image><name>myAMI</name></image>'
47
- .TP
48
- Import the AMI ami-1234567 from the provider ec2-us-west-1 into aeolus providing a path to the description XML file
49
- .B aeolus-image import
50
- \--provider ec2-us-west-1
51
- \--target ec23
52
- \--id ami-1234567
53
- \--description /foo/bar/description.xml
54
- .SH AUTHOR
55
- Martyn Taylor (mtaylor@redhat.com), Jason Guiditta (jguiditta@redhat.com)
56
- .SH SEE ALSO
57
- aeolus-image-list(1), aeolus-image-push(1), aeolus-image-build(1)
@@ -1,80 +0,0 @@
1
- .TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
2
- .SH NAME
3
- aeolus-image \- command for listing aeolus image associated objects.
4
- .SH SYNOPSIS
5
- .B aeolus-image list [\-h|--help] [\-u|--username] [\-w|--password] [\-i|--images] [\-b|--builds [image id]] [\-t|--targetimages [build id]] [\-g|--targets] [\-a|--accounts] [\-p|--providers]
6
- .SH DESCRIPTION
7
- aeolus-image list commands allows users to list information on the contents of particular objects in image warehouse including:
8
- .P
9
- images: high level image representation associated with underlying provider and target images
10
- .br
11
- builds: an object representation of a particular build that has taken place for a high level image
12
- .br
13
- targets: particular targets available to build against, for example 'ec2'
14
- .br
15
- targetimages: represents builds of particular image against a target. For example building against target 'ec2' would create an AMI specific image
16
- .br
17
- providerimages: represents the actual images that have been uploaded to a provider. Similiar to a target image but specific to a particular provider
18
- .SH OPTIONS
19
- .TP
20
- \-u, --user <username>
21
- Conductor username
22
- .TP
23
- \-w, --password <password>
24
- Conductor password
25
- Get usage information for this command and associated commmands
26
- .TP
27
- \-i, --images
28
- Retrieve a list of images
29
- .TP
30
- \-b, --builds <image id>
31
- Retrieve the builds of an image
32
- .TP
33
- \-t, --targetimages <build id>
34
- Retrieve the target images from a build
35
- .TP
36
- \-P, --providerimages
37
- Retrieve the provider images from a target image
38
- .TP
39
- \-g, --targets
40
- Retrieve a list of available targets
41
- .TP
42
- \-p, --providers
43
- Retrieve a list of available providers
44
- .TP
45
- \-a, --accounts
46
- Retrieve a list of available accounts
47
- .TP
48
- \-d, --daemon
49
- Run as a background process
50
- .TP
51
- \-h, --help
52
- .SH EXAMPLES
53
- .TP
54
- List all images
55
- .B aeolus-image list
56
- \--images
57
- .TP
58
- List all builds for an image with id: 12345678-aaaa-1234--1234567890ab
59
- .B aeolus-image list
60
- \--builds 12345678-aaaa-1234--1234567890ab
61
- .TP
62
- List all target images for a given build with id: 12345678-bbbb-1234--1234567890ab
63
- .B aeolus-image list
64
- \--builds 12345678-bbbb-1234--1234567890ab
65
- .TP
66
- List all available targets
67
- .B aeolus-image list
68
- \--targets
69
- .TP
70
- List all available providers
71
- .B aeolus-image list
72
- \--providers
73
- .TP
74
- List all available accounts
75
- .B aeolus-image list
76
- \--account
77
- .SH AUTHOR
78
- Martyn Taylor (mtaylor@redhat.com), Jason Guiditta (jguiditta@redhat.com)
79
- .SH SEE ALSO
80
- aeolus-image-build(1), aeolus-image-push(1), aeolus-image-import(1), aeolus-image-delete(1)
@@ -1,40 +0,0 @@
1
- .TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
2
- .SH NAME
3
- aeolus-image push \- command for pushing aeolus images to back end providers
4
- .SH SYNOPSIS
5
- .B aeolus-image push [\-h|--help] [\-u|--username] [\-w|--password] [\-id [image-id]] [-r|--provider [provider-name]]
6
- .SH DESCRIPTION
7
- aeolus-image push allows users to push built images to a particular backend provider
8
- .SH OPTIONS
9
- .TP
10
- \-u, --user <username>
11
- Conductor username
12
- .TP
13
- \-w, --password <password>
14
- Conductor password
15
- .TP
16
- \-r|--provider
17
- The provider name this image should be pushed to
18
- .TP
19
- \--id <id>
20
- The id of the image for pushing
21
- .TP
22
- \-d, --daemon
23
- Run as a background process
24
- .TP
25
- Get usage information for this command and associated commmands
26
- \-h, --help
27
- .SH EXAMPLES
28
- .TP
29
- Initial push of an image with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
30
- .B aeolus-image push
31
- \--id 12345678-bbbb-1234--1234567890ab
32
- \--provider ec2-us-east-1
33
- Push a build with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
34
- .B aeolus-image push
35
- \--build 12345678-bbbb-1234--1234567890ab
36
- \--provider ec2-us-east-1
37
- .SH AUTHOR
38
- Martyn Taylor (mtaylor@redhat.com), Jason Guiditta (jguiditta@redhat.com)
39
- .SH SEE ALSO
40
- aeolus-image-list(1), aeolus-image-build(1), aeolus-image-import(1)
@@ -1,16 +0,0 @@
1
- .TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
2
- .SH NAME
3
- aeolus-image \- command line tool for managing aeolus images
4
- .SH SYNOPSIS
5
- .B aeolus-image
6
- [\-h]
7
- .SH DESCRIPTION
8
- aeolus-image is a tool that allows users to control their aeolus images through image builder and aeolus conductor. aeolus-image offers four commands options; list, build, push, import. For more information on each command please run man aeolus-image <command> or aeolus-image --help
9
- .SH OPTIONS
10
- .TP
11
- \-h, --help
12
- Get usage information for this tool and subcommands
13
- .SH AUTHOR
14
- Martyn Taylor (mtaylor@redhat.com), Jason Guiditta (jguiditta@redhat.com)
15
- .SH SEE ALSO
16
- aeolus-image-build(1), aeolus-image-push(1), aeolus-image-list(1), aeolus-image-import(1)
@@ -1,76 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Aeolus
4
- module Image
5
- describe BaseCommand do
6
-
7
- it "should determine the correct credentials for HTTP Authentication" do
8
- basec = BaseCommand.new
9
- iwhd = basec.send :iwhd
10
- iwhd.user.should == nil
11
-
12
- conductor = basec.send :conductor
13
- conductor.user.should == "admin"
14
- conductor.password.should == "password"
15
-
16
- basec = BaseCommand.new({:username => "testusername", :password=> "testpassword"})
17
- conductor = basec.send :conductor
18
- conductor.user.should == "testusername"
19
- conductor.password.should == "testpassword"
20
- end
21
-
22
- describe "#read_file" do
23
-
24
- it "should return nil when it cannot find file" do
25
- b = BaseCommand.new
26
- b.send(:read_file, "foo.fake").should be_nil
27
- end
28
-
29
- it "should read file content into string variable" do
30
- b = BaseCommand.new
31
- template_str = b.send(:read_file, "#{File.dirname(__FILE__)}" + "/../examples/custom_repo.tdl")
32
- template_str.should include("<template>")
33
- end
34
- end
35
-
36
- describe "#is_file?" do
37
- it "should return false if no file found" do
38
- b = BaseCommand.new
39
- b.send(:is_file?, "foo.fake").should be_false
40
- end
41
- it "should return true if file found" do
42
- b = BaseCommand.new
43
- valid_file = "#{File.dirname(__FILE__)}" + "/../examples/aeolus-cli"
44
- b.instance_eval {@config_location = valid_file}
45
- b.send(:is_file?, valid_file).should be_true
46
- end
47
- end
48
-
49
- describe "#write_file" do
50
- it "should write a new file" do
51
- b = BaseCommand.new
52
- new_file = "/tmp/foo.fake"
53
- b.instance_eval {@config_location = new_file}
54
- b.send(:write_file)
55
- conf = YAML::load(File.open(File.expand_path(new_file)))
56
- conf.has_key?(:iwhd).should be_true
57
- File.delete(new_file)
58
- end
59
- end
60
-
61
- describe "#validate_xml_document?" do
62
- it "should return errors given non compliant xml" do
63
- b = BaseCommand.new
64
- errors = b.send(:validate_xml_document, "examples/tdl.rng", File.read("spec/fixtures/invalid_template.tdl"))
65
- errors.length.should > 0
66
- end
67
-
68
- it "should return no errors" do
69
- b = BaseCommand.new
70
- errors = b.send(:validate_xml_document, "examples/tdl.rng", File.read("spec/fixtures/valid_template.tdl"))
71
- errors.length.should == 0
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Aeolus
4
- module Image
5
- describe BuildCommand do
6
- before(:each) do
7
- @options[:target] = ['mock','ec2']
8
- @options[:template] = "#{File.dirname(__FILE__)}" + "/../examples/custom_repo.tdl"
9
- end
10
-
11
- describe "#run" do
12
- it "should kick off a build with valid options" do
13
- b = BuildCommand.new(@options, @output)
14
- begin
15
- b.run
16
- rescue SystemExit => e
17
- e.status.should == 0
18
- end
19
- $stdout.string.should include("Image:")
20
- $stdout.string.should include("Target Image:")
21
- $stdout.string.should include("Build:")
22
- end
23
- it "should exit with a message if only image id is provided" do
24
- @options.delete(:template)
25
- @options.delete(:target)
26
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
27
- b = BuildCommand.new(@options, @output)
28
- begin
29
- b.run
30
- rescue SystemExit => e
31
- e.status.should == 1
32
- end
33
- $stdout.string.should include("This combination of parameters is not currently supported")
34
- end
35
- it "should exit with appropriate message when a non compliant template is given" do
36
- @options[:template] = "spec/fixtures/invalid_template.tdl"
37
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
38
- b = BuildCommand.new(@options, @output)
39
- begin
40
- b.run
41
- rescue SystemExit => e
42
- e.status.should == 1
43
- end
44
- $stdout.string.should include("ERROR: The given Template does not conform to the TDL Schema")
45
- end
46
- end
47
-
48
- describe "#combo_implemented?" do
49
- it "should give useful feedback if no template or target is specified" do
50
- @options[:template] = ''
51
- @options[:target] = []
52
- b = BuildCommand.new(@options, @output)
53
- begin
54
- b.combo_implemented?
55
- rescue SystemExit => e
56
- e.status.should == 1
57
- end
58
- $stdout.string.should include("This combination of parameters is not currently supported")
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,82 +0,0 @@
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