aeolus-image 0.4.0 → 0.5.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.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format nested
@@ -0,0 +1,36 @@
1
+ # aeolus-image-rubygem #
2
+ **aeolus-image-rubygem** is a Ruby library used by [Conductor](https://github.com/aeolusproject/conductor) to connect with Image Factory and Image Warehouse.
3
+
4
+ It provides a gem named **aeolus-image**, which shouldn't be confused with the [aeolus-image](https://github.com/aeolusproject/aeolus-image) command-line tool. (There's talk of renaming these shortly to alleviate this confusion.)
5
+
6
+ ## Configuration ##
7
+ aeolus-image-rubygem is meant to be leveraged in code. You might check out [config/initializers/aeolus-image.rb](https://github.com/aeolusproject/conductor/blob/master/src/config/initializers/aeolus-image.rb) in Conductor for an example.
8
+
9
+ ## Usage ##
10
+ After configurating Factory and/or Warehouse hosts, you can do things like the following:
11
+
12
+ ### Warehouse ###
13
+
14
+ ~~~
15
+ images = Aeolus::Image::Warehouse::Image.all
16
+
17
+ image1 = images.first
18
+ image1.name # => ""
19
+ image1.image_builds # => an array of ImageBuild objects
20
+ ~~~
21
+
22
+ ### Factory ###
23
+
24
+ ~~~
25
+ builds_in_progress = Aeolus::Image::Factory::Builder.all
26
+ ~~~
27
+
28
+ #### Start a build with Factory ####
29
+
30
+ ~~~
31
+ img = Aeolus::Image::Factory::Image.new(
32
+ :targets => 'ec2',
33
+ :template => IO.read('/home/mawagner/template.tpl')
34
+ )
35
+ img.save!
36
+ ~~~
data/Rakefile CHANGED
@@ -24,25 +24,28 @@ require './rake/rpmtask'
24
24
  RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild"
25
25
  RPM_SPEC = "rubygem-aeolus-image.spec"
26
26
  RPM_SPEC_IN = "rubygem-aeolus-image.spec.in"
27
- PKG_VERSION = "0.4.0"
27
+ PKG_VERSION = "0.5.1"
28
28
 
29
29
  spec = Gem::Specification.new do |s|
30
- s.name = 'aeolus-image'
31
- s.version = PKG_VERSION
32
- s.summary= 'Ruby Client for Image Warehouse and Image Factory for the Aeolus cloud suite'
33
- s.description = 'Library for managing image via the Factory and Warehouse projects for the aeolus cloud management suite'
34
- s.author = 'Jason Guiditta, Martyn Taylor'
35
- s.email = 'jguiditt@redhat.com, mtaylor@redhat.com'
36
- s.license = 'ASL 2.0'
37
- s.homepage = 'http://aeolusproject.org'
38
- s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*") + %w(COPYING)
30
+ s.name = 'aeolus-image'
31
+ s.version = PKG_VERSION
32
+ s.platform = Gem::Platform::RUBY
33
+ s.authors = 'Jason Guiditta, Martyn Taylor'
34
+ s.email = 'jguiditt@redhat.com, mtaylor@redhat.com'
35
+ s.license = 'ASL 2.0'
36
+ s.homepage = "https://github.com/aeolusproject/aeolus-image-rubygem"
37
+ s.summary = 'Ruby Client for Image Warehouse and Image Factory for the Aeolus cloud suite'
38
+ s.description = "aeolus-image is a Ruby library used by Conductor to connect with Image Factory and Image Warehouse."
39
+
40
+ s.files = Dir["lib/**/*.rb","README.md","COPYING","Rakefile","rake/rpmtask.rb"]
41
+ s.test_files = Dir["spec/**/*.*",".rspec","examples/aeolus-cli"]
39
42
  s.require_path = "lib"
40
- s.add_dependency('nokogiri', '>=0.4.0')
41
- s.add_dependency('rest-client')
42
- s.add_dependency('activeresource', '~>3.0.10')
43
+ s.add_dependency('activeresource')
44
+ s.add_dependency('nokogiri')
43
45
  s.add_dependency('oauth')
46
+ s.add_dependency('rest-client')
44
47
 
45
- s.add_development_dependency('rspec', '~>1.3.0')
48
+ s.add_development_dependency('rspec', '>=1.3.0')
46
49
  end
47
50
 
48
51
  Gem::PackageTask.new(spec) do |p|
@@ -0,0 +1,9 @@
1
+
2
+ # Below is the correct format for this file, please update any older version you may have
3
+ :iwhd:
4
+ :url: http://localhost:9090
5
+
6
+ :conductor:
7
+ :url: http://localhost:3000/conductor
8
+ :username: admin
9
+ :password: password
@@ -26,7 +26,7 @@ module ActiveResourceOAuthClient
26
26
  def request_with_oauth(method, path, *arguments)
27
27
  @oauth_config = Aeolus::Image::Factory::Base.config || {}
28
28
  # Take care to fall back to the standard request method if we don't have full OAuth credentials
29
- unless Aeolus::Image::Factory::Base.use_oauth?
29
+ unless use_oauth_for_url?("#{site.scheme}://#{site.host}:#{site.port}#{path}")
30
30
  return request_without_oauth(method, path, *arguments)
31
31
  end
32
32
  result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
@@ -56,6 +56,12 @@ module ActiveResourceOAuthClient
56
56
  raise SSLError.new(e.message)
57
57
  end
58
58
 
59
+ # Currently, only Factory calls should use OAuth -- extend as needed
60
+ def use_oauth_for_url?(url)
61
+ Aeolus::Image::Factory::Base.use_oauth? and
62
+ url.include?(Aeolus::Image::Factory::Base.config[:site])
63
+ end
64
+
59
65
  alias_method_chain :request, :oauth
60
66
 
61
67
  end
@@ -0,0 +1,126 @@
1
+ # Copyright 2011 Red Hat, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Define a package task library to aid in the definition of RPM
16
+ # packages.
17
+
18
+ require 'rubygems'
19
+ require 'rake'
20
+ require 'rake/packagetask'
21
+
22
+ require 'rbconfig' # used to get system arch
23
+
24
+ module Rake
25
+
26
+ # Create a package based upon a RPM spec.
27
+ # RPM packages, can be produced by this task.
28
+ class RpmTask < PackageTask
29
+ # filename for output RPM spec
30
+ attr_accessor :rpm_spec
31
+
32
+ # RPM build dir
33
+ attr_accessor :topdir
34
+
35
+ # Include extra_release information in the rpm
36
+ attr_accessor :include_extra_release
37
+
38
+ def initialize(rpm_spec, args = {})
39
+ init(rpm_spec,args)
40
+ yield self if block_given?
41
+ define if block_given?
42
+ end
43
+
44
+ def init(rpm_spec,args)
45
+ @rpm_spec = rpm_spec
46
+
47
+ if args[:suffix]
48
+ rpm_spec_in = @rpm_spec + args[:suffix]
49
+ @include_extra_release = eval `grep -q '^[[:space:]]*Release:[[:space:]]*0' #{rpm_spec_in} && echo true || echo false`
50
+
51
+ git_head = `git log -1 --pretty=format:%h`
52
+ extra_release = @include_extra_release ? ("." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}") : ''
53
+
54
+ if args[:pkg_version]
55
+ pkg_version = args[:pkg_version]
56
+ `sed -e "s|@VERSION@|#{pkg_version}|;s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
57
+ else
58
+ `sed -e "s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
59
+ end
60
+ end
61
+
62
+ # parse this out of the rpmbuild macros,
63
+ # not ideal but better than hardcoding this
64
+ File.open('/etc/rpm/macros.dist', "r") { |f|
65
+ f.read.scan(/%dist\s*\.(.*)\n/)
66
+ @distro = $1
67
+ }
68
+
69
+ # Parse rpm name / version out of spec
70
+ # FIXME hacky way to do this for now
71
+ # (would be nice to implement a full blown rpm spec parser for ruby)
72
+ File.open(rpm_spec, "r") { |f|
73
+ contents = f.read
74
+ # Parse out definitions and crudely expand them
75
+ contents.scan(/%define .*\n/).each do |definition|
76
+ words = definition.strip.split(' ')
77
+ key = words[1]
78
+ value = words[2..-1].to_s
79
+ # Modify the contents with expanded values, unless they contain
80
+ # a shell command (since we're not modifying them)
81
+ contents.gsub!("%{#{key}}", value) unless value.match('%\(')
82
+ end
83
+ @name = contents.scan(/\nName: .*\n/).first.split.last
84
+ @version = contents.scan(/\nVersion: .*\n/).first.split.last
85
+ @release = contents.scan(/\nRelease: .*\n/).first.split.last
86
+ @release.gsub!("%{?dist}", ".#{@distro}")
87
+ @arch = contents.scan(/\nBuildArch: .*\n/) # TODO grab local arch if not defined
88
+ if @arch.nil?
89
+ @arch = Config::CONFIG["target_cpu"] # hoping this will work for all cases,
90
+ # can just run the 'arch' cmd if we want
91
+ else
92
+ @arch = @arch.first.split.last
93
+ end
94
+ }
95
+ super(@name, @version)
96
+
97
+ @rpmbuild_cmd = 'rpmbuild'
98
+ end
99
+
100
+ def define
101
+ super
102
+
103
+ directory "#{@topdir}/SOURCES"
104
+ directory "#{@topdir}/SPECS"
105
+
106
+ desc "Build the rpms"
107
+ task :rpms, [:include_extra_release] => [rpm_file]
108
+
109
+ # FIXME properly determine :package build artifact(s) to copy to sources dir
110
+ file rpm_file, [:include_extra_release] => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
111
+ cp "#{package_dir}/#{@name}-#{@version}.tgz", "#{@topdir}/SOURCES/"
112
+ # FIXME - This seems like a hack, but we don't know the gem's name
113
+ cp "#{package_dir}/#{@name.gsub('rubygem-', '')}-#{@version}.gem", "#{@topdir}/SOURCES/"
114
+ cp @rpm_spec, "#{@topdir}/SPECS"
115
+ sh "#{@rpmbuild_cmd} " +
116
+ "--define '_topdir #{@topdir}' " +
117
+ "-ba #{@rpm_spec}"
118
+ end
119
+ end
120
+
121
+ def rpm_file
122
+ # FIXME support all a spec's subpackages as well
123
+ "#{@topdir}/RPMS/#{@arch}/#{@name}-#{@version}-#{@release}.#{@arch}.rpm"
124
+ end
125
+ end
126
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aeolus-image
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 0
10
- version: 0.4.0
8
+ - 5
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Guiditta, Martyn Taylor
@@ -15,26 +15,24 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-09 00:00:00 Z
18
+ date: 2012-08-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: nokogiri
21
+ name: activeresource
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 15
28
+ hash: 3
29
29
  segments:
30
30
  - 0
31
- - 4
32
- - 0
33
- version: 0.4.0
31
+ version: "0"
34
32
  type: :runtime
35
33
  version_requirements: *id001
36
34
  - !ruby/object:Gem::Dependency
37
- name: rest-client
35
+ name: nokogiri
38
36
  prerelease: false
39
37
  requirement: &id002 !ruby/object:Gem::Requirement
40
38
  none: false
@@ -48,23 +46,21 @@ dependencies:
48
46
  type: :runtime
49
47
  version_requirements: *id002
50
48
  - !ruby/object:Gem::Dependency
51
- name: activeresource
49
+ name: oauth
52
50
  prerelease: false
53
51
  requirement: &id003 !ruby/object:Gem::Requirement
54
52
  none: false
55
53
  requirements:
56
- - - ~>
54
+ - - ">="
57
55
  - !ruby/object:Gem::Version
58
- hash: 19
56
+ hash: 3
59
57
  segments:
60
- - 3
61
58
  - 0
62
- - 10
63
- version: 3.0.10
59
+ version: "0"
64
60
  type: :runtime
65
61
  version_requirements: *id003
66
62
  - !ruby/object:Gem::Dependency
67
- name: oauth
63
+ name: rest-client
68
64
  prerelease: false
69
65
  requirement: &id004 !ruby/object:Gem::Requirement
70
66
  none: false
@@ -83,7 +79,7 @@ dependencies:
83
79
  requirement: &id005 !ruby/object:Gem::Requirement
84
80
  none: false
85
81
  requirements:
86
- - - ~>
82
+ - - ">="
87
83
  - !ruby/object:Gem::Version
88
84
  hash: 27
89
85
  segments:
@@ -93,7 +89,7 @@ dependencies:
93
89
  version: 1.3.0
94
90
  type: :development
95
91
  version_requirements: *id005
96
- description: Library for managing image via the Factory and Warehouse projects for the aeolus cloud management suite
92
+ description: aeolus-image is a Ruby library used by Conductor to connect with Image Factory and Image Warehouse.
97
93
  email: jguiditt@redhat.com, mtaylor@redhat.com
98
94
  executables: []
99
95
 
@@ -102,7 +98,6 @@ extensions: []
102
98
  extra_rdoc_files: []
103
99
 
104
100
  files:
105
- - Rakefile
106
101
  - lib/aeolus_image/model/factory/build.rb
107
102
  - lib/aeolus_image/model/factory/provider_image.rb
108
103
  - lib/aeolus_image/model/factory/builder.rb
@@ -120,6 +115,10 @@ files:
120
115
  - lib/aeolus_image/import.rb
121
116
  - lib/aeolus_image/active_resource_oauth_client.rb
122
117
  - lib/aeolus_image.rb
118
+ - README.md
119
+ - COPYING
120
+ - Rakefile
121
+ - rake/rpmtask.rb
123
122
  - spec/vcr_setup.rb
124
123
  - spec/aeolus_image/model/factory/provider_image_spec.rb
125
124
  - spec/vcr/cassettes/oauth_fail_invalid.yml
@@ -141,8 +140,9 @@ files:
141
140
  - spec/models/warehouse/provider_image_spec.rb
142
141
  - spec/fixtures/invalid_template.tdl
143
142
  - spec/fixtures/valid_template.tdl
144
- - COPYING
145
- homepage: http://aeolusproject.org
143
+ - .rspec
144
+ - examples/aeolus-cli
145
+ homepage: https://github.com/aeolusproject/aeolus-image-rubygem
146
146
  licenses:
147
147
  - ASL 2.0
148
148
  post_install_message:
@@ -175,5 +175,27 @@ rubygems_version: 1.8.11
175
175
  signing_key:
176
176
  specification_version: 3
177
177
  summary: Ruby Client for Image Warehouse and Image Factory for the Aeolus cloud suite
178
- test_files: []
179
-
178
+ test_files:
179
+ - spec/vcr_setup.rb
180
+ - spec/aeolus_image/model/factory/provider_image_spec.rb
181
+ - spec/vcr/cassettes/oauth_fail_invalid.yml
182
+ - spec/vcr/cassettes/oauth.yml
183
+ - spec/vcr/cassettes/oauth_success_valid.yml
184
+ - spec/vcr/cassettes/builder.yml
185
+ - spec/vcr/cassettes/oauth_fail_no.yml
186
+ - spec/spec_helper.rb
187
+ - spec/models/factory/base_spec.rb
188
+ - spec/models/factory/builder_spec.rb
189
+ - spec/models/factory/target_image_spec.rb
190
+ - spec/models/factory/provider_image_spec.rb
191
+ - spec/models/warehouse/warehouse_client_spec.rb
192
+ - spec/models/warehouse/image_spec.rb
193
+ - spec/models/warehouse/template_spec.rb
194
+ - spec/models/warehouse/image_build_spec.rb
195
+ - spec/models/warehouse/target_image_spec.rb
196
+ - spec/models/warehouse/warehouse_model_spec.rb
197
+ - spec/models/warehouse/provider_image_spec.rb
198
+ - spec/fixtures/invalid_template.tdl
199
+ - spec/fixtures/valid_template.tdl
200
+ - .rspec
201
+ - examples/aeolus-cli