occi-core 4.2.1 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/occi/collection.rb +4 -4
- data/lib/occi/core/attributes.rb +2 -1
- data/lib/occi/core/category.rb +2 -3
- data/lib/occi/core/mixin.rb +6 -6
- data/lib/occi/core/properties.rb +14 -19
- data/lib/occi/infrastructure/compute.rb +2 -2
- data/lib/occi/infrastructure/network.rb +2 -2
- data/lib/occi/infrastructure/network/ipnetwork.rb +3 -3
- data/lib/occi/infrastructure/networkinterface.rb +4 -4
- data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +3 -3
- data/lib/occi/infrastructure/os_tpl.rb +3 -3
- data/lib/occi/infrastructure/resource_tpl.rb +3 -3
- data/lib/occi/infrastructure/storage.rb +2 -2
- data/lib/occi/infrastructure/storagelink.rb +4 -4
- data/lib/occi/version.rb +1 -1
- data/spec/occi/collection_spec.rb +5 -5
- data/spec/occi/core/properties_spec.rb +5 -1
- data/spec/occi/model_spec.rb +1 -8
- metadata +3 -3
data/lib/occi/collection.rb
CHANGED
@@ -20,11 +20,11 @@ module Occi
|
|
20
20
|
|
21
21
|
self.model = model if model
|
22
22
|
|
23
|
-
@kinds.merge collection.kinds.to_a.collect { |kind| Occi::Core::Kind.new(kind.scheme, kind.term, kind.title, kind.attributes, kind.related, kind.actions) }
|
24
|
-
@mixins.merge collection.mixins.to_a.collect { |mixin| Occi::Core::Mixin.new(mixin.scheme, mixin.term, mixin.title, mixin.attributes, mixin.
|
23
|
+
@kinds.merge collection.kinds.to_a.collect { |kind| Occi::Core::Kind.new(kind.scheme, kind.term, kind.title, kind.attributes, kind.related, kind.actions, kind.location) }
|
24
|
+
@mixins.merge collection.mixins.to_a.collect { |mixin| Occi::Core::Mixin.new(mixin.scheme, mixin.term, mixin.title, mixin.attributes, mixin.depends, mixin.actions, mixin.location, mixin.applies) }
|
25
25
|
@actions.merge collection.actions.to_a.collect { |action| Occi::Core::Action.new(action.scheme, action.term, action.title, action.attributes) }
|
26
|
-
@resources.merge collection.resources.to_a.collect { |resource| Occi::Core::Resource.new(resource.kind, resource.mixins, resource.attributes, resource.links) }
|
27
|
-
@links.merge collection.links.to_a.collect { |link| Occi::Core::Link.new(link.kind, link.mixins, link.attributes) }
|
26
|
+
@resources.merge collection.resources.to_a.collect { |resource| Occi::Core::Resource.new(resource.kind, resource.mixins, resource.attributes, resource.actions, resource.links, resource.location) }
|
27
|
+
@links.merge collection.links.to_a.collect { |link| Occi::Core::Link.new(link.kind, link.mixins, link.attributes, link.actions, link.rel, link.target, link.source, link.location) }
|
28
28
|
@action = Occi::Core::ActionInstance.new(collection.action) if collection.action
|
29
29
|
end
|
30
30
|
|
data/lib/occi/core/attributes.rb
CHANGED
@@ -101,9 +101,10 @@ module Occi
|
|
101
101
|
attributes = Occi::Core::Attributes.new
|
102
102
|
hash.each_pair do |key, value|
|
103
103
|
if Occi::Core::Properties.contains_props?(value)
|
104
|
+
value = value.to_hash if value.kind_of?(Hashie::Mash)
|
104
105
|
attributes[key] = Occi::Core::Properties.new(value)
|
105
106
|
else
|
106
|
-
attributes[key] = self.parse_properties(
|
107
|
+
attributes[key] = self.parse_properties(value)
|
107
108
|
end
|
108
109
|
end
|
109
110
|
|
data/lib/occi/core/category.rb
CHANGED
@@ -14,9 +14,8 @@ module Occi
|
|
14
14
|
def initialize(scheme='http://schemas.ogf.org/occi/core#',
|
15
15
|
term='category',
|
16
16
|
title=nil,
|
17
|
-
attributes=
|
18
|
-
raise ArgumentError, '
|
19
|
-
raise ArgumentError, 'scheme and term cannot be empty' if scheme.empty? || term.empty?
|
17
|
+
attributes=nil)
|
18
|
+
raise ArgumentError, 'Scheme and term cannot be empty' if scheme.blank? || term.blank?
|
20
19
|
attributes ||= Occi::Core::Attributes.new
|
21
20
|
|
22
21
|
scheme << '#' unless scheme.end_with? '#'
|
data/lib/occi/core/mixin.rb
CHANGED
@@ -23,7 +23,7 @@ module Occi
|
|
23
23
|
@depends = Occi::Core::Dependencies.new depends
|
24
24
|
@actions = Occi::Core::Actions.new actions
|
25
25
|
@entities = Occi::Core::Entities.new
|
26
|
-
location.blank? ?
|
26
|
+
@location = location.blank? ? "/mixin/#{term}/" : location
|
27
27
|
@applies = Occi::Core::Kinds.new applies
|
28
28
|
end
|
29
29
|
|
@@ -32,7 +32,7 @@ module Occi
|
|
32
32
|
# @param kind [Occi::Core::Mixin, String] Mixin or Type Identifier of a Mixin where relation should be checked.
|
33
33
|
# @return [true,false]
|
34
34
|
def related_to?(mixin)
|
35
|
-
self.
|
35
|
+
self.to_s == mixin.to_s || self.related.include?(mixin.to_s)
|
36
36
|
end
|
37
37
|
|
38
38
|
def location
|
@@ -40,16 +40,16 @@ module Occi
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def related
|
43
|
-
self.depends
|
43
|
+
self.depends.to_a.concat(self.applies.to_a).uniq
|
44
44
|
end
|
45
45
|
|
46
46
|
# @param [Hash] options
|
47
47
|
# @return [Hashie::Mash] json representation
|
48
48
|
def as_json(options={})
|
49
49
|
mixin = Hashie::Mash.new
|
50
|
-
mixin.
|
51
|
-
mixin.applies = self.applies.
|
52
|
-
mixin.related = self.related.
|
50
|
+
mixin.depends = self.depends.to_a.collect { |m| m.type_identifier } if self.depends.any?
|
51
|
+
mixin.applies = self.applies.to_a.collect { |m| m.type_identifier } if self.applies.any?
|
52
|
+
mixin.related = self.related.to_a.collect { |m| m.type_identifier } if self.related.any?
|
53
53
|
mixin.actions = self.actions if self.actions.any?
|
54
54
|
mixin.location = self.location if self.location
|
55
55
|
mixin.merge! super
|
data/lib/occi/core/properties.rb
CHANGED
@@ -12,7 +12,7 @@ module Occi
|
|
12
12
|
alias_method :mutable?, :mutable
|
13
13
|
|
14
14
|
# Types supported in properties, and their mapping to Ruby Classes
|
15
|
-
SUPPORTED_TYPES =
|
15
|
+
SUPPORTED_TYPES = {}
|
16
16
|
SUPPORTED_TYPES["string"] = [ String ]
|
17
17
|
SUPPORTED_TYPES["number"] = [ Numeric ]
|
18
18
|
SUPPORTED_TYPES["boolean"] = [ TrueClass, FalseClass ]
|
@@ -23,13 +23,10 @@ module Occi
|
|
23
23
|
raise ArgumentError, 'Source_hash must not be a Hashie::Mash instance!' if source_hash.kind_of?(Hashie::Mash)
|
24
24
|
source_hash = Occi::Core::Properties.normalize_props(source_hash)
|
25
25
|
|
26
|
-
self.type = source_hash[:type]
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
self.required = source_hash[:required] = source_hash[:required].nil? ? false : source_hash[:required]
|
31
|
-
self.mutable = source_hash[:mutable] = source_hash[:mutable].nil? ? false : source_hash[:mutable]
|
32
|
-
self.pattern = source_hash[:pattern] ||= '.*'
|
26
|
+
self.type = source_hash[:type] || 'string'
|
27
|
+
self.required = source_hash[:required].nil? ? false : source_hash[:required]
|
28
|
+
self.mutable = source_hash[:mutable].nil? ? false : source_hash[:mutable]
|
29
|
+
self.pattern = source_hash[:pattern] || '.*'
|
33
30
|
self.description = source_hash[:description]
|
34
31
|
self.default = source_hash[:default]
|
35
32
|
end
|
@@ -44,16 +41,13 @@ module Occi
|
|
44
41
|
|
45
42
|
# @param value [Object] Object whose class will be checked against definition
|
46
43
|
def check_value_for_type(value, key_name = nil)
|
47
|
-
raise Occi::Errors::AttributePropertyTypeError,
|
48
|
-
"Property type #{@type} for #{key_name.inspect} is not one of the allowed " \
|
49
|
-
"types: #{Properties.supported_type_names}" unless SUPPORTED_TYPES.key?(@type)
|
50
44
|
raise Occi::Errors::AttributeTypeError,
|
51
45
|
"Attribute value #{value} for #{key_name.inspect} is class #{value.class.name}. " \
|
52
46
|
"It does not match attribute property type #{@type}" unless SUPPORTED_TYPES[@type].any? { |klasse| value.kind_of?(klasse) }
|
53
47
|
end
|
54
48
|
|
55
49
|
def to_hash
|
56
|
-
as_json
|
50
|
+
as_json
|
57
51
|
end
|
58
52
|
|
59
53
|
def to_json(*a)
|
@@ -61,13 +55,14 @@ module Occi
|
|
61
55
|
end
|
62
56
|
|
63
57
|
def as_json(options={})
|
64
|
-
hash =
|
65
|
-
|
66
|
-
hash
|
67
|
-
hash
|
68
|
-
hash
|
69
|
-
hash
|
70
|
-
hash
|
58
|
+
hash = {}
|
59
|
+
|
60
|
+
hash["default"] = self.default if self.default
|
61
|
+
hash["type"] = self.type if self.type
|
62
|
+
hash["required"] = self.required unless self.required.nil?
|
63
|
+
hash["mutable"] = self.mutable unless self.mutable.nil?
|
64
|
+
hash["pattern"] = self.pattern if self.pattern
|
65
|
+
hash["description"] = self.description if self.description
|
71
66
|
|
72
67
|
hash
|
73
68
|
end
|
@@ -46,9 +46,9 @@ module Occi
|
|
46
46
|
self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
47
47
|
term='compute',
|
48
48
|
title = 'compute resource',
|
49
|
-
attributes=self.attributes,
|
49
|
+
attributes=Occi::Core::Attributes.new(self.attributes),
|
50
50
|
parent=Occi::Core::Resource.kind,
|
51
|
-
actions = self.actions,
|
51
|
+
actions = Occi::Core::Actions.new(self.actions),
|
52
52
|
location = '/compute/'
|
53
53
|
|
54
54
|
require 'occi/infrastructure/resource_tpl'
|
@@ -25,9 +25,9 @@ module Occi
|
|
25
25
|
self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
26
26
|
term='network',
|
27
27
|
title = 'network resource',
|
28
|
-
attributes=self.attributes,
|
28
|
+
attributes=Occi::Core::Attributes.new(self.attributes),
|
29
29
|
parent=Occi::Core::Resource.kind,
|
30
|
-
actions = self.actions,
|
30
|
+
actions = Occi::Core::Actions.new(self.actions),
|
31
31
|
location = '/network/'
|
32
32
|
|
33
33
|
require 'occi/infrastructure/network/ipnetwork'
|
@@ -16,13 +16,13 @@ module Occi
|
|
16
16
|
self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure/network#',
|
17
17
|
term='ipnetwork',
|
18
18
|
title='IP network mixin',
|
19
|
-
attributes=self.attributes,
|
19
|
+
attributes=Occi::Core::Attributes.new(self.attributes),
|
20
20
|
dependencies=Occi::Core::Dependencies.new,
|
21
21
|
actions=Occi::Core::Actions.new,
|
22
|
-
location='/
|
22
|
+
location='/mixin/ipnetwork/',
|
23
23
|
applies=Occi::Core::Kinds.new << Occi::Infrastructure::Network.kind
|
24
24
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
@@ -22,10 +22,10 @@ module Occi
|
|
22
22
|
self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
23
23
|
term='networkinterface',
|
24
24
|
title = 'networkinterface link',
|
25
|
-
attributes = self.attributes,
|
25
|
+
attributes = Occi::Core::Attributes.new(self.attributes),
|
26
26
|
parent = Occi::Core::Link.kind,
|
27
|
-
actions = self.actions,
|
28
|
-
location = '/networkinterface/'
|
27
|
+
actions = Occi::Core::Actions.new(self.actions),
|
28
|
+
location = '/link/networkinterface/'
|
29
29
|
|
30
30
|
require 'occi/infrastructure/networkinterface/ipnetworkinterface'
|
31
31
|
self.mixins = Occi::Core::Mixins.new << Occi::Infrastructure::Networkinterface::Ipnetworkinterface.mixin
|
@@ -99,4 +99,4 @@ module Occi
|
|
99
99
|
|
100
100
|
end
|
101
101
|
end
|
102
|
-
end
|
102
|
+
end
|
@@ -16,13 +16,13 @@ module Occi
|
|
16
16
|
self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface#',
|
17
17
|
term='ipnetworkinterface',
|
18
18
|
title='IP network interface mixin',
|
19
|
-
attributes=self.attributes,
|
19
|
+
attributes=Occi::Core::Attributes.new(self.attributes),
|
20
20
|
dependencies=Occi::Core::Dependencies.new,
|
21
21
|
actions=Occi::Core::Actions.new,
|
22
|
-
location='/
|
22
|
+
location='/mixin/ipnetworkinterface/',
|
23
23
|
applies=Occi::Core::Kinds.new << Occi::Infrastructure::Network.kind
|
24
24
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
@@ -9,11 +9,11 @@ module Occi
|
|
9
9
|
self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
10
10
|
term='os_tpl',
|
11
11
|
title='operating system template',
|
12
|
-
attributes=self.attributes,
|
12
|
+
attributes=Occi::Core::Attributes.new(self.attributes),
|
13
13
|
related=Occi::Core::Categories.new << Occi::Infrastructure::Compute.kind,
|
14
14
|
actions=Occi::Core::Actions.new,
|
15
|
-
location='/
|
15
|
+
location='/mixin/os_tpl/'
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -9,11 +9,11 @@ module Occi
|
|
9
9
|
self.mixin = Occi::Core::Mixin.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
10
10
|
term='resource_tpl',
|
11
11
|
title='resource template',
|
12
|
-
attributes=self.attributes,
|
12
|
+
attributes=Occi::Core::Attributes.new(self.attributes),
|
13
13
|
related=Occi::Core::Categories.new << Occi::Infrastructure::Compute.kind,
|
14
14
|
actions=Occi::Core::Actions.new,
|
15
|
-
location='/
|
15
|
+
location='/mixin/resource_tpl/'
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -36,9 +36,9 @@ module Occi
|
|
36
36
|
self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
37
37
|
term='storage',
|
38
38
|
title = 'storage resource',
|
39
|
-
attributes = self.attributes,
|
39
|
+
attributes = Occi::Core::Attributes.new(self.attributes),
|
40
40
|
parent=Occi::Core::Resource.kind,
|
41
|
-
actions = self.actions,
|
41
|
+
actions = Occi::Core::Actions.new(self.actions),
|
42
42
|
location = '/storage/'
|
43
43
|
|
44
44
|
def size
|
@@ -21,10 +21,10 @@ module Occi
|
|
21
21
|
self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/infrastructure#',
|
22
22
|
term='storagelink',
|
23
23
|
title = 'storage link',
|
24
|
-
attributes = self.attributes,
|
24
|
+
attributes = Occi::Core::Attributes.new(self.attributes),
|
25
25
|
parent=Occi::Core::Link.kind,
|
26
|
-
actions = self.actions,
|
27
|
-
location = '/storagelink/'
|
26
|
+
actions = Occi::Core::Actions.new(self.actions),
|
27
|
+
location = '/link/storagelink/'
|
28
28
|
|
29
29
|
|
30
30
|
def deviceid
|
@@ -53,4 +53,4 @@ module Occi
|
|
53
53
|
|
54
54
|
end
|
55
55
|
end
|
56
|
-
end
|
56
|
+
end
|
data/lib/occi/version.rb
CHANGED
@@ -720,7 +720,7 @@ module Occi
|
|
720
720
|
|
721
721
|
context '#get_by_location' do
|
722
722
|
it 'finds category by location' do
|
723
|
-
expect(collection.get_by_location("/
|
723
|
+
expect(collection.get_by_location("/mixin/my_mixin/")).to eql collection.mixins.first
|
724
724
|
end
|
725
725
|
|
726
726
|
it 'fails gracefully' do
|
@@ -775,7 +775,7 @@ module Occi
|
|
775
775
|
collection.action = Occi::Core::ActionInstance.new
|
776
776
|
collection.resources << Occi::Core::Resource.new
|
777
777
|
collection.links << Occi::Core::Link.new
|
778
|
-
expected = "{\"action\":{\"action\":\"http://schemas.ogf.org/occi/core#action_instance\",\"attributes\":{}},\"actions\":[{\"scheme\":\"http://schemas.ogf.org/occi/infrastructure/compute/action#\",\"term\":\"start\",\"attributes\":{}}],\"kinds\":[{\"parent\":\"http://schemas.ogf.org/occi/core#resource\",\"related\":[\"http://schemas.ogf.org/occi/core#resource\"],\"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\"],\"location\":\"/compute/\",\"scheme\":\"http://schemas.ogf.org/occi/infrastructure#\",\"term\":\"compute\",\"title\":\"compute resource\",\"attributes\":{\"occi\":{\"core\":{\"id\":{\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"},\"title\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"summary\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"}},\"compute\":{\"architecture\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"x86|x64\"},\"cores\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"hostname\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*\"},\"memory\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"speed\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"state\":{\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"inactive|active|suspended|error\"}}}}}],\"links\":[{\"kind\":\"http://schemas.ogf.org/occi/core#link\",\"attributes\":{\"occi\":{\"core\":{\"id\":\"#{collection.links.first.id}\"}}},\"id\":\"#{collection.links.first.id}\",\"rel\":\"http://schemas.ogf.org/occi/core#link\"}],\"mixins\":[{\"location\":\"/
|
778
|
+
expected = "{\"action\":{\"action\":\"http://schemas.ogf.org/occi/core#action_instance\",\"attributes\":{}},\"actions\":[{\"scheme\":\"http://schemas.ogf.org/occi/infrastructure/compute/action#\",\"term\":\"start\",\"attributes\":{}}],\"kinds\":[{\"parent\":\"http://schemas.ogf.org/occi/core#resource\",\"related\":[\"http://schemas.ogf.org/occi/core#resource\"],\"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\"],\"location\":\"/compute/\",\"scheme\":\"http://schemas.ogf.org/occi/infrastructure#\",\"term\":\"compute\",\"title\":\"compute resource\",\"attributes\":{\"occi\":{\"core\":{\"id\":{\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"},\"title\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"summary\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"}},\"compute\":{\"architecture\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"x86|x64\"},\"cores\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"hostname\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*\"},\"memory\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"speed\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"state\":{\"default\":\"inactive\",\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"inactive|active|suspended|error\"}}}}}],\"links\":[{\"kind\":\"http://schemas.ogf.org/occi/core#link\",\"attributes\":{\"occi\":{\"core\":{\"id\":\"#{collection.links.first.id}\"}}},\"id\":\"#{collection.links.first.id}\",\"rel\":\"http://schemas.ogf.org/occi/core#link\"}],\"mixins\":[{\"location\":\"/mixin/my_mixin/\",\"scheme\":\"http://example.com/occi/tags#\",\"term\":\"my_mixin\",\"attributes\":{}}],\"resources\":[{\"kind\":\"http://schemas.ogf.org/occi/core#resource\",\"attributes\":{\"occi\":{\"core\":{\"id\":\"#{collection.resources.first.id}\"}}},\"id\":\"#{collection.resources.first.id}\"}]}"
|
779
779
|
|
780
780
|
hash=Hashie::Mash.new(JSON.parse(expected))
|
781
781
|
expect(collection.as_json).to eql(hash)
|
@@ -794,7 +794,7 @@ module Occi
|
|
794
794
|
collection.actions << "http://schemas.ogf.org/occi/infrastructure/compute/action#start"
|
795
795
|
collection.action = Occi::Core::ActionInstance.new
|
796
796
|
collection.links << Occi::Core::Link.new
|
797
|
-
expected = "{\"action\":{\"action\":\"http://schemas.ogf.org/occi/core#action_instance\",\"attributes\":{}},\"actions\":[{\"scheme\":\"http://schemas.ogf.org/occi/infrastructure/compute/action#\",\"term\":\"start\",\"attributes\":{}}],\"kinds\":[{\"parent\":\"http://schemas.ogf.org/occi/core#resource\",\"related\":[\"http://schemas.ogf.org/occi/core#resource\"],\"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\"],\"location\":\"/compute/\",\"scheme\":\"http://schemas.ogf.org/occi/infrastructure#\",\"term\":\"compute\",\"title\":\"compute resource\",\"attributes\":{\"occi\":{\"core\":{\"id\":{\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"},\"title\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"summary\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"}},\"compute\":{\"architecture\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"x86|x64\"},\"cores\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"hostname\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*\"},\"memory\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"speed\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"state\":{\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"inactive|active|suspended|error\"}}}}}],\"links\":[{\"kind\":\"http://schemas.ogf.org/occi/core#link\",\"attributes\":{\"occi\":{\"core\":{\"id\":\"#{collection.links.first.id}\"}}},\"id\":\"#{collection.links.first.id}\",\"rel\":\"http://schemas.ogf.org/occi/core#link\"}],\"mixins\":[{\"location\":\"/
|
797
|
+
expected = "{\"action\":{\"action\":\"http://schemas.ogf.org/occi/core#action_instance\",\"attributes\":{}},\"actions\":[{\"scheme\":\"http://schemas.ogf.org/occi/infrastructure/compute/action#\",\"term\":\"start\",\"attributes\":{}}],\"kinds\":[{\"parent\":\"http://schemas.ogf.org/occi/core#resource\",\"related\":[\"http://schemas.ogf.org/occi/core#resource\"],\"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\"],\"location\":\"/compute/\",\"scheme\":\"http://schemas.ogf.org/occi/infrastructure#\",\"term\":\"compute\",\"title\":\"compute resource\",\"attributes\":{\"occi\":{\"core\":{\"id\":{\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"},\"title\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"summary\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"}},\"compute\":{\"architecture\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"x86|x64\"},\"cores\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"hostname\":{\"type\":\"string\",\"required\":false,\"mutable\":true,\"pattern\":\"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\\\-]*[a-zA-Z0-9])\\\\.)*\"},\"memory\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"speed\":{\"type\":\"number\",\"required\":false,\"mutable\":true,\"pattern\":\".*\"},\"state\":{\"default\":\"inactive\",\"type\":\"string\",\"required\":false,\"mutable\":false,\"pattern\":\"inactive|active|suspended|error\"}}}}}],\"links\":[{\"kind\":\"http://schemas.ogf.org/occi/core#link\",\"attributes\":{\"occi\":{\"core\":{\"id\":\"#{collection.links.first.id}\"}}},\"id\":\"#{collection.links.first.id}\",\"rel\":\"http://schemas.ogf.org/occi/core#link\"}],\"mixins\":[{\"location\":\"/mixin/my_mixin/\",\"scheme\":\"http://example.com/occi/tags#\",\"term\":\"my_mixin\",\"attributes\":{}}]}"
|
798
798
|
|
799
799
|
hash=Hashie::Mash.new(JSON.parse(expected))
|
800
800
|
expect(collection.as_json).to eql(hash)
|
@@ -811,7 +811,7 @@ module Occi
|
|
811
811
|
collection.resources << Occi::Core::Resource.new
|
812
812
|
collection.links << Occi::Core::Link.new
|
813
813
|
|
814
|
-
expected = "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.core.id occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state\";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\"\nCategory: my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\";location=\"/
|
814
|
+
expected = "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.core.id occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state\";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\"\nCategory: my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\";location=\"/mixin/my_mixin/\"\nCategory: start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\"\nCategory: resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.resources.first.id}\"Link: <>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/#{collection.links.first.id}\";category=\"http://schemas.ogf.org/occi/core#link\";occi.core.id=\"#{collection.links.first.id}\"Category: action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
815
815
|
expect(collection.to_text).to eql(expected)
|
816
816
|
end
|
817
817
|
|
@@ -828,7 +828,7 @@ module Occi
|
|
828
828
|
|
829
829
|
it 'renders text correctly, mixins only' do
|
830
830
|
collection.mixins << "http://example.com/occi/tags#my_mixin"
|
831
|
-
expected = "Category: my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\";location=\"/
|
831
|
+
expected = "Category: my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\";location=\"/mixin/my_mixin/\"\n"
|
832
832
|
expect(collection.to_text).to eql(expected)
|
833
833
|
end
|
834
834
|
|
@@ -95,6 +95,8 @@ module Occi
|
|
95
95
|
context '#to_hash' do
|
96
96
|
it 'makes a correct rendering' do
|
97
97
|
expected = Hash.new
|
98
|
+
|
99
|
+
expected["default"] = "defaultvalue"
|
98
100
|
expected["description"] = "Required string value"
|
99
101
|
expected["mutable"] = true
|
100
102
|
expected["pattern"] = "[adefltuv]+"
|
@@ -108,6 +110,8 @@ module Occi
|
|
108
110
|
context '#as_json' do
|
109
111
|
it 'makes a correct rendering' do
|
110
112
|
expected = Hash.new
|
113
|
+
|
114
|
+
expected["default"] = "defaultvalue"
|
111
115
|
expected["description"] = "Required string value"
|
112
116
|
expected["mutable"] = true
|
113
117
|
expected["pattern"] = "[adefltuv]+"
|
@@ -132,7 +136,7 @@ module Occi
|
|
132
136
|
|
133
137
|
context '#to_json' do
|
134
138
|
it 'makes a correct rendering' do
|
135
|
-
expected = '{"type":"string","required":true,"mutable":true,"pattern":"[adefltuv]+","description":"Required string value"}'
|
139
|
+
expected = '{"default":"defaultvalue","type":"string","required":true,"mutable":true,"pattern":"[adefltuv]+","description":"Required string value"}'
|
136
140
|
expect(properties.to_json).to eql expected
|
137
141
|
end
|
138
142
|
end
|
data/spec/occi/model_spec.rb
CHANGED
@@ -245,19 +245,12 @@ module Occi
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
-
context 'for
|
248
|
+
context 'for nonexistent directory' do
|
249
249
|
it 'fails gracefully' do
|
250
250
|
model = Occi::Model.new
|
251
251
|
expect{ model.register_files('this/directory/does/not/exist') }.to raise_exception(ArgumentError)
|
252
252
|
end
|
253
253
|
end
|
254
|
-
|
255
|
-
context 'for invalid input' do
|
256
|
-
it 'fails gracefully' do
|
257
|
-
model = Occi::Model.new
|
258
|
-
expect{ model.register_files('spec/occi') }.to raise_exception(ArgumentError)
|
259
|
-
end
|
260
|
-
end
|
261
254
|
end
|
262
255
|
end
|
263
256
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-12-
|
14
|
+
date: 2013-12-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
276
|
version: '0'
|
277
277
|
segments:
|
278
278
|
- 0
|
279
|
-
hash:
|
279
|
+
hash: 118686830744215401
|
280
280
|
requirements: []
|
281
281
|
rubyforge_project:
|
282
282
|
rubygems_version: 1.8.25
|