occi-api 4.2.6 → 4.3.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a33443d89ab0c83183170cd0876da0c9af576c64
4
- data.tar.gz: 9da580054d01f0c6e007ceabc1b9266e0673324d
3
+ metadata.gz: 7ab882ff01d442af84f9ac23fc4b4da41091f5d6
4
+ data.tar.gz: 6ded8b446e879ad73334b2b42e868c04a9009f3f
5
5
  SHA512:
6
- metadata.gz: a039a1a18bcc7e42736f158b4259f7dd14a976ebdf56b137e19454abbc5b469bf01d05cb0b4bafa717d82e3838950305cd28ce018a5f6bbc9d42e095731f1e76
7
- data.tar.gz: 573576b99c9d4ddca4e1b0d5a6e1d1dc4b96e20f04f9550ee9e391290a346792e5102df995aac2434edbc7a0e4af9251ceacaa68a403fe2ab6a015a825bbbdd5
6
+ metadata.gz: 3a11d6fb175e27d18a240c8303671f8847de44026883cf3dfd60fae017103c2cd9d5b0587bf0d550f710b9370f6419ac56bd155e21ad1071c98e12e68ebff881
7
+ data.tar.gz: 74b2e556f12c701a92a00074b85f4a96a201a45f64691037573642deb281898342f6a02c1f50a826c13f3c851a959415029af922a7cdb67691cb3a8c09d7ad8b
@@ -3,7 +3,7 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.1
6
+ - 2.1
7
7
  - ruby-head
8
8
  - jruby-19mode
9
9
  - jruby-head
@@ -26,9 +26,9 @@ matrix:
26
26
  jdk: openjdk7
27
27
  - rvm: 2.0.0
28
28
  jdk: oraclejdk7
29
- - rvm: 2.1.1
29
+ - rvm: 2.1
30
30
  jdk: openjdk7
31
- - rvm: 2.1.1
31
+ - rvm: 2.1
32
32
  jdk: oraclejdk7
33
33
  - rvm: ruby-head
34
34
  jdk: openjdk7
@@ -42,3 +42,4 @@ branches:
42
42
  - 4.0.x
43
43
  - 4.1.x
44
44
  - 4.2.x
45
+ - 4.3.x
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  rOCCI-api - A Ruby OCCI Framework
2
2
  =================================
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/gwdg/rOCCI-api.png)](http://travis-ci.org/gwdg/rOCCI-api)
5
- [![Dependency Status](https://gemnasium.com/gwdg/rOCCI-api.png)](https://gemnasium.com/gwdg/rOCCI-api)
4
+ [![Build Status](https://secure.travis-ci.org/EGI-FCTF/rOCCI-api.png)](http://travis-ci.org/EGI-FCTF/rOCCI-api)
5
+ [![Dependency Status](https://gemnasium.com/EGI-FCTF/rOCCI-api.png)](https://gemnasium.com/EGI-FCTF/rOCCI-api)
6
6
  [![Gem Version](https://fury-badge.herokuapp.com/rb/occi-api.png)](https://badge.fury.io/rb/occi-api)
7
- [![Code Climate](https://codeclimate.com/github/gwdg/rOCCI-api.png)](https://codeclimate.com/github/gwdg/rOCCI-api)
7
+ [![Code Climate](https://codeclimate.com/github/EGI-FCTF/rOCCI-api.png)](https://codeclimate.com/github/EGI-FCTF/rOCCI-api)
8
8
 
9
9
  Requirements
10
10
  ------------
@@ -12,7 +12,6 @@ Requirements
12
12
  ### Ruby
13
13
  * Ruby 1.9.3 is required
14
14
  * RubyGems have to be installed
15
- * Rake has to be installed (e.g., `gem install rake`)
16
15
 
17
16
  ### Examples
18
17
  #### For distros based on Debian:
@@ -44,12 +43,10 @@ Installation
44
43
 
45
44
  To install the most recent stable version
46
45
 
47
- gem install rake
48
46
  gem install occi-api
49
47
 
50
48
  To install the most recent beta version
51
49
 
52
- gem install rake
53
50
  gem install occi-api --pre
54
51
 
55
52
  ### From source (dev)
@@ -60,7 +57,7 @@ To install the most recent beta version
60
57
 
61
58
  To build and install the bleeding edge version from master
62
59
 
63
- git clone git://github.com/gwdg/rOCCI-api.git
60
+ git clone git://github.com/EGI-FCTF/rOCCI-api.git
64
61
  cd rOCCI-api
65
62
  gem install bundler
66
63
  bundle install
@@ -87,213 +84,18 @@ ruby -v
87
84
 
88
85
  Usage
89
86
  -----
90
- ### Auth
91
-
92
- For Basic auth use
93
-
94
- auth = Hashie::Mash.new
95
- auth.type = 'basic'
96
- auth.username = 'user'
97
- auth.password = 'mypass'
98
-
99
- For Digest auth use
100
-
101
- auth = Hashie::Mash.new
102
- auth.type = 'digest'
103
- auth.username = 'user'
104
- auth.password = 'mypass'
105
-
106
- For X.509 auth use
107
-
108
- auth = Hashie::Mash.new
109
- auth.type = 'x509'
110
- auth.user_cert = '/Path/To/My/usercert.pem'
111
- auth.user_cert_password = 'MyPassword'
112
- auth.ca_path = '/Path/To/root-certificates'
113
-
114
- ### DSL
115
- In your scripts, you can use the OCCI client DSL.
116
-
117
- To include the DSL definitions in a script use
118
-
119
- extend Occi::Api::Dsl
120
-
121
- To include the DSL definitions in a class use
122
-
123
- include Occi::Api::Dsl
124
-
125
- To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
126
-
127
- # defaults
128
- options = {
129
- :endpoint => "http://localhost:3300/",
130
- :auth => {:type => "none"},
131
- :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil},
132
- :auto_connect => "value", auto_connect => true,
133
- :media_type => nil
134
- }
135
-
136
- connect(:http, options ||= {})
137
-
138
- To get the list of available resource, mixin, entity or link types use
139
-
140
- resource_types
141
- mixin_types
142
- entity_types
143
- link_types
144
-
145
- To get compute, storage or network descriptions use
146
-
147
- describe "compute"
148
- describe "storage"
149
- describe "network"
150
-
151
- To get the location of compute, storage or network resources use
152
-
153
- list "compute"
154
- list "storage"
155
- list "network"
156
-
157
- To get the identifiers of specific mixins in specific mixin types use
158
-
159
- mixin "my_template", "os_tpl"
160
- mixin "small", "resource_tpl"
161
-
162
- To get the identifiers of specific mixins with unknown types use
163
-
164
- mixin "medium"
165
-
166
- To get mixin descriptions use
167
-
168
- mixin "medium", nil, true
169
- mixin "my_template", "os_tpl", true
170
-
171
- To get a list of names of all / OS templates / Resource templates mixins use
172
-
173
- mixins
174
- mixins "os_tpl"
175
- mixins "resource_tpl"
176
-
177
- To create a new compute resource use
178
-
179
- os = mixin 'my_os', 'os_tpl'
180
- size = mixin 'large', 'resource_tpl'
181
- cmpt = resource "compute"
182
- cmpt.mixins << os << size
183
- cmpt.title = "My VM"
184
- create cmpt
185
-
186
- To get a description of a specific resource use
187
-
188
- describe "/compute/<OCCI_ID>"
189
- describe "/storage/<OCCI_ID>"
190
- describe "/network/<OCCI_ID>"
191
-
192
- To delete a specific resource use
193
-
194
- delete "/compute/<OCCI_ID>"
195
- delete "/storage/<OCCI_ID>"
196
- delete "/network/<OCCI_ID>"
197
-
198
- ### API
199
- If you need low level access to parts of the OCCI client or need to use more than one instance
200
- at a time, you should use the OCCI client API directly.
201
-
202
- To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
203
-
204
- # defaults
205
- options = {
206
- :endpoint => "http://localhost:3300/",
207
- :auth => {:type => "none"},
208
- :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil},
209
- :auto_connect => "value", auto_connect => true,
210
- :media_type => nil
211
- }
212
-
213
- client = Occi::Api::Client::ClientHttp.new(options ||= {})
214
-
215
- All available categories are automatically registered to the OCCI model during client initialization. You can get them via
216
-
217
- client.model
218
-
219
- To get the list of available resource, mixin, entity or link types use
220
-
221
- client.get_resource_types
222
- client.get_mixin_types
223
- client.get_entity_types
224
- client.get_link_types
225
-
226
- To get compute, storage or network descriptions use
227
-
228
- client.describe "compute"
229
- client.describe "storage"
230
- client.describe "network"
231
-
232
- To get the location of compute, storage or network resources use
233
-
234
- client.list "compute"
235
- client.list "storage"
236
- client.list "network"
237
-
238
- To get the identifiers of specific mixins in specific mixin types use
239
-
240
- client.find_mixin "my_template", "os_tpl"
241
- client.find_mixin "small", "resource_tpl"
242
-
243
- To get the identifiers of specific mixins with unknown types use
244
-
245
- client.find_mixin "medium"
246
-
247
- To get mixin descriptions use
248
-
249
- client.find_mixin "medium", nil, true
250
- client.find_mixin "my_template", "os_tpl", true
251
-
252
- To get a list of names of all / OS templates / Resource templates mixins use
253
-
254
- client.get_mixins
255
- client.get_mixins "os_tpl"
256
- client.get_mixins "resource_tpl"
257
-
258
- To create a new compute resource use
259
-
260
- os = client.find_mixin 'my_os', 'os_tpl'
261
- size = client.find_mixin 'large', 'resource_tpl'
262
- cmpt = client.get_resource "compute"
263
- cmpt.mixins << os << size
264
- cmpt.title = "My VM"
265
- client.create cmpt
266
-
267
- To get a description of a specific resource use
268
-
269
- client.describe "/compute/<OCCI_ID>"
270
- client.describe "/storage/<OCCI_ID>"
271
- client.describe "/network/<OCCI_ID>"
272
-
273
- To delete a specific resource use
274
-
275
- client.delete "/compute/<OCCI_ID>"
276
- client.delete "/storage/<OCCI_ID>"
277
- client.delete "/network/<OCCI_ID>"
278
-
279
- ### Logging
280
-
281
- The OCCI gem includes its own logging mechanism using a message queue. By default, no one is listening to that queue.
282
- A new OCCI Logger can be initialized by specifying the log destination (either a filename or an IO object like
283
- STDOUT) and the log level.
284
-
285
- logger = Occi::Api::Log.new STDOUT
286
- logger.level = Occi::Api::Log::INFO
287
-
288
- You can create multiple Loggers to receive the log output.
289
-
290
- You can always, even if there is no logger defined, log output using the class methods of OCCI::Api::Log e.g.
291
-
292
- Occi::Api::Log.info("Test message")
87
+ Detailed documentation is available in our [Wiki](https://github.com/EGI-FCTF/rOCCI-api/wiki).
293
88
 
294
89
  Changelog
295
90
  ---------
296
91
 
92
+ ### Version 4.3
93
+ * Updated dependencies
94
+ * Powered by rOCCI-core 4.3.x
95
+
96
+ ### Version 4.2
97
+ * Updated dependencies
98
+
297
99
  ### Version 4.1
298
100
  * Dropped Ruby 1.8.x support
299
101
  * Dropped jRuby 1.6.x support
@@ -362,7 +164,7 @@ Development
362
164
 
363
165
  Checkout latest version from GIT:
364
166
 
365
- git clone git://github.com/gwdg/rOCCI-api.git
167
+ git clone git://github.com/EGI-FCTF/rOCCI-api.git
366
168
 
367
169
  Change to rOCCI-api folder
368
170
 
@@ -374,11 +176,11 @@ Install dependencies for deployment
374
176
 
375
177
  ### Code Documentation
376
178
 
377
- [Code Documentation for rOCCI-api by YARD](http://rubydoc.info/github/gwdg/rOCCI-api/)
179
+ [Code Documentation for rOCCI-api by YARD](http://rubydoc.info/github/EGI-FCTF/rOCCI-api/)
378
180
 
379
181
  ### Continuous integration
380
182
 
381
- [Continuous integration for rOCCI-api by Travis-CI](http://travis-ci.org/gwdg/rOCCI-api/)
183
+ [Continuous integration for rOCCI-api by Travis-CI](http://travis-ci.org/EGI-FCTF/rOCCI-api/)
382
184
 
383
185
  ### Contribute
384
186
 
@@ -1,79 +1,9 @@
1
- require 'openssl'
2
-
3
- if defined? JRUBY_VERSION
4
- require 'java'
5
- end
6
-
7
1
  module Occi::Api::Client
8
2
 
9
3
  class AuthnUtils
10
4
 
11
5
  CERT_REGEXP = /\n?(-----BEGIN CERTIFICATE-----\n.+?\n-----END CERTIFICATE-----)\n/m
12
6
 
13
- # Reads credentials from a PKCS#12 compliant file. Returns
14
- # X.509 certificate and decrypted private key in PEM
15
- # formatted string.
16
- #
17
- # @example
18
- # AuthnUtils.extract_pem_from_pkcs12 "~/.globus/usercert.p12", "123456"
19
- # # => #<String>
20
- #
21
- # @param path_to_p12_file [String] Path to a PKCS#12 file with credentials
22
- # @param p12_password [String] Password needed to unlock the PKCS#12 file
23
- # @return [String] Decrypted credentials in a PEM formatted string
24
- def self.extract_pem_from_pkcs12(path_to_p12_file, p12_password)
25
- # decode certificate and its private key
26
- if defined? JRUBY_VERSION
27
- extract_pem_from_pkcs12_java(path_to_p12_file, p12_password)
28
- else
29
- extract_pem_from_pkcs12_c(path_to_p12_file, p12_password)
30
- end
31
- end
32
-
33
- def self.extract_pem_from_pkcs12_java(path_to_p12_file, p12_password)
34
- # Java-based Ruby, read PKCS12 manually
35
- # using KeyStore
36
- keystore = Java::JavaSecurity::KeyStore.getInstance("PKCS12")
37
- p12_input_stream = Java::JavaIo::FileInputStream.new(path_to_p12_file)
38
- pass_char_array = Java::JavaLang::String.new(p12_password).to_char_array
39
-
40
- # load and unlock PKCS#12 store
41
- keystore.load p12_input_stream, pass_char_array
42
-
43
- # read the first certificate and PK
44
- cert = keystore.getCertificate("1")
45
- pk = keystore.getKey("1", pass_char_array)
46
-
47
- pem_from_pkcs12 = ""
48
-
49
- pem_from_pkcs12 << "-----BEGIN CERTIFICATE-----\n"
50
- pem_from_pkcs12 << Java::JavaxXmlBind::DatatypeConverter.printBase64Binary(cert.getEncoded())
51
- pem_from_pkcs12 << "\n-----END CERTIFICATE-----"
52
-
53
- pem_from_pkcs12 << "\n"
54
-
55
- pem_from_pkcs12 << "-----BEGIN PRIVATE KEY-----\n"
56
- pem_from_pkcs12 << Java::JavaxXmlBind::DatatypeConverter.printBase64Binary(pk.getEncoded())
57
- pem_from_pkcs12 << "\n-----END PRIVATE KEY-----"
58
-
59
- pem_from_pkcs12
60
- end
61
-
62
- def self.extract_pem_from_pkcs12_c(path_to_p12_file, p12_password)
63
- # C-based Ruby, use OpenSSL::PKCS12
64
- pem_from_pkcs12 = ""
65
-
66
- pkcs12 = OpenSSL::PKCS12.new(
67
- File.open(path_to_p12_file, 'rb'),
68
- p12_password
69
- )
70
-
71
- # store cert and private key in a single PEM formatted string
72
- pem_from_pkcs12 << pkcs12.certificate.to_pem << pkcs12.key.to_pem
73
-
74
- pem_from_pkcs12
75
- end
76
-
77
7
  # Reads X.509 certificates from a file to an array.
78
8
  #
79
9
  # @example
@@ -83,7 +13,8 @@ module Occi::Api::Client
83
13
  # @param ca_file [String] Path to a PEM file containing certificates
84
14
  # @return [Array<String>] An array of read certificates
85
15
  def self.certs_to_file_ary(ca_file)
86
- # TODO: read and separate multiple certificates
16
+ raise ArgumentError, "PKCS12 file #{ca_file.inspect} " \
17
+ "is not supported in VOMS mode!" if /\A(.)+\.p12\z/ =~ ca_file
87
18
  certs_str = File.open(ca_file).read
88
19
 
89
20
  certs_ary = certs_str.scan(CERT_REGEXP)
@@ -33,8 +33,7 @@ module Occi::Api::Client
33
33
  #
34
34
  # @return [Array<String>] list of available entity types in a human-readable format
35
35
  def get_entity_types
36
- collection = @model.get(Occi::Core::Entity.kind.type_identifier)
37
- collection.kinds.to_a.collect { |kind| kind.term }
36
+ get_types(Occi::Core::Entity.kind)
38
37
  end
39
38
 
40
39
  # Retrieves all available entity type identifiers.
@@ -59,19 +58,7 @@ module Occi::Api::Client
59
58
  # @param type [String] short entity type
60
59
  # @return [String, nil] entity type identifier for the given entity type
61
60
  def get_entity_type_identifier(type)
62
- return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))
63
-
64
- collection = @model.get(Occi::Core::Entity.kind.type_identifier)
65
- e_kinds = collection.kinds.to_a.select { |e| e.term == type }
66
- tis = e_kinds.collect { |e| e.type_identifier }
67
- tis.uniq!
68
-
69
- if tis.length > 1
70
- raise Occi::Api::Client::Errors::AmbiguousNameError,
71
- "Entity type #{type.inspect} is ambiguous, use a type identifier!"
72
- end
73
-
74
- tis.first
61
+ get_type_identifier(type, Occi::Core::Entity.kind)
75
62
  end
76
63
 
77
64
  # Retrieves all available resource types.
@@ -81,8 +68,7 @@ module Occi::Api::Client
81
68
  #
82
69
  # @return [Array<String>] list of available resource types in a human-readable format
83
70
  def get_resource_types
84
- collection = @model.get(Occi::Core::Resource.kind.type_identifier)
85
- collection.kinds.to_a.collect { |kind| kind.term }
71
+ get_types(Occi::Core::Resource.kind)
86
72
  end
87
73
 
88
74
  # Retrieves all available resource type identifiers.
@@ -107,19 +93,7 @@ module Occi::Api::Client
107
93
  # @param type [String] short resource type
108
94
  # @return [String, nil] resource type identifier for the given resource type
109
95
  def get_resource_type_identifier(type)
110
- return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))
111
-
112
- collection = @model.get(Occi::Core::Resource.kind.type_identifier)
113
- r_kinds = collection.kinds.to_a.select { |r| r.term == type }
114
- tis = r_kinds.collect { |r| r.type_identifier }
115
- tis.uniq!
116
-
117
- if tis.length > 1
118
- raise Occi::Api::Client::Errors::AmbiguousNameError,
119
- "Resource type #{type.inspect} is ambiguous, use a type identifier!"
120
- end
121
-
122
- tis.first
96
+ get_type_identifier(type, Occi::Core::Resource.kind)
123
97
  end
124
98
 
125
99
  # Retrieves all available link types.
@@ -129,8 +103,7 @@ module Occi::Api::Client
129
103
  #
130
104
  # @return [Array<String>] list of available link types in a human-readable format
131
105
  def get_link_types
132
- collection = @model.get(Occi::Core::Link.kind.type_identifier)
133
- collection.kinds.to_a.collect { |kind| kind.term }
106
+ get_types(Occi::Core::Link.kind)
134
107
  end
135
108
 
136
109
  # Retrieves all available link type identifiers.
@@ -154,22 +127,34 @@ module Occi::Api::Client
154
127
  # @param type [String] short link type
155
128
  # @return [String, nil] link type identifier for the given link type
156
129
  def get_link_type_identifier(type)
130
+ get_type_identifier(type, Occi::Core::Link.kind)
131
+ end
132
+
133
+ private
134
+
135
+ def get_type_identifier(type, related_to)
157
136
  return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))
158
137
 
159
- collection = @model.get(Occi::Core::Link.kind.type_identifier)
160
- l_kinds = collection.kinds.to_a.select { |r| r.term == type }
161
- tis = l_kinds.collect { |r| r.type_identifier }
138
+ collection = @model.get(related_to.type_identifier)
139
+ e_kinds = collection.kinds.to_a.select { |e| e.term == type }
140
+ tis = e_kinds.collect { |e| e.type_identifier }
162
141
  tis.uniq!
163
142
 
164
143
  if tis.length > 1
165
144
  raise Occi::Api::Client::Errors::AmbiguousNameError,
166
- "Link type #{type.inspect} is ambiguous, use a type identifier!"
145
+ "#{related_to.type_identifier.split('#').capitalize} type " \
146
+ "#{type.inspect} is ambiguous, use a type identifier!"
167
147
  end
168
148
 
169
149
  tis.first
170
150
  end
171
151
 
152
+ def get_types(related_to)
153
+ collection = @model.get(related_to.type_identifier)
154
+ collection ? collection.kinds.to_a.collect { |kind| kind.term } : []
155
+ end
156
+
172
157
  end
173
158
 
174
159
  end
175
- end
160
+ end
@@ -1,4 +1,5 @@
1
1
  require 'httparty'
2
+ require 'persistent_httparty'
2
3
 
3
4
  # load all parts of the ClientHttp
4
5
  Dir[File.join(File.dirname(__FILE__), 'http', '*.rb')].each { |file| require file.gsub('.rb', '') }
@@ -10,6 +11,9 @@ module Occi::Api::Client
10
11
  # HTTParty for raw HTTP requests
11
12
  include HTTParty
12
13
 
14
+ # Take advantage of persistent HTTP connections
15
+ persistent_connection_adapter
16
+
13
17
  # TODO: change default Accept to JSON as soon as it is properly
14
18
  # implemented in OpenStack's OCCI-OS
15
19
  # 'Accept' => 'application/occi+json,text/plain;q=0.8,text/occi;q=0.2'
@@ -14,16 +14,12 @@ module Occi::Api::Client
14
14
  raise ArgumentError, "Missing required option 'user_cert' for x509 auth!" unless @options[:user_cert]
15
15
  raise ArgumentError, "The file specified in 'user_cert' does not exist!" unless File.exists? @options[:user_cert]
16
16
 
17
- # handle PKCS#12 credentials before passing them
18
- # to httparty
17
+ # handle credentials, separate PKCS12 from PEM
18
+ cert_content = File.open(@options[:user_cert], 'rb').read
19
19
  if /\A(.)+\.p12\z/ =~ @options[:user_cert]
20
- pem_cert = ::Occi::Api::Client::AuthnUtils.extract_pem_from_pkcs12(@options[:user_cert], @options[:user_cert_password])
21
- @env_ref.class.pem pem_cert, ''
20
+ @env_ref.class.pkcs12 cert_content, @options[:user_cert_password]
22
21
  else
23
- # httparty will handle ordinary PEM formatted credentials
24
- # TODO: Issue #49, check PEM credentials in jRuby
25
- pem_cert = File.open(@options[:user_cert], 'rb').read
26
- @env_ref.class.pem pem_cert, @options[:user_cert_password]
22
+ @env_ref.class.pem cert_content, @options[:user_cert_password]
27
23
  end
28
24
 
29
25
  @env_ref.class.ssl_ca_path @options[:ca_path] if @options[:ca_path]
@@ -28,18 +28,7 @@ module Occi::Api::Client
28
28
  end
29
29
 
30
30
  response = self.class.get(path, :headers => headers)
31
- response_msg = response_message response
32
-
33
- unless response.code == 200
34
- if response.headers["x-request-id"]
35
- message = "HTTP GET with ID[#{response.headers["x-request-id"].inspect}] failed! " \
36
- "#{response_msg} : #{response.body.inspect}"
37
- else
38
- message = "HTTP GET failed! #{response_msg} : #{response.body.inspect}"
39
- end
40
-
41
- raise message
42
- end
31
+ report_failure(response)
43
32
 
44
33
  get_process_response(path, response)
45
34
  end
@@ -64,18 +53,7 @@ module Occi::Api::Client
64
53
  raise ArgumentError, "Collection is a required argument!" if collection.blank?
65
54
 
66
55
  response = send_coll_request(path, collection)
67
- response_msg = response_message(response)
68
-
69
- unless response.code.between?(200, 201)
70
- if response.headers["x-request-id"]
71
- message = "HTTP POST with ID[#{response.headers["x-request-id"].inspect}] failed! " \
72
- "#{response_msg} : #{response.body.inspect}"
73
- else
74
- message = "HTTP POST failed! #{response_msg} : #{response.body.inspect}"
75
- end
76
-
77
- raise message
78
- end
56
+ report_failure(response)
79
57
 
80
58
  collection.send(:standalone_action_instance?) ? post_action(response) : post_create(response)
81
59
  end
@@ -93,20 +71,9 @@ module Occi::Api::Client
93
71
  raise ArgumentError, "Collection is a required argument!" if collection.blank?
94
72
 
95
73
  response = send_coll_request(path, collection, :put)
96
- response_msg = response_message(response)
97
-
98
- if response.code.between? 200, 201
99
- Occi::Parser.parse(response.content_type, response.body)
100
- else
101
- if response.headers["x-request-id"]
102
- message = "HTTP PUT with ID[#{response.headers["x-request-id"].inspect}] failed! " \
103
- "#{response_msg} : #{response.body.inspect}"
104
- else
105
- message = "HTTP PUT failed! #{response_msg} : #{response.body.inspect}"
106
- end
74
+ report_failure(response)
107
75
 
108
- raise message
109
- end
76
+ Occi::Parser.parse(response.content_type, response.body)
110
77
  end
111
78
 
112
79
  # Performs DELETE requests and returns True on success.
@@ -119,20 +86,7 @@ module Occi::Api::Client
119
86
  # @return [Boolean] status
120
87
  def del(path, filter=nil)
121
88
  raise ArgumentError, "Path is a required argument!" if path.blank?
122
-
123
- response = self.class.delete(path)
124
- response_msg = response_message(response)
125
-
126
- unless response.code == 200
127
- if response.headers["x-request-id"]
128
- message = "HTTP DELETE with ID[#{response.headers["x-request-id"].inspect}] failed! " \
129
- "#{response_msg} : #{response.body.inspect}"
130
- else
131
- message = "HTTP DELETE failed! #{response_msg} : #{response.body.inspect}"
132
- end
133
-
134
- raise message
135
- end
89
+ report_failure(self.class.delete(path))
136
90
 
137
91
  true
138
92
  end
@@ -218,6 +172,26 @@ module Occi::Api::Client
218
172
  end
219
173
  end
220
174
 
175
+ def report_failure(response)
176
+ # Is there something to report?
177
+ return if response.code.between? 200, 202
178
+
179
+ # get a human-readable response message
180
+ response_msg = response_message(response)
181
+
182
+ # include a Request ID if it is available
183
+ if response.headers["x-request-id"]
184
+ message = "HTTP #{response.request.http_method.upcase} with " \
185
+ "ID[#{response.headers["x-request-id"].inspect}] failed! " \
186
+ "#{response_msg} : #{response.body.inspect}"
187
+ else
188
+ message = "HTTP #{response.request.http_method.upcase} failed! " \
189
+ "#{response_msg} : #{response.body.inspect}"
190
+ end
191
+
192
+ raise message
193
+ end
194
+
221
195
  end
222
196
 
223
197
  end
@@ -1,5 +1,5 @@
1
1
  module Occi
2
2
  module Api
3
- VERSION = "4.2.6" unless defined?(::Occi::Api::VERSION)
3
+ VERSION = "4.3.0.beta.1" unless defined?(::Occi::Api::VERSION)
4
4
  end
5
5
  end
@@ -8,19 +8,20 @@ Gem::Specification.new do |gem|
8
8
  gem.name = "occi-api"
9
9
  gem.version = Occi::Api::VERSION
10
10
  gem.authors = ["Florian Feldhaus","Piotr Kasprzak", "Boris Parak"]
11
- gem.email = ["florian.feldhaus@gwdg.de", "piotr.kasprzak@gwdg.de", "xparak@mail.muni.cz"]
11
+ gem.email = ['florian.feldhaus@gmail.com', 'piotr.kasprzak@gwdg.de', 'parak@cesnet.cz']
12
12
  gem.description = %q{This gem provides ready-to-use client classes to simplify the integration of OCCI into your application}
13
- gem.summary = %q{OCCI development library providing a high-level API}
14
- gem.homepage = 'https://github.com/gwdg/rOCCI-api'
13
+ gem.summary = %q{OCCI development library providing a high-level client API}
14
+ gem.homepage = 'https://github.com/EGI-FCTF/rOCCI-api'
15
15
  gem.license = 'Apache License, Version 2.0'
16
16
 
17
17
  gem.files = `git ls-files`.split("\n")
18
18
  gem.test_files = `git ls-files -- {test,spec}/*`.split("\n")
19
- gem.require_paths = ["lib"]
19
+ gem.require_paths = ['lib']
20
20
 
21
- gem.add_dependency 'occi-core', '~> 4.2.16'
22
- gem.add_dependency 'httparty'
23
- gem.add_dependency 'json'
21
+ gem.add_dependency 'occi-core', '~> 4.3', '>= 4.3.0'
22
+ gem.add_dependency 'httparty', '~> 0.13', '>= 0.13.1'
23
+ gem.add_dependency 'json', '~> 1.8', '>= 1.8.1'
24
+ gem.add_dependency 'persistent_httparty', '~> 0.1', '>= 0.1.2'
24
25
 
25
- gem.required_ruby_version = ">= 1.9.3"
26
+ gem.required_ruby_version = '>= 1.9.3'
26
27
  end
@@ -7,45 +7,11 @@ module Occi
7
7
 
8
8
  describe AuthnUtils do
9
9
 
10
- it "can handle PKCS#12 user credentials" do
11
- path = File.expand_path("..", __FILE__)
12
-
13
- pem_cert_pk = AuthnUtils.extract_pem_from_pkcs12(
14
- path + "/rocci-cred.p12",
15
- "passworD123"
16
- )
17
-
18
- pem_cert_ok = File.open(path + "/rocci-cred-cert.pem", "rb").read
19
-
20
- if defined? JRUBY_VERSION
21
- # PK is in PKCS#8 when running jRuby
22
- pem_pk_ok = File.open(path + "/rocci-cred-key-jruby.pem", "rb").read
23
- else
24
- # PK is raw RSA key when running cRuby
25
- pem_pk_ok = File.open(path + "/rocci-cred-key.pem", "rb").read
26
- end
27
-
28
- pem_cert_pk_ok = ""
29
- pem_cert_pk_ok << pem_cert_ok << pem_pk_ok
30
-
31
-
32
- # remove line wrapping
33
- pem_cert_pk.delete! "\n"
34
- pem_cert_pk_ok.delete! "\n"
35
-
36
- # remove trailing new lines
37
- pem_cert_pk.chomp!
38
- pem_cert_pk_ok.chomp!
39
-
40
- pem_cert_pk.should eq pem_cert_pk_ok
41
- end
42
-
43
10
  it "can read CA certificates from a file" do
44
11
  path = File.expand_path("..", __FILE__)
45
12
 
46
- ca_certs = AuthnUtils.certs_to_file_ary(path + "/rocci-cred-cert.pem")
47
-
48
- ca_certs.should =~ [File.open(path + "/rocci-cred-cert.pem", "rb").read.chomp("\n")]
13
+ ca_certs = AuthnUtils.certs_to_file_ary("#{path}/rocci-cred-cert.pem")
14
+ ca_certs.should =~ [File.open("#{path}/rocci-cred-cert.pem", "rb").read.chomp("\n")]
49
15
  end
50
16
 
51
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occi-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.6
4
+ version: 4.3.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Feldhaus
@@ -10,64 +10,102 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-14 00:00:00.000000000 Z
13
+ date: 2014-10-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: occi-core
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 4.2.16
21
+ version: '4.3'
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 4.3.0
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - ~>
29
+ - - "~>"
30
+ - !ruby/object:Gem::Version
31
+ version: '4.3'
32
+ - - ">="
27
33
  - !ruby/object:Gem::Version
28
- version: 4.2.16
34
+ version: 4.3.0
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: httparty
31
37
  requirement: !ruby/object:Gem::Requirement
32
38
  requirements:
33
- - - '>='
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.13'
42
+ - - ">="
34
43
  - !ruby/object:Gem::Version
35
- version: '0'
44
+ version: 0.13.1
36
45
  type: :runtime
37
46
  prerelease: false
38
47
  version_requirements: !ruby/object:Gem::Requirement
39
48
  requirements:
40
- - - '>='
49
+ - - "~>"
41
50
  - !ruby/object:Gem::Version
42
- version: '0'
51
+ version: '0.13'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.1
43
55
  - !ruby/object:Gem::Dependency
44
56
  name: json
45
57
  requirement: !ruby/object:Gem::Requirement
46
58
  requirements:
47
- - - '>='
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ - - ">="
48
63
  - !ruby/object:Gem::Version
49
- version: '0'
64
+ version: 1.8.1
50
65
  type: :runtime
51
66
  prerelease: false
52
67
  version_requirements: !ruby/object:Gem::Requirement
53
68
  requirements:
54
- - - '>='
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.8'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.8.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: persistent_httparty
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.1'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.1.2
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.1'
92
+ - - ">="
55
93
  - !ruby/object:Gem::Version
56
- version: '0'
94
+ version: 0.1.2
57
95
  description: This gem provides ready-to-use client classes to simplify the integration
58
96
  of OCCI into your application
59
97
  email:
60
- - florian.feldhaus@gwdg.de
98
+ - florian.feldhaus@gmail.com
61
99
  - piotr.kasprzak@gwdg.de
62
- - xparak@mail.muni.cz
100
+ - parak@cesnet.cz
63
101
  executables: []
64
102
  extensions: []
65
103
  extra_rdoc_files: []
66
104
  files:
67
- - .gitignore
68
- - .rspec
69
- - .travis.yml
70
- - .yardopts
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - ".yardopts"
71
109
  - AUTHORS
72
110
  - Gemfile
73
111
  - LICENSE
@@ -193,13 +231,10 @@ files:
193
231
  - spec/occi/api/client/http/httparty_fix_spec.rb
194
232
  - spec/occi/api/client/http/net_http_fix_spec.rb
195
233
  - spec/occi/api/client/rocci-cred-cert.pem
196
- - spec/occi/api/client/rocci-cred-key-jruby.pem
197
- - spec/occi/api/client/rocci-cred-key.pem
198
- - spec/occi/api/client/rocci-cred.p12
199
234
  - spec/occi/api/dsl_spec.rb
200
235
  - spec/occi/helpers/helpers_spec.rb
201
236
  - spec/spec_helper.rb
202
- homepage: https://github.com/gwdg/rOCCI-api
237
+ homepage: https://github.com/EGI-FCTF/rOCCI-api
203
238
  licenses:
204
239
  - Apache License, Version 2.0
205
240
  metadata: {}
@@ -209,18 +244,18 @@ require_paths:
209
244
  - lib
210
245
  required_ruby_version: !ruby/object:Gem::Requirement
211
246
  requirements:
212
- - - '>='
247
+ - - ">="
213
248
  - !ruby/object:Gem::Version
214
249
  version: 1.9.3
215
250
  required_rubygems_version: !ruby/object:Gem::Requirement
216
251
  requirements:
217
- - - '>='
252
+ - - ">"
218
253
  - !ruby/object:Gem::Version
219
- version: '0'
254
+ version: 1.3.1
220
255
  requirements: []
221
256
  rubyforge_project:
222
257
  rubygems_version: 2.2.2
223
258
  signing_key:
224
259
  specification_version: 4
225
- summary: OCCI development library providing a high-level API
260
+ summary: OCCI development library providing a high-level client API
226
261
  test_files: []
@@ -1,3 +0,0 @@
1
- -----BEGIN PRIVATE KEY-----
2
- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDcjeRWvUe+p+bOTgl0JtUWpHCDrSoV5DQD59Rinol+1+471JDF6wloBrmo7nCyLtOpDUDUcRZIp9UKCZZLqx0FhmUySFCjU7wBtU1+IOhbEVH97+pff/2x9920C9uyV/06Vr7Ch8G8fYOZCplrmmWs5wj88mUSQBtSYMOZNQxkX18tj3oKgvLhAlRYoIAYJgkhFUsXegMUc7NRa9Kpt2ag2C7eKs9VMZuI9XF+e6xPK6lUPFV8lWzf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