bbrowning-deltacloud-client 0.0.9.4 → 0.0.9.7

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 (3) hide show
  1. data/Rakefile +14 -2
  2. data/lib/deltacloud.rb +34 -12
  3. metadata +9 -11
data/Rakefile CHANGED
@@ -25,8 +25,15 @@ task 'documentation' do
25
25
  load 'lib/documentation.rb'
26
26
  end
27
27
 
28
- Rake::GemPackageTask.new(@spec) do |pkg|
29
- pkg.need_tar = true
28
+ @specs = ['ruby', 'java'].inject({}) do |hash, spec_platform|
29
+ $platform = spec_platform
30
+ hash.update(spec_platform => Gem::Specification.load('deltacloud-client.gemspec'))
31
+ end
32
+
33
+ @specs.values.each do |spec|
34
+ Rake::GemPackageTask.new(spec) do |pkg|
35
+ pkg.need_tar = true
36
+ end
30
37
  end
31
38
 
32
39
  if Gem.available?('rspec')
@@ -47,3 +54,8 @@ desc "Clean Fixtures"
47
54
  task 'fixtures:clean' do
48
55
  FileUtils.rm_rf( File.dirname( __FILE__ ) + '/specs/data' )
49
56
  end
57
+
58
+ begin
59
+ require 'ci/reporter/rake/rspec'
60
+ rescue LoadError
61
+ end
@@ -33,6 +33,22 @@ module DeltaCloud
33
33
  API.new(user_name, password, api_url, &block)
34
34
  end
35
35
 
36
+ # Check given credentials if their are valid against
37
+ # backend cloud provider
38
+ #
39
+ # @param [String, user_name] API user name
40
+ # @param [String, password] API password
41
+ # @param [String, user_name] API URL (eg. http://localhost:3001/api)
42
+ # @return [true|false]
43
+ def self.valid_credentials?(user_name, password, api_url)
44
+ api=API.new(user_name, password, api_url)
45
+ result = false
46
+ api.request(:get, '', :force_auth => '1') do |response|
47
+ result = true if response.code.eql?(200)
48
+ end
49
+ return result
50
+ end
51
+
36
52
  # Return a API driver for specified URL
37
53
  #
38
54
  # @param [String, url] API URL (eg. http://localhost:3001/api)
@@ -178,7 +194,12 @@ module DeltaCloud
178
194
  actions << [link['rel'], link[:href]]
179
195
  define_method :"#{link['rel'].sanitize}!" do
180
196
  client.request(:"#{link['method']}", link['href'], {}, {})
181
- client.send(:"#{item.name}", item['id'])
197
+ @current_state = client.send(:"#{item.name}", item['id']).state
198
+ obj.instance_eval do |o|
199
+ def state
200
+ @current_state
201
+ end
202
+ end
182
203
  end
183
204
  end
184
205
  define_method :actions do
@@ -240,16 +261,16 @@ module DeltaCloud
240
261
  end
241
262
  declare_entry_points_methods(@entry_points)
242
263
  end
243
-
244
- def create_instance_credential(opts={}, &block)
264
+
265
+ def create_key(opts={}, &block)
245
266
  params = { :name => opts[:name] }
246
- instance_credential = nil
247
- request(:post, entry_points[:instance_credentials], {}, params) do |response|
248
- c = DeltaCloud.define_class("InstanceCredential")
249
- instance_credential = base_object(c, :instance_credential, response)
250
- yield instance_credential if block_given?
267
+ key = nil
268
+ request(:post, entry_points[:keys], {}, params) do |response|
269
+ c = DeltaCloud.define_class("Key")
270
+ key = base_object(c, :key, response)
271
+ yield key if block_given?
251
272
  end
252
- return instance_credential
273
+ return key
253
274
  end
254
275
 
255
276
  # Create a new instance, using image +image_id+. Possible optiosn are
@@ -267,17 +288,18 @@ module DeltaCloud
267
288
  realm_id = opts[:realm]
268
289
  user_data = opts[:user_data]
269
290
  key_name = opts[:key_name]
291
+ security_group = opts[:security_group]
270
292
 
271
- params = opts.dup
293
+ params = {}
272
294
  ( params[:realm_id] = realm_id ) if realm_id
273
295
  ( params[:name] = name ) if name
274
296
  ( params[:user_data] = user_data ) if user_data
275
- ( params[:keyname] = user_data ) if key_name
297
+ ( params[:keyname] = key_name ) if key_name
298
+ ( params[:security_group] = security_group) if security_group
276
299
 
277
300
  if opts[:hardware_profile].is_a?(String)
278
301
  params[:hwp_id] = opts[:hardware_profile]
279
302
  elsif opts[:hardware_profile].is_a?(Hash)
280
- params.delete(:hardware_profile)
281
303
  opts[:hardware_profile].each do |k,v|
282
304
  params[:"hwp_#{k}"] = v
283
305
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbrowning-deltacloud-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 99
4
+ hash: 101
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 9
10
- - 4
11
- version: 0.0.9.4
10
+ - 7
11
+ version: 0.0.9.7
12
12
  platform: ruby
13
13
  authors:
14
14
  - Red Hat, Inc.
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-23 00:00:00 -04:00
19
+ date: 2010-10-04 00:00:00 -04:00
20
20
  default_executable: deltacloudc
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -43,14 +43,12 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- hash: 62196439
46
+ hash: 5
47
47
  segments:
48
48
  - 1
49
- - 5
50
- - 0
51
- - beta
52
- - 2
53
- version: 1.5.0.beta.2
49
+ - 4
50
+ - 1
51
+ version: 1.4.1
54
52
  type: :runtime
55
53
  version_requirements: *id002
56
54
  - !ruby/object:Gem::Dependency
@@ -84,7 +82,6 @@ files:
84
82
  - lib/plain_formatter.rb
85
83
  - init.rb
86
84
  - bin/deltacloudc
87
- - COPYING
88
85
  - specs/fixtures/images/img1.yml
89
86
  - specs/fixtures/images/img2.yml
90
87
  - specs/fixtures/images/img3.yml
@@ -107,6 +104,7 @@ files:
107
104
  - specs/spec_helper.rb
108
105
  - specs/storage_snapshot_spec.rb
109
106
  - specs/storage_volume_spec.rb
107
+ - COPYING
110
108
  has_rdoc: true
111
109
  homepage: http://www.deltacloud.org
112
110
  licenses: []