occi-core 4.2.15 → 4.2.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/occi/core/kind.rb +4 -0
- data/lib/occi/parser/text.rb +1 -1
- data/lib/occi/version.rb +1 -1
- data/spec/helpers/to_plain.rb +39 -0
- data/spec/helpers/yaml_hash.rb +32 -0
- data/spec/occi/core/categories_spec.rb +2 -2
- data/spec/occi/model_spec.rb +2 -2
- data/spec/occi/parser/text_samples/occi_categories.body_plain.expected +2 -0
- data/spec/occi/parser/text_samples/occi_categories.expected +2 -0
- data/spec/occi/parser/text_samples/occi_categories.parse_headers.expected +2 -0
- data/spec/occi/parser/text_samples/occi_categories.text +2 -2
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.expected +11 -0
- data/spec/occi/parser/text_samples/occi_link_resource_instance.body_plain.expected +7 -0
- data/spec/occi/parser/text_samples/occi_link_resource_instance.expected +7 -0
- data/spec/occi/parser/text_samples/occi_link_resource_instance.parse.expected +7 -0
- data/spec/occi/parser/text_samples/occi_link_simple.expected +7 -0
- data/spec/occi/parser/text_samples/occi_link_w_attributes.expected +7 -0
- data/spec/occi/parser/text_samples/occi_link_w_category.expected +7 -0
- data/spec/occi/parser/text_samples/occi_model_categories.expected +3 -0
- data/spec/occi/parser/text_samples/occi_network_rocci_server.body_plain.expected +11 -0
- data/spec/occi/parser/text_samples/occi_network_rocci_server.expected +11 -0
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.header.expected +9 -0
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.rack.expected +9 -0
- data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.parse.expected +15 -0
- data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text +15 -0
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links.expected +1 -0
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.expected +9 -0
- data/spec/occi/parser/text_spec.rb +112 -97
- data/spec/occi/parser_spec.rb +30 -24
- data/spec/spec_helper.rb +2 -2
- metadata +23 -18
- data/spec/occi/parser/text_samples/occi_categories.dump +0 -0
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.dump +0 -0
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.resource.dump +0 -0
- data/spec/occi/parser/text_samples/occi_link_resource_instance.dump +0 -0
- data/spec/occi/parser/text_samples/occi_link_simple.dump +0 -0
- data/spec/occi/parser/text_samples/occi_link_simple.link_string.dump +0 -0
- data/spec/occi/parser/text_samples/occi_link_w_attributes.dump +0 -0
- data/spec/occi/parser/text_samples/occi_link_w_category.dump +0 -0
- data/spec/occi/parser/text_samples/occi_model_rocci_server.dump +0 -0
- data/spec/occi/parser/text_samples/occi_network_rocci_server.dump +0 -0
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.dump +0 -0
- data/spec/occi/parser/text_samples/occi_resource_w_attributes.dump +0 -0
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links.dump +0 -0
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links_only.dump +0 -0
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.dump +0 -0
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.resource.dump +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663a8ff9481f04d4d8638876ddedec499a953d0e
|
4
|
+
data.tar.gz: 3a898e3fe675a73c8e7a1570f88faed3e0149a90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c21fd2284cc4192004cc8ddcbd06f84ee9f3620e2b461ed7107720790eb7140496e9b23b9db8d960e82f2254dc4a19d29ae7763a46b6fcb9a9fa320c64c64e76
|
7
|
+
data.tar.gz: 51dd2d1a4a25d1e0bd4f35a5276287e501433c40d431b1242a2e19fef3ad1c29f8a999a1275cb4cd3ff7eede057f15d800850d27f41b328ad019e6cc4fafa447
|
data/lib/occi/core/kind.rb
CHANGED
@@ -38,6 +38,10 @@ module Occi
|
|
38
38
|
|
39
39
|
if parent.to_s == 'http://schemas.ogf.org/occi/core#entity'
|
40
40
|
parent = Occi::Core::Entity.kind
|
41
|
+
elsif parent.to_s == 'http://schemas.ogf.org/occi/core#resource'
|
42
|
+
parent = Occi::Core::Resource.kind
|
43
|
+
elsif parent.to_s == 'http://schemas.ogf.org/occi/core#link'
|
44
|
+
parent = Occi::Core::Link.kind
|
41
45
|
elsif parent.kind_of? Occi::Core::Kind
|
42
46
|
parent = parent
|
43
47
|
else
|
data/lib/occi/parser/text.rb
CHANGED
@@ -36,7 +36,7 @@ module Occi
|
|
36
36
|
category = category(line)
|
37
37
|
|
38
38
|
if category.kind_of? Occi::Core::Kind
|
39
|
-
resource = Occi::Core::
|
39
|
+
resource = Occi::Core::Resource.new(category.type_identifier)
|
40
40
|
resource.kind = category
|
41
41
|
end
|
42
42
|
resource.mixins << category if category.kind_of? Occi::Core::Mixin
|
data/lib/occi/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'psych'
|
2
|
+
|
3
|
+
class ToPlain < Psych::Visitors::Visitor
|
4
|
+
|
5
|
+
# Scalars are just strings.
|
6
|
+
def visit_Psych_Nodes_Scalar o
|
7
|
+
o.value
|
8
|
+
end
|
9
|
+
|
10
|
+
# Sequences are arrays.
|
11
|
+
def visit_Psych_Nodes_Sequence o
|
12
|
+
o.children.each_with_object([]) do |child, list|
|
13
|
+
list << accept(child)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Mappings are hashes.
|
18
|
+
def visit_Psych_Nodes_Mapping o
|
19
|
+
o.children.each_slice(2).each_with_object({}) do |(k,v), h|
|
20
|
+
h[accept(k)] = accept(v)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# We also need to handle documents...
|
25
|
+
def visit_Psych_Nodes_Document o
|
26
|
+
accept o.root
|
27
|
+
end
|
28
|
+
|
29
|
+
# ... and streams.
|
30
|
+
def visit_Psych_Nodes_Stream o
|
31
|
+
o.children.map { |c| accept c }
|
32
|
+
end
|
33
|
+
|
34
|
+
# Aliases aren't handles here :-(
|
35
|
+
def visit_Psych_Nodes_Alias o
|
36
|
+
# Not implemented!
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
|
3
|
+
class YAMLHash < Hashie::Mash
|
4
|
+
|
5
|
+
def load_file fs
|
6
|
+
f = File.open(fs, "rt")
|
7
|
+
self.load f.read
|
8
|
+
f.close
|
9
|
+
end
|
10
|
+
|
11
|
+
def load s
|
12
|
+
lin = s.lines
|
13
|
+
stack = Array.new
|
14
|
+
while (true) do
|
15
|
+
begin
|
16
|
+
line = lin.next
|
17
|
+
rescue
|
18
|
+
break
|
19
|
+
end
|
20
|
+
|
21
|
+
next if /^---/.match(line)
|
22
|
+
|
23
|
+
currentDepth = line.scan(/^\s*/).first.length / 2
|
24
|
+
while (currentDepth) < stack.length
|
25
|
+
stack.pop
|
26
|
+
end
|
27
|
+
|
28
|
+
stack.push(line.lstrip.chomp.gsub(/\s*$/, "").gsub(/[\*\&]\d+/, "Ptr-Emptied").gsub(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/, "ID-Emptied").gsub(/ ! /, " "))
|
29
|
+
self[stack] = nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -9,7 +9,7 @@ module Occi
|
|
9
9
|
resource = model.get_by_id Occi::Core::Resource.type_identifier
|
10
10
|
resource.location = '/new_location/'
|
11
11
|
categories.model = model
|
12
|
-
categories.first.location.
|
12
|
+
expect(categories.first.location).to eq '/new_location/'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "replaces a category string when a model is added with the instance from the model" do
|
@@ -20,7 +20,7 @@ module Occi
|
|
20
20
|
|
21
21
|
resource = model.get_by_id Occi::Core::Resource.type_identifier
|
22
22
|
resource.location = '/new_location/'
|
23
|
-
categories.first.location.
|
23
|
+
expect(categories.first.location).to eq '/new_location/'
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
data/spec/occi/model_spec.rb
CHANGED
@@ -67,8 +67,8 @@ module Occi
|
|
67
67
|
it "returns all registered categories" do
|
68
68
|
model = Occi::Model.new
|
69
69
|
collection = model.get
|
70
|
-
expected=
|
71
|
-
expect(collection).to eql expected
|
70
|
+
expected = File.open("spec/occi/parser/text_samples/occi_model_categories.expected", "rt").read
|
71
|
+
expect(collection.to_text).to eql expected
|
72
72
|
end
|
73
73
|
|
74
74
|
context "for categories with filter" do
|
@@ -0,0 +1,2 @@
|
|
1
|
+
Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"
|
2
|
+
Category: a_a2-_;scheme="http://a.a/a#";class="kind";title="aA2!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a2-A/";attributes="a_2-_.a2-_a a-2.a.b";actions="http://a.a/a2#a2 http://a.b2/b2#b2"
|
@@ -0,0 +1,2 @@
|
|
1
|
+
Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"
|
2
|
+
Category: a_a2-_;scheme="http://a.a/a#";class="kind";title="aA2!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a2-A/";attributes="a_2-_.a2-_a a-2.a.b";actions="http://a.a/a2#a2 http://a.b2/b2#b2"
|
@@ -0,0 +1,2 @@
|
|
1
|
+
Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"
|
2
|
+
Category: a_a2-_;scheme="http://a.a/a#";class="kind";title="aA2!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a2-A/";attributes="a_2-_.a2-_a a-2.a.b";actions="http://a.a/a2#a2 http://a.b2/b2#b2"
|
@@ -1,2 +1,2 @@
|
|
1
|
-
Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1
|
2
|
-
Category: a_a2-_;scheme="http://a.a/a#";class="kind";title="aA2
|
1
|
+
Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"
|
2
|
+
Category: a_a2-_;scheme="http://a.a/a#";class="kind";title="aA2!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a2-A/";attributes="a_2-_.a2-_a a-2.a.b";actions="http://a.a/a2#a2 http://a.b2/b2#b2"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/compute/";title=nil
|
2
|
+
Category: compute;scheme="http://opennebula.org/occi/infrastructure#";class="mixin";location="/mixin/compute/";title=""
|
3
|
+
X-OCCI-Attribute: occi.core.id="4ddbfeae-22d7-5e50-8f85-ba18589e876b"
|
4
|
+
X-OCCI-Attribute: occi.core.title="MonTest1"
|
5
|
+
X-OCCI-Attribute: occi.compute.cores=1
|
6
|
+
X-OCCI-Attribute: occi.compute.memory=0.256
|
7
|
+
X-OCCI-Attribute: occi.compute.state="active"
|
8
|
+
X-OCCI-Attribute: org.opennebula.compute.cpu=1.0
|
9
|
+
Link: </storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/storagelink/b2f7f1de-c60c-5b08-879c-81f52429c4ef";category="http://schemas.ogf.org/occi/infrastructure#storagelink";occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef";occi.core.title="monitoring";occi.storagelink.deviceid="xvda";occi.storagelink.state="inactive";org.opennebula.storagelink.bus="ide";org.opennebula.storagelink.driver="tap2:tapdisk:aio:"
|
10
|
+
Link: </network/e4bd81c4-adda-5626-840d-39bb7959db97>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/networkinterface/e75ab249-9325-511c-82b8-a7e4430381e3";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="e75ab249-9325-511c-82b8-a7e4430381e3";occi.core.title="monitoring";occi.networkinterface.address="192.168.254.1";occi.networkinterface.mac="02:00:c0:a8:fe:01";occi.networkinterface.state="inactive";org.opennebula.networkinterface.bridge="xenbr0"Link: </storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/storagelink/b2f7f1de-c60c-5b08-879c-81f52429c4ef";category="http://schemas.ogf.org/occi/infrastructure#storagelink";occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef";occi.core.title="monitoring";occi.storagelink.deviceid="xvda";occi.storagelink.state="inactive";org.opennebula.storagelink.bus="ide";org.opennebula.storagelink.driver="tap2:tapdisk:aio:"
|
11
|
+
Link: </network/e4bd81c4-adda-5626-840d-39bb7959db97>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/networkinterface/e75ab249-9325-511c-82b8-a7e4430381e3";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="e75ab249-9325-511c-82b8-a7e4430381e3";occi.core.title="monitoring";occi.networkinterface.address="192.168.254.1";occi.networkinterface.mac="02:00:c0:a8:fe:01";occi.networkinterface.state="inactive";org.opennebula.networkinterface.bridge="xenbr0"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Category: networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/networkinterface/";title=nil
|
2
|
+
X-OCCI-Attribute: occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef"
|
3
|
+
X-OCCI-Attribute: occi.core.target="/network/123"
|
4
|
+
X-OCCI-Attribute: occi.core.source="/vms/foo/vm1"
|
5
|
+
X-OCCI-Attribute: occi.networkinterface.interface="eth0"
|
6
|
+
X-OCCI-Attribute: occi.networkinterface.mac="00:11:22:33:44:55"
|
7
|
+
X-OCCI-Attribute: occi.networkinterface.state="active"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Category: networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/networkinterface/";title=nil
|
2
|
+
X-OCCI-Attribute: occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef"
|
3
|
+
X-OCCI-Attribute: occi.core.target="/network/123"
|
4
|
+
X-OCCI-Attribute: occi.core.source="/vms/foo/vm1"
|
5
|
+
X-OCCI-Attribute: occi.networkinterface.interface="eth0"
|
6
|
+
X-OCCI-Attribute: occi.networkinterface.mac="00:11:22:33:44:55"
|
7
|
+
X-OCCI-Attribute: occi.networkinterface.state="active"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Category: networkinterface;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/networkinterface/";title=nil
|
2
|
+
X-OCCI-Attribute: occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef"
|
3
|
+
X-OCCI-Attribute: occi.core.target="/network/123"
|
4
|
+
X-OCCI-Attribute: occi.core.source="/vms/foo/vm1"
|
5
|
+
X-OCCI-Attribute: occi.networkinterface.interface="eth0"
|
6
|
+
X-OCCI-Attribute: occi.networkinterface.mac="00:11:22:33:44:55"
|
7
|
+
X-OCCI-Attribute: occi.networkinterface.state="active"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/link/storagelink/";title="storage link"
|
2
|
+
X-OCCI-Attribute: occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef"
|
3
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
4
|
+
X-OCCI-Attribute: occi.storagelink.deviceid="xvda"
|
5
|
+
X-OCCI-Attribute: occi.storagelink.state="inactive"
|
6
|
+
X-OCCI-Attribute: org.opennebula.storagelink.bus="ide"
|
7
|
+
X-OCCI-Attribute: org.opennebula.storagelink.driver="tap2:tapdisk:aio:"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/link/storagelink/";title="storage link"
|
2
|
+
X-OCCI-Attribute: occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef"
|
3
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
4
|
+
X-OCCI-Attribute: occi.storagelink.deviceid="xvda"
|
5
|
+
X-OCCI-Attribute: occi.storagelink.state="inactive"
|
6
|
+
X-OCCI-Attribute: org.opennebula.storagelink.bus="ide"
|
7
|
+
X-OCCI-Attribute: org.opennebula.storagelink.driver="tap2:tapdisk:aio:"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Category: storagelink;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/link/storagelink/";title="storage link"
|
2
|
+
X-OCCI-Attribute: occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef"
|
3
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
4
|
+
X-OCCI-Attribute: occi.storagelink.deviceid="xvda"
|
5
|
+
X-OCCI-Attribute: occi.storagelink.state="inactive"
|
6
|
+
X-OCCI-Attribute: org.opennebula.storagelink.bus="ide"
|
7
|
+
X-OCCI-Attribute: org.opennebula.storagelink.driver="tap2:tapdisk:aio:"
|
@@ -0,0 +1,3 @@
|
|
1
|
+
Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="entity";location="/entity/";attributes="occi.core.id{immutable} occi.core.title string_attribute"
|
2
|
+
Category: resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="resource";rel="http://schemas.ogf.org/occi/core#entity";location="/new_location/";attributes="occi.core.id{immutable} occi.core.title occi.core.summary"
|
3
|
+
Category: link;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="link";rel="http://schemas.ogf.org/occi/core#entity";location="/link/";attributes="occi.core.id{immutable} occi.core.title occi.core.target occi.core.source stringtype{required} stringtypeoptional"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title=nil
|
2
|
+
Category: network;scheme="http://opennebula.org/occi/infrastructure#";class="mixin";location="/mixin/network/";title=""
|
3
|
+
Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";location="/mixin/ipnetwork/";title=""
|
4
|
+
X-OCCI-Attribute: occi.core.id="e4bd81c4-adda-5626-840d-39bb7959db97"
|
5
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
6
|
+
X-OCCI-Attribute: occi.network.state="active"
|
7
|
+
X-OCCI-Attribute: occi.network.address="192.168.254.0"
|
8
|
+
X-OCCI-Attribute: occi.network.allocation="dynamic"
|
9
|
+
X-OCCI-Attribute: org.opennebula.network.id="6"
|
10
|
+
X-OCCI-Attribute: org.opennebula.network.bridge="xenbr0"
|
11
|
+
X-OCCI-Attribute: org.opennebula.network.vlan="NO"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title=nil
|
2
|
+
Category: network;scheme="http://opennebula.org/occi/infrastructure#";class="mixin";location="/mixin/network/";title=""
|
3
|
+
Category: ipnetwork;scheme="http://schemas.ogf.org/occi/infrastructure#";class="mixin";location="/mixin/ipnetwork/";title=""
|
4
|
+
X-OCCI-Attribute: occi.core.id="e4bd81c4-adda-5626-840d-39bb7959db97"
|
5
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
6
|
+
X-OCCI-Attribute: occi.network.state="active"
|
7
|
+
X-OCCI-Attribute: occi.network.address="192.168.254.0"
|
8
|
+
X-OCCI-Attribute: occi.network.allocation="dynamic"
|
9
|
+
X-OCCI-Attribute: org.opennebula.network.id="6"
|
10
|
+
X-OCCI-Attribute: org.opennebula.network.bridge="xenbr0"
|
11
|
+
X-OCCI-Attribute: org.opennebula.network.vlan="NO"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title=nil
|
2
|
+
X-OCCI-Attribute: occi.core.id="e4bd81c4-adda-5626-840d-39bb7959db97"
|
3
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
4
|
+
X-OCCI-Attribute: occi.network.state="active"
|
5
|
+
X-OCCI-Attribute: occi.network.address="192.168.254.0"
|
6
|
+
X-OCCI-Attribute: occi.network.allocation="dynamic"
|
7
|
+
X-OCCI-Attribute: org.opennebula.network.bridge="xenbr0"
|
8
|
+
X-OCCI-Attribute: org.opennebula.network.id="6"
|
9
|
+
X-OCCI-Attribute: org.opennebula.network.vlan="NO"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Category: network;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/network/";title=nil
|
2
|
+
X-OCCI-Attribute: occi.core.id="e4bd81c4-adda-5626-840d-39bb7959db97"
|
3
|
+
X-OCCI-Attribute: occi.core.title="monitoring"
|
4
|
+
X-OCCI-Attribute: occi.network.state="active"
|
5
|
+
X-OCCI-Attribute: occi.network.address="192.168.254.0"
|
6
|
+
X-OCCI-Attribute: occi.network.allocation="dynamic"
|
7
|
+
X-OCCI-Attribute: org.opennebula.network.bridge="xenbr0"
|
8
|
+
X-OCCI-Attribute: org.opennebula.network.id="6"
|
9
|
+
X-OCCI-Attribute: org.opennebula.network.vlan="NO"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Category: fogbow_request;scheme="http://schemas.fogbowcloud.org/request#";class="kind";location="/fogbow_request/";title="Request new Instances"
|
2
|
+
Category: fogbow_small;scheme="http://schemas.fogbowcloud.org/template/resource#";class="mixin";location="/fogbow_small/";title="Small Flavor"
|
3
|
+
Category: fogbow-linux-x86;scheme="http://schemas.fogbowcloud.org/template/os#";class="mixin";location="/fogbow-linux-x86/";title="fogbow-linux-x86 image"
|
4
|
+
Category: fogbow_userdata;scheme="http://schemas.fogbowcloud.org/request#";class="mixin";location="/fogbow_userdata/";title=""
|
5
|
+
X-OCCI-Attribute: occi.core.id="e076376a-a0d3-448b-b065-d1b63e729f6a"
|
6
|
+
X-OCCI-Attribute: occi.core.title="my test"
|
7
|
+
X-OCCI-Attribute: org.fogbowcloud.request.ssh-public-address="150.165.15.81:40000"
|
8
|
+
X-OCCI-Attribute: org.fogbowcloud.request.user-data="IyEvYmluL3NoCi91c3IvYmluL3NzaCAteSAtTiAtZiAtUiAwLjAuMC4wOjQwMDAwOmxvY2FsaG9zdDoyMiBmb2d0ZXN0QDEwLjEuMC40MyAtcCAyMgo"
|
9
|
+
X-OCCI-Attribute: org.fogbowcloud.request.type="one-time"
|
10
|
+
X-OCCI-Attribute: org.fogbowcloud.request.ssh-address="10.1.0.43:40000"
|
11
|
+
X-OCCI-Attribute: org.fogbowcloud.request.instance-count="1"
|
12
|
+
X-OCCI-Attribute: org.fogbowcloud.request.valid-from="Not defined"
|
13
|
+
X-OCCI-Attribute: org.fogbowcloud.request.valid-until="Not defined"
|
14
|
+
X-OCCI-Attribute: org.fogbowcloud.request.state="failed"
|
15
|
+
X-OCCI-Attribute: org.fogbowcloud.request.instance-id="null"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Category: fogbow_request; scheme="http://schemas.fogbowcloud.org/request#"; class="kind"; title="Request new Instances"; rel="http://schemas.ogf.org/occi/core#resource"; location="http://localhost:8182/fogbow_request/"; attributes="org.fogbowcloud.request.instance-count org.fogbowcloud.request.type org.fogbowcloud.request.valid-until org.fogbowcloud.request.valid-from org.fogbowcloud.request.state org.fogbowcloud.request.instance-id"
|
2
|
+
Category: fogbow_small; scheme="http://schemas.fogbowcloud.org/template/resource#"; class="mixin"; title="Small Flavor"; rel="http://schemas.ogf.org/occi/infrastructure#resource_tpl"; location="http://localhost:8182/fogbow_small/"
|
3
|
+
Category: fogbow-linux-x86; scheme="http://schemas.fogbowcloud.org/template/os#"; class="mixin"; title="fogbow-linux-x86 image"; rel="http://schemas.ogf.org/occi/infrastructure#os_tpl"; location="http://localhost:8182/fogbow-linux-x86/"
|
4
|
+
Category: fogbow_userdata; scheme="http://schemas.fogbowcloud.org/request#"; class="mixin"; location="http://localhost:8182/fogbow_userdata/"
|
5
|
+
X-OCCI-Attribute: occi.core.id="e076376a-a0d3-448b-b065-d1b63e729f6a"
|
6
|
+
X-OCCI-Attribute: occi.core.title="my test"
|
7
|
+
X-OCCI-Attribute: org.fogbowcloud.request.ssh-public-address="150.165.15.81:40000"
|
8
|
+
X-OCCI-Attribute: org.fogbowcloud.request.user-data="IyEvYmluL3NoCi91c3IvYmluL3NzaCAteSAtTiAtZiAtUiAwLjAuMC4wOjQwMDAwOmxvY2FsaG9zdDoyMiBmb2d0ZXN0QDEwLjEuMC40MyAtcCAyMgo"
|
9
|
+
X-OCCI-Attribute: org.fogbowcloud.request.type="one-time"
|
10
|
+
X-OCCI-Attribute: org.fogbowcloud.request.ssh-address="10.1.0.43:40000"
|
11
|
+
X-OCCI-Attribute: org.fogbowcloud.request.instance-count="1"
|
12
|
+
X-OCCI-Attribute: org.fogbowcloud.request.valid-from="Not defined"
|
13
|
+
X-OCCI-Attribute: org.fogbowcloud.request.valid-until="Not defined"
|
14
|
+
X-OCCI-Attribute: org.fogbowcloud.request.state="failed"
|
15
|
+
X-OCCI-Attribute: org.fogbowcloud.request.instance-id="null"
|
@@ -0,0 +1 @@
|
|
1
|
+
Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";title="Compute Resource";rel="http://schemas.ogf.org/occi/core#resource";location="/compute/";attributes="occi.compute.architecture occi.compute.state occi.compute.speed occi.compute.memory occi.compute.cores occi.compute.hostname";actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Category: storage;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind";location="/storage/";title=nil
|
2
|
+
Category: storage;scheme="http://opennebula.org/occi/infrastructure#";class="mixin";location="/mixin/storage/";title=""
|
3
|
+
X-OCCI-Attribute: occi.core.id="33601efd-1c81-5547-8e65-6f8ef3dcb8c6"
|
4
|
+
X-OCCI-Attribute: occi.core.title="EGI-COMPSs-CESNET_NFS_3"
|
5
|
+
X-OCCI-Attribute: occi.storage.state="online"
|
6
|
+
X-OCCI-Attribute: org.opennebula.storage.id="116"
|
7
|
+
X-OCCI-Attribute: org.opennebula.storage.dev_prefix="xvd"
|
8
|
+
X-OCCI-Attribute: org.opennebula.storage.driver="tap2:tapdisk:aio:"
|
9
|
+
X-OCCI-Attribute: org.opennebula.storage.persistent="NO"
|
@@ -5,28 +5,28 @@ module Occi
|
|
5
5
|
describe Text do
|
6
6
|
|
7
7
|
context '.category' do
|
8
|
-
|
9
8
|
it 'parses a string describing an OCCI Category' do
|
10
|
-
category_string = 'Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1
|
11
|
-
|
9
|
+
category_string = 'Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"'
|
12
10
|
category = Occi::Parser::Text.category category_string
|
13
|
-
|
14
|
-
|
15
|
-
expect(category).to eql expected
|
11
|
+
expect(category.to_text).to eql category_string
|
16
12
|
end
|
17
13
|
|
18
14
|
it 'parses a string describing an OCCI Category with unquoted class value' do
|
19
|
-
category_string = 'Category: a_a1-_;scheme="http://a.a/a#";class=kind'
|
20
|
-
|
15
|
+
category_string = 'Category: a_a1-_;scheme="http://a.a/a#";class="kind"'
|
16
|
+
category = Occi::Parser::Text.category category_string
|
17
|
+
expect(category.to_text).to eql "#{category_string};location=\"/a_a1-_/\""
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'parses a string describing an OCCI Category with unquoted class value and explicit location' do
|
21
|
+
category_string = 'Category: a_a1-_;scheme="http://a.a/a#";class="kind";location="/a_a1-_/"'
|
21
22
|
category = Occi::Parser::Text.category category_string
|
22
|
-
expect(category).to eql
|
23
|
+
expect(category.to_text).to eql category_string
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'parses a string describing an OCCI Category with uppercase term' do
|
26
|
-
category_string = 'Category: TERM;scheme="http://a.a/a#";class=kind'
|
27
|
-
expected = Marshal.restore("\x04\bo:\x15Occi::Core::Kind\r:\f@schemeI\"\x12http://a.a/a#\x06:\x06ET:\n@termI\"\tterm\x06;\aT:\v@title0:\x10@attributesC:\eOcci::Core::Attributes{\x00:\f@parent0:\r@actionso:\x18Occi::Core::Actions\x06:\n@hash{\x00:\x0E@entitieso:\x19Occi::Core::Entities\x06;\x0F{\x00:\x0E@locationI\"\v/term/\x06;\aF")
|
27
|
+
category_string = 'Category: TERM;scheme="http://a.a/a#";class="kind"'
|
28
28
|
category = Occi::Parser::Text.category category_string
|
29
|
-
expect(category).to eql
|
29
|
+
expect(category.to_text).to eql 'Category: term;scheme="http://a.a/a#";class="kind";location="/term/"'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'parses a string describing an OCCI Category incl. attributes with properties' do
|
@@ -40,62 +40,54 @@ module Occi
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'parses attributes correctly' do
|
43
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_w_attributes.text", "
|
44
|
-
|
45
|
-
|
46
|
-
expect(collection).to eql expected
|
43
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_w_attributes.text", "rt").read
|
44
|
+
category = Occi::Parser::Text.category resource_string
|
45
|
+
expect(category.to_text).to eql "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\""
|
47
46
|
end
|
48
47
|
|
49
48
|
it 'parses inline links correctly' do
|
50
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_w_inline_links_only.text", "
|
51
|
-
|
52
|
-
|
53
|
-
expect(collection).to eql expected
|
49
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_w_inline_links_only.text", "rt").read
|
50
|
+
category = Occi::Parser::Text.category resource_string
|
51
|
+
expect(category.to_text).to eql "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\""
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'parses inline Links and Mixins correctly' do
|
57
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_w_inline_links.text", "
|
58
|
-
|
59
|
-
|
60
|
-
expect(
|
55
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_w_inline_links.text", "rt").read
|
56
|
+
category = Occi::Parser::Text.category resource_string
|
57
|
+
expected = File.open("spec/occi/parser/text_samples/occi_resource_w_inline_links.expected", "rt").read.chomp
|
58
|
+
expect(category.to_text).to eql expected
|
61
59
|
end
|
62
60
|
|
63
61
|
it 'parses action correctly' do
|
64
62
|
category_string = 'Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Restart Compute instance";attributes="method"'
|
65
63
|
category = Occi::Parser::Text.category category_string
|
66
|
-
|
67
|
-
|
68
|
-
expect(category).to eql expected
|
64
|
+
expect(category.to_text).to eql category_string
|
69
65
|
end
|
70
66
|
|
71
67
|
it 'parses network resource from rOCCI server' do
|
72
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "
|
73
|
-
|
74
|
-
|
75
|
-
expect(collection).to eql expected
|
68
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "rt").read
|
69
|
+
category = Occi::Parser::Text.category resource_string
|
70
|
+
expect(category.to_text).to eql "Category: network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/network/\""
|
76
71
|
end
|
77
|
-
|
72
|
+
|
78
73
|
it 'parses storage resource from rOCCI server' do
|
79
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_storage_rocci_server.text", "
|
80
|
-
|
81
|
-
|
82
|
-
expect(collection).to eql expected
|
74
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_storage_rocci_server.text", "rt").read
|
75
|
+
category = Occi::Parser::Text.category resource_string
|
76
|
+
expect(category.to_text).to eql "Category: storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/storage/\""
|
83
77
|
end
|
84
|
-
|
78
|
+
|
85
79
|
it 'parses compute resource from rOCCI server' do
|
86
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.text", "
|
87
|
-
|
88
|
-
|
89
|
-
expect(collection).to eql expected
|
80
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.text", "rt").read
|
81
|
+
category = Occi::Parser::Text.category resource_string
|
82
|
+
expect(category.to_text).to eql "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\""
|
90
83
|
end
|
91
|
-
|
84
|
+
|
92
85
|
it 'parses model from rOCCI server' do
|
93
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_model_rocci_server.text", "
|
94
|
-
|
95
|
-
|
96
|
-
expect(collection).to eql expected
|
86
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_model_rocci_server.text", "rt").read
|
87
|
+
category = Occi::Parser::Text.category resource_string
|
88
|
+
|
97
89
|
end
|
98
|
-
|
90
|
+
|
99
91
|
it 'raises error for obviously nonsensical class' do
|
100
92
|
category_string = 'Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="actions";title="Restart Compute instance";attributes="method"'
|
101
93
|
expect{ category = Occi::Parser::Text.category category_string }.to raise_error(Occi::Errors::ParserInputError)
|
@@ -122,53 +114,62 @@ module Occi
|
|
122
114
|
|
123
115
|
context '.resource' do
|
124
116
|
it 'parses network resource from rOCCI server' do
|
125
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "
|
126
|
-
|
127
|
-
|
128
|
-
expect(resource).to eql expected
|
117
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "rt").read
|
118
|
+
resource = Occi::Parser::Text.resource resource_string
|
119
|
+
expected = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.expected", "rt").read.chomp
|
120
|
+
expect(resource.to_text).to eql expected
|
129
121
|
end
|
130
122
|
|
131
123
|
it 'parses storage resource from rOCCI server' do
|
132
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_storage_rocci_server.text", "
|
133
|
-
|
134
|
-
|
135
|
-
expect(resource).to eql expected
|
124
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_storage_rocci_server.text", "rt").read
|
125
|
+
resource = Occi::Parser::Text.resource resource_string
|
126
|
+
expected = File.open("spec/occi/parser/text_samples/occi_storage_rocci_server.expected", "rt").read.chomp
|
127
|
+
expect(resource.to_text).to eql expected
|
136
128
|
end
|
137
|
-
|
129
|
+
|
138
130
|
it 'parses compute resource from rOCCI server' do
|
139
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.text", "
|
140
|
-
|
141
|
-
|
142
|
-
expect(resource).to eql expected
|
131
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.text", "rt").read
|
132
|
+
resource = Occi::Parser::Text.resource resource_string
|
133
|
+
expected = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.expected", "rt").read.chomp
|
134
|
+
expect(resource.to_text).to eql expected
|
143
135
|
end
|
144
136
|
|
145
137
|
it 'types parsed compute resource from rOCCI server as Occi::Infrastructure::Compute' do
|
146
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.text", "
|
138
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_compute_rocci_server.text", "rt").read
|
147
139
|
expected_class = Occi::Infrastructure::Compute
|
148
|
-
resource_class =
|
140
|
+
resource_class = Occi::Parser::Text.resource(resource_string).resources.first.class
|
149
141
|
expect(resource_class).to eql expected_class
|
150
142
|
end
|
143
|
+
|
144
|
+
it 'types parsed custom resource as related to Occi::Core::Resource' do
|
145
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text", "rt").read
|
146
|
+
expected_class = "Org::Fogbowcloud::Schemas::Request::FogbowRequest"
|
147
|
+
|
148
|
+
resource_instance = Occi::Parser::Text.resource(resource_string).resources.first
|
149
|
+
resource_class = resource_instance.class.to_s
|
150
|
+
expect(resource_class).to eql expected_class
|
151
|
+
expect(resource_instance).to be_kind_of Occi::Core::Resource
|
152
|
+
end
|
151
153
|
end
|
152
154
|
|
153
155
|
context '.categories' do
|
154
156
|
it 'parses strings describing OCCI Categories' do
|
155
|
-
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "
|
156
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_categories.dump", "rb"))
|
157
|
+
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "rt").read
|
157
158
|
categories = Occi::Parser::Text.categories categories_string
|
158
|
-
|
159
|
+
expected = File.open("spec/occi/parser/text_samples/occi_categories.expected", "rt").read
|
160
|
+
expect(categories.to_text).to eql expected
|
159
161
|
end
|
160
162
|
|
161
163
|
it 'parses strings describing OCCI Categories, skipping unparseable additions' do
|
162
|
-
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "
|
164
|
+
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "rt").read
|
163
165
|
categories_string["\n"] = "\n\n&*$this won't parse\n"
|
164
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_categories.dump", "rb"))
|
165
166
|
categories = Occi::Parser::Text.categories categories_string
|
166
|
-
|
167
|
+
expected = File.open("spec/occi/parser/text_samples/occi_categories.expected", "rt").read
|
168
|
+
expect(categories.to_text).to eql expected
|
167
169
|
end
|
168
170
|
|
169
171
|
it 'does not fail on unparseable input' do
|
170
172
|
categories_string = "\n\n&*$this won't parse\n"
|
171
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_categories.dump", "rb"))
|
172
173
|
categories = Occi::Parser::Text.categories categories_string
|
173
174
|
expect(categories.blank?).to eql true
|
174
175
|
end
|
@@ -177,12 +178,10 @@ module Occi
|
|
177
178
|
|
178
179
|
context '.link' do
|
179
180
|
it 'parses link resource instance' do
|
180
|
-
link_string = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.text", "
|
181
|
+
link_string = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.text", "rt").read
|
181
182
|
link = Occi::Parser::Text.link link_string
|
182
|
-
expected =
|
183
|
-
|
184
|
-
link.links.each { |lnk| lnk.id = 'emptied' }
|
185
|
-
expect(link).to eql expected
|
183
|
+
expected = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.expected", "rt").read.chomp
|
184
|
+
expect(link.to_text).to eql expected
|
186
185
|
end
|
187
186
|
|
188
187
|
end
|
@@ -217,58 +216,54 @@ module Occi
|
|
217
216
|
|
218
217
|
context '.link_string' do
|
219
218
|
it 'parses string with category set' do
|
220
|
-
link_string = File.open("spec/occi/parser/text_samples/occi_link_simple.text", "
|
219
|
+
link_string = File.open("spec/occi/parser/text_samples/occi_link_simple.text", "rt").read
|
221
220
|
link = Occi::Parser::Text.link_string link_string, nil
|
222
|
-
expected =
|
223
|
-
expect(link).to eql expected
|
221
|
+
expected = File.open("spec/occi/parser/text_samples/occi_link_simple.expected", "rt").read.chomp
|
222
|
+
expect(link.to_text).to eql expected
|
224
223
|
end
|
225
224
|
|
226
225
|
it 'parses link with category' do
|
227
|
-
link_string = File.open("spec/occi/parser/text_samples/occi_link_w_category.text", "
|
226
|
+
link_string = File.open("spec/occi/parser/text_samples/occi_link_w_category.text", "rt").read
|
228
227
|
link = Occi::Parser::Text.link_string link_string, nil
|
229
|
-
expected =
|
230
|
-
expect(link).to eql expected
|
228
|
+
expected = File.open("spec/occi/parser/text_samples/occi_link_w_category.expected", "rt").read.chomp
|
229
|
+
expect(link.to_text).to eql expected
|
231
230
|
end
|
232
231
|
|
233
232
|
it 'parses link with attributes' do
|
234
|
-
link_string = File.open("spec/occi/parser/text_samples/occi_link_w_attributes.text", "
|
233
|
+
link_string = File.open("spec/occi/parser/text_samples/occi_link_w_attributes.text", "rt").read
|
235
234
|
link = Occi::Parser::Text.link_string link_string, nil
|
236
|
-
expected =
|
237
|
-
expect(link).to eql expected
|
235
|
+
expected = File.open("spec/occi/parser/text_samples/occi_link_w_attributes.expected", "rt").read.chomp
|
236
|
+
expect(link.to_text).to eql expected
|
238
237
|
end
|
239
238
|
|
240
239
|
it 'parses string with action link' do
|
241
240
|
link_string = 'Link: </compute/04106bce-87eb-4f8f-a665-2f624e54ba46?action=restart>; rel="http://schemas.ogf.org/occi/infrastructure/compute/action#restart"'
|
242
241
|
link = Occi::Parser::Text.link_string(link_string, "source")
|
243
|
-
|
244
|
-
expect(link).to eql expected
|
242
|
+
expect(link.to_text).to eql "Category: restart;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\""
|
245
243
|
end
|
246
244
|
end
|
247
245
|
|
248
246
|
context 'compatibility' do
|
249
247
|
after(:each) { Occi::Settings.reload! }
|
250
|
-
|
251
248
|
context 'terms' do
|
252
249
|
it 'parses uppercase term, compatibility on' do
|
253
250
|
Occi::Settings['compatibility']=true
|
254
|
-
category_string = 'Category: TERM;scheme="http://a.a/a#";class=kind'
|
255
|
-
expected = Marshal.restore("\x04\bo:\x15Occi::Core::Kind\r:\f@schemeI\"\x12http://a.a/a#\x06:\x06ET:\n@termI\"\tterm\x06;\aT:\v@title0:\x10@attributesC:\eOcci::Core::Attributes{\x00:\f@parent0:\r@actionso:\x18Occi::Core::Actions\x06:\n@hash{\x00:\x0E@entitieso:\x19Occi::Core::Entities\x06;\x0F{\x00:\x0E@locationI\"\v/term/\x06;\aF")
|
251
|
+
category_string = 'Category: TERM;scheme="http://a.a/a#";class="kind"'
|
256
252
|
category = Occi::Parser::Text.category category_string
|
257
|
-
expect(category).to eql
|
253
|
+
expect(category.to_text).to eql "Category: term;scheme=\"http://a.a/a#\";class=\"kind\";location=\"/term/\""
|
258
254
|
end
|
259
255
|
|
260
256
|
it 'refuses uppercase term, compatibility off' do
|
261
257
|
Occi::Settings['compatibility']=false
|
262
|
-
category_string = 'Category: TERM;scheme="http://a.a/a#";class=kind'
|
258
|
+
category_string = 'Category: TERM;scheme="http://a.a/a#";class="kind"'
|
263
259
|
expect{ category = Occi::Parser::Text.category category_string }.to raise_error(Occi::Errors::ParserInputError)
|
264
260
|
end
|
265
261
|
|
266
262
|
it 'parses term starting with number, compatibility on' do
|
267
263
|
Occi::Settings['compatibility']=true
|
268
|
-
category_string = 'Category: 1TERM;scheme="http://a.a/a#";class=kind'
|
269
|
-
expected = Marshal.restore("\x04\bo:\x15Occi::Core::Kind\r:\f@schemeI\"\x12http://a.a/a#\x06:\x06ET:\n@termI\"\n1term\x06;\aT:\v@title0:\x10@attributesC:\eOcci::Core::Attributes{\x00:\f@parent0:\r@actionso:\x18Occi::Core::Actions\x06:\n@hash{\x00:\x0E@entitieso:\x19Occi::Core::Entities\x06;\x0F{\x00:\x0E@locationI\"\f/1term/\x06;\aF")
|
264
|
+
category_string = 'Category: 1TERM;scheme="http://a.a/a#";class="kind"'
|
270
265
|
category = Occi::Parser::Text.category category_string
|
271
|
-
expect(category).to eql
|
266
|
+
expect(category.to_text).to eql "Category: 1term;scheme=\"http://a.a/a#\";class=\"kind\";location=\"/1term/\""
|
272
267
|
end
|
273
268
|
|
274
269
|
it 'refuses term starting with number, compatibility off' do
|
@@ -277,15 +272,27 @@ module Occi
|
|
277
272
|
expect{ category = Occi::Parser::Text.category category_string }.to raise_error(Occi::Errors::ParserInputError)
|
278
273
|
end
|
279
274
|
|
275
|
+
|
276
|
+
it 'parses upper case Category with compatibility mode on' do
|
277
|
+
Occi::Settings['compatibility']=true
|
278
|
+
category_string = 'Category: A_A1-_;scheme="http://a.a/a#";class="kind"'
|
279
|
+
expect{ category = Occi::Parser::Text.category category_string }.to_not raise_error
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'refuses upper case Category with compatibility mode off' do
|
283
|
+
Occi::Settings['compatibility']=false
|
284
|
+
category_string = 'Category: A_A1-_;scheme="http://a.a/a#";class="kind"'
|
285
|
+
expect{ category = Occi::Parser::Text.category category_string }.to raise_error(Occi::Errors::ParserInputError)
|
286
|
+
end
|
287
|
+
|
280
288
|
end
|
281
289
|
|
282
290
|
context 'schemes' do
|
283
291
|
it 'parses a Category, compatibility on' do
|
284
292
|
Occi::Settings['compatibility']=true
|
285
|
-
category_string = 'Category: a_a1-_;scheme="http://a.a/a#a_a1-_";class="kind";title="aA1
|
293
|
+
category_string = 'Category: a_a1-_;scheme="http://a.a/a#a_a1-_";class="kind";title="aA1!§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"'
|
286
294
|
category = Occi::Parser::Text.category category_string
|
287
|
-
|
288
|
-
expect(category).to eql expected
|
295
|
+
expect(category.to_text).to eql "Category: a_a1-_;scheme=\"http://a.a/a#\";class=\"kind\";title=\"aA1!§$%&/()=?`´ß+*#-_.:,;<>\";rel=\"http://a.a/b#a\";location=\"/a1-A/\";attributes=\"a_1-_.a1-_a a-1.a.b\";actions=\"http://a.a/a1#a1 http://a.b1/b1#b2\""
|
289
296
|
end
|
290
297
|
|
291
298
|
it 'parses a Category, compatibility off' do
|
@@ -296,7 +303,15 @@ module Occi
|
|
296
303
|
end
|
297
304
|
end
|
298
305
|
|
299
|
-
context 'other OCCI implementations' do
|
306
|
+
context 'with other OCCI implementations' do
|
307
|
+
|
308
|
+
it 'correctly parses input from FogBow Cloud' do
|
309
|
+
category_string = File.open("spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text", "rt").read
|
310
|
+
category = Occi::Parser::Text.category category_string
|
311
|
+
expected = "Category: fogbow_request;scheme=\"http://schemas.fogbowcloud.org/request#\";class=\"kind\";title=\"Request new Instances\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/fogbow_request/\";attributes=\"org.fogbowcloud.request.instance-count org.fogbowcloud.request.type org.fogbowcloud.request.valid-until org.fogbowcloud.request.valid-from org.fogbowcloud.request.state org.fogbowcloud.request.instance-id\""
|
312
|
+
expect(category.to_text).to eql expected
|
313
|
+
end
|
314
|
+
|
300
315
|
it 'renders correctly OCCI from other sources'
|
301
316
|
end
|
302
317
|
|
data/spec/occi/parser_spec.rb
CHANGED
@@ -127,35 +127,33 @@ module Occi
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'parses categories' do
|
130
|
-
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "
|
131
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_categories.dump", "rb"))
|
130
|
+
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "rt").read
|
132
131
|
categories = Occi::Parser.parse('text/plain', categories_string, true)
|
133
|
-
|
132
|
+
expected = File.open("spec/occi/parser/text_samples/occi_categories.parse_headers.expected", "rt").read
|
133
|
+
expect(categories.to_text).to eql expected
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'parses resources from headers' do
|
137
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.dump", "rb"))
|
138
137
|
resource = Occi::Parser.parse('text/occi', '', false, Occi::Core::Resource, resource_in_headers)
|
139
|
-
|
138
|
+
expected = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.header.expected", "rt").read.chomp
|
139
|
+
expect(resource.to_text).to eql expected
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'parses resources from rack-compliant headers' do
|
143
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.dump", "rb"))
|
144
143
|
resource = Occi::Parser.parse('text/occi', '', false, Occi::Core::Resource, rack_resource_in_headers)
|
145
|
-
|
144
|
+
expected = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.rack.expected", "rt").read.chomp
|
145
|
+
expect(resource.to_text).to eql expected
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'parses link' do
|
149
|
-
link_string = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.text", "
|
149
|
+
link_string = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.text", "rt").read
|
150
150
|
link = Occi::Parser.parse('text/plain', link_string, false, Occi::Core::Link)
|
151
|
-
expected =
|
152
|
-
|
153
|
-
link.links.each { |lnk| lnk.id = 'emptied' }
|
154
|
-
expect(link).to eql expected
|
151
|
+
expected = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.parse.expected", "rt").read.chomp
|
152
|
+
expect(link.to_text).to eql expected
|
155
153
|
end
|
156
154
|
|
157
155
|
it 'fails gracefully for unknown entity type' do
|
158
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "
|
156
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "rt").read
|
159
157
|
expect{ Occi::Parser.parse('text/plain', resource_string, false, Occi::Core::Action) }.to raise_error(Occi::Errors::ParserTypeError)
|
160
158
|
end
|
161
159
|
end
|
@@ -221,26 +219,24 @@ module Occi
|
|
221
219
|
|
222
220
|
context '.parse_body_plain' do
|
223
221
|
it 'parses categories' do
|
224
|
-
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "
|
225
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_categories.dump", "rb"))
|
222
|
+
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "rt").read
|
226
223
|
categories = Occi::Parser.parse('text/plain', categories_string, true)
|
227
|
-
|
224
|
+
expected = File.open("spec/occi/parser/text_samples/occi_categories.body_plain.expected", "rt").read
|
225
|
+
expect(categories.to_text).to eql expected
|
228
226
|
end
|
229
227
|
|
230
228
|
it 'parses resources' do
|
231
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "
|
232
|
-
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.dump", "rb"))
|
229
|
+
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "rt").read
|
233
230
|
resource = Occi::Parser.parse('text/plain', resource_string, false, Occi::Core::Resource)
|
234
|
-
|
231
|
+
expected = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.body_plain.expected", "rt").read.chomp
|
232
|
+
expect(resource.to_text).to eql expected
|
235
233
|
end
|
236
234
|
|
237
235
|
it 'parses links' do
|
238
|
-
link_string = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.text", "
|
236
|
+
link_string = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.text", "rt").read
|
239
237
|
link = Occi::Parser.parse('text/plain', link_string, false, Occi::Core::Link)
|
240
|
-
expected =
|
241
|
-
|
242
|
-
link.links.each { |lnk| lnk.id = 'emptied' }
|
243
|
-
expect(link).to eql expected
|
238
|
+
expected = File.open("spec/occi/parser/text_samples/occi_link_resource_instance.body_plain.expected", "rt").read.chomp
|
239
|
+
expect(link.to_text).to eql expected
|
244
240
|
end
|
245
241
|
|
246
242
|
it 'copes with unknown entity type' do
|
@@ -249,5 +245,15 @@ module Occi
|
|
249
245
|
end
|
250
246
|
end
|
251
247
|
|
248
|
+
context 'output from other producers' do
|
249
|
+
it 'parses input from FogBow Cloud' do
|
250
|
+
category_string = File.open("spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text", "rt").read
|
251
|
+
collection = Occi::Parser.parse('text/plain', category_string)
|
252
|
+
expected = File.open("spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.parse.expected", "rt").read.chomp
|
253
|
+
expect(collection.to_text).to eql expected
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
252
258
|
end
|
253
259
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,8 @@ end
|
|
11
11
|
require 'occi-core'
|
12
12
|
require 'json_spec'
|
13
13
|
|
14
|
+
Dir["#{File.dirname(__FILE__)}/helpers/*.rb"].each {|file| require file }
|
15
|
+
|
14
16
|
# simplify the usage of VCR; this will allow us to use
|
15
17
|
#
|
16
18
|
# it "does something", :vcr do
|
@@ -23,7 +25,5 @@ require 'json_spec'
|
|
23
25
|
# ...
|
24
26
|
# end
|
25
27
|
RSpec.configure do |c|
|
26
|
-
# in RSpec 3 this will no longer be necessary.
|
27
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
28
28
|
c.include JsonSpec::Helpers
|
29
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Feldhaus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -164,6 +164,8 @@ files:
|
|
164
164
|
- lib/occi/settings.rb
|
165
165
|
- lib/occi/version.rb
|
166
166
|
- occi-core.gemspec
|
167
|
+
- spec/helpers/to_plain.rb
|
168
|
+
- spec/helpers/yaml_hash.rb
|
167
169
|
- spec/occi-core_spec.rb
|
168
170
|
- spec/occi/collection_samples/collection1.json
|
169
171
|
- spec/occi/collection_samples/directory2/collection2.json
|
@@ -191,33 +193,36 @@ files:
|
|
191
193
|
- spec/occi/log_spec.rb
|
192
194
|
- spec/occi/model_spec.rb
|
193
195
|
- spec/occi/parser/json_samples/test.json
|
194
|
-
- spec/occi/parser/text_samples/occi_categories.
|
196
|
+
- spec/occi/parser/text_samples/occi_categories.body_plain.expected
|
197
|
+
- spec/occi/parser/text_samples/occi_categories.expected
|
198
|
+
- spec/occi/parser/text_samples/occi_categories.parse_headers.expected
|
195
199
|
- spec/occi/parser/text_samples/occi_categories.text
|
196
|
-
- spec/occi/parser/text_samples/occi_compute_rocci_server.
|
197
|
-
- spec/occi/parser/text_samples/occi_compute_rocci_server.resource.dump
|
200
|
+
- spec/occi/parser/text_samples/occi_compute_rocci_server.expected
|
198
201
|
- spec/occi/parser/text_samples/occi_compute_rocci_server.text
|
199
|
-
- spec/occi/parser/text_samples/occi_link_resource_instance.
|
202
|
+
- spec/occi/parser/text_samples/occi_link_resource_instance.body_plain.expected
|
203
|
+
- spec/occi/parser/text_samples/occi_link_resource_instance.expected
|
204
|
+
- spec/occi/parser/text_samples/occi_link_resource_instance.parse.expected
|
200
205
|
- spec/occi/parser/text_samples/occi_link_resource_instance.text
|
201
|
-
- spec/occi/parser/text_samples/occi_link_simple.
|
202
|
-
- spec/occi/parser/text_samples/occi_link_simple.link_string.dump
|
206
|
+
- spec/occi/parser/text_samples/occi_link_simple.expected
|
203
207
|
- spec/occi/parser/text_samples/occi_link_simple.text
|
204
|
-
- spec/occi/parser/text_samples/occi_link_w_attributes.
|
208
|
+
- spec/occi/parser/text_samples/occi_link_w_attributes.expected
|
205
209
|
- spec/occi/parser/text_samples/occi_link_w_attributes.text
|
206
|
-
- spec/occi/parser/text_samples/occi_link_w_category.
|
210
|
+
- spec/occi/parser/text_samples/occi_link_w_category.expected
|
207
211
|
- spec/occi/parser/text_samples/occi_link_w_category.text
|
208
|
-
- spec/occi/parser/text_samples/
|
212
|
+
- spec/occi/parser/text_samples/occi_model_categories.expected
|
209
213
|
- spec/occi/parser/text_samples/occi_model_rocci_server.text
|
210
|
-
- spec/occi/parser/text_samples/occi_network_rocci_server.
|
211
|
-
- spec/occi/parser/text_samples/occi_network_rocci_server.
|
214
|
+
- spec/occi/parser/text_samples/occi_network_rocci_server.body_plain.expected
|
215
|
+
- spec/occi/parser/text_samples/occi_network_rocci_server.expected
|
216
|
+
- spec/occi/parser/text_samples/occi_network_rocci_server.resource.header.expected
|
217
|
+
- spec/occi/parser/text_samples/occi_network_rocci_server.resource.rack.expected
|
212
218
|
- spec/occi/parser/text_samples/occi_network_rocci_server.text
|
213
|
-
- spec/occi/parser/text_samples/
|
219
|
+
- spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.parse.expected
|
220
|
+
- spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text
|
214
221
|
- spec/occi/parser/text_samples/occi_resource_w_attributes.text
|
215
|
-
- spec/occi/parser/text_samples/occi_resource_w_inline_links.
|
222
|
+
- spec/occi/parser/text_samples/occi_resource_w_inline_links.expected
|
216
223
|
- spec/occi/parser/text_samples/occi_resource_w_inline_links.text
|
217
|
-
- spec/occi/parser/text_samples/occi_resource_w_inline_links_only.dump
|
218
224
|
- spec/occi/parser/text_samples/occi_resource_w_inline_links_only.text
|
219
|
-
- spec/occi/parser/text_samples/occi_storage_rocci_server.
|
220
|
-
- spec/occi/parser/text_samples/occi_storage_rocci_server.resource.dump
|
225
|
+
- spec/occi/parser/text_samples/occi_storage_rocci_server.expected
|
221
226
|
- spec/occi/parser/text_samples/occi_storage_rocci_server.text
|
222
227
|
- spec/occi/parser/text_spec.rb
|
223
228
|
- spec/occi/parser_spec.rb
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|