occi 2.5.19 → 3.0.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +3 -1
- data/AUTHORS +4 -3
- data/Gemfile +9 -0
- data/Gemfile.lock +64 -21
- data/README.md +19 -14
- data/Rakefile +12 -8
- data/Test Results - discovery_interface.html +862 -0
- data/bin/occi +333 -83
- data/examples/dsl_example.rb +6 -6
- data/examples/x509auth_example.rb +6 -6
- data/features/common/step_definitions/common_steps.rb +32 -0
- data/features/occi/core/create/create.feature +17 -0
- data/features/occi/core/create/step_definitions/create_steps.rb +0 -0
- data/features/occi/core/delete/delete.feature +14 -0
- data/features/occi/core/delete/step_definitions/delete_steps.rb +0 -0
- data/features/occi/core/discovery_interface/discovery_interface.feature +35 -0
- data/features/occi/core/discovery_interface/step_definitions/discovery_interface_steps.rb +19 -0
- data/features/occi/core/miscellaneous/miscellaneous.feature +14 -0
- data/features/occi/core/miscellaneous/step_definitions/miscellaneous_steps.rb +0 -0
- data/features/occi/core/read/read.feature +14 -0
- data/features/occi/core/read/step_definitions/read_steps.rb +0 -0
- data/features/occi/core/update/step_definitions/update_steps.rb +0 -0
- data/features/occi/core/update/update.feature +14 -0
- data/features/occi/infrastructure/create/create.feature +14 -0
- data/features/occi/infrastructure/create/step_definitions/create_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/occi.rb +29 -3
- data/lib/occi/api/client/client_amqp.rb +756 -0
- data/lib/occi/api/client/client_http.rb +922 -0
- data/lib/occi/api/client/http/httparty_fix.rb +53 -0
- data/lib/occi/api/client/http/net_http_fix.rb +46 -0
- data/lib/occi/api/dsl.rb +77 -73
- data/lib/occi/bin/helpers.rb +91 -0
- data/lib/occi/bin/occi_opts.rb +251 -0
- data/lib/occi/bin/resource_output_factory.rb +90 -0
- data/lib/occi/bin/templates/compute.erb +15 -0
- data/lib/occi/bin/templates/network.erb +11 -0
- data/lib/occi/bin/templates/os_tpl.erb +9 -0
- data/lib/occi/bin/templates/resource_tpl.erb +9 -0
- data/lib/occi/bin/templates/storage.erb +10 -0
- data/lib/occi/collection.rb +122 -25
- data/lib/occi/core.rb +18 -9
- data/lib/occi/core/action.rb +20 -4
- data/lib/occi/core/action_instance.rb +24 -0
- data/lib/occi/core/actions.rb +22 -0
- data/lib/occi/core/attribute_properties.rb +33 -84
- data/lib/occi/core/attributes.rb +32 -14
- data/lib/occi/core/categories.rb +46 -0
- data/lib/occi/core/category.rb +94 -20
- data/lib/occi/core/entities.rb +50 -0
- data/lib/occi/core/entity.rb +130 -89
- data/lib/occi/core/kind.rb +28 -35
- data/lib/occi/core/kinds.rb +22 -0
- data/lib/occi/core/link.rb +43 -40
- data/lib/occi/core/links.rb +34 -0
- data/lib/occi/core/mixin.rb +28 -23
- data/lib/occi/core/mixins.rb +22 -0
- data/lib/occi/core/related.rb +20 -0
- data/lib/occi/core/resource.rb +40 -40
- data/lib/occi/core/resources.rb +14 -0
- data/lib/occi/infrastructure.rb +27 -0
- data/lib/occi/infrastructure/compute.rb +159 -0
- data/lib/occi/infrastructure/network.rb +131 -0
- data/lib/occi/infrastructure/network/ipnetwork.rb +34 -0
- data/lib/occi/infrastructure/networkinterface.rb +124 -0
- data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +34 -0
- data/lib/occi/infrastructure/os_tpl.rb +19 -0
- data/lib/occi/infrastructure/resource_tpl.rb +19 -0
- data/lib/occi/infrastructure/storage.rb +96 -0
- data/lib/occi/infrastructure/storagelink.rb +73 -0
- data/lib/occi/log.rb +6 -2
- data/lib/occi/model.rb +38 -70
- data/lib/occi/parser.rb +108 -88
- data/lib/occi/version.rb +2 -2
- data/lib/occiantlr/OCCIANTLR.g +6 -5
- data/lib/occiantlr/OCCIANTLRLexer.rb +52 -52
- data/lib/occiantlr/OCCIANTLRParser.rb +678 -569
- data/lib/occiantlr/README.md +1 -1
- data/occi.gemspec +2 -1
- data/spec/cassettes/client_http_text_plain.yml +1066 -0
- data/spec/occi/api/client/client_amqp_spec.rb +148 -0
- data/spec/occi/api/client/client_http_0.5_spec.rb +292 -0
- data/spec/occi/api/client/client_http_spec.rb +259 -0
- data/spec/occi/api/dsl_spec.rb +0 -0
- data/spec/occi/collection_spec.rb +23 -10
- data/spec/occi/core/categories_spec.rb +30 -0
- data/spec/occi/core/category_spec.rb +41 -0
- data/spec/occi/core/entity_spec.rb +52 -0
- data/spec/occi/core/resource_spec.rb +21 -0
- data/spec/occi/infrastructure/compute_spec.rb +32 -0
- data/spec/occi/log_spec.rb +10 -10
- data/spec/occi/model_spec.rb +24 -24
- data/spec/occi/parser_spec.rb +89 -39
- data/spec/occi/test.json +22 -58
- data/spec/occiantlr/parser_spec.rb +5 -7
- data/spec/spec_helper.rb +13 -3
- metadata +116 -19
- data/etc/model/infrastructure/compute.json +0 -108
- data/etc/model/infrastructure/ipnetwork.json +0 -40
- data/etc/model/infrastructure/ipnetworkinterface.json +0 -40
- data/etc/model/infrastructure/network.json +0 -55
- data/etc/model/infrastructure/networkinterface.json +0 -38
- data/etc/model/infrastructure/os_template.json +0 -9
- data/etc/model/infrastructure/resource_template.json +0 -9
- data/etc/model/infrastructure/storage.json +0 -72
- data/etc/model/infrastructure/storagelink.json +0 -38
- data/lib/occi/api/client.rb +0 -596
- data/lib/occi/client/occiopts.rb +0 -146
- data/spec/occi/client_spec.rb +0 -12
File without changes
|
@@ -1,19 +1,32 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'occi'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Occi
|
5
5
|
describe Collection do
|
6
|
-
describe "initialize" do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
it "should create a new Occi collection including the Occi base objects" do
|
8
|
+
collection = Occi::Collection.new
|
9
|
+
collection.kinds << "http://schemas.ogf.org/occi/infrastructure#compute"
|
10
|
+
collection.mixins << "http://example.com/occi/tags#my_mixin"
|
11
|
+
collection.actions << "http://schemas.ogf.org/occi/infrastructure/compute/action#start"
|
12
|
+
collection.action = Occi::Core::Action_instance.new
|
13
|
+
collection.resources << Occi::Core::Resource.new
|
14
|
+
collection.links << Occi::Core::Link.new
|
15
|
+
collection.kinds.first.should be_kind_of Occi::Core::Kind
|
16
|
+
collection.mixins.first.should be_kind_of Occi::Core::Mixin
|
17
|
+
collection.actions.first.should be_kind_of Occi::Core::Action
|
18
|
+
collection.resources.first.should be_kind_of Occi::Core::Resource
|
19
|
+
collection.links.first.should be_kind_of Occi::Core::Link
|
20
|
+
collection.action.should be_kind_of Occi::Core::Action_instance
|
21
|
+
end
|
16
22
|
|
23
|
+
it "registers a model, creates a new OCCI Resource and checks it against the model" do
|
24
|
+
collection = Occi::Collection.new
|
25
|
+
collection.model.should be_kind_of Occi::Model
|
26
|
+
collection.resources.create 'http://schemas.ogf.org/occi/core#resource'
|
27
|
+
collection.resources.first.should be_kind_of Occi::Core::Resource
|
28
|
+
expect { collection.check }.to_not raise_error
|
17
29
|
end
|
30
|
+
|
18
31
|
end
|
19
32
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'occi'
|
3
|
+
|
4
|
+
module Occi
|
5
|
+
module Core
|
6
|
+
describe Categories do
|
7
|
+
|
8
|
+
it "replaces an existing category instance when a model is added with the instance from the model" do
|
9
|
+
categories = Occi::Core::Categories.new
|
10
|
+
categories << Occi::Core::Resource.kind
|
11
|
+
model = Occi::Model.new
|
12
|
+
resource = model.get_by_id Occi::Core::Resource.type_identifier
|
13
|
+
resource.location = '/new_location/'
|
14
|
+
categories.model = model
|
15
|
+
categories.first.location.should == '/new_location/'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "replaces a category string when a model is added with the instance from the model" do
|
19
|
+
categories = Occi::Core::Categories.new
|
20
|
+
categories << Occi::Core::Resource.type_identifier
|
21
|
+
model = Occi::Model.new
|
22
|
+
resource = model.get_by_id Occi::Core::Resource.type_identifier
|
23
|
+
resource.location = '/new_location/'
|
24
|
+
categories.model = model
|
25
|
+
categories.first.location.should == '/new_location/'
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require 'occi'
|
3
|
+
|
4
|
+
module Occi
|
5
|
+
module Core
|
6
|
+
describe Category do
|
7
|
+
|
8
|
+
it "gets OCCI Resource class by term and scheme" do
|
9
|
+
scheme = 'http://schemas.ogf.org/occi/core'
|
10
|
+
term = 'resource'
|
11
|
+
klass = Occi::Core::Category.get_class scheme, term
|
12
|
+
klass.should be Occi::Core::Resource
|
13
|
+
klass.superclass.should be Occi::Core::Entity
|
14
|
+
end
|
15
|
+
|
16
|
+
it "gets non predefined OCCI class by term, scheme and related class" do
|
17
|
+
scheme = 'http://example.com/occi'
|
18
|
+
term = 'test'
|
19
|
+
related = ['http://schemas.ogf.org/occi/core#resource']
|
20
|
+
klass = Occi::Core::Category.get_class scheme, term, related
|
21
|
+
klass.should be Com::Example::Occi::Test
|
22
|
+
klass.superclass.should be Occi::Core::Resource
|
23
|
+
end
|
24
|
+
|
25
|
+
it "does not get OCCI class by term and scheme if it relates to existing class not derived from OCCI Entity" do
|
26
|
+
scheme = 'http://hashie/'
|
27
|
+
term = 'mash'
|
28
|
+
related = ['http://schemas.ogf.org/occi/core#resource']
|
29
|
+
expect { Occi::Core::Category.get_class scheme, term, related }.to raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it "checks if the category is related to another category" do
|
33
|
+
category = Occi::Core::Resource.kind
|
34
|
+
category.related_to?(Occi::Core::Entity.kind).should be true
|
35
|
+
end
|
36
|
+
|
37
|
+
# rendering
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require 'occi'
|
3
|
+
|
4
|
+
module Occi
|
5
|
+
module Core
|
6
|
+
describe Entity do
|
7
|
+
|
8
|
+
it "initializes itself successfully" do
|
9
|
+
entity = Occi::Core::Entity.new
|
10
|
+
entity.should be_kind_of Occi::Core::Entity
|
11
|
+
end
|
12
|
+
|
13
|
+
it "initializes a subclass successfully using a type identifier" do
|
14
|
+
type_identifier = 'http://example.com/testnamespace#test'
|
15
|
+
entity = Occi::Core::Entity.new type_identifier
|
16
|
+
entity.should be_kind_of 'Com::Example::Testnamespace::Test'.constantize
|
17
|
+
entity.kind.type_identifier.should == type_identifier
|
18
|
+
entity.kind.related.first.should == Occi::Core::Entity.kind
|
19
|
+
end
|
20
|
+
|
21
|
+
it "initializes a subclass successfully using an OCCI Kind" do
|
22
|
+
kind = Occi::Core::Resource.kind
|
23
|
+
entity = Occi::Core::Entity.new kind
|
24
|
+
entity.should be_kind_of Occi::Core::Resource
|
25
|
+
entity.kind.type_identifier.should == Occi::Core::Resource.type_identifier
|
26
|
+
entity.kind.related.first.should == Occi::Core::Entity.kind
|
27
|
+
end
|
28
|
+
|
29
|
+
it "converts mixin type identifiers to objects if a mixin is added to the entities mixins" do
|
30
|
+
mixin = 'http://example.com/mynamespace#mymixin'
|
31
|
+
entity = Occi::Core::Entity.new
|
32
|
+
entity.mixins << mixin
|
33
|
+
entity.mixins.first.to_s.should == mixin
|
34
|
+
end
|
35
|
+
|
36
|
+
# TODO: check adding of model
|
37
|
+
it "checks the attributes against their definition in its kind and associated mixins" do
|
38
|
+
entity = Occi::Core::Entity.new
|
39
|
+
expect { entity.check }.to raise_error
|
40
|
+
entity.model = Occi::Model.new
|
41
|
+
entity.title = 'test'
|
42
|
+
uuid = UUIDTools::UUID.random_create.to_s
|
43
|
+
entity.id = uuid
|
44
|
+
expect { entity.check }.to_not raise_error
|
45
|
+
entity.id = 0
|
46
|
+
expect { entity.check }.to raise_error
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require 'occi'
|
3
|
+
|
4
|
+
module Occi
|
5
|
+
module Core
|
6
|
+
describe Resource do
|
7
|
+
|
8
|
+
it "should link another resource succesfully" do
|
9
|
+
resource = Occi::Core::Resource.new
|
10
|
+
target = Occi::Core::Resource.new
|
11
|
+
# create a random ID as the resource must already exist and therefore must have an ID assigned
|
12
|
+
target.id = UUIDTools::UUID.random_create.to_s
|
13
|
+
resource.link target
|
14
|
+
resource.links.should have(1).link
|
15
|
+
resource.links.first.should be_kind_of Occi::Core::Link
|
16
|
+
resource.links.first.target.should be target
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'occi'
|
3
|
+
|
4
|
+
module Occi
|
5
|
+
module Infrastructure
|
6
|
+
describe Compute do
|
7
|
+
|
8
|
+
it "should create a storagelink to an existing storage resource" do
|
9
|
+
compute = Occi::Infrastructure::Compute.new
|
10
|
+
target = Occi::Infrastructure::Storage.new
|
11
|
+
# create a random ID as the storage resource must already exist and therefore must have an ID assigned
|
12
|
+
target.id = UUIDTools::UUID.random_create.to_s
|
13
|
+
compute.storagelink target
|
14
|
+
compute.links.should have(1).link
|
15
|
+
compute.links.first.should be_kind_of Occi::Infrastructure::Storagelink
|
16
|
+
compute.links.first.target.should be target
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create a networkinterface to an existing network resource" do
|
20
|
+
compute = Occi::Infrastructure::Compute.new
|
21
|
+
target = Occi::Infrastructure::Network.new
|
22
|
+
# create a random ID as the network resource must already exist and therefore must have an ID assigned
|
23
|
+
target.id = UUIDTools::UUID.random_create.to_s
|
24
|
+
compute.networkinterface target
|
25
|
+
compute.links.should have(1).link
|
26
|
+
compute.links.first.should be_kind_of Occi::Infrastructure::Networkinterface
|
27
|
+
compute.links.first.target.should be target
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/occi/log_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require "rspec"
|
2
2
|
require 'occi/log'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Occi
|
5
5
|
describe Log do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
7
|
+
it "should log a message to a pipe" do
|
8
|
+
r, w = IO.pipe
|
9
|
+
logger = Occi::Log.new(w)
|
10
|
+
logger.level = Occi::Log::INFO
|
11
|
+
Occi::Log.info("Test")
|
12
|
+
r.readline.include?("Test")
|
13
|
+
logger.close
|
15
14
|
end
|
15
|
+
|
16
16
|
end
|
17
|
-
end
|
17
|
+
end
|
data/spec/occi/model_spec.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
require "rspec"
|
2
|
-
require 'occi
|
2
|
+
require 'occi'
|
3
3
|
|
4
4
|
describe "Model" do
|
5
5
|
|
6
6
|
it "initializes Core Model successfully" do
|
7
|
-
model =
|
8
|
-
model.get_by_id('http://schemas.ogf.org/occi/core#entity').should be_kind_of
|
9
|
-
model.get_by_id('http://schemas.ogf.org/occi/core#resource').should be_kind_of
|
10
|
-
model.get_by_id('http://schemas.ogf.org/occi/core#link').should be_kind_of
|
7
|
+
model = Occi::Model.new
|
8
|
+
model.get_by_id('http://schemas.ogf.org/occi/core#entity').should be_kind_of Occi::Core::Kind
|
9
|
+
model.get_by_id('http://schemas.ogf.org/occi/core#resource').should be_kind_of Occi::Core::Kind
|
10
|
+
model.get_by_id('http://schemas.ogf.org/occi/core#link').should be_kind_of Occi::Core::Kind
|
11
11
|
end
|
12
12
|
|
13
13
|
it "initializes Infrastructure Model successfully" do
|
14
|
-
model =
|
14
|
+
model = Occi::Model.new
|
15
15
|
model.register_infrastructure
|
16
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#compute').should be_kind_of
|
17
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#os_tpl').should be_kind_of
|
18
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#resource_tpl').should be_kind_of
|
19
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#network').should be_kind_of
|
20
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure/network#ipnetwork').should be_kind_of
|
21
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#networkinterface').should be_kind_of
|
22
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface').should be_kind_of
|
23
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#storage').should be_kind_of
|
24
|
-
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#storagelink').should be_kind_of
|
16
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#compute').should be_kind_of Occi::Core::Kind
|
17
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#os_tpl').should be_kind_of Occi::Core::Mixin
|
18
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#resource_tpl').should be_kind_of Occi::Core::Mixin
|
19
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#network').should be_kind_of Occi::Core::Kind
|
20
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure/network#ipnetwork').should be_kind_of Occi::Core::Mixin
|
21
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#networkinterface').should be_kind_of Occi::Core::Kind
|
22
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface').should be_kind_of Occi::Core::Mixin
|
23
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#storage').should be_kind_of Occi::Core::Kind
|
24
|
+
model.get_by_id('http://schemas.ogf.org/occi/infrastructure#storagelink').should be_kind_of Occi::Core::Kind
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns all registered categories" do
|
28
|
-
model =
|
28
|
+
model = Occi::Model.new
|
29
29
|
collection = model.get
|
30
|
-
collection.kind_of?
|
30
|
+
collection.kind_of? Occi::Collection
|
31
31
|
collection.kinds.should have(3).kinds
|
32
32
|
collection.mixins.should be_empty
|
33
33
|
collection.actions.should be_empty
|
@@ -36,17 +36,17 @@ describe "Model" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns categories with filter" do
|
39
|
-
model =
|
39
|
+
model = Occi::Model.new
|
40
40
|
model.register_infrastructure
|
41
|
-
compute =
|
42
|
-
ipnetwork =
|
43
|
-
filter =
|
41
|
+
compute = Occi::Core::Kind.new('http://schemas.ogf.org/occi/infrastructure#','compute')
|
42
|
+
ipnetwork = Occi::Core::Mixin.new('http://schemas.ogf.org/occi/infrastructure/network#','ipnetwork')
|
43
|
+
filter = Occi::Collection.new
|
44
44
|
filter.kinds << compute
|
45
45
|
filter.mixins << ipnetwork
|
46
46
|
collection = model.get(filter)
|
47
|
-
collection.kind_of?
|
48
|
-
collection.kinds.first.attributes.should be_kind_of
|
49
|
-
collection.mixins.first.attributes.should be_kind_of
|
47
|
+
collection.kind_of? Occi::Collection
|
48
|
+
collection.kinds.first.attributes.should be_kind_of Occi::Core::Attributes
|
49
|
+
collection.mixins.first.attributes.should be_kind_of Occi::Core::Attributes
|
50
50
|
collection.actions.should be_empty
|
51
51
|
collection.resources.should be_empty
|
52
52
|
collection.links.should be_empty
|
data/spec/occi/parser_spec.rb
CHANGED
@@ -1,64 +1,114 @@
|
|
1
1
|
require "rspec"
|
2
|
-
require 'occi
|
2
|
+
require 'occi'
|
3
3
|
|
4
4
|
describe "Parser" do
|
5
5
|
|
6
|
-
it "should parse OCCI message with
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
collection.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
it "should parse an OCCI message with MIME type text/plain containing an OCCI resource" do
|
7
|
+
# create new collection
|
8
|
+
collection = Occi::Collection.new
|
9
|
+
# create new resource within collection
|
10
|
+
resource = collection.resources.create
|
11
|
+
|
12
|
+
# render collection to text/plain MIME type
|
13
|
+
rendered_collection = collection.to_text
|
14
|
+
# parse rendered collection and compare with original collection
|
15
|
+
Occi::Parser.parse('text/plain',rendered_collection).should == collection
|
16
|
+
|
17
|
+
# add attributes to resource
|
18
|
+
resource.id = UUIDTools::UUID.random_create.to_s
|
19
|
+
resource.title = 'title'
|
20
|
+
|
21
|
+
# render collection to text/plain MIME type
|
22
|
+
rendered_collection = collection.to_text
|
23
|
+
# parse rendered collection and compare with original collection
|
24
|
+
Occi::Parser.parse('text/plain',rendered_collection).should == collection
|
25
|
+
|
26
|
+
# add mixin to resource
|
27
|
+
resource.mixins << Occi::Core::Mixin.new
|
28
|
+
|
29
|
+
# render collection to text/plain MIME type
|
30
|
+
rendered_collection = collection.to_text
|
31
|
+
# parse rendered collection and compare with original collection
|
32
|
+
Occi::Parser.parse('text/plain',rendered_collection).should == collection
|
33
|
+
|
34
|
+
# add link to resource
|
35
|
+
link = resource.links.create
|
36
|
+
link.target = 'http://example.com/resource/aee5acf5-71de-40b0-bd1c-2284658bfd0e'
|
37
|
+
|
38
|
+
# render collection to text/plain MIME type
|
39
|
+
rendered_collection = collection.to_text
|
40
|
+
# parse rendered collection and compare with original collection
|
41
|
+
Occi::Parser.parse('text/plain',rendered_collection).should == collection
|
15
42
|
end
|
16
43
|
|
17
|
-
it "should parse OCCI message with
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
44
|
+
it "should parse an OCCI message with MIME type application/occi+json containing an OCCI resource" do
|
45
|
+
# create new collection
|
46
|
+
collection = Occi::Collection.new
|
47
|
+
# create new resource within collection
|
48
|
+
resource = collection.resources.create
|
49
|
+
|
50
|
+
# render collection to text/plain MIME type
|
51
|
+
rendered_collection = collection.to_json
|
52
|
+
# parse rendered collection and compare with original collection
|
53
|
+
Occi::Parser.parse('application/occi+json',rendered_collection).should == collection
|
54
|
+
|
55
|
+
# add attributes to resource
|
56
|
+
resource.id = UUIDTools::UUID.random_create.to_s
|
57
|
+
resource.title = 'title'
|
58
|
+
|
59
|
+
# render collection to text/plain MIME type
|
60
|
+
rendered_collection = collection.to_json
|
61
|
+
# parse rendered collection and compare with original collection
|
62
|
+
Occi::Parser.parse('application/occi+json',rendered_collection).should == collection
|
63
|
+
|
64
|
+
# add mixin to resource
|
65
|
+
resource.mixins << Occi::Core::Mixin.new
|
66
|
+
|
67
|
+
# render collection to text/plain MIME type
|
68
|
+
rendered_collection = collection.to_json
|
69
|
+
# parse rendered collection and compare with original collection
|
70
|
+
Occi::Parser.parse('application/occi+json',rendered_collection).should == collection
|
71
|
+
|
72
|
+
# add link to resource
|
73
|
+
link = resource.links.create
|
74
|
+
link.target = 'http://example.com/resource/aee5acf5-71de-40b0-bd1c-2284658bfd0e'
|
75
|
+
|
76
|
+
# render collection to text/plain MIME type
|
77
|
+
rendered_collection = collection.to_json
|
78
|
+
# parse rendered collection and compare with original collection
|
79
|
+
Occi::Parser.parse('application/occi+json',rendered_collection).should == collection
|
31
80
|
end
|
32
81
|
|
33
82
|
it "should parse an OVF file" do
|
34
83
|
media_type = 'application/ovf+xml'
|
35
84
|
body = File.read('spec/occi/test.ovf')
|
36
|
-
|
37
|
-
storage_resources = collection.resources.select { |resource| resource.kind == 'http://schemas.ogf.org/occi/infrastructure#storage' }
|
85
|
+
collection = Occi::Parser.parse(media_type, body)
|
86
|
+
storage_resources = collection.resources.select { |resource| resource.kind.to_s == 'http://schemas.ogf.org/occi/infrastructure#storage' }
|
38
87
|
storage_resources.should have(1).storage_resource
|
39
|
-
storage_resources.first.
|
40
|
-
network_resources = collection.resources.select { |resource| resource.kind == 'http://schemas.ogf.org/occi/infrastructure#network' }
|
88
|
+
storage_resources.first.title.should == 'lamp'
|
89
|
+
network_resources = collection.resources.select { |resource| resource.kind.to_s == 'http://schemas.ogf.org/occi/infrastructure#network' }
|
41
90
|
network_resources.should have(1).network_resource
|
42
|
-
network_resources.first.
|
43
|
-
compute_resources = collection.resources.select { |resource| resource.kind == 'http://schemas.ogf.org/occi/infrastructure#compute' }
|
91
|
+
network_resources.first.title.should == 'VM Network'
|
92
|
+
compute_resources = collection.resources.select { |resource| resource.kind.to_s == 'http://schemas.ogf.org/occi/infrastructure#compute' }
|
44
93
|
compute_resources.should have(1).compute_resource
|
45
94
|
compute_resources.first.attributes.occi!.compute!.cores.should == 1
|
46
|
-
compute_resources.first.attributes.occi!.compute!.memory.should ==
|
95
|
+
compute_resources.first.attributes.occi!.compute!.memory.should == 0.25
|
47
96
|
end
|
48
97
|
|
49
98
|
it "should parse an OVA container" do
|
50
99
|
media_type = 'application/ova'
|
51
100
|
body = File.read('spec/occi/test.ova')
|
52
|
-
|
53
|
-
storage_resources = collection.resources.select { |resource| resource.kind == 'http://schemas.ogf.org/occi/infrastructure#storage' }
|
101
|
+
collection = Occi::Parser.parse(media_type, body)
|
102
|
+
storage_resources = collection.resources.select { |resource| resource.kind.to_s == 'http://schemas.ogf.org/occi/infrastructure#storage' }
|
54
103
|
storage_resources.should have(1).storage_resource
|
55
|
-
storage_resources.first.
|
56
|
-
network_resources = collection.resources.select { |resource| resource.kind == 'http://schemas.ogf.org/occi/infrastructure#network' }
|
104
|
+
storage_resources.first.title.should == 'lamp'
|
105
|
+
network_resources = collection.resources.select { |resource| resource.kind.to_s == 'http://schemas.ogf.org/occi/infrastructure#network' }
|
57
106
|
network_resources.should have(1).network_resource
|
58
|
-
network_resources.first.
|
59
|
-
compute_resources = collection.resources.select { |resource| resource.kind == 'http://schemas.ogf.org/occi/infrastructure#compute' }
|
107
|
+
network_resources.first.title.should == 'VM Network'
|
108
|
+
compute_resources = collection.resources.select { |resource| resource.kind.to_s == 'http://schemas.ogf.org/occi/infrastructure#compute' }
|
60
109
|
compute_resources.should have(1).compute_resource
|
61
110
|
compute_resources.first.attributes.occi!.compute!.cores.should == 1
|
62
|
-
compute_resources.first.attributes.occi!.compute!.memory.should ==
|
111
|
+
compute_resources.first.attributes.occi!.compute!.memory.should == 0.25
|
63
112
|
end
|
64
|
-
|
113
|
+
|
114
|
+
end
|