occi 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -7
- data/etc/model/infrastructure/compute.json +4 -11
- data/etc/model/infrastructure/ipnetwork.json +3 -6
- data/etc/model/infrastructure/ipnetworkinterface.json +3 -6
- data/etc/model/infrastructure/network.json +1 -2
- data/etc/model/infrastructure/networkinterface.json +2 -4
- data/etc/model/infrastructure/storage.json +2 -5
- data/examples/x509auth_example.rb +42 -0
- data/lib/occi/client.rb +270 -167
- data/lib/occi/collection.rb +12 -7
- data/lib/occi/core/action.rb +1 -0
- data/lib/occi/core/attribute_properties.rb +10 -3
- data/lib/occi/core/attributes.rb +10 -2
- data/lib/occi/core/category.rb +7 -0
- data/lib/occi/core/entity.rb +32 -12
- data/lib/occi/core/kind.rb +3 -0
- data/lib/occi/core/link.rb +24 -5
- data/lib/occi/core/mixin.rb +3 -0
- data/lib/occi/core/resource.rb +20 -15
- data/lib/occi/log.rb +7 -5
- data/lib/occi/model.rb +9 -5
- data/lib/occi/parser.rb +28 -2
- data/lib/occi/version.rb +1 -1
- metadata +4 -3
data/lib/occi/parser.rb
CHANGED
@@ -57,11 +57,15 @@ module OCCI
|
|
57
57
|
|
58
58
|
private
|
59
59
|
|
60
|
+
# @param [Hash] header
|
61
|
+
# @return [Array] list of URIs
|
60
62
|
def self.header_locations(header)
|
61
63
|
x_occi_location_strings = header['HTTP_X_OCCI_LOCATION'].to_s.split(',')
|
62
64
|
x_occi_location_strings.collect { |loc| OCCIANTLR::Parser.new('X-OCCI-Location: ' + loc).x_occi_location }
|
63
65
|
end
|
64
66
|
|
67
|
+
# @param [Hash] header
|
68
|
+
# @return [OCCI::Collection]
|
65
69
|
def self.header_categories(header)
|
66
70
|
collection = OCCI::Collection.new
|
67
71
|
category_strings = header['HTTP_CATEGORY'].to_s.split(',')
|
@@ -74,6 +78,9 @@ module OCCI
|
|
74
78
|
collection
|
75
79
|
end
|
76
80
|
|
81
|
+
# @param [Hash] header
|
82
|
+
# @param [Class] entity_type
|
83
|
+
# @return [OCCI::Collection]
|
77
84
|
def self.header_entity(header, entity_type)
|
78
85
|
collection = OCCI::Collection.new
|
79
86
|
entity = Hashie::Mash.new
|
@@ -92,16 +99,23 @@ module OCCI
|
|
92
99
|
collection.links << OCCI::Core::Link.new(entity.kind, entity.mixins, entity.attributes)
|
93
100
|
elsif entity_type == OCCI::Core::Resource
|
94
101
|
link_strings = header['HTTP_LINK'].to_s.split(',')
|
95
|
-
link_strings.each
|
102
|
+
link_strings.each do |link_string|
|
103
|
+
link = OCCIANTLR::Parser.new('Link: ' + link_string).link
|
104
|
+
entity.links << OCCI::Core::Link.new(link.kind, link.mixins, link.attributes, link.actions, link.rel)
|
105
|
+
end
|
96
106
|
collection.resources << OCCI::Core::Resource.new(entity.kind, entity.mixins, entity.attributes, entity.links)
|
97
107
|
end
|
98
108
|
collection
|
99
109
|
end
|
100
110
|
|
111
|
+
# @param [String] text
|
112
|
+
# @return [Array] list of URIs
|
101
113
|
def self.text_locations(text)
|
102
114
|
text.lines.collect { |line| OCCIANTLR::Parser.new(line).x_occi_location if line.include? 'X-OCCI-Location' }.compact
|
103
115
|
end
|
104
116
|
|
117
|
+
# @param [String] text
|
118
|
+
# @return [OCCI::Collection]
|
105
119
|
def self.text_categories(text)
|
106
120
|
collection = OCCI::Collection.new
|
107
121
|
text.each_line do |line|
|
@@ -114,6 +128,9 @@ module OCCI
|
|
114
128
|
collection
|
115
129
|
end
|
116
130
|
|
131
|
+
# @param [String] text
|
132
|
+
# @param [Class] entity_type
|
133
|
+
# @return [OCCI::Collection]
|
117
134
|
def self.text_entity(text, entity_type)
|
118
135
|
collection = OCCI::Collection.new
|
119
136
|
entity = Hashie::Mash.new
|
@@ -131,12 +148,14 @@ module OCCI
|
|
131
148
|
entity.source = links.first.attributes!.occi!.core!.source
|
132
149
|
collection.links << OCCI::Core::Link.new(entity.kind, entity.mixins, entity.attributes)
|
133
150
|
elsif entity_type == OCCI::Core::Resource
|
134
|
-
entity.links = links
|
151
|
+
entity.links = links.collect { |link| OCCI::Core::Link.new(link.kind, link.mixins, link.attributes, link.actions, link.rel) }
|
135
152
|
collection.resources << OCCI::Core::Resource.new(entity.kind, entity.mixins, entity.attributes, entity.links)
|
136
153
|
end unless entity.kind.nil?
|
137
154
|
collection
|
138
155
|
end
|
139
156
|
|
157
|
+
# @param [String] json
|
158
|
+
# @return [OCCI::Collection]
|
140
159
|
def self.json(json)
|
141
160
|
collection = OCCI::Collection.new
|
142
161
|
hash = Hashie::Mash.new(JSON.parse(json))
|
@@ -147,6 +166,8 @@ module OCCI
|
|
147
166
|
collection
|
148
167
|
end
|
149
168
|
|
169
|
+
# @param [String] xml
|
170
|
+
# @return [OCCI::Collection]
|
150
171
|
def self.xml(xml)
|
151
172
|
collection = OCCI::Collection.new
|
152
173
|
hash = Hashie::Mash.new(Hash.from_xml(Nokogiri::XML(xml)))
|
@@ -159,6 +180,7 @@ module OCCI
|
|
159
180
|
|
160
181
|
|
161
182
|
####################Helper method for calculation of storage size based on allocation units configured###########
|
183
|
+
|
162
184
|
def self.calculate_capacity_bytes(capacity, alloc_units_bytes)
|
163
185
|
total_capacity_bytes = alloc_units_bytes * capacity.to_i
|
164
186
|
total_capacity_bytes
|
@@ -182,6 +204,8 @@ module OCCI
|
|
182
204
|
|
183
205
|
###############End of Helper methods for OVF Parsing ##################################################################
|
184
206
|
|
207
|
+
# @param [String] ova
|
208
|
+
# @return [OCCI::Collection]
|
185
209
|
def self.ova(ova)
|
186
210
|
tar = Gem::Package::TarReader.new(StringIO.new(ova))
|
187
211
|
ovf = mf = cert = nil
|
@@ -208,6 +232,8 @@ module OCCI
|
|
208
232
|
self.ovf(File.read(ovf), files)
|
209
233
|
end
|
210
234
|
|
235
|
+
# @param [String] ovf
|
236
|
+
# @param [Hash] files key value pairs of file names and paths to the file
|
211
237
|
def self.ovf(ovf, files={ })
|
212
238
|
collection = OCCI::Collection.new
|
213
239
|
doc = Nokogiri::XML(ovf)
|
data/lib/occi/version.rb
CHANGED
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.
|
4
|
+
version: 2.5.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-
|
13
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- etc/model/infrastructure/resource_template.json
|
153
153
|
- etc/model/infrastructure/storage.json
|
154
154
|
- etc/model/infrastructure/storagelink.json
|
155
|
+
- examples/x509auth_example.rb
|
155
156
|
- lib/occi.rb
|
156
157
|
- lib/occi/client.rb
|
157
158
|
- lib/occi/collection.rb
|
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
206
|
version: '0'
|
206
207
|
requirements: []
|
207
208
|
rubyforge_project:
|
208
|
-
rubygems_version: 1.8.
|
209
|
+
rubygems_version: 1.8.24
|
209
210
|
signing_key:
|
210
211
|
specification_version: 3
|
211
212
|
summary: OCCI toolkit
|