occi-core 4.2.4 → 4.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
+ - 2.1.0
6
7
  - ruby-head
7
8
  - jruby-19mode
8
9
  - jruby-head
@@ -25,13 +26,19 @@ matrix:
25
26
  jdk: openjdk7
26
27
  - rvm: 2.0.0
27
28
  jdk: oraclejdk7
29
+ - rvm: 2.1.0
30
+ jdk: openjdk7
31
+ - rvm: 2.1.0
32
+ jdk: oraclejdk7
28
33
  - rvm: ruby-head
29
34
  jdk: openjdk7
30
35
  - rvm: ruby-head
31
36
  jdk: oraclejdk7
37
+ fast_finish: true
32
38
 
33
39
  branches:
34
40
  only:
35
41
  - master
36
42
  - 4.0.x
37
43
  - 4.1.x
44
+ - 4.2.x
@@ -18,14 +18,14 @@ module Occi
18
18
  @resources = Occi::Core::Resources.new
19
19
  @links = Occi::Core::Links.new
20
20
 
21
- self.model = model if model
22
-
23
21
  @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
22
  @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
23
  @actions.merge collection.actions.to_a.collect { |action| Occi::Core::Action.new(action.scheme, action.term, action.title, action.attributes) }
26
24
  @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
25
  @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
- @action = Occi::Core::ActionInstance.new(collection.action) if collection.action
26
+ @action = Occi::Core::ActionInstance.new(collection.action.action, collection.action.attributes) if collection.action
27
+
28
+ self.model = model if model
29
29
  end
30
30
 
31
31
  def <<(object)
@@ -35,6 +35,8 @@ module Occi
35
35
  self.resources << object if object.kind_of? Occi::Core::Resource
36
36
  self.links << object if object.kind_of? Occi::Core::Link
37
37
 
38
+ self.action = object if object.kind_of? Occi::Core::ActionInstance
39
+
38
40
  self
39
41
  end
40
42
 
@@ -52,18 +54,18 @@ module Occi
52
54
  # @return [Occi::Core::Model]
53
55
  def model=(model)
54
56
  @model = model
57
+
55
58
  @kinds.model = model
56
59
  @mixins.model = model
57
60
  @actions.model = model
58
61
  @resources.model = model
59
62
  @links.model = model
63
+
64
+ @action.model = model if @action
60
65
  end
61
66
 
62
67
  def check
63
- @resources.check
64
- @links.check
65
- # TODO: check action instance format, should check be applicable?
66
- #@action.check
68
+ @resources.check && @links.check && (@action ? @action.check : true)
67
69
  end
68
70
 
69
71
  # @param [Occi::Collection] other_collection
@@ -104,11 +106,13 @@ module Occi
104
106
  collection.actions.replace other_collection.actions.select { |action| get_by_id(action.type_identifier) }
105
107
  collection.resources.replace other_collection.resources.select { |resource| get_by_id(resource.id) }
106
108
  collection.links.replace other_collection.links.select { |link| get_by_id(link.id) }
109
+
107
110
  if collection.action == other_collection.action
108
111
  collection.action = other_collection.action
109
112
  else
110
113
  collection.action = nil
111
114
  end
115
+
112
116
  collection
113
117
  end
114
118
 
@@ -148,6 +152,8 @@ module Occi
148
152
 
149
153
  # @return [Hashie::Mash] json representation
150
154
  def as_json(options = {})
155
+ return @action.as_json if standalone_action_instance?
156
+
151
157
  collection = Hashie::Mash.new
152
158
  collection.kinds = @kinds.collect { |kind| kind.as_json } if @kinds.any?
153
159
  collection.mixins = @mixins.collect { |mixin| mixin.as_json } if @mixins.any?
@@ -167,7 +173,6 @@ module Occi
167
173
  end
168
174
  collection.links = lnks.collect { |link| link.as_json } if lnks.to_a.any?
169
175
 
170
- collection.action = @action.as_json if @action
171
176
  collection
172
177
  end
173
178
 
@@ -14,20 +14,22 @@ module Occi
14
14
  self.action = Occi::Core::Action.new scheme='http://schemas.ogf.org/occi/core#',
15
15
  term='action_instance',
16
16
  title='action',
17
- attributes=self.attributes
17
+ attributes=Occi::Core::Attributes.new(self.attributes)
18
18
 
19
19
  def initialize(action = self.action, attributes=self.attributes)
20
20
  raise ArgumentError, 'action cannot be nil' unless action
21
- raise ArgumentError, 'attributes cannot be nil' unless attributes
22
- raise ArgumentError, 'attributes must respond to #convert' unless attributes.respond_to? :convert
23
21
 
24
22
  if action.kind_of? String
25
23
  scheme, term = action.split '#'
26
24
  action = Occi::Core::Action.new(scheme, term)
27
25
  end
28
-
29
26
  @action = action
30
- @attributes = Occi::Core::Attributes.new(attributes)
27
+
28
+ if attributes.kind_of? Occi::Core::Attributes
29
+ @attributes = attributes.convert
30
+ else
31
+ @attributes = Occi::Core::Attributes.new(attributes || {})
32
+ end
31
33
  end
32
34
 
33
35
  # @param [Hash] options
@@ -75,6 +77,12 @@ module Occi
75
77
  action.nil? || action.empty?
76
78
  end
77
79
 
80
+ # @return [Bool] Result of the validation process
81
+ def check
82
+ # TODO: impl check for ActionInstance attributes
83
+ true
84
+ end
85
+
78
86
  end
79
87
  end
80
88
  end
@@ -288,7 +288,7 @@ module Occi
288
288
  raise Occi::Errors::AttributeTypeError,
289
289
  "Value #{value.to_s} does not match pattern #{pattern}" unless value.to_s.match "^#{pattern}$"
290
290
  else
291
- Occi::Log.warn "[#{self.class}] Skipping pattern checks on attributes, turn off " \
291
+ Occi::Log.debug "[#{self.class}] Skipping pattern checks on attributes, turn off " \
292
292
  "the compatibility mode and enable the attribute pattern check in settings!"
293
293
  end
294
294
  end
@@ -337,7 +337,7 @@ module Occi
337
337
  "Attribute #{key} with value #{attributes[key]} does not " \
338
338
  "match pattern #{definitions[key].pattern}" unless attributes[key].to_s.match "^#{definitions[key].pattern}$"
339
339
  else
340
- Occi::Log.warn "[#{self.class}] [#{key}] Skipping pattern checks on attributes, turn off " \
340
+ Occi::Log.debug "[#{self.class}] [#{key}] Skipping pattern checks on attributes, turn off " \
341
341
  "the compatibility mode and enable the attribute pattern check in settings!"
342
342
  end
343
343
  end
@@ -160,10 +160,11 @@ module Occi
160
160
  # @param [true,false] set default values for all empty attributes
161
161
  def check(set_defaults = false)
162
162
 
163
- raise ArgumentError, 'No model has been assigned to this entity' unless @model # XXX: Needs error type
163
+ raise ArgumentError, 'No model has been assigned to this entity' unless @model
164
164
 
165
165
  kind = @model.get_by_id(@kind.to_s)
166
- raise Occi::Errors::KindNotDefinedError, "Kind not found for entity #{self.to_s}!" unless kind # XXX: Needs error type
166
+ raise Occi::Errors::KindNotDefinedError,
167
+ "Kind not found for entity #{self.class.name}[#{self.to_s.inspect}]!" unless kind
167
168
 
168
169
  definitions = Occi::Core::Attributes.new
169
170
  definitions.merge! kind.attributes
@@ -4,12 +4,14 @@ module Occi
4
4
 
5
5
  attr_accessor :entities, :depends, :actions, :location, :applies
6
6
 
7
- # @param [String ] scheme
7
+ # @param [String] scheme
8
8
  # @param [String] term
9
9
  # @param [String] title
10
10
  # @param [Occi::Core::Attributes,Hash,NilClass] attributes
11
- # @param [Occi::Core::Categories,Hash,NilClass] related
11
+ # @param [Occi::Core::Categories,Hash,NilClass] depends
12
12
  # @param [Occi::Core::Actions,Hash,NilClass] actions
13
+ # @param [String] location
14
+ # @param [Occi::Core::Kinds, NilClass] applies
13
15
  def initialize(scheme='http://schemas.ogf.org/occi/core#',
14
16
  term='mixin',
15
17
  title=nil,
@@ -10,9 +10,10 @@ module Occi
10
10
  term='os_tpl',
11
11
  title='operating system template',
12
12
  attributes=Occi::Core::Attributes.new(self.attributes),
13
- related=Occi::Core::Categories.new << Occi::Infrastructure::Compute.kind,
13
+ dependencies=Occi::Core::Dependencies.new,
14
14
  actions=Occi::Core::Actions.new,
15
- location='/mixin/os_tpl/'
15
+ location='/mixin/os_tpl/',
16
+ applies=Occi::Core::Kinds.new << Occi::Infrastructure::Compute.kind
16
17
  end
17
18
 
18
19
  end
@@ -10,9 +10,10 @@ module Occi
10
10
  term='resource_tpl',
11
11
  title='resource template',
12
12
  attributes=Occi::Core::Attributes.new(self.attributes),
13
- related=Occi::Core::Categories.new << Occi::Infrastructure::Compute.kind,
13
+ dependencies=Occi::Core::Dependencies.new,
14
14
  actions=Occi::Core::Actions.new,
15
- location='/mixin/resource_tpl/'
15
+ location='/mixin/resource_tpl/',
16
+ applies=Occi::Core::Kinds.new << Occi::Infrastructure::Compute.kind
16
17
  end
17
18
 
18
19
  end
@@ -14,7 +14,7 @@ module Occi
14
14
 
15
15
  # register Occi Core categories enitity, resource and link
16
16
  def register_core
17
- Occi::Log.info "[#{self.class}] Registering OCCI Core categories enitity, resource and link"
17
+ Occi::Log.debug "[#{self.class}] Registering OCCI Core categories enitity, resource and link"
18
18
  register Occi::Core::Entity.kind
19
19
  register Occi::Core::Resource.kind
20
20
  register Occi::Core::Link.kind
@@ -22,7 +22,7 @@ module Occi
22
22
 
23
23
  # register Occi Infrastructure categories
24
24
  def register_infrastructure
25
- Occi::Log.info "[#{self.class}] Registering OCCI Infrastructure categories"
25
+ Occi::Log.debug "[#{self.class}] Registering OCCI Infrastructure categories"
26
26
  Occi::Infrastructure.categories.each { |category| register category }
27
27
  end
28
28
 
@@ -32,7 +32,7 @@ module Occi
32
32
  # recursively searched for files with the extension .json .
33
33
  # @param [Sting] scheme_base_url base location for provider specific extensions of the OCCI model
34
34
  def register_files(path, scheme_base_url='http://localhost')
35
- Occi::Log.info "[#{self.class}] Initializing OCCI Model from #{path}"
35
+ Occi::Log.debug "[#{self.class}] Initializing OCCI Model from #{path}"
36
36
  raise ArgumentError, "Directory \"#{path}\" does not exist" unless File.directory?(path)
37
37
  Dir.glob(path + '/**/*.json').each do |file|
38
38
  collection = Occi::Collection.new(JSON.parse(File.read(file)))
@@ -22,7 +22,7 @@ module Occi
22
22
  collection = parse_headers(header, category, entity_type)
23
23
 
24
24
  Occi::Log.debug "[#{self}] Parsing #{media_type} from body"
25
- coll_body = parse_body(media_type, body, category, entity_type)
25
+ coll_body = parse_body(media_type, body || '', category, entity_type)
26
26
  collection.merge! coll_body if coll_body && !coll_body.empty?
27
27
 
28
28
  collection
@@ -62,6 +62,9 @@ module Occi
62
62
  elsif entity_type == Occi::Core::Link
63
63
  Occi::Log.debug "[#{self}] Parsing a link from headers"
64
64
  collection = Occi::Parser::Text.link(header)
65
+ elsif entity_type == Occi::Core::ActionInstance
66
+ Occi::Log.debug "[#{self}] Parsing an action instance from headers"
67
+ collection = Occi::Parser::Text.action(header)
65
68
  else
66
69
  raise Occi::Errors::ParserTypeError, "Entity type '#{entity_type}' not supported"
67
70
  end
@@ -98,12 +101,14 @@ module Occi
98
101
 
99
102
  def parse_body_plain(body, category, entity_type)
100
103
  if category
101
- collection = Occi::Parser::Text.categories body.split "\n"
104
+ collection = Occi::Parser::Text.categories body.split("\n")
102
105
  else
103
106
  if entity_type == Occi::Core::Resource
104
- collection = Occi::Parser::Text.resource body.split "\n"
107
+ collection = Occi::Parser::Text.resource body.split("\n")
105
108
  elsif entity_type == Occi::Core::Link
106
- collection = Occi::Parser::Text.link body.split "\n"
109
+ collection = Occi::Parser::Text.link body.split("\n")
110
+ elsif entity_type == Occi::Core::ActionInstance
111
+ collection = Occi::Parser::Text.action body.split("\n")
107
112
  else
108
113
  raise Occi::Errors::ParserTypeError, "Entity type #{entity_type} not supported"
109
114
  end
@@ -11,6 +11,8 @@ module Occi
11
11
  Occi::Log.error "[#{self}] Failed to parse JSON input: #{perr.message}"
12
12
  raise Occi::Errors::ParserInputError, perr.message
13
13
  end
14
+
15
+ hash = { :action => hash } if hash && hash.action
14
16
  collection = Occi::Collection.new(hash)
15
17
 
16
18
  if collection.resources.size == 1 && collection.links.size > 0
@@ -101,7 +101,7 @@ module Occi
101
101
  # match string to regular expression
102
102
  match = regexp.match string
103
103
 
104
- raise Occi::Errors::ParserInputError, "could not match #{string}" unless match
104
+ raise Occi::Errors::ParserInputError, "Could not match #{string}" unless match
105
105
 
106
106
  term = match[:term].downcase
107
107
  scheme = match[:scheme]
@@ -148,7 +148,7 @@ module Occi
148
148
  # match string to regular expression
149
149
  match = regexp.match string
150
150
 
151
- raise Occi::Errors::ParserInputError, "could not match #{string}" unless match
151
+ raise Occi::Errors::ParserInputError, "Could not match #{string}" unless match
152
152
 
153
153
  value = match[:string] if match[:string]
154
154
 
@@ -167,7 +167,7 @@ module Occi
167
167
  # match string to regular expression
168
168
  match = regexp.match string
169
169
 
170
- raise Occi::Errors::ParserInputError, "could not match #{string}" unless match
170
+ raise Occi::Errors::ParserInputError, "Could not match #{string}" unless match
171
171
 
172
172
  target = match[:uri]
173
173
  rel = match[:rel]
@@ -201,11 +201,38 @@ module Occi
201
201
  # match string to regular expression
202
202
  match = regexp.match string
203
203
 
204
- raise Occi::Errors::ParserInputError, "could not match #{string}" unless match
204
+ raise Occi::Errors::ParserInputError, "Could not match #{string}" unless match
205
205
 
206
206
  match[:location]
207
207
  end
208
208
 
209
+ def action(lines)
210
+ Occi::Log.debug "[#{self}] Parsing through Occi::Parser::Text.action"
211
+ collection = Occi::Collection.new
212
+ action_instance = nil
213
+
214
+ block = Proc.new { |line|
215
+ line.strip!
216
+
217
+ case line
218
+ when /^Category:/
219
+ action_instance = Occi::Core::ActionInstance.new
220
+ action_instance.action = category(line)
221
+ when /^X-OCCI-Attribute:/
222
+ raise Occi::Errors::ParserInputError,
223
+ "Line #{line.inspect} arrived out of order!" unless action_instance
224
+ action_instance.attributes.merge! attribute(line)
225
+ end
226
+ }
227
+ lines.respond_to?(:each) ? lines.each(&block) : lines.each_line(&block)
228
+
229
+ unless action_instance.blank?
230
+ collection << action_instance
231
+ end
232
+
233
+ collection
234
+ end
235
+
209
236
  end
210
237
 
211
238
  end
@@ -1,3 +1,3 @@
1
1
  module Occi
2
- VERSION = "4.2.4" unless defined?(::Occi::VERSION)
2
+ VERSION = "4.2.5" unless defined?(::Occi::VERSION)
3
3
  end
@@ -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\":{\"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}\"}]}"
778
+ expected = "{\"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\":{\"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\":{}}]}"
797
+ expected = "{\"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)
@@ -40,28 +40,28 @@ module Occi
40
40
  expect { Occi::Core::ActionInstance.new nil }.to raise_error(ArgumentError)
41
41
  end
42
42
 
43
- it 'fails without attributes' do
44
- expect { Occi::Core::ActionInstance.new action, nil }.to raise_error(ArgumentError)
43
+ it 'does not fail without attributes' do
44
+ expect { Occi::Core::ActionInstance.new action, nil }.not_to raise_error(ArgumentError)
45
45
  end
46
46
 
47
- it 'with an Occi::Core::Action instance' do
47
+ it 'does not fail with an Occi::Core::Action instance' do
48
48
  expect { Occi::Core::ActionInstance.new action }.not_to raise_error
49
49
  end
50
50
 
51
- it 'with a valid action type identifier' do
51
+ it 'does not fail with a valid action type identifier' do
52
52
  expect { Occi::Core::ActionInstance.new action_string }.not_to raise_error
53
53
  end
54
54
 
55
- it 'with an invalid action type identifier' do
55
+ it 'fails with an invalid action type identifier' do
56
56
  expect { Occi::Core::ActionInstance.new action_string_invalid }.to raise_error(ArgumentError)
57
57
  end
58
58
 
59
- it 'with an Occi::Core::Attributes instance' do
59
+ it 'does not fail with an Occi::Core::Attributes instance' do
60
60
  expect { Occi::Core::ActionInstance.new action, attributes }.not_to raise_error
61
61
  end
62
62
 
63
- it 'with un-convertable attribute values' do
64
- expect { Occi::Core::ActionInstance.new action, attributes_unconvertable}.to raise_error(ArgumentError)
63
+ it 'does not fail with un-convertable attribute values' do
64
+ expect { Occi::Core::ActionInstance.new action, attributes_unconvertable}.not_to raise_error(ArgumentError)
65
65
  end
66
66
  end
67
67
 
@@ -93,7 +93,7 @@ module Occi
93
93
  it 'renders to text w/ an attribute' do
94
94
  expected = %Q|Category: action;scheme="http://schemas.ogf.org/occi/core#";class="action"
95
95
  X-OCCI-Attribute: occi.core.title="test"|
96
- expect(Occi::Core::ActionInstance.new(action, attributes_one).to_text).to eq(expected)
96
+ expect(Occi::Core::ActionInstance.new(action, attributes_one.to_hash).to_text).to eq(expected)
97
97
  end
98
98
 
99
99
  it 'renders to text w/ attributes' do
@@ -101,12 +101,12 @@ X-OCCI-Attribute: occi.core.title="test"|
101
101
  X-OCCI-Attribute: occi.core.title="test"
102
102
  X-OCCI-Attribute: occi.core.id="1"
103
103
  X-OCCI-Attribute: org.opennebula.network.id=1|
104
- expect(Occi::Core::ActionInstance.new(action, attributes_multi).to_text).to eq(expected)
104
+ expect(Occi::Core::ActionInstance.new(action, attributes_multi.to_hash).to_text).to eq(expected)
105
105
  end
106
106
 
107
107
  it 'renders to text w/ a nil attribute' do
108
108
  expected = "Category: action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
109
- expect(Occi::Core::ActionInstance.new(action, attributes_wnil).to_text).to eq(expected)
109
+ expect(Occi::Core::ActionInstance.new(action, attributes_wnil.to_hash).to_text).to eq(expected)
110
110
  end
111
111
  end
112
112
 
@@ -121,7 +121,7 @@ X-OCCI-Attribute: org.opennebula.network.id=1|
121
121
  "Category" => "action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\"",
122
122
  "X-OCCI-Attribute" => "occi.core.title=\"test\""
123
123
  }
124
- expect(Occi::Core::ActionInstance.new(action, attributes_one).to_header).to eq(expected)
124
+ expect(Occi::Core::ActionInstance.new(action, attributes_one.to_hash).to_header).to eq(expected)
125
125
  end
126
126
 
127
127
  it 'renders to hash w/ attributes' do
@@ -129,12 +129,12 @@ X-OCCI-Attribute: org.opennebula.network.id=1|
129
129
  "Category" => "action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\"",
130
130
  "X-OCCI-Attribute" => "occi.core.title=\"test\",occi.core.id=\"1\",org.opennebula.network.id=1"
131
131
  }
132
- expect(Occi::Core::ActionInstance.new(action, attributes_multi).to_header).to eq(expected)
132
+ expect(Occi::Core::ActionInstance.new(action, attributes_multi.to_hash).to_header).to eq(expected)
133
133
  end
134
134
 
135
135
  it 'renders to hash w/ a nil attribute' do
136
136
  expected = {"Category" => "action;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""}
137
- expect(Occi::Core::ActionInstance.new(action, attributes_wnil).to_header).to eq(expected)
137
+ expect(Occi::Core::ActionInstance.new(action, attributes_wnil.to_hash).to_header).to eq(expected)
138
138
  end
139
139
  end
140
140
 
@@ -176,7 +176,7 @@ X-OCCI-Attribute: org.opennebula.network.id=1|
176
176
  expected.action = "http://schemas.ogf.org/occi/core#action"
177
177
  expected.attributes = {"occi" => {"core" => {"title" => "test"}}}
178
178
 
179
- expect(Occi::Core::ActionInstance.new(action, attributes_one).as_json).to eq(expected)
179
+ expect(Occi::Core::ActionInstance.new(action, attributes_one.to_hash).as_json).to eq(expected)
180
180
  end
181
181
 
182
182
  it 'renders to Hashie::Mash w/ attributes' do
@@ -187,7 +187,7 @@ X-OCCI-Attribute: org.opennebula.network.id=1|
187
187
  "org" => {"opennebula" => {"network" => {"id" => 1}}}
188
188
  }
189
189
 
190
- expect(Occi::Core::ActionInstance.new(action, attributes_multi).as_json).to eq(expected)
190
+ expect(Occi::Core::ActionInstance.new(action, attributes_multi.to_hash).as_json).to eq(expected)
191
191
  end
192
192
  end
193
193
 
@@ -170,7 +170,7 @@ module Occi
170
170
 
171
171
  it 'fails gracefully for unknown entity type' do
172
172
  resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "rb").read
173
- expect{ Occi::Parser.parse('text/plain', resource_string, false, Occi::Core::ActionInstance) }.to raise_error(Occi::Errors::ParserTypeError)
173
+ expect{ Occi::Parser.parse('text/plain', resource_string, false, Occi::Core::Action) }.to raise_error(Occi::Errors::ParserTypeError)
174
174
  end
175
175
  end
176
176
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occi-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.4
4
+ version: 4.2.5
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Florian Feldhaus
@@ -10,11 +11,12 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2014-01-06 00:00:00.000000000 Z
14
+ date: 2014-01-09 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: json
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
21
  - - ! '>='
20
22
  - !ruby/object:Gem::Version
@@ -22,6 +24,7 @@ dependencies:
22
24
  type: :runtime
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
29
  - - ! '>='
27
30
  - !ruby/object:Gem::Version
@@ -29,6 +32,7 @@ dependencies:
29
32
  - !ruby/object:Gem::Dependency
30
33
  name: hashie
31
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
32
36
  requirements:
33
37
  - - ! '>='
34
38
  - !ruby/object:Gem::Version
@@ -36,6 +40,7 @@ dependencies:
36
40
  type: :runtime
37
41
  prerelease: false
38
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
39
44
  requirements:
40
45
  - - ! '>='
41
46
  - !ruby/object:Gem::Version
@@ -43,6 +48,7 @@ dependencies:
43
48
  - !ruby/object:Gem::Dependency
44
49
  name: uuidtools
45
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
46
52
  requirements:
47
53
  - - ! '>='
48
54
  - !ruby/object:Gem::Version
@@ -50,6 +56,7 @@ dependencies:
50
56
  type: :runtime
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
53
60
  requirements:
54
61
  - - ! '>='
55
62
  - !ruby/object:Gem::Version
@@ -57,6 +64,7 @@ dependencies:
57
64
  - !ruby/object:Gem::Dependency
58
65
  name: nokogiri
59
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
69
  - - ~>
62
70
  - !ruby/object:Gem::Version
@@ -64,6 +72,7 @@ dependencies:
64
72
  type: :runtime
65
73
  prerelease: false
66
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
67
76
  requirements:
68
77
  - - ~>
69
78
  - !ruby/object:Gem::Version
@@ -71,6 +80,7 @@ dependencies:
71
80
  - !ruby/object:Gem::Dependency
72
81
  name: activesupport
73
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
74
84
  requirements:
75
85
  - - ~>
76
86
  - !ruby/object:Gem::Version
@@ -78,6 +88,7 @@ dependencies:
78
88
  type: :runtime
79
89
  prerelease: false
80
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
81
92
  requirements:
82
93
  - - ~>
83
94
  - !ruby/object:Gem::Version
@@ -85,6 +96,7 @@ dependencies:
85
96
  - !ruby/object:Gem::Dependency
86
97
  name: settingslogic
87
98
  requirement: !ruby/object:Gem::Requirement
99
+ none: false
88
100
  requirements:
89
101
  - - ! '>='
90
102
  - !ruby/object:Gem::Version
@@ -92,6 +104,7 @@ dependencies:
92
104
  type: :runtime
93
105
  prerelease: false
94
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
95
108
  requirements:
96
109
  - - ! '>='
97
110
  - !ruby/object:Gem::Version
@@ -245,25 +258,29 @@ files:
245
258
  homepage: https://github.com/gwdg/rOCCI-core
246
259
  licenses:
247
260
  - Apache License, Version 2.0
248
- metadata: {}
249
261
  post_install_message:
250
262
  rdoc_options: []
251
263
  require_paths:
252
264
  - lib
253
265
  required_ruby_version: !ruby/object:Gem::Requirement
266
+ none: false
254
267
  requirements:
255
268
  - - ! '>='
256
269
  - !ruby/object:Gem::Version
257
270
  version: 1.9.3
258
271
  required_rubygems_version: !ruby/object:Gem::Requirement
272
+ none: false
259
273
  requirements:
260
274
  - - ! '>='
261
275
  - !ruby/object:Gem::Version
262
276
  version: '0'
277
+ segments:
278
+ - 0
279
+ hash: -1899763597318893191
263
280
  requirements: []
264
281
  rubyforge_project:
265
- rubygems_version: 2.1.11
282
+ rubygems_version: 1.8.25
266
283
  signing_key:
267
- specification_version: 4
284
+ specification_version: 3
268
285
  summary: OCCI toolkit
269
286
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDU3NTg4MzhjZGYyMGI0N2Y3M2ViYmRmMTA2ZWI5OWY3YjYwMzcxZA==
5
- data.tar.gz: !binary |-
6
- OGRmNTk3NmIwZGUwNWQ3ZTlhN2Y4YjA4NDU4MzJkMmIxZDg4NDExMA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- N2E0MTUzMTlmZDlhYzZjYzZjOGZmYjgxNjZlZmY5NzA4NDk5ZmMyOWY0ZmJm
10
- ODlkMzJlM2IyN2IzMjI1ODI3NDdjYWI3YTI5OWY0Y2QxYzdjZWUyYTgyN2Uz
11
- MmQ4YTU1ZWFhNDlhN2IzNjUwYmRkZDJjZDUxYjRjYmVjZDg3OWM=
12
- data.tar.gz: !binary |-
13
- ZWNlMTdkYWYwMmNiNzZiZjRjYTExOTFjYzA1OTg2ODgyZjQ0M2UyZDk4Y2Q3
14
- ZDg4MmJiYjFjYmU3YWIwYzcyOTdmNDIwOGM4YjNlMmYxNjBhODMwZTczOTI1
15
- ZWJkN2EzMzUwZDJiMjBkZWFmM2ZiYjk0MjFmYmNkYTJkMjZkYTI=