ogle 0.1.0 → 0.1.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/lib/ogle/image.rb CHANGED
@@ -7,11 +7,11 @@ module Ogle
7
7
  ##
8
8
  # Returns information about images.
9
9
  #
10
- # +verbose+: A Boolean toggling the returning of
11
- # additional image information.
10
+ # +details+: A Boolean toggling the returning of detailed image
11
+ # information.
12
12
 
13
- def all verbose = false
14
- path = verbose ? "/images/detail" : "/images"
13
+ def all details = false
14
+ path = details ? "/images/detail" : "/images"
15
15
 
16
16
  response = @connection.get path
17
17
 
@@ -39,8 +39,14 @@ module Ogle
39
39
  end
40
40
  end
41
41
 
42
- def runable
43
- all.select do |image|
42
+ ##
43
+ # Return only runable images.
44
+ #
45
+ # +details+: A Boolean toggling the returning of detailed image
46
+ # information.
47
+
48
+ def runable details = false
49
+ all(details).select do |image|
44
50
  runable? image
45
51
  end
46
52
  end
data/lib/ogle/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ogle
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,28 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://10.3.170.32:9292/images/detail
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ content-type:
20
+ - text/html; charset=UTF-8
21
+ content-length:
22
+ - "3113"
23
+ date:
24
+ - Wed, 13 Apr 2011 23:30:22 GMT
25
+ connection:
26
+ - keep-alive
27
+ body: "{\"images\": [{\"status\": \"active\", \"name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"deleted\": false, \"container_format\": \"aki\", \"created_at\": \"2011-04-11T17:18:44\", \"disk_format\": \"aki\", \"updated_at\": \"2011-04-11T17:18:44\", \"id\": 1, \"location\": \"file:///var/lib/glance/images/1\", \"checksum\": \"73152adae523a52d481f5150deb30356\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"amd64\", \"version\": \"2.6.35\", \"type\": \"kernel\", \"uploader\": \"root@cc-01\", \"distro\": \"Ubuntu\"}, \"size\": 4408912}, {\"status\": \"active\", \"name\": \"maverick-server-uec-amd64.img\", \"deleted\": false, \"container_format\": \"ami\", \"created_at\": \"2011-04-11T17:18:45\", \"disk_format\": \"ami\", \"updated_at\": \"2011-04-11T17:18:51\", \"id\": 2, \"location\": \"file:///var/lib/glance/images/2\", \"checksum\": \"d2d3b3049f897dff2f86295d5a9e879e\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"1\", \"type\": \"machine\", \"version\": \"10.10\", \"kernel_name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"uploader\": \"root@cc-01\", \"arch\": \"amd64\", \"distro\": \"Ubuntu\"}, \"size\": 1476395008}, {\"status\": \"active\", \"name\": \"CentOS5-5.5-Base_VM-032311-212432\", \"deleted\": false, \"container_format\": \"ami\", \"created_at\": \"2011-04-11T21:04:51\", \"disk_format\": \"ami\", \"updated_at\": \"2011-04-11T21:04:56\", \"id\": 6, \"location\": \"file:///var/lib/glance/images/6\", \"checksum\": \"6277381feb8708c393c64499a0ce7e1e\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"x86_64\", \"version\": \"5.5\", \"type\": \"machine\", \"uploader\": \"root@cc-01\", \"distro\": \"CentOS\"}, \"size\": 816906240}, {\"status\": \"active\", \"name\": \"initrd.img-2.6.28-11-generic\", \"deleted\": false, \"container_format\": \"ari\", \"created_at\": \"2011-04-11T21:18:33\", \"disk_format\": \"ari\", \"updated_at\": \"2011-04-11T21:18:33\", \"id\": 7, \"location\": \"file:///var/lib/glance/images/7\", \"checksum\": \"4ee1b2aa5c15472b41dafe39f4854aac\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"x86_64\", \"type\": \"ramdisk\", \"uploader\": \"root@cc-01\", \"distro\": \"CentOS\"}, \"size\": 8679404}, {\"status\": \"active\", \"name\": \"vmlinuz-2.6.28-11-generic\", \"deleted\": false, \"container_format\": \"aki\", \"created_at\": \"2011-04-11T21:18:34\", \"disk_format\": \"aki\", \"updated_at\": \"2011-04-11T21:18:34\", \"id\": 8, \"location\": \"file:///var/lib/glance/images/8\", \"checksum\": \"d15243d1203d0aecf187ff969d6764ea\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"x86_64\", \"version\": \"2.6.28-11-generic\", \"type\": \"kernel\", \"uploader\": \"root@cc-01\", \"distro\": \"CentOS\"}, \"size\": 3522336}, {\"status\": \"active\", \"name\": \"centos.5-3.x86-64.img\", \"deleted\": false, \"container_format\": \"ami\", \"created_at\": \"2011-04-11T21:18:34\", \"disk_format\": \"ami\", \"updated_at\": \"2011-04-11T21:18:39\", \"id\": 9, \"location\": \"file:///var/lib/glance/images/9\", \"checksum\": \"79523e49084752f61b49398b19831b23\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"8\", \"arch\": \"x86_64\", \"ramdisk_id\": \"7\", \"version\": \"5.3\", \"kernel_name\": \"vmlinuz-2.6.28-11-generic\", \"ramdisk_name\": \"initrd.img-2.6.28-11-generic\", \"uploader\": \"root@cc-01\", \"type\": \"machine\", \"distro\": \"CentOS\"}, \"size\": 1049624576}]}"
28
+ http_version: "1.1"
@@ -18,64 +18,55 @@ describe Ogle::Image do
18
18
  end
19
19
 
20
20
  it "returns a hash of images" do
21
- @response.size.must_be :>=, 5
21
+ @response.size.must_be :>=, 1
22
22
  end
23
23
 
24
24
  it "returns metadata" do
25
- must_have_valid_keys @response.first, %w(
26
- name
27
- container_format
28
- disk_format
29
- checksum
30
- id
31
- size
32
- )
25
+ must_have_valid_keys @response.first, METADATA_KEYS
33
26
  end
34
27
  end
35
28
 
36
- describe "#all true" do
29
+ describe "#all with details" do
37
30
  before do
38
- VCR.use_cassette "images_all_verbose" do
31
+ VCR.use_cassette "images_all_with_details" do
39
32
  @response = CONNECTION.image.all true
40
33
  end
41
34
  end
42
35
 
43
36
  it "returns a detailed hash of images" do
44
- @response.size.must_be :>=, 5
37
+ @response.size.must_be :>=, 1
45
38
  end
46
39
 
47
40
  it "returns metadata" do
48
- must_have_valid_keys @response.first, %w(
49
- status
50
- name
51
- deleted
52
- container_format
53
- created_at
54
- disk_format
55
- updated_at
56
- id
57
- location
58
- checksum
59
- is_public
60
- deleted_at
61
- properties
62
- size
63
- )
41
+ must_have_valid_keys @response.first, DETAILED_METADATA_KEYS
64
42
  end
65
43
  end
66
44
 
67
- ##
68
- # TODO: Make these tests less brittle
69
-
70
- describe "#all runable" do
45
+ describe "#runable" do
71
46
  before do
72
- VCR.use_cassette "images_all_runable" do
47
+ VCR.use_cassette "images_runable" do
73
48
  @response = CONNECTION.image.runable
74
49
  end
75
50
  end
76
51
 
77
52
  it "returns a hash of all images which are runable" do
78
- @response.size.must_be :==, 3
53
+ @response.any? { |i| i['id'] != 1}.must_equal true
54
+ end
55
+
56
+ it "returns metadata" do
57
+ must_have_valid_keys @response.first, METADATA_KEYS
58
+ end
59
+ end
60
+
61
+ describe "#runable with details" do
62
+ before do
63
+ VCR.use_cassette "images_runable_with_details" do
64
+ @response = CONNECTION.image.runable(true)
65
+ end
66
+ end
67
+
68
+ it "returns metadata" do
69
+ must_have_valid_keys @response.first, DETAILED_METADATA_KEYS
79
70
  end
80
71
  end
81
72
 
@@ -86,25 +77,8 @@ describe Ogle::Image do
86
77
  end
87
78
  end
88
79
 
89
- ### TODO: May want to refactor these keys into a variable,
90
- ### TODO: since Images#find verbose shares them.
91
80
  it "returns X-Image-Meta-* headers as a hash" do
92
- must_have_valid_keys @response, %w(
93
- status
94
- name
95
- deleted
96
- container_format
97
- created_at
98
- disk_format
99
- updated_at
100
- id
101
- location
102
- checksum
103
- is_public
104
- deleted_at
105
- properties
106
- size
107
- )
81
+ must_have_valid_keys @response, DETAILED_METADATA_KEYS
108
82
  end
109
83
 
110
84
  it "returns a nested properties hash" do
data/test/test_helper.rb CHANGED
@@ -3,6 +3,31 @@ Bundler.setup :default, :test
3
3
  %w(minitest/spec ogle vcr webmock).each { |r| require r }
4
4
 
5
5
  class MiniTest::Unit::TestCase
6
+ METADATA_KEYS = %w(
7
+ name
8
+ container_format
9
+ disk_format
10
+ checksum
11
+ id
12
+ size
13
+ )
14
+
15
+ DETAILED_METADATA_KEYS = %w(
16
+ status
17
+ name
18
+ deleted
19
+ container_format
20
+ created_at
21
+ disk_format
22
+ updated_at
23
+ id
24
+ location
25
+ checksum
26
+ is_public
27
+ deleted_at
28
+ properties
29
+ size
30
+ )
6
31
  end
7
32
 
8
33
  VCR.config do |c|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ogle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kevin Bringard
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-13 00:00:00 -06:00
13
+ date: 2011-04-14 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -89,9 +89,10 @@ files:
89
89
  - lib/ogle/version.rb
90
90
  - ogle.gemspec
91
91
  - test/cassettes/images_all.yml
92
- - test/cassettes/images_all_runable.yml
93
- - test/cassettes/images_all_verbose.yml
92
+ - test/cassettes/images_all_with_details.yml
94
93
  - test/cassettes/images_find.yml
94
+ - test/cassettes/images_runable.yml
95
+ - test/cassettes/images_runable_with_details.yml
95
96
  - test/lib/ogle/resource_test.rb
96
97
  - test/test_helper.rb
97
98
  has_rdoc: true
@@ -124,8 +125,9 @@ specification_version: 3
124
125
  summary: Ruby interface for OpenStack Glance
125
126
  test_files:
126
127
  - test/cassettes/images_all.yml
127
- - test/cassettes/images_all_runable.yml
128
- - test/cassettes/images_all_verbose.yml
128
+ - test/cassettes/images_all_with_details.yml
129
129
  - test/cassettes/images_find.yml
130
+ - test/cassettes/images_runable.yml
131
+ - test/cassettes/images_runable_with_details.yml
130
132
  - test/lib/ogle/resource_test.rb
131
133
  - test/test_helper.rb