fog 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -3
- data/fog.gemspec +2 -2
- data/lib/fog.rb +1 -1
- data/lib/fog/cdn/aws.rb +4 -1
- data/lib/fog/compute/parsers/terremark_ecloud/get_ip_address.rb +23 -0
- data/lib/fog/compute/parsers/terremark_ecloud/get_task.rb +42 -0
- data/lib/fog/compute/parsers/terremark_ecloud/get_task_list.rb +51 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_ip_address.rb +19 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_task.rb +19 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_task_list.rb +19 -0
- data/lib/fog/compute/requests/terremark_ecloud/get_versions.rb +4 -2
- data/lib/fog/compute/requests/terremark_ecloud/login.rb +29 -0
- data/lib/fog/compute/terremark_ecloud.rb +18 -34
- data/lib/fog/core/attributes.rb +1 -1
- data/lib/fog/core/collection.rb +1 -0
- data/lib/fog/core/credentials.rb +1 -1
- data/lib/fog/core/model.rb +1 -0
- data/lib/fog/dns/aws.rb +4 -1
- data/lib/fog/storage/aws.rb +4 -3
- data/lib/fog/storage/google.rb +4 -1
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +23 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +47 -35
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +5 -0
- data/spec/vcloud/models/vdc_spec.rb +7 -8
- data/spec/vcloud/requests/get_network_spec.rb +10 -10
- data/spec/vcloud/requests/get_organization_spec.rb +7 -8
- data/spec/vcloud/requests/get_vdc_spec.rb +4 -5
- data/spec/vcloud/requests/get_versions_spec.rb +2 -2
- data/spec/vcloud/spec_helper.rb +36 -32
- data/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +3 -4
- data/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +4 -5
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +26 -3
- data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +4 -4
- data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/node_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +3 -4
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/models/server_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +5 -5
- data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +4 -4
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +7 -8
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +3 -3
- data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +13 -13
- data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +3 -4
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +5 -6
- data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +9 -10
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +5 -6
- data/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +1 -1
- data/spec/vcloud/vcloud_spec.rb +3 -3
- data/tests/compute/requests/terremark_ecloud/organization_tests.rb +5 -0
- data/tests/compute/requests/terremark_ecloud/task_tests.rb +39 -0
- data/tests/helpers/formats_helper.rb +5 -3
- metadata +47 -38
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fog (0.5.
|
4
|
+
fog (0.5.3)
|
5
5
|
builder
|
6
6
|
excon (>= 0.5.2)
|
7
7
|
formatador (>= 0.0.16)
|
@@ -17,9 +17,9 @@ GEM
|
|
17
17
|
builder (3.0.0)
|
18
18
|
excon (0.5.2)
|
19
19
|
formatador (0.0.16)
|
20
|
-
json (1.
|
20
|
+
json (1.5.1)
|
21
21
|
mime-types (1.16)
|
22
|
-
net-ssh (2.0
|
22
|
+
net-ssh (2.1.0)
|
23
23
|
nokogiri (1.4.4)
|
24
24
|
rake (0.8.7)
|
25
25
|
rspec (1.3.1)
|
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.5.
|
11
|
-
s.date = '2011-02-
|
10
|
+
s.version = '0.5.3'
|
11
|
+
s.date = '2011-02-15'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
data/lib/fog.rb
CHANGED
data/lib/fog/cdn/aws.rb
CHANGED
@@ -87,7 +87,10 @@ module Fog
|
|
87
87
|
@port = options[:port] || 443
|
88
88
|
@scheme = options[:scheme] || 'https'
|
89
89
|
@version = options[:version] || '2010-11-01'
|
90
|
-
|
90
|
+
unless options.has_key?(:persistent)
|
91
|
+
options[:persistent] = true
|
92
|
+
end
|
93
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
|
91
94
|
end
|
92
95
|
|
93
96
|
def reload
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module TerremarkEcloud
|
4
|
+
module Compute
|
5
|
+
|
6
|
+
class GetIpAddress < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_element(name)
|
13
|
+
case name
|
14
|
+
when 'Id', 'Href', 'Name', 'RnatAddress', 'Server', 'Status'
|
15
|
+
@response[name] = @value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module TerremarkEcloud
|
4
|
+
module Compute
|
5
|
+
|
6
|
+
class GetTask < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_element(name, attrs = [])
|
13
|
+
case name
|
14
|
+
when 'Task'
|
15
|
+
for attribute in %w{href status type}
|
16
|
+
if value = attr_value(attribute, attrs)
|
17
|
+
@response[attribute] = value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
for attribute in %w{endTime startTime}
|
21
|
+
if value = attr_value(attribute, attrs)
|
22
|
+
@response[attribute] = Time.parse(value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
when 'Owner', 'Result'
|
26
|
+
data = {}
|
27
|
+
for attribute in %w{href name type}
|
28
|
+
if value = attr_value(attribute, attrs)
|
29
|
+
data[attribute] = value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
@response[name] = data
|
33
|
+
end
|
34
|
+
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module TerremarkEcloud
|
4
|
+
module Compute
|
5
|
+
|
6
|
+
class GetTaskList < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = { 'Tasks' => [] }
|
10
|
+
@task = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_element(name, attrs = [])
|
14
|
+
case name
|
15
|
+
when 'Task'
|
16
|
+
for attribute in %w{href status type}
|
17
|
+
if value = attr_value(attribute, attrs)
|
18
|
+
@task[attribute] = value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
for attribute in %w{endTime startTime}
|
22
|
+
if value = attr_value(attribute, attrs)
|
23
|
+
@task[attribute] = Time.parse(value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
when 'Owner', 'Result'
|
27
|
+
data = {}
|
28
|
+
for attribute in %w{href name type}
|
29
|
+
if value = attr_value(attribute, attrs)
|
30
|
+
data[attribute] = value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@task[name] = data
|
34
|
+
end
|
35
|
+
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def end_element(name)
|
40
|
+
case name
|
41
|
+
when 'Task'
|
42
|
+
@response['Tasks'] << @task
|
43
|
+
@task = {}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module TerremarkEcloud
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/compute/parsers/terremark_ecloud/get_ip_address'
|
7
|
+
|
8
|
+
def get_ip_address(href)
|
9
|
+
request({
|
10
|
+
:href => href,
|
11
|
+
:idempotent => true,
|
12
|
+
:parser => Fog::Parsers::TerremarkEcloud::Compute::GetIpAddress.new
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module TerremarkEcloud
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/compute/parsers/terremark_ecloud/get_task'
|
7
|
+
|
8
|
+
def get_task(href)
|
9
|
+
request({
|
10
|
+
:href => href,
|
11
|
+
:idempotent => true,
|
12
|
+
:parser => Fog::Parsers::TerremarkEcloud::Compute::GetTask.new
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module TerremarkEcloud
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/compute/parsers/terremark_ecloud/get_task_list'
|
7
|
+
|
8
|
+
def get_task_list(href)
|
9
|
+
request({
|
10
|
+
:href => href,
|
11
|
+
:idempotent => true,
|
12
|
+
:parser => Fog::Parsers::TerremarkEcloud::Compute::GetTaskList.new
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -11,11 +11,13 @@ module Fog
|
|
11
11
|
:expects => 200,
|
12
12
|
:method => 'GET',
|
13
13
|
:parser => Fog::Parsers::TerremarkEcloud::Compute::GetVersions.new
|
14
|
-
})
|
14
|
+
})
|
15
15
|
version_info = response.body['SupportedVersions'].detect {|version_info| version_info['Version'] == @version}
|
16
|
-
unless login_url = version_info && version_info['LoginUrl']
|
16
|
+
unless @login_url = version_info && version_info['LoginUrl']
|
17
|
+
# no LoginUrl matches specified version
|
17
18
|
raise "TerremarkEcloud does not support version #{@version}"
|
18
19
|
end
|
20
|
+
response
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module TerremarkEcloud
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
require 'fog/compute/parsers/terremark_ecloud/login'
|
7
|
+
|
8
|
+
def login
|
9
|
+
unless @login_url
|
10
|
+
get_versions
|
11
|
+
end
|
12
|
+
connection = Fog::Connection.new(@login_url)
|
13
|
+
response = connection.request({
|
14
|
+
:expects => 200,
|
15
|
+
:method => 'POST',
|
16
|
+
:headers => {
|
17
|
+
'Authorization' => ('Basic ' << Base64.encode64("#{@username}:#{@password}").chomp!),
|
18
|
+
'Content-Type' => 'application/vnd.vmware.vcloud.orgList+xml'
|
19
|
+
},
|
20
|
+
:parser => Fog::Parsers::TerremarkEcloud::Compute::Login.new
|
21
|
+
})
|
22
|
+
@token = response.headers['Set-Cookie']
|
23
|
+
response
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -10,10 +10,15 @@ module Fog
|
|
10
10
|
request_path 'fog/compute/requests/terremark_ecloud'
|
11
11
|
request :get_catalog
|
12
12
|
request :get_catalog_item
|
13
|
+
request :get_ip_address
|
13
14
|
request :get_ip_addresses
|
14
15
|
request :get_network
|
15
16
|
request :get_organization
|
17
|
+
request :get_task
|
18
|
+
request :get_task_list
|
19
|
+
request :get_versions
|
16
20
|
request :get_vdc
|
21
|
+
request :login
|
17
22
|
|
18
23
|
class Mock
|
19
24
|
|
@@ -36,6 +41,7 @@ module Fog
|
|
36
41
|
@password = options[:terremark_ecloud_password]
|
37
42
|
@version = '0.8b-ext2.6'
|
38
43
|
@versions_endpoint = options[:versions_endpoint] || 'https://services.enterprisecloud.terremark.com/api/versions'
|
44
|
+
@connection = Fog::Connection.new(@versions_endpoint, options[:persistent])
|
39
45
|
end
|
40
46
|
|
41
47
|
def organization_href
|
@@ -54,14 +60,16 @@ module Fog
|
|
54
60
|
end
|
55
61
|
|
56
62
|
begin
|
57
|
-
|
58
|
-
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:headers => {
|
63
|
+
uri = URI.parse(params.delete(:href))
|
64
|
+
@connection.request({
|
65
|
+
:body => params[:body],
|
66
|
+
:expects => params[:expects] || 200,
|
67
|
+
:headers => {
|
63
68
|
'Cookie' => @token
|
64
|
-
}.merge(params[:headers] || {})
|
69
|
+
}.merge(params[:headers] || {}),
|
70
|
+
:method => params[:method] || 'GET',
|
71
|
+
:parser => params[:parser],
|
72
|
+
:path => uri.path
|
65
73
|
})
|
66
74
|
rescue Excon::Errors::Unauthorized # expired token
|
67
75
|
get_token_and_organization
|
@@ -72,33 +80,9 @@ module Fog
|
|
72
80
|
private
|
73
81
|
|
74
82
|
def get_token_and_organization
|
75
|
-
|
76
|
-
|
77
|
-
response =
|
78
|
-
:expects => 200,
|
79
|
-
:method => 'GET',
|
80
|
-
:parser => Fog::Parsers::TerremarkEcloud::Compute::GetVersions.new
|
81
|
-
});
|
82
|
-
version_info = response.body['SupportedVersions'].detect {|version_info| version_info['Version'] == @version}
|
83
|
-
unless login_url = version_info && version_info['LoginUrl']
|
84
|
-
# no LoginUrl matches specified version
|
85
|
-
raise "TerremarkEcloud does not support version #{@version}"
|
86
|
-
end
|
87
|
-
|
88
|
-
connection = Fog::Connection.new(login_url)
|
89
|
-
response = connection.request({
|
90
|
-
:expects => 200,
|
91
|
-
:method => 'POST',
|
92
|
-
:headers => {
|
93
|
-
'Authorization' => ('Basic ' << Base64.encode64("#{@username}:#{@password}").chomp!),
|
94
|
-
'Content-Type' => 'application/vnd.vmware.vcloud.orgList+xml'
|
95
|
-
},
|
96
|
-
:parser => Fog::Parsers::TerremarkEcloud::Compute::Login.new
|
97
|
-
})
|
98
|
-
|
99
|
-
@token = response.headers['Set-Cookie']
|
100
|
-
|
101
|
-
if organization = response.body['OrgList'].first
|
83
|
+
response = self.login
|
84
|
+
# if there is only one organization we will note it as a starting point
|
85
|
+
if (response.body['OrgList'].length == 1) && (organization = response.body['OrgList'].first)
|
102
86
|
@organization_href = organization['href']
|
103
87
|
end
|
104
88
|
end
|
data/lib/fog/core/attributes.rb
CHANGED
data/lib/fog/core/collection.rb
CHANGED
data/lib/fog/core/credentials.rb
CHANGED
@@ -33,7 +33,7 @@ module Fog
|
|
33
33
|
@credentials ||= begin
|
34
34
|
if File.exists?(credentials_path)
|
35
35
|
credentials = YAML.load_file(credentials_path)
|
36
|
-
(credentials && credentials[credential]) or raise LoadError.new
|
36
|
+
(credentials && credentials[credential]) or raise LoadError.new(missing_credentials)
|
37
37
|
else
|
38
38
|
{}
|
39
39
|
end
|
data/lib/fog/core/model.rb
CHANGED
data/lib/fog/dns/aws.rb
CHANGED
@@ -92,7 +92,10 @@ module Fog
|
|
92
92
|
@port = options[:port] || 443
|
93
93
|
@scheme = options[:scheme] || 'https'
|
94
94
|
@version = options[:version] || '2010-10-01'
|
95
|
-
|
95
|
+
unless options.has_key?(:persistent)
|
96
|
+
options[:persistent] = true
|
97
|
+
end
|
98
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
|
96
99
|
end
|
97
100
|
|
98
101
|
def reload
|
data/lib/fog/storage/aws.rb
CHANGED
@@ -99,7 +99,6 @@ module Fog
|
|
99
99
|
query << "AWSAccessKeyId=#{@aws_access_key_id}"
|
100
100
|
query << "Signature=#{CGI.escape(signature(params))}"
|
101
101
|
query << "Expires=#{params[:headers]['Date']}"
|
102
|
-
bucket = params[:host].split('.').first
|
103
102
|
"https://#{@host}/#{params[:path]}?#{query.join('&')}"
|
104
103
|
end
|
105
104
|
|
@@ -221,7 +220,6 @@ module Fog
|
|
221
220
|
end
|
222
221
|
end
|
223
222
|
|
224
|
-
|
225
223
|
class Real
|
226
224
|
include Utils
|
227
225
|
extend Fog::Deprecation
|
@@ -278,8 +276,11 @@ module Fog
|
|
278
276
|
@path = options[:path] || '/'
|
279
277
|
@port = options[:port] || 443
|
280
278
|
@scheme = options[:scheme] || 'https'
|
279
|
+
unless options.has_key?(:persistent)
|
280
|
+
options[:persistent] = true
|
281
|
+
end
|
281
282
|
end
|
282
|
-
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent]
|
283
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
|
283
284
|
end
|
284
285
|
|
285
286
|
def reload
|