fog 0.2.11 → 0.2.12
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.
- data/fog.gemspec +8 -2
- data/lib/fog.rb +2 -1
- data/lib/fog/bin.rb +2 -1
- data/lib/fog/linode.rb +75 -0
- data/lib/fog/linode/bin.rb +30 -0
- data/lib/fog/linode/requests/avail_datacenters.rb +29 -0
- data/lib/fog/linode/requests/avail_distributions.rb +33 -0
- data/lib/fog/linode/requests/avail_kernels.rb +34 -0
- data/lib/fog/linode/requests/avail_linodeplans.rb +29 -0
- data/lib/fog/vcloud.rb +14 -12
- data/lib/fog/vcloud/extension.rb +3 -3
- data/lib/fog/vcloud/terremark/ecloud.rb +14 -13
- metadata +9 -3
data/fog.gemspec
CHANGED
@@ -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.2.
|
11
|
-
s.date = '2010-07-
|
10
|
+
s.version = '0.2.12'
|
11
|
+
s.date = '2010-07-09'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -236,6 +236,12 @@ Gem::Specification.new do |s|
|
|
236
236
|
lib/fog/deprecation.rb
|
237
237
|
lib/fog/errors.rb
|
238
238
|
lib/fog/hmac.rb
|
239
|
+
lib/fog/linode.rb
|
240
|
+
lib/fog/linode/bin.rb
|
241
|
+
lib/fog/linode/requests/avail_datacenters.rb
|
242
|
+
lib/fog/linode/requests/avail_distributions.rb
|
243
|
+
lib/fog/linode/requests/avail_kernels.rb
|
244
|
+
lib/fog/linode/requests/avail_linodeplans.rb
|
239
245
|
lib/fog/local.rb
|
240
246
|
lib/fog/local/bin.rb
|
241
247
|
lib/fog/local/models/directories.rb
|
data/lib/fog.rb
CHANGED
@@ -29,6 +29,7 @@ require 'fog/ssh'
|
|
29
29
|
|
30
30
|
require 'fog/aws'
|
31
31
|
require 'fog/bluebox'
|
32
|
+
require 'fog/linode'
|
32
33
|
require 'fog/local'
|
33
34
|
require 'fog/new_servers'
|
34
35
|
require 'fog/rackspace'
|
@@ -39,7 +40,7 @@ require 'fog/vcloud'
|
|
39
40
|
module Fog
|
40
41
|
|
41
42
|
unless const_defined?(:VERSION)
|
42
|
-
VERSION = '0.2.
|
43
|
+
VERSION = '0.2.12'
|
43
44
|
end
|
44
45
|
|
45
46
|
module Mock
|
data/lib/fog/bin.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'fog/credentials'
|
2
2
|
|
3
3
|
require 'fog/aws/bin'
|
4
|
+
require 'fog/linode/bin'
|
4
5
|
require 'fog/local/bin'
|
5
6
|
require 'fog/new_servers/bin'
|
6
7
|
require 'fog/rackspace/bin'
|
@@ -14,7 +15,7 @@ module Fog
|
|
14
15
|
|
15
16
|
def services
|
16
17
|
services = []
|
17
|
-
[::AWS, ::Local, ::NewServers, ::Rackspace, ::Slicehost, ::Terremark, ::Vcloud, ::Bluebox].each do |service|
|
18
|
+
[::AWS, ::Linode, ::Local, ::NewServers, ::Rackspace, ::Slicehost, ::Terremark, ::Vcloud, ::Bluebox].each do |service|
|
18
19
|
if service.initialized?
|
19
20
|
services << service
|
20
21
|
end
|
data/lib/fog/linode.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
module Fog
|
2
|
+
module Linode
|
3
|
+
extend Fog::Service
|
4
|
+
|
5
|
+
requires :linode_api_key
|
6
|
+
|
7
|
+
model_path 'fog/linode/models'
|
8
|
+
|
9
|
+
request_path 'fog/linode/requests'
|
10
|
+
request 'avail_datacenters'
|
11
|
+
request 'avail_distributions'
|
12
|
+
request 'avail_kernels'
|
13
|
+
request 'avail_linodeplans'
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
include Collections
|
17
|
+
|
18
|
+
def self.data
|
19
|
+
@data ||= Hash.new do |hash, key|
|
20
|
+
hash[key] = {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset_data(keys=data.keys)
|
25
|
+
for key in [*keys]
|
26
|
+
data.delete(key)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(options={})
|
31
|
+
@linode_api_key = options[:linode_api_key]
|
32
|
+
@data = self.class.data[@linode_api_key]
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
class Real
|
38
|
+
include Collections
|
39
|
+
|
40
|
+
def initialize(options={})
|
41
|
+
@linode_api_key = options[:linode_api_key]
|
42
|
+
@host = options[:host] || "api.linode.com"
|
43
|
+
@port = options[:port] || 443
|
44
|
+
@scheme = options[:scheme] || 'https'
|
45
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
46
|
+
end
|
47
|
+
|
48
|
+
def reload
|
49
|
+
@connection.reset
|
50
|
+
end
|
51
|
+
|
52
|
+
def request(params)
|
53
|
+
params[:query] ||= {}
|
54
|
+
params[:query].merge!(:api_key => @linode_api_key)
|
55
|
+
|
56
|
+
begin
|
57
|
+
response = @connection.request(params.merge!({:host => @host}))
|
58
|
+
rescue Excon::Errors::Error => error
|
59
|
+
raise case error
|
60
|
+
when Excon::Errors::NotFound
|
61
|
+
Fog::Linode::NotFound.slurp(error)
|
62
|
+
else
|
63
|
+
error
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
unless response.body.empty?
|
68
|
+
response.body = JSON.parse(response.body)
|
69
|
+
end
|
70
|
+
response
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Linode
|
2
|
+
class << self
|
3
|
+
if Fog.credentials[:linode_api_key]
|
4
|
+
|
5
|
+
def initialized?
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](service)
|
10
|
+
@@connections ||= Hash.new do |hash, key|
|
11
|
+
credentials = Fog.credentials.reject do |k,v|
|
12
|
+
![:linode_api_key].include?(k)
|
13
|
+
end
|
14
|
+
hash[key] = case key
|
15
|
+
when :linode
|
16
|
+
Fog::Linode.new(credentials)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@@connections[service]
|
20
|
+
end
|
21
|
+
|
22
|
+
else
|
23
|
+
|
24
|
+
def initialized?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Linode
|
3
|
+
class Real
|
4
|
+
|
5
|
+
# Get available data centers
|
6
|
+
#
|
7
|
+
# ==== Returns
|
8
|
+
# * response<~Excon::Response>:
|
9
|
+
# * body<~Array>:
|
10
|
+
# TODO: docs
|
11
|
+
def avail_datacenters
|
12
|
+
request(
|
13
|
+
:expects => 200,
|
14
|
+
:method => 'GET',
|
15
|
+
:query => { :api_action => 'avail.datacenters' }
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
|
23
|
+
def avail_datacenters
|
24
|
+
Fog::Mock.not_implemented
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
module Linode
|
3
|
+
class Real
|
4
|
+
|
5
|
+
# Get available distributions
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * options<~Hash>:
|
9
|
+
# * distributionId<~Integer>: id to limit results to
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Array>:
|
14
|
+
# TODO: docs
|
15
|
+
def avail_distributions(options={})
|
16
|
+
request(
|
17
|
+
:expects => 200,
|
18
|
+
:method => 'GET',
|
19
|
+
:query => { :api_action => 'avail.distributions' }.merge!(options)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def avail_distributions(distribution_id)
|
28
|
+
Fog::Mock.not_implemented
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fog
|
2
|
+
module Linode
|
3
|
+
class Real
|
4
|
+
|
5
|
+
# Get available kernels
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * options<~Hash>:
|
9
|
+
# * kernelId<~Integer>: id to limit results to
|
10
|
+
# * isXen<~Integer>: if 1 limits results to only zen
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Array>:
|
15
|
+
# TODO: docs
|
16
|
+
def avail_kernels(options={})
|
17
|
+
request(
|
18
|
+
:expects => 200,
|
19
|
+
:method => 'GET',
|
20
|
+
:query => { :api_action => 'avail.kernels' }.merge!(options)
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
|
28
|
+
def avail_kernels(distribution_id)
|
29
|
+
Fog::Mock.not_implemented
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Linode
|
3
|
+
class Real
|
4
|
+
|
5
|
+
# Get available plans
|
6
|
+
#
|
7
|
+
# ==== Returns
|
8
|
+
# * response<~Excon::Response>:
|
9
|
+
# * body<~Array>:
|
10
|
+
# TODO: docs
|
11
|
+
def avail_linodeplans
|
12
|
+
request(
|
13
|
+
:expects => 200,
|
14
|
+
:method => 'GET',
|
15
|
+
:query => { :api_action => 'avail.linodeplans' }
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
|
23
|
+
def avail_linodeplans
|
24
|
+
Fog::Mock.not_implemented
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/fog/vcloud.rb
CHANGED
@@ -44,7 +44,7 @@ module Fog
|
|
44
44
|
extend Fog::Vcloud::Generators
|
45
45
|
|
46
46
|
attr_accessor :login_uri
|
47
|
-
attr_reader :
|
47
|
+
attr_reader :versions_uri
|
48
48
|
|
49
49
|
def initialize(options = {})
|
50
50
|
@connections = {}
|
@@ -53,7 +53,6 @@ module Fog
|
|
53
53
|
@version = options[:version]
|
54
54
|
@username = options[:username]
|
55
55
|
@password = options[:password]
|
56
|
-
@login_uri = get_login_uri
|
57
56
|
@persistent = options[:persistent]
|
58
57
|
end
|
59
58
|
|
@@ -98,6 +97,9 @@ module Fog
|
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
100
|
+
def supported_versions
|
101
|
+
@supported_versions ||= get_versions(@versions_uri).body[:VersionInfo]
|
102
|
+
end
|
101
103
|
|
102
104
|
private
|
103
105
|
|
@@ -118,31 +120,31 @@ module Fog
|
|
118
120
|
end
|
119
121
|
|
120
122
|
def supported_version_numbers
|
121
|
-
case
|
123
|
+
case supported_versions
|
122
124
|
when Array
|
123
|
-
|
125
|
+
supported_versions.map { |version| version[:Version] }
|
124
126
|
when Hash
|
125
|
-
|
127
|
+
[ supported_versions[:Version] ]
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
129
131
|
def get_login_uri
|
130
132
|
check_versions
|
131
|
-
URI.parse case
|
133
|
+
URI.parse case supported_versions
|
132
134
|
when Array
|
133
|
-
|
135
|
+
supported_versions.detect {|version| version[:Version] == @version }[:LoginUrl]
|
134
136
|
when Hash
|
135
|
-
|
137
|
+
supported_versions[:LoginUrl]
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
139
|
-
# Load up @all_versions and
|
141
|
+
# Load up @all_versions and supported_versions from the provided :versions_uri
|
140
142
|
# If there are no supported versions raise an error
|
141
143
|
# And choose a default version is none is specified
|
142
144
|
def check_versions
|
143
|
-
|
145
|
+
supported_versions = get_versions(@versions_uri).body[:VersionInfo]
|
144
146
|
|
145
|
-
if
|
147
|
+
if supported_versions.empty?
|
146
148
|
raise UnsupportedVersion.new("No supported versions found @ #{@version_uri}")
|
147
149
|
end
|
148
150
|
|
@@ -164,6 +166,7 @@ module Fog
|
|
164
166
|
# login handles the auth, but we just need the Set-Cookie
|
165
167
|
# header from that call.
|
166
168
|
def do_login
|
169
|
+
@login_uri ||= get_login_uri
|
167
170
|
@login_results = login
|
168
171
|
@cookie = @login_results.headers['Set-Cookie']
|
169
172
|
end
|
@@ -346,7 +349,6 @@ module Fog
|
|
346
349
|
|
347
350
|
def initialize(credentials = {})
|
348
351
|
@versions_uri = URI.parse('https://vcloud.fakey.com/api/versions')
|
349
|
-
@login_uri = get_login_uri
|
350
352
|
end
|
351
353
|
|
352
354
|
def mock_it(status, mock_data, mock_headers = {})
|
data/lib/fog/vcloud/extension.rb
CHANGED
@@ -63,7 +63,7 @@ module Fog
|
|
63
63
|
request :power_reset
|
64
64
|
request :power_shutdown
|
65
65
|
|
66
|
-
versions "v0.8b-ext2.3"
|
66
|
+
versions "v0.8b-ext2.3", "0.8b-ext2.3"
|
67
67
|
|
68
68
|
module Mock
|
69
69
|
def self.base_url
|
@@ -189,19 +189,20 @@ module Fog
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
module Real
|
193
|
+
private
|
192
194
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
@version = (supported_version_ids & Versions::SUPPORTED).sort.first
|
195
|
+
# If we don't support any versions the service does, then raise an error.
|
196
|
+
# If the @version that super selected isn't in our supported list, then select one that is.
|
197
|
+
def check_versions
|
198
|
+
super
|
199
|
+
unless (supported_version_numbers & Fog::Vcloud::Terremark::Ecloud.supported_versions).length > 0
|
200
|
+
raise UnsupportedVersion.new("\nService @ #{@versions_uri} supports: #{supported_version_numbers.join(', ')}\n" +
|
201
|
+
"Fog::Vcloud::Terremark::Ecloud supports: #{Fog::Vcloud::Terremark::Ecloud.supported_versions.join(', ')}")
|
202
|
+
end
|
203
|
+
unless supported_version_numbers.include?(@version)
|
204
|
+
@version = (supported_version_numbers & Fog::Vcloud::Terremark::Ecloud.supported_versions).sort.first
|
205
|
+
end
|
205
206
|
end
|
206
207
|
end
|
207
208
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 12
|
9
|
+
version: 0.2.12
|
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-07-
|
17
|
+
date: 2010-07-09 00:00:00 -07:00
|
18
18
|
default_executable: fog
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -325,6 +325,12 @@ files:
|
|
325
325
|
- lib/fog/deprecation.rb
|
326
326
|
- lib/fog/errors.rb
|
327
327
|
- lib/fog/hmac.rb
|
328
|
+
- lib/fog/linode.rb
|
329
|
+
- lib/fog/linode/bin.rb
|
330
|
+
- lib/fog/linode/requests/avail_datacenters.rb
|
331
|
+
- lib/fog/linode/requests/avail_distributions.rb
|
332
|
+
- lib/fog/linode/requests/avail_kernels.rb
|
333
|
+
- lib/fog/linode/requests/avail_linodeplans.rb
|
328
334
|
- lib/fog/local.rb
|
329
335
|
- lib/fog/local/bin.rb
|
330
336
|
- lib/fog/local/models/directories.rb
|