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,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
4
- require 'config_parser.rb'
5
- parser = Aeolus::Image::ConfigParser.new(ARGV)
6
- puts parser.process
@@ -1,9 +0,0 @@
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
@@ -1,18 +0,0 @@
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>
@@ -1,3 +0,0 @@
1
- <image>
2
- <name>Test Image</name>
3
- </image>
@@ -1,207 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!-- This Schema is lifted from the OZ project: http://www.aeolusproject.org/oz.html any changes to this schema should be done in the upstream project, then added here-->
3
- <!-- A Relax NG schema for the TDL (template description language) format -->
4
- <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
5
- <start>
6
- <ref name='template'/>
7
- </start>
8
-
9
- <define name='template'>
10
- <element name='template'>
11
- <interleave>
12
- <element name='name'>
13
- <text/>
14
- </element>
15
- <element name='os'>
16
- <interleave>
17
- <element name='name'>
18
- <text/>
19
- </element>
20
- <element name='version'>
21
- <text/>
22
- </element>
23
- <element name='arch'>
24
- <choice>
25
- <value>i386</value>
26
- <value>x86_64</value>
27
- </choice>
28
- </element>
29
- <element name='install'>
30
- <choice>
31
- <ref name='url'/>
32
- <ref name='iso'/>
33
- </choice>
34
- </element>
35
- <optional>
36
- <element name='rootpw'>
37
- <text/>
38
- </element>
39
- </optional>
40
- <optional>
41
- <element name='key'>
42
- <text/>
43
- </element>
44
- </optional>
45
- </interleave>
46
- </element>
47
- <optional>
48
- <element name='description'>
49
- <text/>
50
- </element>
51
- </optional>
52
- <optional>
53
- <element name='packages'>
54
- <zeroOrMore>
55
- <element name='package'>
56
- <attribute name='name'>
57
- <text/>
58
- </attribute>
59
- <interleave>
60
- <optional>
61
- <element name='repository'>
62
- <text/>
63
- </element>
64
- </optional>
65
- <optional>
66
- <element name='file'>
67
- <text/>
68
- </element>
69
- </optional>
70
- <optional>
71
- <element name='arguments'>
72
- <text/>
73
- </element>
74
- </optional>
75
- </interleave>
76
- </element>
77
- </zeroOrMore>
78
- </element>
79
- </optional>
80
- <optional>
81
- <element name='files'>
82
- <zeroOrMore>
83
- <element name='file'>
84
- <attribute name='name'>
85
- <text/>
86
- </attribute>
87
- <choice>
88
- <ref name='rawtype'/>
89
- <ref name='base64type'/>
90
- </choice>
91
- </element>
92
- </zeroOrMore>
93
- </element>
94
- </optional>
95
- <optional>
96
- <element name='commands'>
97
- <zeroOrMore>
98
- <element name='command'>
99
- <attribute name='name'>
100
- <text/>
101
- </attribute>
102
- <choice>
103
- <ref name='rawtype'/>
104
- <ref name='base64type'/>
105
- </choice>
106
- </element>
107
- </zeroOrMore>
108
- </element>
109
- </optional>
110
- <optional>
111
- <element name='repositories'>
112
- <zeroOrMore>
113
- <element name='repository'>
114
- <attribute name='name'>
115
- <text/>
116
- </attribute>
117
- <interleave>
118
- <element name='url'>
119
- <text/>
120
- </element>
121
- <optional>
122
- <element name='signed'>
123
- <ref name='bool'/>
124
- </element>
125
- </optional>
126
- </interleave>
127
- </element>
128
- </zeroOrMore>
129
- </element>
130
- </optional>
131
- </interleave>
132
- </element>
133
- </define>
134
-
135
- <define name='url'>
136
- <attribute name='type'>
137
- <value>url</value>
138
- </attribute>
139
- <element name='url'>
140
- <text/>
141
- </element>
142
- </define>
143
-
144
- <define name='iso'>
145
- <attribute name='type'>
146
- <value>iso</value>
147
- </attribute>
148
- <interleave>
149
- <element name='iso'>
150
- <text/>
151
- </element>
152
- <optional>
153
- <choice>
154
- <element name='md5sum'>
155
- <text/>
156
- </element>
157
- <element name='sha1sum'>
158
- <text/>
159
- </element>
160
- <element name='sha256sum'>
161
- <text/>
162
- </element>
163
- </choice>
164
- </optional>
165
- </interleave>
166
- </define>
167
-
168
- <define name='bool'>
169
- <choice>
170
- <data type="string">
171
- <param name="pattern">[Tt][Rr][Uu][Ee]</param>
172
- </data>
173
- <data type="string">
174
- <param name="pattern">[Ff][Aa][Ll][Ss][Ee]</param>
175
- </data>
176
- <data type="string">
177
- <param name="pattern">[Yy][Ee][Ss]</param>
178
- </data>
179
- <data type="string">
180
- <param name="pattern">[Nn][Oo]</param>
181
- </data>
182
- </choice>
183
- </define>
184
-
185
- <define name='rawtype'>
186
- <optional>
187
- <attribute name='type'>
188
- <value>raw</value>
189
- </attribute>
190
- </optional>
191
- <text/>
192
- </define>
193
-
194
- <define name='base64'>
195
- <data type="string">
196
- <param name="pattern">[a-zA-Z0-9+/]+={0,2}</param>
197
- </data>
198
- </define>
199
-
200
- <define name='base64type'>
201
- <attribute name='type'>
202
- <value>base64</value>
203
- </attribute>
204
- <ref name='base64'/>
205
- </define>
206
-
207
- </grammar>
@@ -1,134 +0,0 @@
1
- require 'yaml'
2
- require 'rest_client'
3
- require 'nokogiri'
4
-
5
- module Aeolus
6
- module Image
7
- #This will house some methods that multiple Command classes need to use.
8
- class BaseCommand
9
- attr_accessor :options
10
-
11
- def initialize(opts={}, logger=nil)
12
- logger(logger)
13
- @options = opts
14
- @config_location = "~/.aeolus-cli"
15
- @config = load_config
16
- end
17
-
18
- protected
19
- def not_implemented
20
- "This option or combination is not yet implemented"
21
- end
22
-
23
- def logger(logger=nil)
24
- @logger ||= logger
25
- unless @logger
26
- @logger = Logger.new(STDOUT)
27
- @logger.level = Logger::INFO
28
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
29
- end
30
- return @logger
31
- end
32
-
33
- def iwhd
34
- create_resource(:iwhd)
35
- end
36
-
37
- def conductor
38
- create_resource(:conductor)
39
- end
40
-
41
- def read_file(path)
42
- begin
43
- full_path = File.expand_path(path)
44
- if is_file?(path)
45
- File.read(full_path)
46
- else
47
- return nil
48
- end
49
- rescue
50
- nil
51
- end
52
- end
53
-
54
- # TODO: Consider ripping all this file-related stuff into a module or
55
- # class for better encapsulation and testability
56
- def is_file?(path)
57
- full_path = File.expand_path(path)
58
- if File.exist?(full_path) && !File.directory?(full_path)
59
- return true
60
- end
61
- false
62
- end
63
-
64
- def quit(code)
65
- exit(code)
66
- end
67
-
68
- def validate_xml_document(schema_path, xml_string)
69
- schema = Nokogiri::XML::RelaxNG(File.read(schema_path))
70
- doc = Nokogiri::XML xml_string
71
- schema.validate(doc)
72
- end
73
-
74
- private
75
- def load_config
76
- begin
77
- file_str = read_file(@config_location)
78
- if is_file?(@config_location) && !file_str.include?(":url")
79
- lines = File.readlines(File.expand_path(@config_location)).map do |line|
80
- "#" + line
81
- end
82
- File.open(File.expand_path(@config_location), 'w') do |file|
83
- file.puts lines
84
- end
85
- write_file
86
- end
87
- write_file unless is_file?(@config_location)
88
- YAML::load(File.open(File.expand_path(@config_location)))
89
- rescue Errno::ENOENT
90
- #TODO: Create a custom exception to wrap CLI Exceptions
91
- raise "Unable to locate or write configuration file: \"" + @config_location + "\""
92
- end
93
- end
94
-
95
- def write_file
96
- example = File.read(File.expand_path(File.dirname(__FILE__) + "/../examples/aeolus-cli"))
97
- File.open(File.expand_path(@config_location), 'a+') do |f|
98
- f.write(example)
99
- end
100
- end
101
-
102
- def create_resource(resource_name)
103
- # Check to see if config has a resource with this name
104
- if !@config.has_key?(resource_name)
105
- raise "Unable to determine resource: " + resource_name.to_s + " from configuration file. Please check: " + @config_location
106
- return
107
- end
108
-
109
- #Use command line arguments for username/password
110
- if @options.has_key?(:username)
111
- if @options.has_key?(:password)
112
- RestClient::Resource.new(@config[resource_name][:url], :user => @options[:username], :password => @options[:password])
113
- else
114
- #TODO: Create a custom exception to wrap CLI Exceptions
115
- raise "Password not found for user: " + @options[:username]
116
- end
117
-
118
- #Use config for username/password
119
- elsif @config[resource_name].has_key?(:username)
120
- if @config[resource_name].has_key?(:password)
121
- RestClient::Resource.new(@config[resource_name][:url], :user => @config[resource_name][:username], :password => @config[resource_name][:password])
122
- else
123
- #TODO: Create a custom exception to wrap CLI Exceptions
124
- raise "Password not found for user: " + @config[resource_name][:username]
125
- end
126
-
127
- # Do not use authentication
128
- else
129
- RestClient::Resource.new(@config[resource_name][:url])
130
- end
131
- end
132
- end
133
- end
134
- end
@@ -1,68 +0,0 @@
1
- require 'imagefactory'
2
-
3
- module Aeolus
4
- module Image
5
- class BuildCommand < BaseCommand
6
- attr_accessor :console
7
- def initialize(opts={}, logger=nil)
8
- super(opts, logger)
9
- default = {
10
- :template_str => '',
11
- :template => '',
12
- :target => [],
13
- :image => '',
14
- :build => ''
15
- }
16
- @options = default.merge(@options)
17
- @console = ImageFactoryConsole.new()
18
- @console.start
19
- end
20
-
21
- def run
22
- if combo_implemented?
23
- @options[:template_str] = read_file(@options[:template])
24
- if @options[:template_str].nil?
25
- puts "Cannot find specified file"
26
- quit(1)
27
- end
28
-
29
- # Validate XML against TDL Schema
30
- errors = validate_xml_document(File.dirname(__FILE__) + "/../examples/tdl.rng", @options[:template_str])
31
- if errors.length > 0
32
- puts "ERROR: The given Template does not conform to the TDL Schema, see below for specific details:"
33
- errors.each do |error|
34
- puts "- " + error.message
35
- end
36
- quit(1)
37
- end
38
-
39
- #This is a temporary hack in case the agent doesn't show up on bus immediately
40
- sleep(5)
41
- @console.build(@options[:template_str], @options[:target], @options[:image], @options[:build]).each do |adaptor|
42
- puts ""
43
- puts "Target Image: #{adaptor.image_id}"
44
- puts "Image: #{adaptor.image}"
45
- puts "Build: #{adaptor.build}"
46
- puts "Status: #{adaptor.status}"
47
- puts "Percent Complete: #{adaptor.percent_complete}"
48
- end
49
- quit(0)
50
- end
51
- end
52
-
53
- def combo_implemented?
54
- if @options[:template].empty? || @options[:target].empty?
55
- puts "This combination of parameters is not currently supported"
56
- quit(1)
57
- end
58
- true
59
- end
60
-
61
- def quit(code)
62
- @console.shutdown
63
- super
64
- end
65
-
66
- end
67
- end
68
- end