occi 1.1.0 → 1.2.0
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/.autotest +21 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -2
- data/README.md +1 -5
- data/VERSION +1 -1
- data/lib/occi/client.rb +13 -12
- data/lib/occi/compute.rb +4 -0
- data/lib/occi/network.rb +4 -0
- data/lib/occi/resource.rb +59 -0
- data/lib/occi/storage.rb +7 -0
- data/occi.gemspec +25 -18
- data/test/fixtures/cassettes/{computes_post.yml → compute_create.yml} +2 -2
- data/test/fixtures/cassettes/compute_delete.yml +1 -22
- data/test/fixtures/cassettes/compute_find.yml +28 -0
- data/test/fixtures/cassettes/{compute_put.yml → compute_update.yml} +3 -3
- data/test/fixtures/cassettes/{networks_get.yml → network_all.yml} +2 -2
- data/test/fixtures/cassettes/{networks_post.yml → network_create.yml} +1 -1
- data/test/fixtures/cassettes/network_delete.yml +1 -1
- data/test/fixtures/cassettes/{computes_get.yml → network_find.yml} +3 -3
- data/test/fixtures/cassettes/{storages_get.yml → storage_all.yml} +3 -3
- data/test/fixtures/cassettes/{storages_post.yml → storage_create.yml} +1 -1
- data/test/fixtures/cassettes/storage_delete.yml +1 -22
- data/test/fixtures/cassettes/storage_find.yml +28 -0
- data/test/lib/occi/compute_test.rb +91 -0
- data/test/lib/occi/network_test.rb +57 -0
- data/test/lib/occi/storage_test.rb +67 -0
- data/test/test_helper.rb +3 -2
- metadata +38 -19
- data/lib/occi/entity.rb +0 -63
- data/lib/occi/pool.rb +0 -52
- data/test/fixtures/cassettes/compute_get.yml +0 -55
- data/test/fixtures/cassettes/network_get.yml +0 -55
- data/test/fixtures/cassettes/storage_get.yml +0 -55
- data/test/lib/occi/entity_test.rb +0 -54
- data/test/lib/occi/pool_test.rb +0 -99
@@ -2,7 +2,7 @@
|
|
2
2
|
- !ruby/struct:VCR::HTTPInteraction
|
3
3
|
request: !ruby/struct:VCR::Request
|
4
4
|
method: :get
|
5
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/
|
5
|
+
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/network
|
6
6
|
body:
|
7
7
|
headers:
|
8
8
|
accept:
|
@@ -19,10 +19,10 @@
|
|
19
19
|
content-type:
|
20
20
|
- text/html;charset=utf-8
|
21
21
|
content-length:
|
22
|
-
- "
|
22
|
+
- "313"
|
23
23
|
connection:
|
24
24
|
- keep-alive
|
25
25
|
server:
|
26
26
|
- thin 1.2.7 codename No Hup
|
27
|
-
body: "<
|
27
|
+
body: "<NETWORK_COLLECTION><NETWORK href=\"http://cm-01.cloud.int.ev1.atti.com:4567/network/23\" name=\"10.3.174.0\"/><NETWORK href=\"http://cm-01.cloud.int.ev1.atti.com:4567/network/25\" name=\"10.3.172.0\"/><NETWORK href=\"http://cm-01.cloud.int.ev1.atti.com:4567/network/26\" name=\"Test Framework\"/></NETWORK_COLLECTION> "
|
28
28
|
http_version: "1.1"
|
@@ -46,5 +46,5 @@
|
|
46
46
|
- keep-alive
|
47
47
|
server:
|
48
48
|
- thin 1.2.7 codename No Hup
|
49
|
-
body: <STORAGE href="http://cm-01.cloud.int.ev1.atti.com:4567/storage/
|
49
|
+
body: <STORAGE href="http://cm-01.cloud.int.ev1.atti.com:4567/storage/39"><ID>39</ID><NAME>Test Framework</NAME><TYPE>OS</TYPE><DESCRIPTION>Test Framework Image.</DESCRIPTION><SIZE>0</SIZE></STORAGE>
|
50
50
|
http_version: "1.1"
|
@@ -2,28 +2,7 @@
|
|
2
2
|
- !ruby/struct:VCR::HTTPInteraction
|
3
3
|
request: !ruby/struct:VCR::Request
|
4
4
|
method: :delete
|
5
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/storage/
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
accept:
|
9
|
-
- application/xml
|
10
|
-
connection:
|
11
|
-
- keep-alive
|
12
|
-
keep-alive:
|
13
|
-
- 30
|
14
|
-
response: !ruby/struct:VCR::Response
|
15
|
-
status: !ruby/struct:VCR::ResponseStatus
|
16
|
-
code: 204
|
17
|
-
message: No Content
|
18
|
-
headers:
|
19
|
-
server:
|
20
|
-
- thin 1.2.7 codename No Hup
|
21
|
-
body:
|
22
|
-
http_version: "1.1"
|
23
|
-
- !ruby/struct:VCR::HTTPInteraction
|
24
|
-
request: !ruby/struct:VCR::Request
|
25
|
-
method: :delete
|
26
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/storage/30
|
5
|
+
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/storage/39
|
27
6
|
body:
|
28
7
|
headers:
|
29
8
|
accept:
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/storage/39
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
|
+
- application/xml
|
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
|
+
- "193"
|
23
|
+
connection:
|
24
|
+
- keep-alive
|
25
|
+
server:
|
26
|
+
- thin 1.2.7 codename No Hup
|
27
|
+
body: <STORAGE href="http://cm-01.cloud.int.ev1.atti.com:4567/storage/39"><ID>39</ID><NAME>Test Framework</NAME><TYPE>OS</TYPE><DESCRIPTION>Test Framework Image.</DESCRIPTION><SIZE>0</SIZE></STORAGE>
|
28
|
+
http_version: "1.1"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Occi::Compute do
|
4
|
+
describe "#all" do
|
5
|
+
#it "returns a parsed XML document" do
|
6
|
+
# VCR.use_cassette "compute_all" do
|
7
|
+
# response = Connection.compute.all
|
8
|
+
|
9
|
+
# is_okay response
|
10
|
+
# end
|
11
|
+
#end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#create" do
|
15
|
+
before do
|
16
|
+
##
|
17
|
+
# Adding NETWORK_NAME to the CONTEXT should be reworked.
|
18
|
+
# We want the vm to divine it's IP from its MAC Address on
|
19
|
+
# boot. Then we no longer need the coupling in the XML.
|
20
|
+
# CLOUD-35 open to address this.
|
21
|
+
|
22
|
+
@builder = Nokogiri::XML::Builder.new do
|
23
|
+
COMPUTE {
|
24
|
+
NAME "Test Framework"
|
25
|
+
INSTANCE_TYPE "small"
|
26
|
+
DISK {
|
27
|
+
STORAGE(:href => "http://www.opennebula.org/storage/11")
|
28
|
+
}
|
29
|
+
NIC {
|
30
|
+
NETWORK(:href => "http://www.opennebula.org/network/25")
|
31
|
+
}
|
32
|
+
CONTEXT {
|
33
|
+
NETWORK_NAME "10.3.172.0"
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end.to_xml
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns a parsed XML document" do
|
40
|
+
VCR.use_cassette "compute_create" do
|
41
|
+
response = Connection.compute.create @builder
|
42
|
+
|
43
|
+
is_created response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#find" do
|
49
|
+
it "returns a parsed XML document" do
|
50
|
+
id = cassette_for("compute_create").xpath('//ID').text
|
51
|
+
|
52
|
+
VCR.use_cassette "compute_find" do
|
53
|
+
response = Connection.compute.find id
|
54
|
+
|
55
|
+
is_okay response
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#delete" do
|
61
|
+
it "returns a parsed XML document" do
|
62
|
+
id = cassette_for("compute_create").xpath('//ID').text
|
63
|
+
|
64
|
+
VCR.use_cassette "compute_delete" do
|
65
|
+
response = Connection.compute.delete id
|
66
|
+
|
67
|
+
is_no_content response
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#update" do
|
73
|
+
before do
|
74
|
+
@builder = Nokogiri::XML::Builder.new do
|
75
|
+
COMPUTE {
|
76
|
+
STATE "shutdown"
|
77
|
+
}
|
78
|
+
end.to_xml
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns a parsed XML document" do
|
82
|
+
id = cassette_for("compute_create").xpath('//ID').text
|
83
|
+
|
84
|
+
VCR.use_cassette "compute_update" do
|
85
|
+
response = Connection.compute.update id, @builder
|
86
|
+
|
87
|
+
is_accepted response
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Occi::Network do
|
4
|
+
describe "#all" do
|
5
|
+
it "returns a parsed XML document" do
|
6
|
+
VCR.use_cassette "network_all" do
|
7
|
+
response = Connection.network.all
|
8
|
+
|
9
|
+
is_okay response
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#create" do
|
15
|
+
before do
|
16
|
+
@builder = Nokogiri::XML::Builder.new do
|
17
|
+
NETWORK {
|
18
|
+
NAME "Test Framework"
|
19
|
+
ADDRESS "192.168.1.1"
|
20
|
+
SIZE "200"
|
21
|
+
}
|
22
|
+
end.to_xml
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns a parsed XML document" do
|
26
|
+
VCR.use_cassette "network_create" do
|
27
|
+
response = Connection.network.create @builder
|
28
|
+
|
29
|
+
is_created response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#find" do
|
35
|
+
it "returns a parsed XML document" do
|
36
|
+
id = cassette_for("network_create").xpath('//ID').text
|
37
|
+
|
38
|
+
VCR.use_cassette "network_find" do
|
39
|
+
response = Connection.network.find id
|
40
|
+
|
41
|
+
is_okay response
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#delete" do
|
47
|
+
it "returns a parsed XML document" do
|
48
|
+
id = cassette_for("network_create").xpath('//ID').text
|
49
|
+
|
50
|
+
VCR.use_cassette "network_delete" do
|
51
|
+
response = Connection.network.delete id
|
52
|
+
|
53
|
+
is_no_content response
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Occi::Storage do
|
4
|
+
describe "#all" do
|
5
|
+
it "returns a parsed XML document" do
|
6
|
+
VCR.use_cassette "storage_all" do
|
7
|
+
response = Connection.network.all
|
8
|
+
|
9
|
+
is_okay response
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#create" do
|
15
|
+
before do
|
16
|
+
@builder = Nokogiri::XML::Builder.new do
|
17
|
+
STORAGE {
|
18
|
+
NAME "Test Framework"
|
19
|
+
DESCRIPTION "Test Framework Image."
|
20
|
+
TYPE "OS"
|
21
|
+
### Not exactly sure what URL does.
|
22
|
+
URL "file:///dev/null"
|
23
|
+
}
|
24
|
+
end.to_xml
|
25
|
+
|
26
|
+
@upload = {
|
27
|
+
:parts => {
|
28
|
+
:file => "/dev/null",
|
29
|
+
:occixml => @builder,
|
30
|
+
},
|
31
|
+
:content_type => "application/octet-stream"
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns a parsed XML document" do
|
36
|
+
VCR.use_cassette "storage_create" do
|
37
|
+
response = Connection.storage.create @upload
|
38
|
+
|
39
|
+
is_created response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#find" do
|
45
|
+
it "returns a parsed XML document" do
|
46
|
+
id = cassette_for("storage_create").xpath('//ID').text
|
47
|
+
|
48
|
+
VCR.use_cassette "storage_find" do
|
49
|
+
response = Connection.storage.find id
|
50
|
+
|
51
|
+
is_okay response
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#delete" do
|
57
|
+
it "returns a parsed XML document" do
|
58
|
+
id = cassette_for("storage_create").xpath('//ID').text
|
59
|
+
|
60
|
+
VCR.use_cassette "storage_delete" do
|
61
|
+
response = Connection.storage.delete id
|
62
|
+
|
63
|
+
is_no_content response
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
require "bundler"
|
1
2
|
Bundler.setup :default, :test
|
2
3
|
|
3
|
-
%w(minitest/spec nokogiri vcr webmock occi).each { |r| require r }
|
4
|
+
%w(minitest/autorun minitest/spec nokogiri vcr webmock occi).each { |r| require r }
|
4
5
|
|
5
6
|
class MiniTest::Unit::TestCase
|
6
7
|
Connection = Occi::Client.new(
|
@@ -41,7 +42,7 @@ WebMock.disable_net_connect! :allow => "one.example.com"
|
|
41
42
|
VCR.config do |c|
|
42
43
|
c.stub_with :webmock
|
43
44
|
c.cassette_library_dir = "test/fixtures/cassettes"
|
44
|
-
c.default_cassette_options = { :record => :
|
45
|
+
c.default_cassette_options = { :record => :none }
|
45
46
|
end
|
46
47
|
|
47
48
|
MiniTest::Unit.autorun
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- retr0h
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-06 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -135,6 +135,21 @@ dependencies:
|
|
135
135
|
type: :development
|
136
136
|
prerelease: false
|
137
137
|
version_requirements: *id008
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: ZenTest
|
140
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
segments:
|
146
|
+
- 4
|
147
|
+
- 4
|
148
|
+
- 2
|
149
|
+
version: 4.4.2
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: *id009
|
138
153
|
description:
|
139
154
|
email: john@dewey.ws
|
140
155
|
executables: []
|
@@ -145,6 +160,7 @@ extra_rdoc_files:
|
|
145
160
|
- LICENSE
|
146
161
|
- README.md
|
147
162
|
files:
|
163
|
+
- .autotest
|
148
164
|
- .rvmrc
|
149
165
|
- Gemfile
|
150
166
|
- Gemfile.lock
|
@@ -154,24 +170,26 @@ files:
|
|
154
170
|
- VERSION
|
155
171
|
- lib/occi.rb
|
156
172
|
- lib/occi/client.rb
|
157
|
-
- lib/occi/
|
158
|
-
- lib/occi/
|
173
|
+
- lib/occi/compute.rb
|
174
|
+
- lib/occi/network.rb
|
175
|
+
- lib/occi/resource.rb
|
176
|
+
- lib/occi/storage.rb
|
159
177
|
- occi.gemspec
|
178
|
+
- test/fixtures/cassettes/compute_create.yml
|
160
179
|
- test/fixtures/cassettes/compute_delete.yml
|
161
|
-
- test/fixtures/cassettes/
|
162
|
-
- test/fixtures/cassettes/
|
163
|
-
- test/fixtures/cassettes/
|
164
|
-
- test/fixtures/cassettes/
|
180
|
+
- test/fixtures/cassettes/compute_find.yml
|
181
|
+
- test/fixtures/cassettes/compute_update.yml
|
182
|
+
- test/fixtures/cassettes/network_all.yml
|
183
|
+
- test/fixtures/cassettes/network_create.yml
|
165
184
|
- test/fixtures/cassettes/network_delete.yml
|
166
|
-
- test/fixtures/cassettes/
|
167
|
-
- test/fixtures/cassettes/
|
168
|
-
- test/fixtures/cassettes/
|
185
|
+
- test/fixtures/cassettes/network_find.yml
|
186
|
+
- test/fixtures/cassettes/storage_all.yml
|
187
|
+
- test/fixtures/cassettes/storage_create.yml
|
169
188
|
- test/fixtures/cassettes/storage_delete.yml
|
170
|
-
- test/fixtures/cassettes/
|
171
|
-
- test/
|
172
|
-
- test/
|
173
|
-
- test/lib/occi/
|
174
|
-
- test/lib/occi/pool_test.rb
|
189
|
+
- test/fixtures/cassettes/storage_find.yml
|
190
|
+
- test/lib/occi/compute_test.rb
|
191
|
+
- test/lib/occi/network_test.rb
|
192
|
+
- test/lib/occi/storage_test.rb
|
175
193
|
- test/test_helper.rb
|
176
194
|
has_rdoc: true
|
177
195
|
homepage: http://github.com/retr0h/occi
|
@@ -206,6 +224,7 @@ signing_key:
|
|
206
224
|
specification_version: 3
|
207
225
|
summary: Ruby bindings to Open Cloud Computing Interface (OCCI).
|
208
226
|
test_files:
|
209
|
-
- test/lib/occi/
|
210
|
-
- test/lib/occi/
|
227
|
+
- test/lib/occi/compute_test.rb
|
228
|
+
- test/lib/occi/network_test.rb
|
229
|
+
- test/lib/occi/storage_test.rb
|
211
230
|
- test/test_helper.rb
|
data/lib/occi/entity.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Entity
|
3
|
-
Gets = %w(
|
4
|
-
compute
|
5
|
-
network
|
6
|
-
storage
|
7
|
-
).map { |v| "#{v}_get" }.freeze
|
8
|
-
|
9
|
-
Deletes = %w(
|
10
|
-
compute
|
11
|
-
network
|
12
|
-
storage
|
13
|
-
).map { |v| "#{v}_delete" }.freeze
|
14
|
-
|
15
|
-
Puts = %w(
|
16
|
-
compute
|
17
|
-
).map { |v| "#{v}_put" }.freeze
|
18
|
-
|
19
|
-
##
|
20
|
-
# The _get methods:
|
21
|
-
# Returns the representation of the Compute resource identified by +compute_id+.
|
22
|
-
# 200 OK: An XML representation of the pool in the http body.
|
23
|
-
#
|
24
|
-
# The _delete methods:
|
25
|
-
# Deletes the Compute resource identified by +compute_id+.
|
26
|
-
# 204 No Content : The Compute has been successfully deleted.
|
27
|
-
#
|
28
|
-
# The _put methods:
|
29
|
-
# Update request for a Compute identified by +compute_id+.
|
30
|
-
# 202 Accepted : The update request is being process, polling required to confirm update.
|
31
|
-
|
32
|
-
(Gets + Deletes + Puts).each do |method|
|
33
|
-
define_method method do |*args|
|
34
|
-
id = args[0]
|
35
|
-
params = args[1] || {}
|
36
|
-
path, verb = method.split("_")
|
37
|
-
|
38
|
-
request.send verb, "/#{path}/#{id}", params
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# :method: compute_get
|
44
|
-
|
45
|
-
##
|
46
|
-
# :method: compute_delete
|
47
|
-
|
48
|
-
##
|
49
|
-
# :method: compute_put
|
50
|
-
|
51
|
-
##
|
52
|
-
# :method: network_get
|
53
|
-
|
54
|
-
##
|
55
|
-
# :method: network_delete
|
56
|
-
|
57
|
-
##
|
58
|
-
# :method: storage_get
|
59
|
-
|
60
|
-
##
|
61
|
-
# :method: storage_delete
|
62
|
-
end
|
63
|
-
end
|