ogle 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: http://gluster.trunk:9292/v1/images
5
+ uri: http://glance.trunk:9292/v1/images
6
6
  body:
7
7
  headers:
8
8
  accept:
@@ -2,7 +2,7 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: http://gluster.trunk:9292/v1/images/detail
5
+ uri: http://glance.trunk:9292/v1/images/detail
6
6
  body:
7
7
  headers:
8
8
  accept:
@@ -0,0 +1,120 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://glance.trunk:9292/v1/images
6
+ body: |
7
+ Test-Image
8
+
9
+ headers:
10
+ accept:
11
+ - application/json
12
+ content-type:
13
+ - application/octet-stream
14
+ content-length:
15
+ - 11
16
+ transfer-encoding:
17
+ - chunked
18
+ x-image-meta-name:
19
+ - image_update_metadata
20
+ x-image-meta-is-public:
21
+ - "true"
22
+ x-image-meta-property-distro:
23
+ - test-distro
24
+ x-image-meta-property-arch:
25
+ - test-arch
26
+ x-image-meta-property-uploader:
27
+ - test-uploader
28
+ x-image-meta-property-type:
29
+ - test-type
30
+ x-image-meta-property-kernel-name:
31
+ - test-kernel-name
32
+ x-image-meta-property-kernel-id:
33
+ - test-kernel-id
34
+ x-image-meta-property-version:
35
+ - test-version
36
+ connection:
37
+ - keep-alive
38
+ keep-alive:
39
+ - 30
40
+ response: !ruby/struct:VCR::Response
41
+ status: !ruby/struct:VCR::ResponseStatus
42
+ code: 201
43
+ message: Created
44
+ headers:
45
+ content-type:
46
+ - text/plain; charset=UTF-8
47
+ content-length:
48
+ - "565"
49
+ location:
50
+ - http://glance.trunk:9292/v1/images/83
51
+ etag:
52
+ - 8cb22c184821cdc62a9dc5c34cf8a125
53
+ date:
54
+ - Wed, 08 Jun 2011 05:48:48 GMT
55
+ connection:
56
+ - keep-alive
57
+ body: "{\"image\": {\"status\": \"active\", \"name\": \"image_update_metadata\", \"deleted\": false, \"container_format\": null, \"created_at\": \"2011-06-08T05:48:48\", \"disk_format\": null, \"updated_at\": \"2011-06-08T05:48:48\", \"id\": 83, \"location\": \"file:///var/lib/glance/images/83\", \"checksum\": \"8cb22c184821cdc62a9dc5c34cf8a125\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"test-kernel-id\", \"type\": \"test-type\", \"version\": \"test-version\", \"kernel_name\": \"test-kernel-name\", \"uploader\": \"test-uploader\", \"arch\": \"test-arch\", \"distro\": \"test-distro\"}, \"size\": 11}}"
58
+ http_version: "1.1"
59
+ - !ruby/struct:VCR::HTTPInteraction
60
+ request: !ruby/struct:VCR::Request
61
+ method: :put
62
+ uri: http://glance.trunk:9292/v1/images/83
63
+ body:
64
+ headers:
65
+ accept:
66
+ - application/json
67
+ content-type:
68
+ - application/json
69
+ x-image-meta-is-public:
70
+ - "false"
71
+ connection:
72
+ - keep-alive
73
+ keep-alive:
74
+ - 30
75
+ response: !ruby/struct:VCR::Response
76
+ status: !ruby/struct:VCR::ResponseStatus
77
+ code: 200
78
+ message: OK
79
+ headers:
80
+ content-type:
81
+ - text/plain; charset=UTF-8
82
+ content-length:
83
+ - "379"
84
+ location:
85
+ - http://glance.trunk:9292/images/83
86
+ etag:
87
+ - 8cb22c184821cdc62a9dc5c34cf8a125
88
+ date:
89
+ - Wed, 08 Jun 2011 05:48:48 GMT
90
+ connection:
91
+ - keep-alive
92
+ body: "{\"image\": {\"status\": \"active\", \"name\": \"image_update_metadata\", \"deleted\": false, \"container_format\": null, \"created_at\": \"2011-06-08T05:48:48\", \"disk_format\": null, \"updated_at\": \"2011-06-08T05:48:48\", \"id\": 83, \"location\": \"file:///var/lib/glance/images/83\", \"checksum\": \"8cb22c184821cdc62a9dc5c34cf8a125\", \"is_public\": false, \"deleted_at\": null, \"properties\": {}, \"size\": 11}}"
93
+ http_version: "1.1"
94
+ - !ruby/struct:VCR::HTTPInteraction
95
+ request: !ruby/struct:VCR::Request
96
+ method: :delete
97
+ uri: http://glance.trunk:9292/v1/images/83
98
+ body:
99
+ headers:
100
+ accept:
101
+ - application/json
102
+ connection:
103
+ - keep-alive
104
+ keep-alive:
105
+ - 30
106
+ response: !ruby/struct:VCR::Response
107
+ status: !ruby/struct:VCR::ResponseStatus
108
+ code: 200
109
+ message: OK
110
+ headers:
111
+ content-type:
112
+ - text/html; charset=UTF-8
113
+ content-length:
114
+ - "0"
115
+ date:
116
+ - Wed, 08 Jun 2011 05:48:48 GMT
117
+ connection:
118
+ - keep-alive
119
+ body:
120
+ http_version: "1.1"
@@ -0,0 +1,120 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://glance.trunk:9292/v1/images
6
+ body: |
7
+ Test-Image
8
+
9
+ headers:
10
+ accept:
11
+ - application/json
12
+ content-type:
13
+ - application/octet-stream
14
+ content-length:
15
+ - 11
16
+ transfer-encoding:
17
+ - chunked
18
+ x-image-meta-name:
19
+ - image_update_properties
20
+ x-image-meta-is-public:
21
+ - "true"
22
+ x-image-meta-property-distro:
23
+ - test-distro
24
+ x-image-meta-property-arch:
25
+ - test-arch
26
+ x-image-meta-property-uploader:
27
+ - test-uploader
28
+ x-image-meta-property-type:
29
+ - test-type
30
+ x-image-meta-property-kernel-name:
31
+ - test-kernel-name
32
+ x-image-meta-property-kernel-id:
33
+ - test-kernel-id
34
+ x-image-meta-property-version:
35
+ - test-version
36
+ connection:
37
+ - keep-alive
38
+ keep-alive:
39
+ - 30
40
+ response: !ruby/struct:VCR::Response
41
+ status: !ruby/struct:VCR::ResponseStatus
42
+ code: 201
43
+ message: Created
44
+ headers:
45
+ content-type:
46
+ - text/plain; charset=UTF-8
47
+ content-length:
48
+ - "567"
49
+ location:
50
+ - http://glance.trunk:9292/v1/images/85
51
+ etag:
52
+ - 8cb22c184821cdc62a9dc5c34cf8a125
53
+ date:
54
+ - Wed, 08 Jun 2011 05:51:19 GMT
55
+ connection:
56
+ - keep-alive
57
+ body: "{\"image\": {\"status\": \"active\", \"name\": \"image_update_properties\", \"deleted\": false, \"container_format\": null, \"created_at\": \"2011-06-08T05:51:19\", \"disk_format\": null, \"updated_at\": \"2011-06-08T05:51:19\", \"id\": 85, \"location\": \"file:///var/lib/glance/images/85\", \"checksum\": \"8cb22c184821cdc62a9dc5c34cf8a125\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"test-kernel-id\", \"type\": \"test-type\", \"version\": \"test-version\", \"kernel_name\": \"test-kernel-name\", \"uploader\": \"test-uploader\", \"arch\": \"test-arch\", \"distro\": \"test-distro\"}, \"size\": 11}}"
58
+ http_version: "1.1"
59
+ - !ruby/struct:VCR::HTTPInteraction
60
+ request: !ruby/struct:VCR::Request
61
+ method: :put
62
+ uri: http://glance.trunk:9292/v1/images/85
63
+ body:
64
+ headers:
65
+ accept:
66
+ - application/json
67
+ content-type:
68
+ - application/json
69
+ x-image-meta-property-kernel-id:
70
+ - updated-test-kernel-id
71
+ connection:
72
+ - keep-alive
73
+ keep-alive:
74
+ - 30
75
+ response: !ruby/struct:VCR::Response
76
+ status: !ruby/struct:VCR::ResponseStatus
77
+ code: 200
78
+ message: OK
79
+ headers:
80
+ content-type:
81
+ - text/plain; charset=UTF-8
82
+ content-length:
83
+ - "417"
84
+ location:
85
+ - http://glance.trunk:9292/images/85
86
+ etag:
87
+ - 8cb22c184821cdc62a9dc5c34cf8a125
88
+ date:
89
+ - Wed, 08 Jun 2011 05:51:19 GMT
90
+ connection:
91
+ - keep-alive
92
+ body: "{\"image\": {\"status\": \"active\", \"name\": \"image_update_properties\", \"deleted\": false, \"container_format\": null, \"created_at\": \"2011-06-08T05:51:19\", \"disk_format\": null, \"updated_at\": \"2011-06-08T05:51:19\", \"id\": 85, \"location\": \"file:///var/lib/glance/images/85\", \"checksum\": \"8cb22c184821cdc62a9dc5c34cf8a125\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"updated-test-kernel-id\"}, \"size\": 11}}"
93
+ http_version: "1.1"
94
+ - !ruby/struct:VCR::HTTPInteraction
95
+ request: !ruby/struct:VCR::Request
96
+ method: :delete
97
+ uri: http://glance.trunk:9292/v1/images/85
98
+ body:
99
+ headers:
100
+ accept:
101
+ - application/json
102
+ connection:
103
+ - keep-alive
104
+ keep-alive:
105
+ - 30
106
+ response: !ruby/struct:VCR::Response
107
+ status: !ruby/struct:VCR::ResponseStatus
108
+ code: 200
109
+ message: OK
110
+ headers:
111
+ content-type:
112
+ - text/html; charset=UTF-8
113
+ content-length:
114
+ - "0"
115
+ date:
116
+ - Wed, 08 Jun 2011 05:51:19 GMT
117
+ connection:
118
+ - keep-alive
119
+ body:
120
+ http_version: "1.1"
@@ -7,7 +7,7 @@ CONNECTION = Ogle::Client.new(
7
7
  describe Ogle::Image do
8
8
  describe "#all" do
9
9
  before do
10
- VCR.use_cassette "images_all" do
10
+ VCR.use_cassette "image_all" do
11
11
  @response = CONNECTION.image.all
12
12
  end
13
13
  end
@@ -23,12 +23,12 @@ describe Ogle::Image do
23
23
 
24
24
  describe "#all with details" do
25
25
  before do
26
- VCR.use_cassette "images_all_with_details" do
26
+ VCR.use_cassette "image_all_with_details" do
27
27
  @response = CONNECTION.image.all true
28
28
  end
29
29
  end
30
30
 
31
- it "returns detailed images" do
31
+ it "returns all images" do
32
32
  @response.size.must_be :>=, 1
33
33
  end
34
34
 
@@ -39,7 +39,7 @@ describe Ogle::Image do
39
39
 
40
40
  describe "#runable" do
41
41
  before do
42
- VCR.use_cassette "images_runable" do
42
+ VCR.use_cassette "image_runable" do
43
43
  @response = CONNECTION.image.runable
44
44
  end
45
45
  end
@@ -54,8 +54,8 @@ describe Ogle::Image do
54
54
  end
55
55
 
56
56
  describe "#runable with details" do
57
- VCR.use_cassette "images_runable_with_details" do
58
- response = CONNECTION.image.runable(true)
57
+ VCR.use_cassette "image_runable_with_details" do
58
+ response = CONNECTION.image.runable true
59
59
 
60
60
  it "returns metadata" do
61
61
  must_have_valid_methods response.first, DETAILED_METADATA_KEYS
@@ -65,12 +65,19 @@ describe Ogle::Image do
65
65
 
66
66
  describe "#find" do
67
67
  before do
68
- VCR.use_cassette "images_find" do
69
- @response = CONNECTION.image.find 4
68
+ VCR.use_cassette "image_find" do
69
+ @image_id = upload("image_find").id
70
+ @response = CONNECTION.image.find @image_id
70
71
  end
71
72
  end
72
73
 
73
- it "returns X-Image-Meta-* headers as a hash" do
74
+ after do
75
+ VCR.use_cassette "image_find" do
76
+ CONNECTION.image.destroy @image_id
77
+ end
78
+ end
79
+
80
+ it "returns metadata with details" do
74
81
  must_have_valid_methods @response, DETAILED_METADATA_KEYS
75
82
  end
76
83
 
@@ -88,33 +95,95 @@ describe Ogle::Image do
88
95
  end
89
96
 
90
97
  describe "#destroy" do
91
- VCR.use_cassette "image_destroy" do
92
- response = CONNECTION.image.destroy 56
98
+ before do
99
+ VCR.use_cassette "image_destroy" do
100
+ @image_id = upload("image_destroy").id
101
+ end
102
+ end
103
+
104
+ it "returns OK" do
105
+ VCR.use_cassette "image_destroy" do
106
+ response = CONNECTION.image.destroy @image_id
93
107
 
94
- it "returns an HTTP/1.1 200 OK" do
95
- response.code.must_equal "200"
108
+ response.return.must_equal true
96
109
  end
97
110
  end
98
111
  end
99
112
 
100
113
  describe "#create" do
101
- VCR.use_cassette "image_create" do
102
- testfile = File.join TEST_ROOT, "support", "test-image"
103
- metadata = {
104
- "x-image-meta-is-public" => "true",
105
- "x-image-meta-property-test" => "yes",
106
- "x-image-meta-property-distro" => "test-distro",
107
- "x-image-meta-property-version" => "test-version-1"
108
- }
114
+ before do
115
+ VCR.use_cassette "image_create" do
116
+ @response = upload "image_create"
117
+ end
118
+ end
109
119
 
110
- response = CONNECTION.image.create "#{testfile}", "test-image", metadata
120
+ it "returns metadata" do
121
+ must_have_valid_methods @response, METADATA_KEYS
122
+ end
111
123
 
112
- it "returns an HTTP/1.1 201 OK" do
113
- response.code.must_equal "201"
114
- end
124
+ it "returns a nested properties hash" do
125
+ must_have_valid_keys @response.properties, %w(
126
+ distro
127
+ arch
128
+ uploader
129
+ type
130
+ kernel_name
131
+ kernel_id
132
+ version
133
+ )
115
134
  end
116
135
  end
117
136
 
137
+ describe "#update" do
138
+ describe "metadata" do
139
+ before do
140
+ VCR.use_cassette "image_update_metadata" do
141
+ @image = upload "image_update_metadata"
142
+ end
143
+ end
144
+
145
+ after do
146
+ VCR.use_cassette "image_update_metadata" do
147
+ CONNECTION.image.destroy @image.id
148
+ end
149
+ end
150
+
151
+ it "updates metadata" do
152
+ VCR.use_cassette "image_update_metadata" do
153
+ @image.is_public.must_equal true
154
+
155
+ response = CONNECTION.image.update @image.id, { "x-image-meta-is-public" => "false" }
156
+
157
+ response.is_public.must_equal false
158
+ end
159
+ end
160
+ end
161
+
162
+ describe "properties" do
163
+ before do
164
+ VCR.use_cassette "image_update_properties" do
165
+ @image = upload "image_update_properties"
166
+ @image.properties['kernel_id'].must_equal "test-kernel-id"
167
+
168
+ @response = CONNECTION.image.update @image.id, { "x-image-meta-property-kernel_id" => "updated-test-kernel-id" }
169
+ end
170
+ end
171
+
172
+ after do
173
+ VCR.use_cassette "image_update_properties" do
174
+ CONNECTION.image.destroy @image.id
175
+ end
176
+ end
177
+
178
+ it "updates property hash" do
179
+ @response.properties['kernel_id'].must_equal "updated-test-kernel-id"
180
+ end
181
+
182
+ it "doesn't maintain old properties" do
183
+ @response.properties.size.must_equal 1
184
+ end
185
+ end
186
+ end
118
187
 
119
188
  def must_have_valid_keys response, keys
120
189
  raise "The response passed in is empty." if response.keys.empty?
@@ -124,21 +193,47 @@ describe Ogle::Image do
124
193
  def must_have_valid_methods response, keys
125
194
  keys.each { |k| response.respond_to? k }
126
195
  end
196
+
197
+ def upload name
198
+ image = File.join TEST_ROOT, "support", "test-image"
199
+ metadata = {
200
+ "x-image-meta-is-public" => "true",
201
+ "x-image-meta-property-distro" => "test-distro",
202
+ "x-image-meta-property-arch" => "test-arch",
203
+ "x-image-meta-property-uploader" => "test-uploader",
204
+ "x-image-meta-property-type" => "test-type",
205
+ "x-image-meta-property-kernel_name" => "test-kernel-name",
206
+ "x-image-meta-property-kernel_id" => "test-kernel-id",
207
+ "x-image-meta-property-version" => "test-version"
208
+ }
209
+
210
+ CONNECTION.image.create name, image, metadata
211
+ end
127
212
  end
128
213
 
214
+ ##
215
+ # These test expect images with ids of:
216
+ # - for decimal (0-9)
217
+ # - for hex >9
218
+
129
219
  describe Ogle::ImageData do
220
+ before do
221
+ @decimal_image_id = 4
222
+ @hexadecimal_image_id = 36
223
+ end
224
+
130
225
  describe "#to_ami_id" do
131
226
  it "return a valid ami id" do
132
- VCR.use_cassette "image_find" do
133
- @response = CONNECTION.image.find 4
227
+ VCR.use_cassette "image_find_with_decimal" do
228
+ @response = CONNECTION.image.find @decimal_image_id
134
229
 
135
230
  @response.to_ami_id.must_equal "ami-00000004"
136
231
  end
137
232
  end
138
233
 
139
234
  it "return a valid hex ami id" do
140
- VCR.use_cassette "image_find" do
141
- @response = CONNECTION.image.find 36
235
+ VCR.use_cassette "image_find_with_hexadecimal" do
236
+ @response = CONNECTION.image.find @hexadecimal_image_id
142
237
 
143
238
  @response.to_ami_id.must_equal "ami-00000024"
144
239
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ogle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kevin Bringard
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-06-02 00:00:00 -06:00
14
+ date: 2011-06-08 00:00:00 -06:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  requirements:
23
23
  - - ~>
24
24
  - !ruby/object:Gem::Version
25
- version: 2.6.0
25
+ version: 2.7.0
26
26
  type: :runtime
27
27
  version_requirements: *id001
28
28
  - !ruby/object:Gem::Dependency
@@ -90,14 +90,17 @@ files:
90
90
  - lib/ogle/image.rb
91
91
  - lib/ogle/version.rb
92
92
  - ogle.gemspec
93
+ - test/cassettes/image_all.yml
94
+ - test/cassettes/image_all_with_details.yml
93
95
  - test/cassettes/image_create.yml
94
96
  - test/cassettes/image_destroy.yml
95
97
  - test/cassettes/image_find.yml
96
- - test/cassettes/images_all.yml
97
- - test/cassettes/images_all_with_details.yml
98
- - test/cassettes/images_find.yml
99
- - test/cassettes/images_runable.yml
100
- - test/cassettes/images_runable_with_details.yml
98
+ - test/cassettes/image_find_with_decimal.yml
99
+ - test/cassettes/image_find_with_hexadecimal.yml
100
+ - test/cassettes/image_runable.yml
101
+ - test/cassettes/image_runable_with_details.yml
102
+ - test/cassettes/image_update_metadata.yml
103
+ - test/cassettes/image_update_properties.yml
101
104
  - test/lib/ogle/image_test.rb
102
105
  - test/support/test-image
103
106
  - test/test_helper.rb
@@ -130,14 +133,17 @@ signing_key:
130
133
  specification_version: 3
131
134
  summary: Ruby interface for OpenStack Glance
132
135
  test_files:
136
+ - test/cassettes/image_all.yml
137
+ - test/cassettes/image_all_with_details.yml
133
138
  - test/cassettes/image_create.yml
134
139
  - test/cassettes/image_destroy.yml
135
140
  - test/cassettes/image_find.yml
136
- - test/cassettes/images_all.yml
137
- - test/cassettes/images_all_with_details.yml
138
- - test/cassettes/images_find.yml
139
- - test/cassettes/images_runable.yml
140
- - test/cassettes/images_runable_with_details.yml
141
+ - test/cassettes/image_find_with_decimal.yml
142
+ - test/cassettes/image_find_with_hexadecimal.yml
143
+ - test/cassettes/image_runable.yml
144
+ - test/cassettes/image_runable_with_details.yml
145
+ - test/cassettes/image_update_metadata.yml
146
+ - test/cassettes/image_update_properties.yml
141
147
  - test/lib/ogle/image_test.rb
142
148
  - test/support/test-image
143
149
  - test/test_helper.rb