ogle 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,15 +23,15 @@ Depending on the call you make, glance will sometimes return JSON and others XML
23
23
  )
24
24
 
25
25
  # This will give a list of all the images
26
- response = CONNECTION.images.all
26
+ response = CONNECTION.image.all
27
27
  puts response
28
28
 
29
29
  # This will give a detailed list of all the images
30
- response = CONNECTION.images true
30
+ response = CONNECTION.image true
31
31
  puts response
32
32
 
33
33
  # This will return headers for a specific image as a hash
34
- response = CONNECTION.images.find 6
34
+ response = CONNECTION.image.find 6
35
35
  puts response
36
36
 
37
37
  ## Compatability
@@ -41,3 +41,8 @@ ruby 1.9.2
41
41
  ## Testing
42
42
 
43
43
  $ bundle exec rake
44
+
45
+ ## TODOs
46
+
47
+ * Image#all should return all public/runnable images.
48
+ See lib/nephophobia/image.rb#pubic?
data/lib/ogle/image.rb CHANGED
@@ -38,5 +38,20 @@ module Ogle
38
38
  end
39
39
  end
40
40
  end
41
+
42
+ def runable
43
+ all.select do |image|
44
+ runable? image
45
+ end
46
+ end
47
+
48
+ private
49
+ ##
50
+ # Kernels and Ramdisks are not runable, so we want to ignore them.
51
+
52
+ def runable? image
53
+ image['container_format'] == "ami" &&
54
+ image['disk_format'] == "ami"
55
+ end
41
56
  end
42
57
  end
data/lib/ogle/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ogle
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -26,3 +26,30 @@
26
26
  - keep-alive
27
27
  body: "{\"images\": [{\"name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1-initrd\", \"container_format\": \"ari\", \"disk_format\": \"ari\", \"checksum\": \"2d222d406f3ed30e03ed44123c33cba6\", \"id\": 1, \"size\": 5882349}, {\"name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz\", \"container_format\": \"aki\", \"disk_format\": \"aki\", \"checksum\": \"3ed2965d3f8d877a3ee3e061fd648e9a\", \"id\": 2, \"size\": 4404752}, {\"name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1.img\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"10047a119149e08fb206eea89832eee0\", \"id\": 3, \"size\": 25165824}, {\"name\": \"CentOS5-5.5-Base_VM-032311-212432\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"6277381feb8708c393c64499a0ce7e1e\", \"id\": 4, \"size\": 816906240}, {\"name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"container_format\": \"aki\", \"disk_format\": \"aki\", \"checksum\": \"73152adae523a52d481f5150deb30356\", \"id\": 5, \"size\": 4408912}, {\"name\": \"maverick-server-uec-amd64.img\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"d511da81009517c53f36ff4e8602ff62\", \"id\": 6, \"size\": 1476395008}]}"
28
28
  http_version: "1.1"
29
+ - !ruby/struct:VCR::HTTPInteraction
30
+ request: !ruby/struct:VCR::Request
31
+ method: :get
32
+ uri: http://10.3.170.32:9292/images
33
+ body:
34
+ headers:
35
+ accept:
36
+ - application/json
37
+ connection:
38
+ - keep-alive
39
+ keep-alive:
40
+ - 30
41
+ response: !ruby/struct:VCR::Response
42
+ status: !ruby/struct:VCR::ResponseStatus
43
+ code: 200
44
+ message: OK
45
+ headers:
46
+ content-type:
47
+ - text/html; charset=UTF-8
48
+ content-length:
49
+ - "1019"
50
+ date:
51
+ - Wed, 13 Apr 2011 22:32:26 GMT
52
+ connection:
53
+ - keep-alive
54
+ body: "{\"images\": [{\"name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"container_format\": \"aki\", \"disk_format\": \"aki\", \"checksum\": \"73152adae523a52d481f5150deb30356\", \"id\": 1, \"size\": 4408912}, {\"name\": \"maverick-server-uec-amd64.img\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"d2d3b3049f897dff2f86295d5a9e879e\", \"id\": 2, \"size\": 1476395008}, {\"name\": \"CentOS5-5.5-Base_VM-032311-212432\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"6277381feb8708c393c64499a0ce7e1e\", \"id\": 6, \"size\": 816906240}, {\"name\": \"initrd.img-2.6.28-11-generic\", \"container_format\": \"ari\", \"disk_format\": \"ari\", \"checksum\": \"4ee1b2aa5c15472b41dafe39f4854aac\", \"id\": 7, \"size\": 8679404}, {\"name\": \"vmlinuz-2.6.28-11-generic\", \"container_format\": \"aki\", \"disk_format\": \"aki\", \"checksum\": \"d15243d1203d0aecf187ff969d6764ea\", \"id\": 8, \"size\": 3522336}, {\"name\": \"centos.5-3.x86-64.img\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"79523e49084752f61b49398b19831b23\", \"id\": 9, \"size\": 1049624576}]}"
55
+ http_version: "1.1"
@@ -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
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
+ - "1019"
23
+ date:
24
+ - Wed, 13 Apr 2011 22:32:49 GMT
25
+ connection:
26
+ - keep-alive
27
+ body: "{\"images\": [{\"name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"container_format\": \"aki\", \"disk_format\": \"aki\", \"checksum\": \"73152adae523a52d481f5150deb30356\", \"id\": 1, \"size\": 4408912}, {\"name\": \"maverick-server-uec-amd64.img\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"d2d3b3049f897dff2f86295d5a9e879e\", \"id\": 2, \"size\": 1476395008}, {\"name\": \"CentOS5-5.5-Base_VM-032311-212432\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"6277381feb8708c393c64499a0ce7e1e\", \"id\": 6, \"size\": 816906240}, {\"name\": \"initrd.img-2.6.28-11-generic\", \"container_format\": \"ari\", \"disk_format\": \"ari\", \"checksum\": \"4ee1b2aa5c15472b41dafe39f4854aac\", \"id\": 7, \"size\": 8679404}, {\"name\": \"vmlinuz-2.6.28-11-generic\", \"container_format\": \"aki\", \"disk_format\": \"aki\", \"checksum\": \"d15243d1203d0aecf187ff969d6764ea\", \"id\": 8, \"size\": 3522336}, {\"name\": \"centos.5-3.x86-64.img\", \"container_format\": \"ami\", \"disk_format\": \"ami\", \"checksum\": \"79523e49084752f61b49398b19831b23\", \"id\": 9, \"size\": 1049624576}]}"
28
+ http_version: "1.1"
@@ -26,3 +26,30 @@
26
26
  - keep-alive
27
27
  body: "{\"images\": [{\"status\": \"active\", \"name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1-initrd\", \"deleted\": false, \"container_format\": \"ari\", \"created_at\": \"2011-04-06T20:03:11.914270\", \"disk_format\": \"ari\", \"updated_at\": \"2011-04-06T20:03:12.206204\", \"id\": 1, \"location\": \"file:///var/lib/glance/images/1\", \"checksum\": \"2d222d406f3ed30e03ed44123c33cba6\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"amd64\", \"type\": \"ramdisk\", \"uploader\": \"root@e3ab3\", \"distro\": \"ttylinux\"}, \"size\": 5882349}, {\"status\": \"active\", \"name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz\", \"deleted\": false, \"container_format\": \"aki\", \"created_at\": \"2011-04-06T20:03:12.585510\", \"disk_format\": \"aki\", \"updated_at\": \"2011-04-06T20:03:12.846637\", \"id\": 2, \"location\": \"file:///var/lib/glance/images/2\", \"checksum\": \"3ed2965d3f8d877a3ee3e061fd648e9a\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"amd64\", \"version\": \"2.5.35-22_1\", \"type\": \"kernel\", \"uploader\": \"root@e3ab3\", \"distro\": \"ttylinux\"}, \"size\": 4404752}, {\"status\": \"active\", \"name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1.img\", \"deleted\": false, \"container_format\": \"ami\", \"created_at\": \"2011-04-06T20:03:13.227286\", \"disk_format\": \"ami\", \"updated_at\": \"2011-04-06T20:03:13.602220\", \"id\": 3, \"location\": \"file:///var/lib/glance/images/3\", \"checksum\": \"10047a119149e08fb206eea89832eee0\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"2\", \"arch\": \"amd64\", \"ramdisk_id\": \"1\", \"version\": \"1.0\", \"kernel_name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz\", \"ramdisk_name\": \"ttylinux-uec-amd64-12.1_2.6.35-22_1-initrd\", \"uploader\": \"root@e3ab3\", \"type\": \"machine\", \"distro\": \"ttylinux\"}, \"size\": 25165824}, {\"status\": \"active\", \"name\": \"CentOS5-5.5-Base_VM-032311-212432\", \"deleted\": false, \"container_format\": \"ami\", \"created_at\": \"2011-04-06T20:03:59.759260\", \"disk_format\": \"ami\", \"updated_at\": \"2011-04-06T20:04:04.498592\", \"id\": 4, \"location\": \"file:///var/lib/glance/images/4\", \"checksum\": \"6277381feb8708c393c64499a0ce7e1e\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"x86_64\", \"builder\": \"kevin\", \"version\": \"5.5\", \"uploader\": \"root@e3ab3\", \"type\": \"machine\", \"distro\": \"CentOS\"}, \"size\": 816906240}, {\"status\": \"active\", \"name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"deleted\": false, \"container_format\": \"aki\", \"created_at\": \"2011-04-06T20:04:47.984648\", \"disk_format\": \"aki\", \"updated_at\": \"2011-04-06T20:04:48.281538\", \"id\": 5, \"location\": \"file:///var/lib/glance/images/5\", \"checksum\": \"73152adae523a52d481f5150deb30356\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"arch\": \"amd64\", \"version\": \"2.6.32\", \"type\": \"kernel\", \"uploader\": \"root@e3ab3\", \"distro\": \"Ubuntu\"}, \"size\": 4408912}, {\"status\": \"active\", \"name\": \"maverick-server-uec-amd64.img\", \"deleted\": false, \"container_format\": \"ami\", \"created_at\": \"2011-04-06T20:04:48.664176\", \"disk_format\": \"ami\", \"updated_at\": \"2011-04-06T20:04:57.042658\", \"id\": 6, \"location\": \"file:///var/lib/glance/images/6\", \"checksum\": \"d511da81009517c53f36ff4e8602ff62\", \"is_public\": true, \"deleted_at\": null, \"properties\": {\"kernel_id\": \"5\", \"type\": \"machine\", \"version\": \"10.10\", \"kernel_name\": \"maverick-server-uec-amd64-vmlinuz-virtual\", \"uploader\": \"root@e3ab3\", \"arch\": \"amd64\", \"distro\": \"Ubuntu\"}, \"size\": 1476395008}]}"
28
28
  http_version: "1.1"
29
+ - !ruby/struct:VCR::HTTPInteraction
30
+ request: !ruby/struct:VCR::Request
31
+ method: :get
32
+ uri: http://10.3.170.32:9292/images/detail
33
+ body:
34
+ headers:
35
+ accept:
36
+ - application/json
37
+ connection:
38
+ - keep-alive
39
+ keep-alive:
40
+ - 30
41
+ response: !ruby/struct:VCR::Response
42
+ status: !ruby/struct:VCR::ResponseStatus
43
+ code: 200
44
+ message: OK
45
+ headers:
46
+ content-type:
47
+ - text/html; charset=UTF-8
48
+ content-length:
49
+ - "3113"
50
+ date:
51
+ - Wed, 13 Apr 2011 22:32:27 GMT
52
+ connection:
53
+ - keep-alive
54
+ 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}]}"
55
+ http_version: "1.1"
@@ -70,3 +70,70 @@
70
70
  - keep-alive
71
71
  body:
72
72
  http_version: "1.1"
73
+ - !ruby/struct:VCR::HTTPInteraction
74
+ request: !ruby/struct:VCR::Request
75
+ method: :head
76
+ uri: http://10.3.170.32:9292/images/6
77
+ body:
78
+ headers:
79
+ accept:
80
+ - application/json
81
+ connection:
82
+ - keep-alive
83
+ keep-alive:
84
+ - 30
85
+ response: !ruby/struct:VCR::Response
86
+ status: !ruby/struct:VCR::ResponseStatus
87
+ code: 200
88
+ message: OK
89
+ headers:
90
+ content-type:
91
+ - text/html; charset=UTF-8
92
+ content-length:
93
+ - "0"
94
+ x-image-meta-property-distro:
95
+ - CentOS
96
+ x-image-meta-id:
97
+ - "6"
98
+ x-image-meta-property-arch:
99
+ - x86_64
100
+ x-image-meta-deleted:
101
+ - "False"
102
+ x-image-meta-container-format:
103
+ - ami
104
+ x-image-meta-location:
105
+ - file:///var/lib/glance/images/6
106
+ x-image-meta-deleted-at:
107
+ - ""
108
+ x-image-meta-created-at:
109
+ - 2011-04-11T21:04:51
110
+ x-image-meta-size:
111
+ - "816906240"
112
+ x-image-meta-status:
113
+ - active
114
+ x-image-meta-property-type:
115
+ - machine
116
+ x-image-meta-property-uploader:
117
+ - root@cc-01
118
+ x-image-meta-is-public:
119
+ - "True"
120
+ x-image-meta-updated-at:
121
+ - 2011-04-11T21:04:56
122
+ x-image-meta-checksum:
123
+ - 6277381feb8708c393c64499a0ce7e1e
124
+ x-image-meta-property-version:
125
+ - "5.5"
126
+ x-image-meta-disk-format:
127
+ - ami
128
+ x-image-meta-name:
129
+ - CentOS5-5.5-Base_VM-032311-212432
130
+ location:
131
+ - http://10.3.170.32:9292/images/6
132
+ etag:
133
+ - 6277381feb8708c393c64499a0ce7e1e
134
+ date:
135
+ - Wed, 13 Apr 2011 22:32:26 GMT
136
+ connection:
137
+ - keep-alive
138
+ body:
139
+ http_version: "1.1"
@@ -1,7 +1,7 @@
1
1
  require "test_helper"
2
2
 
3
3
  CONNECTION = Ogle::Client.new(
4
- :host => "10.1.170.33"
4
+ :host => "10.3.170.32"
5
5
  )
6
6
 
7
7
  def must_have_valid_keys response, keys
@@ -18,7 +18,7 @@ describe Ogle::Image do
18
18
  end
19
19
 
20
20
  it "returns a hash of images" do
21
- @response.size.must_be :>=, 1
21
+ @response.size.must_be :>=, 5
22
22
  end
23
23
 
24
24
  it "returns metadata" do
@@ -41,7 +41,7 @@ describe Ogle::Image do
41
41
  end
42
42
 
43
43
  it "returns a detailed hash of images" do
44
- @response.size.must_be :>=, 1
44
+ @response.size.must_be :>=, 5
45
45
  end
46
46
 
47
47
  it "returns metadata" do
@@ -64,6 +64,21 @@ describe Ogle::Image do
64
64
  end
65
65
  end
66
66
 
67
+ ##
68
+ # TODO: Make these tests less brittle
69
+
70
+ describe "#all runable" do
71
+ before do
72
+ VCR.use_cassette "images_all_runable" do
73
+ @response = CONNECTION.image.runable
74
+ end
75
+ end
76
+
77
+ it "returns a hash of all images which are runable" do
78
+ @response.size.must_be :==, 3
79
+ end
80
+ end
81
+
67
82
  describe "#find" do
68
83
  before do
69
84
  VCR.use_cassette "images_find" do
data/test/test_helper.rb CHANGED
@@ -8,7 +8,7 @@ end
8
8
  VCR.config do |c|
9
9
  c.stub_with :webmock
10
10
  c.cassette_library_dir = "test/cassettes"
11
- c.default_cassette_options = { :record => :none }
11
+ c.default_cassette_options = { :record => :new_episodes }
12
12
  end
13
13
 
14
14
  MiniTest::Unit.autorun
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ogle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
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-12 00:00:00 -06:00
13
+ date: 2011-04-13 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -89,6 +89,7 @@ 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
92
93
  - test/cassettes/images_all_verbose.yml
93
94
  - test/cassettes/images_find.yml
94
95
  - test/lib/ogle/resource_test.rb
@@ -123,6 +124,7 @@ specification_version: 3
123
124
  summary: Ruby interface for OpenStack Glance
124
125
  test_files:
125
126
  - test/cassettes/images_all.yml
127
+ - test/cassettes/images_all_runable.yml
126
128
  - test/cassettes/images_all_verbose.yml
127
129
  - test/cassettes/images_find.yml
128
130
  - test/lib/ogle/resource_test.rb