occi 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 { |link| entity.links << OCCIANTLR::Parser.new('Link: ' + link).link }
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)
@@ -1,3 +1,3 @@
1
1
  module OCCI
2
- VERSION = "2.4.0" unless defined?(::OCCI::VERSION)
2
+ VERSION = "2.5.0" unless defined?(::OCCI::VERSION)
3
3
  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.4.0
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-07-26 00:00:00.000000000 Z
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.19
209
+ rubygems_version: 1.8.24
209
210
  signing_key:
210
211
  specification_version: 3
211
212
  summary: OCCI toolkit