occi 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +1 -1
  3. data/Gemfile +3 -20
  4. data/Gemfile.lock +10 -59
  5. data/README.md +64 -2
  6. data/etc/model/infrastructure/compute.json +115 -0
  7. data/etc/model/infrastructure/ipnetwork.json +43 -0
  8. data/etc/model/infrastructure/ipnetworkinterface.json +43 -0
  9. data/etc/model/infrastructure/network.json +56 -0
  10. data/etc/model/infrastructure/networkinterface.json +40 -0
  11. data/etc/model/infrastructure/os_template.json +9 -0
  12. data/etc/model/infrastructure/resource_template.json +9 -0
  13. data/etc/model/infrastructure/storage.json +75 -0
  14. data/etc/model/infrastructure/storagelink.json +38 -0
  15. data/lib/occi/collection.rb +34 -0
  16. data/lib/occi/core/action.rb +0 -21
  17. data/lib/occi/core/attribute_properties.rb +0 -21
  18. data/lib/occi/core/attributes.rb +1 -20
  19. data/lib/occi/core/category.rb +0 -21
  20. data/lib/occi/core/entity.rb +7 -28
  21. data/lib/occi/core/kind.rb +1 -22
  22. data/lib/occi/core/link.rb +3 -23
  23. data/lib/occi/core/mixin.rb +0 -22
  24. data/lib/occi/core/resource.rb +3 -24
  25. data/lib/occi/log.rb +24 -22
  26. data/lib/occi/model.rb +102 -0
  27. data/lib/occi/{parse.rb → parser.rb} +73 -56
  28. data/lib/occi/version.rb +1 -1
  29. data/lib/occi.rb +17 -17
  30. data/lib/{occi/antlr → occiantlr}/.gitignore +0 -0
  31. data/lib/{occi/antlr/OCCI.g → occiantlr/OCCIANTLR.g} +17 -50
  32. data/lib/{occi/antlr/OCCI.tokens → occiantlr/OCCIANTLR.tokens} +4 -2
  33. data/lib/{occi/antlr/OCCILexer.rb → occiantlr/OCCIANTLRLexer.rb} +597 -555
  34. data/lib/occiantlr/OCCIANTLRParser.rb +2232 -0
  35. data/lib/{occi/antlr → occiantlr}/README.md +0 -0
  36. data/occi.gemspec +3 -0
  37. data/spec/occi/collection_spec.rb +19 -0
  38. data/spec/occi/log_spec.rb +16 -0
  39. data/spec/occi/model_spec.rb +26 -0
  40. data/spec/occi/parser_spec.rb +12 -0
  41. data/spec/occiantlr/parser_spec.rb +84 -0
  42. metadata +78 -14
  43. data/lib/occi/antlr/OCCIParser.rb +0 -2472
  44. data/lib/occi/core/collection.rb +0 -27
  45. data/lib/occi/exceptions.rb +0 -59
  46. data/lib/occi/registry.rb +0 -87
  47. data/spec/occi/antlr/parser_spec.rb +0 -82
@@ -0,0 +1,38 @@
1
+ {
2
+ "kinds":[
3
+ {
4
+ "term":"storagelink",
5
+ "scheme":"http://schemas.ogf.org/occi/infrastructure#",
6
+ "title":"Storage Link",
7
+ "related":[
8
+ "http://schemas.ogf.org/occi/core#link"
9
+ ],
10
+ "attributes":{
11
+ "occi":{
12
+ "storagelink":{
13
+ "deviceid":{
14
+ "mutable":true,
15
+ "required":false,
16
+ "type":"string",
17
+ "pattern":".*"
18
+ },
19
+ "mountpoint":{
20
+ "mutable":true,
21
+ "required":false,
22
+ "type":"string",
23
+ "pattern":".*"
24
+ },
25
+ "state":{
26
+ "mutable":false,
27
+ "required":false,
28
+ "type":"string",
29
+ "pattern":"active|inactive",
30
+ "default":"inactive"
31
+ }
32
+ }
33
+ }
34
+ },
35
+ "location":"/storagelink/"
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1,34 @@
1
+ require 'hashie/mash'
2
+
3
+ module OCCI
4
+ class Collection
5
+ attr_accessor :kinds
6
+ attr_accessor :mixins
7
+ attr_accessor :actions
8
+ attr_accessor :resources
9
+ attr_accessor :links
10
+
11
+ # Initialize a new OCCI Collection by initializing all supplied OCCI objects
12
+ #
13
+ # @param [Hash] collection including one or more of the keys kinds, mixins, actions, resources, links
14
+ def initialize(collection={ })
15
+ collection = Hashie::Mash.new(collection)
16
+ @kinds = @mixins = @actions = @resources = @links = []
17
+ @kinds = collection.kinds.collect { |kind| OCCI::Core::Kind.new(kind) } if collection.kinds.instance_of? Array
18
+ @mixins = collection.mixins.collect { |mixin| OCCI::Core::Mixin.new(mixin) } if collection.mixins.instance_of? Array
19
+ @actions = collection.actions.collect { |action| OCCI::Core::Action.new(action) } if collection.actions.instance_of? Array
20
+ @resources = collection.resources.collect { |resource| OCCI::Core::Resource.new(resource) } if collection.resources.instance_of? Array
21
+ @links = collection.links { |link| OCCI::Core::Link.new(link) } if collection.links.instance_of? Array
22
+ end
23
+
24
+ # @return [Array] categories combined list of all kinds, mixins and actions
25
+ def categories
26
+ @kinds + @mixins + @actions
27
+ end
28
+
29
+ # @return [Array] entities combined list of all resources and links
30
+ def entities
31
+ @resources + @links
32
+ end
33
+ end
34
+ end
@@ -1,24 +1,3 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Action
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'occi/core/category'
23
2
 
24
3
  module OCCI
@@ -1,24 +1,3 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: storing a single Attribute
19
- # Author(s): Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'hashie/mash'
23
2
 
24
3
  module OCCI
@@ -1,23 +1,4 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: storing a single Attribute
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
1
+ require 'hashie/mash'
21
2
 
22
3
  module OCCI
23
4
  module Core
@@ -1,24 +1,3 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Category
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'json'
23
2
  require 'hashie/mash'
24
3
 
@@ -1,28 +1,7 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Entity
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'rubygems'
23
2
  require 'uuidtools'
24
- require 'hashie'
25
- require 'occi/registry'
3
+ require 'hashie/mash'
4
+ require 'occi/model'
26
5
  require 'occi/core/attributes'
27
6
  require 'occi/core/kind'
28
7
  require 'occi/core/attribute_properties'
@@ -47,7 +26,7 @@ module OCCI
47
26
  data.attributes!.occi!.core!.title!.mutable = true
48
27
 
49
28
  kind = OCCI::Core::Kind.new(data)
50
- OCCI::Registry.register(kind)
29
+ OCCI::Model.register(kind)
51
30
  end
52
31
 
53
32
  def initialize(entity=nil, default = nil)
@@ -76,16 +55,16 @@ module OCCI
76
55
  end
77
56
 
78
57
  def location
79
- '/' + OCCI::Registry.get_by_id(self.kind).term + '/' + self.id if self.kind
58
+ '/' + OCCI::Model.get_by_id(self.kind).term + '/' + self.id if self.kind
80
59
  end
81
60
 
82
61
  def type_identifier
83
- OCCI::Registry.get_by_id(self.kind).type_identifier
62
+ OCCI::Model.get_by_id(self.kind).type_identifier
84
63
  end
85
64
 
86
65
  def check
87
- definitions = OCCI::Registry.get_by_id(self.kind).attributes if self.kind
88
- self.mixins.each { |mixin| definitions.merge!(OCCI::Registry.get_by_id(mixin).attributes) if OCCI::Registry.get_by_id(mixin).attributes } if self.mixins
66
+ definitions = OCCI::Model.get_by_id(self.kind).attributes if self.kind
67
+ self.mixins.each { |mixin| definitions.merge!(OCCI::Model.get_by_id(mixin).attributes) if OCCI::Model.get_by_id(mixin).attributes } if self.mixins
89
68
  self.attributes = Entity.check(self.attributes, definitions) if definitions
90
69
  end
91
70
 
@@ -1,24 +1,3 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Kind
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'json'
23
2
  require 'occi/core/category'
24
3
  require 'occi/core/action'
@@ -42,7 +21,7 @@ module OCCI
42
21
  when "http://schemas.ogf.org/occi/core#link"
43
22
  return OCCI::Core::Link.name
44
23
  else
45
- OCCI::Registry.get_by_id(self[:related].first).entity_type unless self[:term] == 'entity'
24
+ OCCI::Model.get_by_id(self[:related].first).entity_type unless self[:term] == 'entity'
46
25
  end
47
26
  end
48
27
 
@@ -1,27 +1,7 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Link
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
1
+ require 'hashie/mash'
2
+ require 'occi/model'
22
3
  require 'occi/core/entity'
23
4
  require 'occi/core/kind'
24
- require 'hashie'
25
5
 
26
6
  module OCCI
27
7
  module Core
@@ -47,7 +27,7 @@ module OCCI
47
27
  data.attributes!.occi!.core!.source!.mutable = true
48
28
 
49
29
  kind = OCCI::Core::Kind.new(data)
50
- OCCI::Registry.register(kind)
30
+ OCCI::Model.register(kind)
51
31
  end
52
32
 
53
33
  def target
@@ -1,27 +1,5 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Mixin
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'json'
23
2
  require 'occi/core/category'
24
- require 'occi/core/action'
25
3
 
26
4
  module OCCI
27
5
  module Core
@@ -1,28 +1,7 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI Core Resource
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
- require 'occi/registry'
1
+ require 'hashie/mash'
2
+ require 'occi/model'
23
3
  require 'occi/core/entity'
24
4
  require 'occi/core/kind'
25
- require 'hashie'
26
5
 
27
6
  module OCCI
28
7
  module Core
@@ -41,7 +20,7 @@ module OCCI
41
20
  data.attributes!.occi!.core!.summary!.mutable = true
42
21
 
43
22
  kind = OCCI::Core::Kind.new(data)
44
- OCCI::Registry.register(kind)
23
+ OCCI::Model.register(kind)
45
24
  end
46
25
 
47
26
  def summary
data/lib/occi/log.rb CHANGED
@@ -1,45 +1,47 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ##############################################################################
16
-
17
- ##############################################################################
18
- # Description: OCCI logger
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
1
  require 'logger'
2
+ require 'active_support/notifications'
23
3
 
24
4
  module OCCI
25
5
  class Log
26
6
 
7
+ include Logger::Severity
8
+
9
+ # creates a new OCCI logger
10
+ # @param [IO,String] logdev The log device. This is a filename (String) or IO object (typically +STDOUT+,
11
+ # +STDERR+, or an open file).
12
+ # @param [Constant] level Logging severity threshold (e.g. <tt>OCCI::Log::INFO</tt>).
13
+ def initialize(logdev, level)
14
+ @logger = Logger.new(logdev)
15
+ @logger.level = level
16
+
17
+ # subscribe to log messages and send to logger
18
+ @log_subscriber = ActiveSupport::Notifications.subscribe("log") do |name, start, finish, id, payload|
19
+ @logger.log(payload[:level], payload[:message])
20
+ end
21
+ end
22
+
23
+ # @see info
27
24
  def self.debug(message)
28
- ActiveSupport::Notifications.instrument("log",:level=>Logger::DEBUG,:message=>message)
25
+ ActiveSupport::Notifications.instrument("log", :level => Logger::DEBUG, :message => message)
29
26
  end
30
27
 
28
+ # Log an +INFO+ message
29
+ # @param [String] message the message to log; does not need to be a String
31
30
  def self.info(message)
32
31
  ActiveSupport::Notifications.instrument("log", :level => Logger::INFO, :message => message)
33
32
  end
34
33
 
34
+ # @see info
35
35
  def self.warn(message)
36
36
  ActiveSupport::Notifications.instrument("log", :level => Logger::WARN, :message => message)
37
37
  end
38
38
 
39
+ # @see info
39
40
  def self.error(message)
40
41
  ActiveSupport::Notifications.instrument("log", :level => Logger::ERROR, :message => message)
41
42
  end
42
43
 
44
+ # @see info
43
45
  def self.fatal(message)
44
46
  ActiveSupport::Notifications.instrument("log", :level => Logger::FATAL, :message => message)
45
47
  end
data/lib/occi/model.rb ADDED
@@ -0,0 +1,102 @@
1
+ require 'hashie/mash'
2
+ require 'occi/log'
3
+
4
+ module OCCI
5
+ class Model
6
+ @@categories = { }
7
+ @@locations = { }
8
+
9
+ # register OCCI Core categories enitity, resource and link
10
+ def self.register_core
11
+ OCCI::Log.info("### Registering OCCI Core categories enitity, resource and link ###")
12
+ OCCI::Core::Entity.register
13
+ OCCI::Core::Resource.register
14
+ OCCI::Core::Link.register
15
+ end
16
+
17
+ # register OCCI Infrastructure categories
18
+ def self.register_infrastructure
19
+ OCCI::Log.info("### Registering OCCI Infrastructure categories ###")
20
+ self.register_files('etc/model/infrastructure')
21
+ end
22
+
23
+ # register OCCI categories from files
24
+ #
25
+ # @param [String] path to a folder containing files which include OCCI collections in JSON format. The path is
26
+ # recursively searched for files with the extension .json .
27
+ def self.register_files(path)
28
+ OCCI::Log.info("### Initializing OCCI Model from #{path} ###")
29
+ Dir.glob(path + '/**/*.json').each do |file|
30
+ collection = OCCI::Collection.new(JSON.parse(File.read(file)))
31
+ # add location of service provider to scheme if it has a relative location
32
+ collection.kinds.collect { |kind| kind.scheme = self.location + kind.scheme if kind.scheme.start_with? '/' } if collection.kinds
33
+ collection.mixins.collect { |mixin| mixin.scheme = self.location + mixin.scheme if mixin.scheme.start_with? '/' } if collection.mixins
34
+ collection.actions.collect { |action| action.scheme = self.location + action.scheme if action.scheme.start_with? '/' } if collection.actions
35
+ self.register_collection(collection)
36
+ end
37
+ end
38
+
39
+ # register OCCI categories from OCCI collection
40
+ def self.register_collection(collection)
41
+ collection.kinds.each { |kind| self.register(OCCI::Core::Kind.new(kind)) } if collection.kinds
42
+ collection.mixins.each { |mixin| self.register(OCCI::Core::Mixin.new(mixin)) } if collection.mixins
43
+ collection.actions.each { |action| self.register(OCCI::Core::Action.new(action)) } if collection.actions
44
+ end
45
+
46
+ def self.reset()
47
+ @@categories.each_value.each { |category| category.entities = [] if category.entities }
48
+ end
49
+
50
+ # ---------------------------------------------------------------------------------------------------------------------
51
+ def self.register(category)
52
+ OCCI::Log.debug("### Registering category #{category.type_identifier}")
53
+ @@categories[category.type_identifier] = category
54
+ @@locations[category.location] = category.type_identifier unless category.kind_of?(OCCI::Core::Action)
55
+ end
56
+
57
+ # ---------------------------------------------------------------------------------------------------------------------
58
+ def self.unregister(category)
59
+ OCCI::Log.debug("### Unregistering category #{category.type_identifier}")
60
+ @@categories.delete(category.type_identifier)
61
+ @@locations.delete(category.location) unless category.kind_of?(OCCI :Core::Action)
62
+ end
63
+
64
+ # Returns the category corresponding to a given type identifier
65
+ #
66
+ # @param [URI] type identifier of a category
67
+ def self.get_by_id(id)
68
+ @@categories.fetch(id) { OCCI::Log.debug("Category with id #{id} not found"); nil }
69
+ end
70
+
71
+ # Returns the category corresponding to a given location
72
+ #
73
+ # @param [URI] Location of a category
74
+ def self.get_by_location(location)
75
+ id = @@locations.fetch(location) { OCCI::Log.debug("Category with location #{location} not found"); nil }
76
+ self.get_by_id(id)
77
+ end
78
+
79
+ # Return all categories from model. If filter is present, return only the categories specified by filter
80
+ #
81
+ # @param [Hashie:Hash] filter
82
+ # @return [Hashie::Mash] collection
83
+ def self.get(filter = [])
84
+ collection = Hashie::Mash.new({ :kinds => [], :mixins => [], :actions => [] })
85
+ filter.each do |cat|
86
+ category = get_by_id(cat.type_identifier)
87
+ collection.kinds << category if category.kind_of?(OCCI::Core::Kind)
88
+ collection.mixins << category if category.kind_of?(OCCI::Core::Mixin)
89
+ collection.actions << category if category.kind_of?(OCCI::Core::Action)
90
+ end
91
+ if filter.empty?
92
+ @@categories.each_value do |category|
93
+ collection.kinds << category if category.kind_of? OCCI::Core::Kind
94
+ collection.mixins << category if category.kind_of? OCCI::Core::Mixin
95
+ collection.actions << category if category.kind_of? OCCI::Core::Action
96
+ end
97
+ end
98
+ return collection
99
+ end
100
+
101
+ end
102
+ end