occi 2.0.6 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.yardopts +1 -1
- data/Gemfile +3 -20
- data/Gemfile.lock +10 -59
- data/README.md +64 -2
- data/etc/model/infrastructure/compute.json +115 -0
- data/etc/model/infrastructure/ipnetwork.json +43 -0
- data/etc/model/infrastructure/ipnetworkinterface.json +43 -0
- data/etc/model/infrastructure/network.json +56 -0
- data/etc/model/infrastructure/networkinterface.json +40 -0
- data/etc/model/infrastructure/os_template.json +9 -0
- data/etc/model/infrastructure/resource_template.json +9 -0
- data/etc/model/infrastructure/storage.json +75 -0
- data/etc/model/infrastructure/storagelink.json +38 -0
- data/lib/occi/collection.rb +34 -0
- data/lib/occi/core/action.rb +0 -21
- data/lib/occi/core/attribute_properties.rb +0 -21
- data/lib/occi/core/attributes.rb +1 -20
- data/lib/occi/core/category.rb +0 -21
- data/lib/occi/core/entity.rb +7 -28
- data/lib/occi/core/kind.rb +1 -22
- data/lib/occi/core/link.rb +3 -23
- data/lib/occi/core/mixin.rb +0 -22
- data/lib/occi/core/resource.rb +3 -24
- data/lib/occi/log.rb +24 -22
- data/lib/occi/model.rb +102 -0
- data/lib/occi/{parse.rb → parser.rb} +73 -56
- data/lib/occi/version.rb +1 -1
- data/lib/occi.rb +17 -17
- data/lib/{occi/antlr → occiantlr}/.gitignore +0 -0
- data/lib/{occi/antlr/OCCI.g → occiantlr/OCCIANTLR.g} +17 -50
- data/lib/{occi/antlr/OCCI.tokens → occiantlr/OCCIANTLR.tokens} +4 -2
- data/lib/{occi/antlr/OCCILexer.rb → occiantlr/OCCIANTLRLexer.rb} +597 -555
- data/lib/occiantlr/OCCIANTLRParser.rb +2232 -0
- data/lib/{occi/antlr → occiantlr}/README.md +0 -0
- data/occi.gemspec +3 -0
- data/spec/occi/collection_spec.rb +19 -0
- data/spec/occi/log_spec.rb +16 -0
- data/spec/occi/model_spec.rb +26 -0
- data/spec/occi/parser_spec.rb +12 -0
- data/spec/occiantlr/parser_spec.rb +84 -0
- metadata +78 -14
- data/lib/occi/antlr/OCCIParser.rb +0 -2472
- data/lib/occi/core/collection.rb +0 -27
- data/lib/occi/exceptions.rb +0 -59
- data/lib/occi/registry.rb +0 -87
- data/spec/occi/antlr/parser_spec.rb +0 -82
data/lib/occi/core/collection.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module OCCI
|
2
|
-
module Core
|
3
|
-
class Collection
|
4
|
-
attr_accessor :kinds
|
5
|
-
attr_accessor :mixins
|
6
|
-
attr_accessor :actions
|
7
|
-
attr_accessor :resources
|
8
|
-
attr_accessor :links
|
9
|
-
|
10
|
-
def initialize(kinds=[], mixins=[], actions=[], resources=[], links=[])
|
11
|
-
@kinds = kinds
|
12
|
-
@mixins = mixins
|
13
|
-
@actions = actions
|
14
|
-
@resources = resources
|
15
|
-
@links = links
|
16
|
-
end
|
17
|
-
|
18
|
-
def categories
|
19
|
-
@kinds + @mixins + @actions
|
20
|
-
end
|
21
|
-
|
22
|
-
def entities
|
23
|
-
@resources + @links
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/occi/exceptions.rb
DELETED
@@ -1,59 +0,0 @@
|
|
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: registry for all Category/Kind/Mixin instances currently
|
19
|
-
# known to the OCCI server
|
20
|
-
# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
|
21
|
-
##############################################################################
|
22
|
-
|
23
|
-
module OCCI
|
24
|
-
|
25
|
-
# Tried to create an already existing mixin
|
26
|
-
class MixinAlreadyExistsError < RuntimeError;
|
27
|
-
end
|
28
|
-
|
29
|
-
class CategoryNotFoundException < RuntimeError;
|
30
|
-
end
|
31
|
-
|
32
|
-
class CategoryMissingException < RuntimeError;
|
33
|
-
end
|
34
|
-
|
35
|
-
class MixinNotFoundException < RuntimeError;
|
36
|
-
end
|
37
|
-
|
38
|
-
class MixinCreationException < RuntimeError;
|
39
|
-
end
|
40
|
-
|
41
|
-
class LocationAlreadyRegisteredException < RuntimeError;
|
42
|
-
end
|
43
|
-
|
44
|
-
class LocationNotRegisteredException < RuntimeError;
|
45
|
-
end
|
46
|
-
|
47
|
-
# Tried to create an already existing mixin
|
48
|
-
class BackendError < RuntimeError;
|
49
|
-
end
|
50
|
-
|
51
|
-
class ParserException < RuntimeError;
|
52
|
-
end
|
53
|
-
|
54
|
-
class ContentTypeNotSupported < RuntimeError;
|
55
|
-
end
|
56
|
-
|
57
|
-
class CategoryNotFound < RuntimeError;
|
58
|
-
end
|
59
|
-
end
|
data/lib/occi/registry.rb
DELETED
@@ -1,87 +0,0 @@
|
|
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: registry for all Category/Kind/Mixin instances currently
|
19
|
-
# known to the OCCI server
|
20
|
-
# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
|
21
|
-
##############################################################################
|
22
|
-
|
23
|
-
require 'occi/log'
|
24
|
-
|
25
|
-
module OCCI
|
26
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
27
|
-
module Registry
|
28
|
-
|
29
|
-
@@categories = {}
|
30
|
-
@@locations = {}
|
31
|
-
|
32
|
-
def self.reset()
|
33
|
-
@@categories.each_value.each {|category| category.entities = [] if category.entities}
|
34
|
-
end
|
35
|
-
|
36
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
37
|
-
def self.register(category)
|
38
|
-
OCCI::Log.debug("### Registering category #{category.type_identifier}")
|
39
|
-
@@categories[category.type_identifier] = category
|
40
|
-
@@locations[category.location] = category.type_identifier unless category.kind_of?(OCCI::Core::Action)
|
41
|
-
end
|
42
|
-
|
43
|
-
# ---------------------------------------------------------------------------------------------------------------------
|
44
|
-
def self.unregister(category)
|
45
|
-
OCCI::Log.debug("### Unregistering category #{category.type_identifier}")
|
46
|
-
@@categories.delete(category.type_identifier)
|
47
|
-
@@locations.delete(category.location) unless category.kind_of?(OCCI :Core::Action)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Returns the category corresponding to a given type identifier
|
51
|
-
#
|
52
|
-
# @param [URI] type identifier of a category
|
53
|
-
def self.get_by_id(id)
|
54
|
-
@@categories.fetch(id) { OCCI::Log.debug("Category with id #{id} not found"); nil }
|
55
|
-
end
|
56
|
-
|
57
|
-
# Returns the category corresponding to a given location
|
58
|
-
#
|
59
|
-
# @param [URI] Location of a category
|
60
|
-
def self.get_by_location(location)
|
61
|
-
id = @@locations.fetch(location) { OCCI::Log.debug("Category with location #{location} not found"); nil }
|
62
|
-
self.get_by_id(id)
|
63
|
-
end
|
64
|
-
|
65
|
-
# Return all categories from category registry. If filter is present, return only the categories specified by filter
|
66
|
-
#
|
67
|
-
# @param [Hashie:Hash] filter
|
68
|
-
# @return [Hashie::Mash] collection
|
69
|
-
def self.get(filter = [])
|
70
|
-
collection = Hashie::Mash.new({:kinds => [], :mixins => [], :actions => []})
|
71
|
-
filter.each do |cat|
|
72
|
-
category = get_by_id(cat.type_identifier)
|
73
|
-
collection.kinds << category if category.kind_of?(OCCI::Core::Kind)
|
74
|
-
collection.mixins << category if category.kind_of?(OCCI::Core::Mixin)
|
75
|
-
collection.actions << category if category.kind_of?(OCCI::Core::Action)
|
76
|
-
end
|
77
|
-
if filter.empty?
|
78
|
-
@@categories.each_value do |category|
|
79
|
-
collection.kinds << category if category.kind_of? OCCI::Core::Kind
|
80
|
-
collection.mixins << category if category.kind_of? OCCI::Core::Mixin
|
81
|
-
collection.actions << category if category.kind_of? OCCI::Core::Action
|
82
|
-
end
|
83
|
-
end
|
84
|
-
return collection
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'hashie'
|
3
|
-
|
4
|
-
require 'occi/antlr/OCCIParser'
|
5
|
-
|
6
|
-
module OCCI
|
7
|
-
describe Parser do
|
8
|
-
describe "#Category" do
|
9
|
-
it "is parsed successful" do
|
10
|
-
ATTRIBUTE = {:mutable => true, :required => false, :type => {:string => {}}, :default => ''}
|
11
|
-
term = 'entity'
|
12
|
-
scheme = 'http://schemas.ogf.org/occi/core#'
|
13
|
-
class_type = 'kind'
|
14
|
-
title = 'Storage Resource How\'s your quotes escaping?\"'
|
15
|
-
rel = 'http://schemas.ogf.org/occi/core#resource'
|
16
|
-
location = '/storage/'
|
17
|
-
attributes = Hashie::Mash.new
|
18
|
-
attributes.occi!.storage!.size = ATTRIBUTE
|
19
|
-
attributes.occi!.storage!.state = ATTRIBUTE
|
20
|
-
attributes_string = 'occi.storage.size occi.storage.state'
|
21
|
-
actions = Array.new
|
22
|
-
actions << 'http://schemas.ogf.org/occi/infrastructure/storage/action#resize'
|
23
|
-
actions << 'http://schemas.ogf.org/occi/infrastructure/storage/action#online'
|
24
|
-
|
25
|
-
category_string = %Q{Category: #{term}; scheme="#{scheme}"; class="#{class_type}"; title="#{title}"; rel="#{rel}"; location="#{location}"; attributes="#{attributes_string}"; actions="#{actions.join(' ')}"}
|
26
|
-
|
27
|
-
category = Parser.new(category_string).category
|
28
|
-
kind = category[:kinds].first
|
29
|
-
kind[:term].should == term
|
30
|
-
kind[:scheme].should == scheme
|
31
|
-
kind[:title].should == title
|
32
|
-
kind[:related].should == rel
|
33
|
-
kind[:location].should == location
|
34
|
-
kind[:attributes].should == attributes
|
35
|
-
kind[:actions].should == actions
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#Link" do
|
40
|
-
it "is parsed successful" do
|
41
|
-
target = '/network/123'
|
42
|
-
rel = 'http://schemas.ogf.org/occi/infrastructure#network'
|
43
|
-
self_location = '/link/networkinterface/456'
|
44
|
-
category = 'http://schemas.ogf.org/occi/infrastructure#networkinterface'
|
45
|
-
attributes = Hashie::Mash.new
|
46
|
-
attributes.occi!.networkinterface!.interface = '"eth0"'
|
47
|
-
attributes.occi!.networkinterface!.mac = '"00:11:22:33:44:55"'
|
48
|
-
attributes.occi!.networkinterface!.state = '"active"'
|
49
|
-
attributes_string = %Q{occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active"}
|
50
|
-
link_string = %Q{Link: <#{target}>; rel="#{rel}"; self="#{self_location}"; category="#{category}"; #{attributes_string}}
|
51
|
-
|
52
|
-
link = OCCI::Parser.new(link_string).link
|
53
|
-
link[:target].should == target
|
54
|
-
link[:rel].should == rel
|
55
|
-
link[:self].should == self_location
|
56
|
-
link[:category].should == category
|
57
|
-
link[:attributes].should == attributes
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#X-OCCI-Attribute" do
|
62
|
-
it "is parsed successful" do
|
63
|
-
attribute = Hashie::Mash.new
|
64
|
-
attribute.occi!.compute!.architecture = '"x86_64"'
|
65
|
-
|
66
|
-
x_occi_attributes_string = %Q{X-OCCI-Attribute: occi.compute.architecture="x86_64"}
|
67
|
-
|
68
|
-
x_occi_attribute = OCCI::Parser.new(x_occi_attributes_string).x_occi_attribute
|
69
|
-
x_occi_attribute.should == attribute
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#X-OCCI-Location" do
|
74
|
-
it "is parsed successful" do
|
75
|
-
location = URI.parse('http://example.com/compute/123')
|
76
|
-
location_string = %Q{X-OCCI-Location: #{location.to_s}}
|
77
|
-
x_occi_location = OCCI::Parser.new(location_string).x_occi_location
|
78
|
-
x_occi_location.should == location
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|