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.
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
File without changes
data/occi.gemspec CHANGED
@@ -21,6 +21,9 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency 'json'
22
22
  gem.add_dependency 'antlr3'
23
23
  gem.add_dependency 'hashie'
24
+ gem.add_dependency 'uuidtools'
25
+ gem.add_dependency 'nokogiri'
26
+ gem.add_dependency 'activesupport'
24
27
 
25
28
  gem.required_ruby_version = ">= 1.8.7"
26
29
  end
@@ -0,0 +1,19 @@
1
+ require 'rspec'
2
+ require 'occi'
3
+
4
+ module OCCI
5
+ describe Collection do
6
+ describe "initialize" do
7
+
8
+ it "should create a new OCCI collection including the OCCI base objects" do
9
+ collection = Hashie::Mash.new(:kinds => [], :mixins => [], :actions => [], :resources => [], :links => [])
10
+ collection.kinds << { :term => "compute", :scheme => "http://schemas.ogf.org/occi/infrastructure#" }
11
+ collection.mixins << { :term => "my_mixin", :scheme => "http://example.com/occi/tags#" }
12
+ collection.actions << { :term => "start", :scheme => "http://schemas.ogf.org/occi/infrastructure/compute/action#" }
13
+ collection.resources << { :kind => "http://schemas.ogf.org/occi/infrastructure#compute" }
14
+ collection.links << { :kind => "http://schemas.ogf.org/occi/infrastructure#storagelink" }
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ require "rspec"
2
+ require 'occi/log'
3
+
4
+ module OCCI
5
+ describe Log do
6
+
7
+ describe "log messages" do
8
+ it "should log a message to a pipe" do
9
+ r, w = IO.pipe
10
+ OCCI::Log.new(w, OCCI::Log::INFO)
11
+ OCCI::Log.info("Test")
12
+ r.readline.include?("Test")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ require "rspec"
2
+ require 'occi/model'
3
+
4
+ describe "Model" do
5
+
6
+ it "initializes Core Model successfully" do
7
+ OCCI::Model.register_core
8
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/core#entity').should be_kind_of OCCI::Core::Kind
9
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/core#resource').should be_kind_of OCCI::Core::Kind
10
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/core#link').should be_kind_of OCCI::Core::Kind
11
+ end
12
+
13
+ it "initializes Infrastructure Model successfully" do
14
+ OCCI::Model.register_files('etc/model/infrastructure/')
15
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#compute').should be_kind_of OCCI::Core::Kind
16
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#os_tpl').should be_kind_of OCCI::Core::Mixin
17
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#resource_tpl').should be_kind_of OCCI::Core::Mixin
18
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#network').should be_kind_of OCCI::Core::Kind
19
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure/network#ipnetwork').should be_kind_of OCCI::Core::Mixin
20
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#networkinterface').should be_kind_of OCCI::Core::Kind
21
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface').should be_kind_of OCCI::Core::Mixin
22
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#storage').should be_kind_of OCCI::Core::Kind
23
+ OCCI::Model.get_by_id('http://schemas.ogf.org/occi/infrastructure#storagelink').should be_kind_of OCCI::Core::Kind
24
+ end
25
+
26
+ end
@@ -0,0 +1,12 @@
1
+ require "rspec"
2
+ require 'occi/parser'
3
+
4
+ describe "Parser" do
5
+
6
+ it "should parse OCCI message with entity in text plain format" do
7
+ media_type = 'text/plain'
8
+ body = %Q|Category: compute; scheme="http://schemas.ogf.org/occi/infrastructure#"; class="kind"\nX-OCCI-Attribute: occi.compute.cores=2|
9
+ category = false
10
+ OCCI::Parser.parse(media_type,body,category)
11
+ end
12
+ end
@@ -0,0 +1,84 @@
1
+ require 'rspec'
2
+ require 'hashie'
3
+
4
+ require 'occiantlr/OCCIANTLRParser'
5
+
6
+ module OCCI
7
+ module ANTLR
8
+ describe Parser do
9
+ describe "#Category" do
10
+ it "is parsed successful" do
11
+ ATTRIBUTE = { :mutable => true, :required => false, :type => "string" }
12
+ term = 'entity'
13
+ scheme = 'http://schemas.ogf.org/occi/core#'
14
+ class_type = 'kind'
15
+ title = 'Storage Resource How\'s your quotes escaping?\"'
16
+ rel = 'http://schemas.ogf.org/occi/core#resource'
17
+ location = '/storage/'
18
+ attributes = Hashie::Mash.new
19
+ attributes.occi!.storage!.size = ATTRIBUTE
20
+ attributes.occi!.storage!.state = ATTRIBUTE
21
+ attributes_string = 'occi.storage.size occi.storage.state'
22
+ actions = Array.new
23
+ actions << 'http://schemas.ogf.org/occi/infrastructure/storage/action#resize'
24
+ actions << 'http://schemas.ogf.org/occi/infrastructure/storage/action#online'
25
+
26
+ category_string = %Q{Category: #{term}; scheme="#{scheme}"; class="#{class_type}"; title="#{title}"; rel="#{rel}"; location="#{location}"; attributes="#{attributes_string}"; actions="#{actions.join(' ')}"}
27
+
28
+ category = OCCIANTLR::Parser.new(category_string).category
29
+ kind = category[:kinds].first
30
+ kind[:term].should == term
31
+ kind[:scheme].should == scheme
32
+ kind[:title].should == title
33
+ kind[:related].should == rel
34
+ kind[:location].should == location
35
+ kind[:attributes].should == attributes
36
+ kind[:actions].should == actions
37
+ end
38
+ end
39
+
40
+ describe "#Link" do
41
+ it "is parsed successful" do
42
+ target = '/network/123'
43
+ rel = 'http://schemas.ogf.org/occi/infrastructure#network'
44
+ self_location = '/link/networkinterface/456'
45
+ category = 'http://schemas.ogf.org/occi/infrastructure#networkinterface'
46
+ attributes = Hashie::Mash.new
47
+ attributes.occi!.networkinterface!.interface = '"eth0"'
48
+ attributes.occi!.networkinterface!.mac = '"00:11:22:33:44:55"'
49
+ attributes.occi!.networkinterface!.state = '"active"'
50
+ attributes_string = %Q{occi.networkinterface.interface="eth0";occi.networkinterface.mac="00:11:22:33:44:55";occi.networkinterface.state="active"}
51
+ link_string = %Q{Link: <#{target}>; rel="#{rel}"; self="#{self_location}"; category="#{category}"; #{attributes_string}}
52
+
53
+ link = OCCIANTLR::Parser.new(link_string).link
54
+ link[:target].should == target
55
+ link[:rel].should == rel
56
+ link[:self].should == self_location
57
+ link[:category].should == category
58
+ link[:attributes].should == attributes
59
+ end
60
+ end
61
+
62
+ describe "#X-OCCI-Attribute" do
63
+ it "is parsed successful" do
64
+ attribute = Hashie::Mash.new
65
+ attribute.occi!.compute!.architecture = '"x86_64"'
66
+
67
+ x_occi_attributes_string = %Q{X-OCCI-Attribute: occi.compute.architecture="x86_64"}
68
+
69
+ x_occi_attribute = OCCIANTLR::Parser.new(x_occi_attributes_string).x_occi_attribute
70
+ x_occi_attribute.should == attribute
71
+ end
72
+ end
73
+
74
+ describe "#X-OCCI-Location" do
75
+ it "is parsed successful" do
76
+ location = URI.parse('http://example.com/compute/123')
77
+ location_string = %Q{X-OCCI-Location: #{location.to_s}}
78
+ x_occi_location = OCCIANTLR::Parser.new(location_string).x_occi_location
79
+ x_occi_location.should == location
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-06 00:00:00.000000000 Z
13
+ date: 2012-06-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -60,6 +60,54 @@ dependencies:
60
60
  - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: uuidtools
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: nokogiri
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: activesupport
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
63
111
  description: OCCI is a collection of classes to simplify the implementation of the
64
112
  Open Cloud Computing API in Ruby
65
113
  email:
@@ -80,30 +128,42 @@ files:
80
128
  - LICENSE
81
129
  - README.md
82
130
  - Rakefile
131
+ - etc/model/infrastructure/compute.json
132
+ - etc/model/infrastructure/ipnetwork.json
133
+ - etc/model/infrastructure/ipnetworkinterface.json
134
+ - etc/model/infrastructure/network.json
135
+ - etc/model/infrastructure/networkinterface.json
136
+ - etc/model/infrastructure/os_template.json
137
+ - etc/model/infrastructure/resource_template.json
138
+ - etc/model/infrastructure/storage.json
139
+ - etc/model/infrastructure/storagelink.json
83
140
  - lib/occi.rb
84
- - lib/occi/antlr/.gitignore
85
- - lib/occi/antlr/OCCI.g
86
- - lib/occi/antlr/OCCI.tokens
87
- - lib/occi/antlr/OCCILexer.rb
88
- - lib/occi/antlr/OCCIParser.rb
89
- - lib/occi/antlr/README.md
141
+ - lib/occi/collection.rb
90
142
  - lib/occi/core/action.rb
91
143
  - lib/occi/core/attribute_properties.rb
92
144
  - lib/occi/core/attributes.rb
93
145
  - lib/occi/core/category.rb
94
- - lib/occi/core/collection.rb
95
146
  - lib/occi/core/entity.rb
96
147
  - lib/occi/core/kind.rb
97
148
  - lib/occi/core/link.rb
98
149
  - lib/occi/core/mixin.rb
99
150
  - lib/occi/core/resource.rb
100
- - lib/occi/exceptions.rb
101
151
  - lib/occi/log.rb
102
- - lib/occi/parse.rb
103
- - lib/occi/registry.rb
152
+ - lib/occi/model.rb
153
+ - lib/occi/parser.rb
104
154
  - lib/occi/version.rb
155
+ - lib/occiantlr/.gitignore
156
+ - lib/occiantlr/OCCIANTLR.g
157
+ - lib/occiantlr/OCCIANTLR.tokens
158
+ - lib/occiantlr/OCCIANTLRLexer.rb
159
+ - lib/occiantlr/OCCIANTLRParser.rb
160
+ - lib/occiantlr/README.md
105
161
  - occi.gemspec
106
- - spec/occi/antlr/parser_spec.rb
162
+ - spec/occi/collection_spec.rb
163
+ - spec/occi/log_spec.rb
164
+ - spec/occi/model_spec.rb
165
+ - spec/occi/parser_spec.rb
166
+ - spec/occiantlr/parser_spec.rb
107
167
  - spec/spec_helper.rb
108
168
  homepage: https://github.com/gwdg/occi
109
169
  licenses: []
@@ -130,6 +190,10 @@ signing_key:
130
190
  specification_version: 3
131
191
  summary: OCCI toolkit
132
192
  test_files:
133
- - spec/occi/antlr/parser_spec.rb
193
+ - spec/occi/collection_spec.rb
194
+ - spec/occi/log_spec.rb
195
+ - spec/occi/model_spec.rb
196
+ - spec/occi/parser_spec.rb
197
+ - spec/occiantlr/parser_spec.rb
134
198
  - spec/spec_helper.rb
135
199
  has_rdoc: