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
data/lib/occi/pool.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Pool
|
3
|
-
Gets = %w(
|
4
|
-
computes
|
5
|
-
networks
|
6
|
-
storages
|
7
|
-
).map { |v| "#{v}_get" }.freeze
|
8
|
-
|
9
|
-
Posts = %w(
|
10
|
-
computes
|
11
|
-
networks
|
12
|
-
storages
|
13
|
-
).map { |v| "#{v}_post" }.freeze
|
14
|
-
|
15
|
-
##
|
16
|
-
# The _get methods:
|
17
|
-
# Returns the contents of the pool.
|
18
|
-
# 200 OK: An XML representation of the pool in the http body.
|
19
|
-
#
|
20
|
-
# The _post methods:
|
21
|
-
# Request for the creation of an ER. An XML representation of a
|
22
|
-
# VM without the ID element should be passed in the http body.
|
23
|
-
# 201 Created: An XML representation of a ER of type COMPUTE with the ID.
|
24
|
-
|
25
|
-
(Gets + Posts).each do |method|
|
26
|
-
define_method method do |*args|
|
27
|
-
params = args[0] || {}
|
28
|
-
path, verb = method.split("_")
|
29
|
-
|
30
|
-
request.send verb, "/#{path.sub(%r{s$}, '')}", params
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# :method: computes_get
|
36
|
-
|
37
|
-
##
|
38
|
-
# :method: computes_post
|
39
|
-
|
40
|
-
##
|
41
|
-
# :method: networks_get
|
42
|
-
|
43
|
-
##
|
44
|
-
# :method: networks_post
|
45
|
-
|
46
|
-
##
|
47
|
-
# :method: storages_get
|
48
|
-
|
49
|
-
##
|
50
|
-
# :method: storages_post
|
51
|
-
end
|
52
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :get
|
5
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/compute/135
|
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
|
-
- "712"
|
23
|
-
connection:
|
24
|
-
- keep-alive
|
25
|
-
server:
|
26
|
-
- thin 1.2.7 codename No Hup
|
27
|
-
body: <COMPUTE href="http://cm-01.cloud.int.ev1.atti.com:4567/compute/135"><ID>135</ID><NAME>Test Framework</NAME><INSTANCE_TYPE>small</INSTANCE_TYPE><STATE>DONE</STATE><DISK><STORAGE href="http://cm-01.cloud.int.ev1.atti.com:4567/storage/11" name="Centos 5.4 x86_64"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><NIC><NETWORK href="http://cm-01.cloud.int.ev1.atti.com:4567/network/14" name="10.3.172.0"/><IP>10.3.172.25</IP><MAC>02:00:0a:03:ac:19</MAC></NIC><CONTEXT><FILES>/opt/tpkg/opennebula-2.0/../var/opennebula-2.0/templates/context/init.sh</FILES><GATEWAY>10.3.172.1</GATEWAY><HOSTNAME>02:00:0a:03:ac:19</HOSTNAME><IP_PUBLIC>10.3.172.25</IP_PUBLIC><NETMASK>/23</NETMASK><TARGET>hdc</TARGET></CONTEXT></COMPUTE>
|
28
|
-
http_version: "1.1"
|
29
|
-
- !ruby/struct:VCR::HTTPInteraction
|
30
|
-
request: !ruby/struct:VCR::Request
|
31
|
-
method: :get
|
32
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/compute/143
|
33
|
-
body:
|
34
|
-
headers:
|
35
|
-
accept:
|
36
|
-
- application/xml
|
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
|
-
- "715"
|
50
|
-
connection:
|
51
|
-
- keep-alive
|
52
|
-
server:
|
53
|
-
- thin 1.2.7 codename No Hup
|
54
|
-
body: <COMPUTE href="http://cm-01.cloud.int.ev1.atti.com:4567/compute/143"><ID>143</ID><NAME>Test Framework</NAME><INSTANCE_TYPE>small</INSTANCE_TYPE><STATE>PENDING</STATE><DISK><STORAGE href="http://cm-01.cloud.int.ev1.atti.com:4567/storage/11" name="Centos 5.4 x86_64"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><NIC><NETWORK href="http://cm-01.cloud.int.ev1.atti.com:4567/network/14" name="10.3.172.0"/><IP>10.3.172.33</IP><MAC>02:00:0a:03:ac:21</MAC></NIC><CONTEXT><FILES>/opt/tpkg/opennebula-2.0/../var/opennebula-2.0/templates/context/init.sh</FILES><GATEWAY>10.3.172.1</GATEWAY><HOSTNAME>02:00:0a:03:ac:21</HOSTNAME><IP_PUBLIC>10.3.172.33</IP_PUBLIC><NETMASK>/23</NETMASK><TARGET>hdc</TARGET></CONTEXT></COMPUTE>
|
55
|
-
http_version: "1.1"
|
@@ -1,55 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :get
|
5
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/network/19
|
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: 404
|
17
|
-
message: Not Found
|
18
|
-
headers:
|
19
|
-
content-type:
|
20
|
-
- text/html;charset=utf-8
|
21
|
-
content-length:
|
22
|
-
- "44"
|
23
|
-
connection:
|
24
|
-
- keep-alive
|
25
|
-
server:
|
26
|
-
- thin 1.2.7 codename No Hup
|
27
|
-
body: "[VirtualNetworkInfo] Error getting NET [19]."
|
28
|
-
http_version: "1.1"
|
29
|
-
- !ruby/struct:VCR::HTTPInteraction
|
30
|
-
request: !ruby/struct:VCR::Request
|
31
|
-
method: :get
|
32
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/network/21
|
33
|
-
body:
|
34
|
-
headers:
|
35
|
-
accept:
|
36
|
-
- application/xml
|
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
|
-
- "162"
|
50
|
-
connection:
|
51
|
-
- keep-alive
|
52
|
-
server:
|
53
|
-
- thin 1.2.7 codename No Hup
|
54
|
-
body: <NETWORK href="http://cm-01.cloud.int.ev1.atti.com:4567/network/21"><ID>21</ID><NAME>Test Framework</NAME><ADDRESS>192.168.1.1</ADDRESS><SIZE>200</SIZE></NETWORK>
|
55
|
-
http_version: "1.1"
|
@@ -1,55 +0,0 @@
|
|
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/23
|
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: 404
|
17
|
-
message: Not Found
|
18
|
-
headers:
|
19
|
-
content-type:
|
20
|
-
- text/html;charset=utf-8
|
21
|
-
content-length:
|
22
|
-
- "37"
|
23
|
-
connection:
|
24
|
-
- keep-alive
|
25
|
-
server:
|
26
|
-
- thin 1.2.7 codename No Hup
|
27
|
-
body: "[ImageInfo] Error getting IMAGE [23]."
|
28
|
-
http_version: "1.1"
|
29
|
-
- !ruby/struct:VCR::HTTPInteraction
|
30
|
-
request: !ruby/struct:VCR::Request
|
31
|
-
method: :get
|
32
|
-
uri: http://oneadmin:a9464e3228ae563be6207bbf50437a219550f48b@one.example.com:4567/storage/30
|
33
|
-
body:
|
34
|
-
headers:
|
35
|
-
accept:
|
36
|
-
- application/xml
|
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
|
-
- "193"
|
50
|
-
connection:
|
51
|
-
- keep-alive
|
52
|
-
server:
|
53
|
-
- thin 1.2.7 codename No Hup
|
54
|
-
body: <STORAGE href="http://cm-01.cloud.int.ev1.atti.com:4567/storage/30"><ID>30</ID><NAME>Test Framework</NAME><TYPE>OS</TYPE><DESCRIPTION>Test Framework Image.</DESCRIPTION><SIZE>0</SIZE></STORAGE>
|
55
|
-
http_version: "1.1"
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Occi::Entity do
|
4
|
-
Magic_Ids = [
|
5
|
-
cassette_for("computes_post"),
|
6
|
-
cassette_for("networks_post"),
|
7
|
-
cassette_for("storages_post")
|
8
|
-
].map { |ele| ele.xpath('//ID').text }
|
9
|
-
|
10
|
-
Occi::Entity::Gets.each_with_index do |method, i|
|
11
|
-
describe "#{method}/#{Magic_Ids[i]}" do
|
12
|
-
|
13
|
-
it "returns a parsed XML document" do
|
14
|
-
VCR.use_cassette method do
|
15
|
-
response = Connection.send method, Magic_Ids[i]
|
16
|
-
|
17
|
-
is_okay response
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
Occi::Entity::Deletes.each_with_index do |method, i|
|
24
|
-
describe "#{method}/#{Magic_Ids[i]}" do
|
25
|
-
|
26
|
-
it "returns a parsed XML document" do
|
27
|
-
VCR.use_cassette method do
|
28
|
-
response = Connection.send method, Magic_Ids[i]
|
29
|
-
|
30
|
-
is_no_content response
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Magic_Vm = "134"
|
37
|
-
describe "#compute_put/#{Magic_Vm}" do
|
38
|
-
before do
|
39
|
-
@builder = Nokogiri::XML::Builder.new do
|
40
|
-
COMPUTE {
|
41
|
-
STATE "shutdown"
|
42
|
-
}
|
43
|
-
end.to_xml
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns a parsed XML document" do
|
47
|
-
VCR.use_cassette "compute_put" do
|
48
|
-
response = Connection.compute_put Magic_Vm, :body => @builder
|
49
|
-
|
50
|
-
is_accepted response
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/test/lib/occi/pool_test.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Occi::Pool do
|
4
|
-
Occi::Pool::Gets.each do |method|
|
5
|
-
describe "#{method}" do
|
6
|
-
it "returns a parsed XML document" do
|
7
|
-
VCR.use_cassette method do
|
8
|
-
response = Connection.send method
|
9
|
-
|
10
|
-
is_okay response
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#computes_post" do
|
17
|
-
before do
|
18
|
-
##
|
19
|
-
# Adding NETWORK_NAME to the CONTEXT should be reworked.
|
20
|
-
# We want the vm to divine it's IP from its MAC Address on
|
21
|
-
# boot. Then we no longer need the coupling in the XML.
|
22
|
-
# CLOUD-35 open to address this.
|
23
|
-
|
24
|
-
@builder = Nokogiri::XML::Builder.new do
|
25
|
-
COMPUTE {
|
26
|
-
NAME "Test Framework"
|
27
|
-
INSTANCE_TYPE "small"
|
28
|
-
DISK {
|
29
|
-
STORAGE(:href => "http://www.opennebula.org/storage/11")
|
30
|
-
}
|
31
|
-
NIC {
|
32
|
-
NETWORK(:href => "http://www.opennebula.org/network/14")
|
33
|
-
}
|
34
|
-
CONTEXT {
|
35
|
-
NETWORK_NAME "10.3.172.0"
|
36
|
-
}
|
37
|
-
}
|
38
|
-
end.to_xml
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns a parsed XML document" do
|
42
|
-
VCR.use_cassette "computes_post" do
|
43
|
-
response = Connection.computes_post :body => @builder
|
44
|
-
|
45
|
-
is_created response
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#networks_post" do
|
51
|
-
before do
|
52
|
-
@builder = Nokogiri::XML::Builder.new do
|
53
|
-
NETWORK {
|
54
|
-
NAME "Test Framework"
|
55
|
-
ADDRESS "192.168.1.1"
|
56
|
-
SIZE "200"
|
57
|
-
}
|
58
|
-
end.to_xml
|
59
|
-
end
|
60
|
-
|
61
|
-
it "returns a parsed XML document" do
|
62
|
-
VCR.use_cassette "networks_post" do
|
63
|
-
response = Connection.networks_post :body => @builder
|
64
|
-
|
65
|
-
is_created response
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#storages_post" do
|
71
|
-
before do
|
72
|
-
@builder = Nokogiri::XML::Builder.new do
|
73
|
-
STORAGE {
|
74
|
-
NAME "Test Framework"
|
75
|
-
DESCRIPTION "Test Framework Image."
|
76
|
-
TYPE "OS"
|
77
|
-
### Not exactly sure what URL does.
|
78
|
-
URL "file:///dev/null"
|
79
|
-
}
|
80
|
-
end.to_xml
|
81
|
-
|
82
|
-
@upload = {
|
83
|
-
:parts => {
|
84
|
-
:file => "/dev/null",
|
85
|
-
:occixml => @builder,
|
86
|
-
},
|
87
|
-
:content_type => "application/octet-stream"
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns a parsed XML document" do
|
92
|
-
VCR.use_cassette "storages_post" do
|
93
|
-
response = Connection.storages_post :upload => @upload
|
94
|
-
|
95
|
-
is_created response
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|