fog 0.3.26 → 0.3.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fog (0.3.26)
4
+ fog (0.3.27)
5
5
  builder
6
6
  excon (>= 0.2.8)
7
7
  formatador (>= 0.0.16)
8
8
  json
9
9
  mime-types
10
+ named-parameters (>= 0.0.14)
10
11
  net-ssh (>= 2.0.23)
11
12
  nokogiri (>= 1.4.4)
12
13
  ruby-hmac
@@ -21,6 +22,7 @@ GEM
21
22
  formatador (>= 0.0.12)
22
23
  json (1.4.6)
23
24
  mime-types (1.16)
25
+ named-parameters (0.0.14)
24
26
  net-ssh (2.0.23)
25
27
  nokogiri (1.4.4)
26
28
  rake (0.8.7)
@@ -40,6 +42,7 @@ DEPENDENCIES
40
42
  formatador (>= 0.0.16)
41
43
  json
42
44
  mime-types
45
+ named-parameters (>= 0.0.14)
43
46
  net-ssh (>= 2.0.23)
44
47
  nokogiri (>= 1.4.4)
45
48
  rake
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.3.26'
11
- s.date = '2010-12-01'
10
+ s.version = '0.3.27'
11
+ s.date = '2010-12-04'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
47
47
  s.add_dependency('formatador', '>=0.0.16')
48
48
  s.add_dependency('json')
49
49
  s.add_dependency('mime-types')
50
+ s.add_dependency('named-parameters', '>=0.0.14')
50
51
  s.add_dependency('net-ssh', '>=2.0.23')
51
52
  s.add_dependency('nokogiri', '>=1.4.4')
52
53
  s.add_dependency('ruby-hmac')
data/lib/fog.rb CHANGED
@@ -3,6 +3,7 @@ require 'base64'
3
3
  require 'cgi'
4
4
  require 'excon'
5
5
  require 'formatador'
6
+ require 'named-parameters'
6
7
  require 'time'
7
8
 
8
9
  __DIR__ = File.dirname(__FILE__)
@@ -18,7 +19,7 @@ module Fog
18
19
  @mocking = false
19
20
 
20
21
  unless const_defined?(:VERSION)
21
- VERSION = '0.3.26'
22
+ VERSION = '0.3.27'
22
23
  end
23
24
 
24
25
  module Mock
@@ -3,6 +3,7 @@ module Fog
3
3
  class CDN < Fog::Service
4
4
 
5
5
  requires :aws_access_key_id, :aws_secret_access_key
6
+ recognizes :host, :path, :port, :scheme, :version, :persistent
6
7
 
7
8
  model_path 'fog/aws/models/cdn'
8
9
 
@@ -2,7 +2,7 @@ module Fog
2
2
  module AWS
3
3
  class Compute < Fog::Service
4
4
 
5
- requires :aws_access_key_id, :aws_secret_access_key
5
+ requires :aws_access_key_id, :aws_secret_access_key
6
6
  recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
7
7
 
8
8
  model_path 'fog/aws/models/compute'
@@ -3,6 +3,7 @@ module Fog
3
3
  class ELB < Fog::Service
4
4
 
5
5
  requires :aws_access_key_id, :aws_secret_access_key
6
+ recognizes :region, :host, :path, :port, :scheme, :persistent
6
7
 
7
8
  request_path 'fog/aws/requests/elb'
8
9
  request :create_load_balancer
@@ -3,6 +3,7 @@ module Fog
3
3
  class IAM < Fog::Service
4
4
 
5
5
  requires :aws_access_key_id, :aws_secret_access_key
6
+ recognizes :host, :path, :port, :scheme, :persistent
6
7
 
7
8
  request_path 'fog/aws/requests/iam'
8
9
  request :add_user_to_group
@@ -27,7 +27,7 @@ module Fog
27
27
  connection.deregister_image(id)
28
28
 
29
29
  if(delete_snapshot && root_device_type == "ebs")
30
- block_device = block_device_mapping.select {|block_device| block_device['deviceName'] == root_device_name}
30
+ block_device = block_device_mapping.detect {|block_device| block_device['deviceName'] == root_device_name}
31
31
  @connection.snapshots.new(:id => block_device['snapshotId']).destroy
32
32
  else
33
33
  true
@@ -43,8 +43,8 @@ module Fog
43
43
  self.filters ||= {}
44
44
  super
45
45
  end
46
-
47
- def all(filters = @filters)
46
+
47
+ def all(filters = filters)
48
48
  self.filters = filters
49
49
  data = connection.describe_images(filters).body
50
50
  load(data['imagesSet'])
@@ -84,7 +84,7 @@ module Fog
84
84
  end
85
85
 
86
86
  def key_pair=(new_keypair)
87
- key_name = new_keypair && new_keypair.name
87
+ self.key_name = new_keypair && new_keypair.name
88
88
  end
89
89
 
90
90
  def private_key_path
@@ -151,7 +151,8 @@ module Fog
151
151
 
152
152
  def setup(credentials = {})
153
153
  requires :identity, :ip_address, :username
154
- sleep(10) # takes a bit before EC2 instances will play nice
154
+ require 'json'
155
+
155
156
  commands = [
156
157
  %{mkdir .ssh},
157
158
  %{passwd -l root},
@@ -160,7 +161,16 @@ module Fog
160
161
  if public_key
161
162
  commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
162
163
  end
163
- Fog::SSH.new(ip_address, username, credentials).run(commands)
164
+ # allow some retries over the first 120 seconds because aws is weird
165
+ Timeout::timeout(120) do
166
+ begin
167
+ Timeout::timeout(4) do
168
+ Fog::SSH.new(ip_address, username, credentials).run(commands)
169
+ end
170
+ rescue Net::SSH::AuthenticationFailed, Timeout::Error
171
+ retry
172
+ end
173
+ end
164
174
  rescue Errno::ECONNREFUSED => e
165
175
  sleep(1)
166
176
  retry
@@ -98,7 +98,19 @@ module Fog
98
98
  end
99
99
 
100
100
  server.save
101
- server.wait_for { ready? }
101
+ # eventual consistency sometimes means a delay before it appears
102
+ retries = 3
103
+ begin
104
+ server.wait_for { ready? }
105
+ rescue Fog::Errors::Error => error
106
+ sleep(1)
107
+ retries -= 1
108
+ if retries > 0
109
+ retry
110
+ else
111
+ raise error
112
+ end
113
+ end
102
114
  server.setup(:key_data => [server.private_key])
103
115
  server
104
116
  end
@@ -86,12 +86,13 @@ module Fog
86
86
 
87
87
  response.status = 200
88
88
  response.body = {
89
- 'Contents' => truncated_contents,
90
- 'IsTruncated' => truncated_contents.size != contents.size,
91
- 'Marker' => options['marker'],
92
- 'MaxKeys' => max_keys,
93
- 'Name' => bucket['Name'],
94
- 'Prefix' => options['prefix']
89
+ 'CommonPrefixes' => [],
90
+ 'Contents' => truncated_contents,
91
+ 'IsTruncated' => truncated_contents.size != contents.size,
92
+ 'Marker' => options['marker'],
93
+ 'MaxKeys' => max_keys,
94
+ 'Name' => bucket['Name'],
95
+ 'Prefix' => options['prefix']
95
96
  }
96
97
  if options['max-keys'] && options['max-keys'] < response.body['Contents'].length
97
98
  response.body['IsTruncated'] = true
@@ -3,7 +3,8 @@ module Fog
3
3
  class SimpleDB < Fog::Service
4
4
 
5
5
  requires :aws_access_key_id, :aws_secret_access_key
6
-
6
+ recognizes :host, :nil_string, :path, :port, :scheme, :persistent
7
+
7
8
  request_path 'fog/aws/requests/simpledb'
8
9
  request :batch_put_attributes
9
10
  request :create_domain
@@ -3,7 +3,8 @@ module Fog
3
3
  class Storage < Fog::Service
4
4
 
5
5
  requires :aws_access_key_id, :aws_secret_access_key
6
-
6
+ recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
7
+
7
8
  model_path 'fog/aws/models/storage'
8
9
  collection :directories
9
10
  model :directory
@@ -175,6 +176,7 @@ module Fog
175
176
  end
176
177
  end
177
178
 
179
+
178
180
  class Real
179
181
  include Utils
180
182
  extend Fog::Deprecation
@@ -3,6 +3,7 @@ module Fog
3
3
  class Compute < Fog::Service
4
4
 
5
5
  requires :bluebox_api_key, :bluebox_customer_id
6
+ recognizes :bluebox_host, :bluebox_port, :bluebox_scheme, :persistent
6
7
 
7
8
  model_path 'fog/bluebox/models/compute'
8
9
  model :flavor
@@ -5,6 +5,7 @@ module Fog
5
5
  API_URL = "https://api.gb1.brightbox.com/"
6
6
 
7
7
  requires :brightbox_client_id, :brightbox_secret
8
+ recognizes :brightbox_auth_url, :brightbox_api_url
8
9
 
9
10
  model_path 'fog/brightbox/models/compute'
10
11
  model :account # Singular resource, no collection
@@ -148,6 +148,7 @@ module Fog
148
148
  !identity
149
149
  end
150
150
 
151
+ # check that the attributes specified in args exist and is not nil
151
152
  def requires(*args)
152
153
  missing = []
153
154
  for arg in [:connection] | args
@@ -28,7 +28,6 @@ module Fog
28
28
  unless credentials && credentials[credential]
29
29
  print("\n To run as '#{credential}', add the following to #{config_path}\n")
30
30
  yml = <<-YML
31
-
32
31
  :#{credential}:
33
32
  :aws_access_key_id: INTENTIONALLY_LEFT_BLANK
34
33
  :aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
@@ -51,7 +50,7 @@ module Fog
51
50
  :terremark_username: INTENTIONALLY_LEFT_BLANK
52
51
  :terremark_password: INTENTIONALLY_LEFT_BLANK
53
52
  YML
54
- print(yml)
53
+ print("\n#{yml}\n")
55
54
  raise(ArgumentError.new("Missing Credentials"))
56
55
  end
57
56
  credentials[credential]
@@ -34,13 +34,16 @@ module Fog
34
34
  EOS
35
35
  end
36
36
 
37
+ def requirements
38
+ declared_parameters_for :new, :required
39
+ end
40
+
37
41
  def new(options={})
38
42
  if Fog.bin
39
- default_credentials = Fog.credentials.reject {|key, value| !requirements.include?(key)}
43
+ default_credentials = filter_parameters(Fog.credentials)
40
44
  options = default_credentials.merge(options)
41
45
  end
42
46
 
43
- validate_arguments(options)
44
47
  setup_requirements
45
48
 
46
49
  if Fog.mocking?
@@ -110,41 +113,10 @@ module Fog
110
113
  @requests ||= []
111
114
  end
112
115
 
113
- def requires(*args)
114
- requirements.concat(args)
115
- end
116
-
117
- def requirements
118
- @requirements ||= []
119
- end
120
-
121
- def recognizes(*args)
122
- recognized.concat(args)
123
- end
124
-
125
- def recognized
126
- @recognized ||= []
127
- end
128
-
129
116
  def reset_data(keys=Mock.data.keys)
130
117
  Mock.reset_data(keys)
131
118
  end
132
119
 
133
- def validate_arguments(options)
134
- missing = requirements - options.keys
135
- unless missing.empty?
136
- raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
137
- end
138
-
139
- # FIXME: avoid failing for the services that don't have recognizes yet
140
- unless recognizes.empty?
141
- unrecognized = options.keys - requirements - recognized
142
- unless unrecognized.empty?
143
- raise ArgumentError, "Unrecognized arguments: #{unrecognized.join(', ')}"
144
- end
145
- end
146
- end
147
-
148
120
  end
149
121
 
150
122
  end
@@ -42,8 +42,7 @@ module Fog
42
42
  require 'net/ssh'
43
43
  @address = address
44
44
  @username = username
45
- @options = options.merge(:paranoid => false)
46
- @options.merge(:verbose => true)
45
+ @options = { :paranoid => false }.merge(options)
47
46
  end
48
47
 
49
48
  def run(commands)
@@ -2,8 +2,8 @@ module Fog
2
2
  module GoGrid
3
3
  class Compute < Fog::Service
4
4
 
5
- requires :go_grid_api_key
6
- requires :go_grid_shared_secret
5
+ requires :go_grid_api_key, :go_grid_shared_secret
6
+ recognizes :host, :path, :port, :scheme, :persistent
7
7
 
8
8
  model_path 'fog/go_grid/models/compute'
9
9
  model :image
@@ -3,6 +3,7 @@ module Fog
3
3
  class Storage < Fog::Service
4
4
 
5
5
  requires :google_storage_access_key_id, :google_storage_secret_access_key
6
+ recognizes :host, :port, :scheme, :persistent
6
7
 
7
8
  model_path 'fog/google/models/storage'
8
9
  collection :directories
@@ -135,6 +136,7 @@ module Fog
135
136
  end
136
137
  end
137
138
 
139
+
138
140
  class Real
139
141
  include Utils
140
142
  extend Fog::Deprecation
@@ -3,6 +3,7 @@ module Fog
3
3
  class Compute < Fog::Service
4
4
 
5
5
  requires :linode_api_key
6
+ recognizes :port, :scheme, :persistent
6
7
 
7
8
  model_path 'fog/linode/models/compute'
8
9
 
@@ -4,8 +4,8 @@ module Fog
4
4
  module NewServers
5
5
  class Compute < Fog::Service
6
6
 
7
- requires :new_servers_password
8
- requires :new_servers_username
7
+ requires :new_servers_password, :new_servers_username
8
+ recognizes :host, :port, :scheme, :persistent
9
9
 
10
10
  model_path 'fog/new_servers/models/compute'
11
11
 
@@ -1,6 +1,7 @@
1
1
  module Fog
2
2
  module Rackspace
3
-
3
+
4
+ include NamedParameters
4
5
  extend Fog::Provider
5
6
 
6
7
  service_path 'fog/rackspace'
@@ -10,6 +11,11 @@ module Fog
10
11
  service 'servers'
11
12
  service 'storage'
12
13
 
14
+ # NOTE: might be better to rely on the caller alone to enforce parameter
15
+ # requirements...
16
+ has_named_parameters :'self.authenticate',
17
+ :required => [ :rackspace_api_key, :rackspace_username ],
18
+ :optional => [ :rackspace_auth_url ]
13
19
  def self.authenticate(options)
14
20
  rackspace_auth_url = options[:rackspace_auth_url] || "auth.api.rackspacecloud.com"
15
21
  connection = Fog::Connection.new("https://" + rackspace_auth_url)
@@ -3,6 +3,9 @@ module Fog
3
3
  class CDN < Fog::Service
4
4
 
5
5
  requires :rackspace_api_key, :rackspace_username
6
+ # NOTE: recognizes clause delegates to Fog::Rackspace.authenticate's so
7
+ # we also declare those parameters that the authenticate expects...
8
+ recognizes :rackspace_auth_url, :persistent
6
9
 
7
10
  model_path 'fog/rackspace/models/cdn'
8
11
 
@@ -3,6 +3,9 @@ module Fog
3
3
  class Compute < Fog::Service
4
4
 
5
5
  requires :rackspace_api_key, :rackspace_username
6
+ # NOTE: recognizes clause delegates to Fog::Rackspace.authenticate's so
7
+ # we also declare those parameters that the authenticate expects...
8
+ recognizes :rackspace_auth_url, :persistent
6
9
 
7
10
  model_path 'fog/rackspace/models/compute'
8
11
  model :flavor
@@ -3,6 +3,9 @@ module Fog
3
3
  class Storage < Fog::Service
4
4
 
5
5
  requires :rackspace_api_key, :rackspace_username
6
+ # NOTE: recognizes clause delegates to Fog::Rackspace.authenticate's so
7
+ # we also declare those parameters that the authenticate expects...
8
+ recognizes :rackspace_auth_url, :persistent
6
9
 
7
10
  model_path 'fog/rackspace/models/storage'
8
11
  model :directory
@@ -3,6 +3,7 @@ module Fog
3
3
  class Compute < Fog::Service
4
4
 
5
5
  requires :slicehost_password
6
+ recognizes :host, :port, :scheme, :persistent
6
7
 
7
8
  model_path 'fog/slicehost/models/compute'
8
9
  model :flavor
@@ -32,7 +32,9 @@ module Fog
32
32
  end
33
33
 
34
34
  class Real
35
-
35
+ requires :terremark_ecloud_password, :terremark_ecloud_username
36
+ recognizes :host, :path, :port, :scheme, :persistent
37
+
36
38
  include Fog::Terremark::Shared::Real
37
39
  include Fog::Terremark::Shared::Parser
38
40
 
@@ -19,7 +19,8 @@ end
19
19
  module Fog
20
20
  class Vcloud < Fog::Service
21
21
 
22
- requires :username, :password, :versions_uri
22
+ requires :username, :password, :module, :versions_uri
23
+ recognizes :version, :persistent
23
24
 
24
25
  model_path 'fog/vcloud/models'
25
26
  model :vdc
@@ -1,28 +1,25 @@
1
- __DIR__ = File.dirname(__FILE__)
2
- __LIB_DIR__ = File.join(__DIR__, '../lib')
3
-
4
- [ __DIR__, __LIB_DIR__ ].each do |directory|
5
- $LOAD_PATH.unshift directory unless
6
- $LOAD_PATH.include?(directory) ||
7
- $LOAD_PATH.include?(File.expand_path(directory))
8
- end
9
-
10
- require 'fog'
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
11
2
  require 'fog/core/bin'
12
3
 
13
4
  Fog.bin = true
14
5
 
15
- require 'tests/helpers/collection_tests'
16
- require 'tests/helpers/model_tests'
6
+ __DIR__ = File.dirname(__FILE__)
7
+
8
+ $LOAD_PATH.unshift __DIR__ unless
9
+ $LOAD_PATH.include?(__DIR__) ||
10
+ $LOAD_PATH.include?(File.expand_path(__DIR__))
11
+
12
+ require 'helpers/collection_tests'
13
+ require 'helpers/model_tests'
17
14
 
18
- require 'tests/helpers/compute/flavors_tests'
19
- require 'tests/helpers/compute/server_tests'
20
- require 'tests/helpers/compute/servers_tests'
15
+ require 'helpers/compute/flavors_tests'
16
+ require 'helpers/compute/server_tests'
17
+ require 'helpers/compute/servers_tests'
21
18
 
22
- require 'tests/helpers/storage/directory_tests'
23
- require 'tests/helpers/storage/directories_tests'
24
- require 'tests/helpers/storage/file_tests'
25
- require 'tests/helpers/storage/files_tests'
19
+ require 'helpers/storage/directory_tests'
20
+ require 'helpers/storage/directories_tests'
21
+ require 'helpers/storage/file_tests'
22
+ require 'helpers/storage/files_tests'
26
23
 
27
24
  # Use so you can run in mock mode from the command line:
28
25
  #
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 26
9
- version: 0.3.26
8
+ - 27
9
+ version: 0.3.27
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-01 00:00:00 -08:00
17
+ date: 2010-12-04 00:00:00 -08:00
18
18
  default_executable: fog
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,20 @@ dependencies:
85
85
  prerelease: false
86
86
  type: :runtime
87
87
  version_requirements: &id006 !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
93
+ - 0
94
+ - 14
95
+ version: 0.0.14
96
+ requirement: *id006
97
+ name: named-parameters
98
+ - !ruby/object:Gem::Dependency
99
+ prerelease: false
100
+ type: :runtime
101
+ version_requirements: &id007 !ruby/object:Gem::Requirement
88
102
  requirements:
89
103
  - - ">="
90
104
  - !ruby/object:Gem::Version
@@ -93,12 +107,12 @@ dependencies:
93
107
  - 0
94
108
  - 23
95
109
  version: 2.0.23
96
- requirement: *id006
110
+ requirement: *id007
97
111
  name: net-ssh
98
112
  - !ruby/object:Gem::Dependency
99
113
  prerelease: false
100
114
  type: :runtime
101
- version_requirements: &id007 !ruby/object:Gem::Requirement
115
+ version_requirements: &id008 !ruby/object:Gem::Requirement
102
116
  requirements:
103
117
  - - ">="
104
118
  - !ruby/object:Gem::Version
@@ -107,36 +121,36 @@ dependencies:
107
121
  - 4
108
122
  - 4
109
123
  version: 1.4.4
110
- requirement: *id007
124
+ requirement: *id008
111
125
  name: nokogiri
112
126
  - !ruby/object:Gem::Dependency
113
127
  prerelease: false
114
128
  type: :runtime
115
- version_requirements: &id008 !ruby/object:Gem::Requirement
129
+ version_requirements: &id009 !ruby/object:Gem::Requirement
116
130
  requirements:
117
131
  - - ">="
118
132
  - !ruby/object:Gem::Version
119
133
  segments:
120
134
  - 0
121
135
  version: "0"
122
- requirement: *id008
136
+ requirement: *id009
123
137
  name: ruby-hmac
124
138
  - !ruby/object:Gem::Dependency
125
139
  prerelease: false
126
140
  type: :development
127
- version_requirements: &id009 !ruby/object:Gem::Requirement
141
+ version_requirements: &id010 !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
130
144
  - !ruby/object:Gem::Version
131
145
  segments:
132
146
  - 0
133
147
  version: "0"
134
- requirement: *id009
148
+ requirement: *id010
135
149
  name: rake
136
150
  - !ruby/object:Gem::Dependency
137
151
  prerelease: false
138
152
  type: :development
139
- version_requirements: &id010 !ruby/object:Gem::Requirement
153
+ version_requirements: &id011 !ruby/object:Gem::Requirement
140
154
  requirements:
141
155
  - - "="
142
156
  - !ruby/object:Gem::Version
@@ -145,12 +159,12 @@ dependencies:
145
159
  - 3
146
160
  - 1
147
161
  version: 1.3.1
148
- requirement: *id010
162
+ requirement: *id011
149
163
  name: rspec
150
164
  - !ruby/object:Gem::Dependency
151
165
  prerelease: false
152
166
  type: :development
153
- version_requirements: &id011 !ruby/object:Gem::Requirement
167
+ version_requirements: &id012 !ruby/object:Gem::Requirement
154
168
  requirements:
155
169
  - - "="
156
170
  - !ruby/object:Gem::Version
@@ -159,7 +173,7 @@ dependencies:
159
173
  - 1
160
174
  - 10
161
175
  version: 0.1.10
162
- requirement: *id011
176
+ requirement: *id012
163
177
  name: shindo
164
178
  description: The Ruby cloud computing library.
165
179
  email: geemus@gmail.com