fog 0.3.31 → 0.3.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.document +3 -0
  2. data/.gitignore +10 -0
  3. data/Gemfile.lock +1 -4
  4. data/README.rdoc +29 -37
  5. data/Rakefile +5 -25
  6. data/bin/fog +1 -3
  7. data/examples/dns_methods.rb +389 -0
  8. data/examples/storage.rb +103 -0
  9. data/fog.gemspec +4 -778
  10. data/lib/fog.rb +5 -66
  11. data/lib/fog/aws.rb +3 -0
  12. data/lib/fog/aws/bin.rb +7 -2
  13. data/lib/fog/aws/cdn.rb +2 -2
  14. data/lib/fog/aws/compute.rb +2 -2
  15. data/lib/fog/aws/dns.rb +101 -0
  16. data/lib/fog/aws/elb.rb +2 -2
  17. data/lib/fog/aws/iam.rb +2 -2
  18. data/lib/fog/aws/models/compute/image.rb +1 -0
  19. data/lib/fog/aws/models/compute/server.rb +1 -1
  20. data/lib/fog/aws/models/compute/servers.rb +1 -13
  21. data/lib/fog/aws/parsers/compute/describe_images.rb +36 -34
  22. data/lib/fog/aws/parsers/dns/change_resource_record_sets.rb +26 -0
  23. data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +55 -0
  24. data/lib/fog/aws/parsers/dns/delete_hosted_zone.rb +25 -0
  25. data/lib/fog/aws/parsers/dns/get_change.rb +26 -0
  26. data/lib/fog/aws/parsers/dns/get_hosted_zone.rb +43 -0
  27. data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +35 -0
  28. data/lib/fog/aws/parsers/dns/list_resource_record_sets.rb +46 -0
  29. data/lib/fog/aws/requests/compute/describe_images.rb +1 -0
  30. data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +90 -0
  31. data/lib/fog/aws/requests/dns/create_hosted_zone.rb +68 -0
  32. data/lib/fog/aws/requests/dns/delete_hosted_zone.rb +48 -0
  33. data/lib/fog/aws/requests/dns/get_change.rb +47 -0
  34. data/lib/fog/aws/requests/dns/get_hosted_zone.rb +51 -0
  35. data/lib/fog/aws/requests/dns/list_hosted_zones.rb +63 -0
  36. data/lib/fog/aws/requests/dns/list_resource_record_sets.rb +68 -0
  37. data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
  38. data/lib/fog/aws/requests/storage/put_object_url.rb +2 -2
  39. data/lib/fog/aws/requests/storage/sync_clock.rb +28 -0
  40. data/lib/fog/aws/simpledb.rb +2 -2
  41. data/lib/fog/aws/storage.rb +5 -3
  42. data/lib/fog/bluebox.rb +2 -0
  43. data/lib/fog/bluebox/compute.rb +2 -2
  44. data/lib/fog/brightbox.rb +2 -0
  45. data/lib/fog/brightbox/compute.rb +2 -2
  46. data/lib/fog/core.rb +21 -1
  47. data/lib/fog/core/bin.rb +3 -1
  48. data/lib/fog/core/compute.rb +1 -0
  49. data/lib/fog/core/credentials.rb +72 -50
  50. data/lib/fog/core/deprecation.rb +11 -5
  51. data/lib/fog/core/mock.rb +34 -0
  52. data/lib/fog/core/model.rb +9 -1
  53. data/lib/fog/core/service.rb +40 -26
  54. data/lib/fog/core/storage.rb +1 -0
  55. data/lib/fog/core/time.rb +21 -0
  56. data/lib/fog/core/wait_for.rb +17 -0
  57. data/lib/fog/go_grid.rb +2 -0
  58. data/lib/fog/go_grid/compute.rb +2 -2
  59. data/lib/fog/google.rb +2 -0
  60. data/lib/fog/google/requests/storage/get_bucket.rb +6 -5
  61. data/lib/fog/google/requests/storage/get_object_url.rb +4 -4
  62. data/lib/fog/google/requests/storage/put_object_url.rb +4 -4
  63. data/lib/fog/google/storage.rb +4 -3
  64. data/lib/fog/linode.rb +3 -0
  65. data/lib/fog/linode/bin.rb +5 -3
  66. data/lib/fog/linode/compute.rb +6 -2
  67. data/lib/fog/linode/dns.rb +80 -0
  68. data/lib/fog/linode/requests/dns/domain_create.rb +52 -0
  69. data/lib/fog/linode/requests/dns/domain_delete.rb +35 -0
  70. data/lib/fog/linode/requests/dns/domain_list.rb +50 -0
  71. data/lib/fog/linode/requests/dns/domain_resource_create.rb +53 -0
  72. data/lib/fog/linode/requests/dns/domain_resource_delete.rb +36 -0
  73. data/lib/fog/linode/requests/dns/domain_resource_list.rb +48 -0
  74. data/lib/fog/linode/requests/dns/domain_resource_update.rb +54 -0
  75. data/lib/fog/linode/requests/dns/domain_update.rb +48 -0
  76. data/lib/fog/local.rb +2 -0
  77. data/lib/fog/local/storage.rb +3 -3
  78. data/lib/fog/new_servers.rb +2 -0
  79. data/lib/fog/new_servers/compute.rb +2 -2
  80. data/lib/fog/rackspace.rb +2 -0
  81. data/lib/fog/rackspace/cdn.rb +2 -2
  82. data/lib/fog/rackspace/compute.rb +2 -2
  83. data/lib/fog/rackspace/storage.rb +2 -2
  84. data/lib/fog/slicehost.rb +3 -0
  85. data/lib/fog/slicehost/bin.rb +2 -0
  86. data/lib/fog/slicehost/compute.rb +2 -2
  87. data/lib/fog/slicehost/dns.rb +84 -0
  88. data/lib/fog/slicehost/parsers/dns/create_record.rb +26 -0
  89. data/lib/fog/slicehost/parsers/dns/create_zone.rb +26 -0
  90. data/lib/fog/slicehost/parsers/dns/get_record.rb +26 -0
  91. data/lib/fog/slicehost/parsers/dns/get_records.rb +30 -0
  92. data/lib/fog/slicehost/parsers/dns/get_zone.rb +26 -0
  93. data/lib/fog/slicehost/parsers/dns/get_zones.rb +30 -0
  94. data/lib/fog/slicehost/requests/compute/create_slice.rb +2 -2
  95. data/lib/fog/slicehost/requests/compute/delete_slice.rb +3 -17
  96. data/lib/fog/slicehost/requests/dns/create_record.rb +61 -0
  97. data/lib/fog/slicehost/requests/dns/create_zone.rb +54 -0
  98. data/lib/fog/slicehost/requests/dns/delete_record.rb +31 -0
  99. data/lib/fog/slicehost/requests/dns/delete_zone.rb +31 -0
  100. data/lib/fog/slicehost/requests/dns/get_record.rb +40 -0
  101. data/lib/fog/slicehost/requests/dns/get_records.rb +41 -0
  102. data/lib/fog/slicehost/requests/dns/get_zone.rb +40 -0
  103. data/lib/fog/slicehost/requests/dns/get_zones.rb +38 -0
  104. data/lib/fog/terremark.rb +2 -0
  105. data/lib/fog/terremark/ecloud.rb +2 -4
  106. data/lib/fog/vcloud.rb +4 -2
  107. data/lib/fog/vcloud/bin.rb +3 -1
  108. data/lib/fog/vcloud/mock_data_classes.rb +77 -11
  109. data/lib/fog/vcloud/terremark/ecloud.rb +22 -7
  110. data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb +60 -0
  111. data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb +36 -0
  112. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +28 -13
  113. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +2 -2
  114. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
  115. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +4 -1
  116. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +5 -5
  117. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +6 -2
  118. data/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb +111 -0
  119. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +2 -4
  120. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +1 -3
  121. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +39 -27
  122. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +1 -2
  123. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +21 -6
  124. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +2 -1
  125. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -17
  126. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +12 -10
  127. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -10
  128. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +1 -12
  129. data/lib/fog/zerigo.rb +15 -0
  130. data/lib/fog/zerigo/bin.rb +25 -0
  131. data/lib/fog/zerigo/dns.rb +96 -0
  132. data/lib/fog/zerigo/parsers/dns/count_hosts.rb +24 -0
  133. data/lib/fog/zerigo/parsers/dns/count_zones.rb +24 -0
  134. data/lib/fog/zerigo/parsers/dns/create_host.rb +26 -0
  135. data/lib/fog/zerigo/parsers/dns/create_zone.rb +26 -0
  136. data/lib/fog/zerigo/parsers/dns/find_hosts.rb +30 -0
  137. data/lib/fog/zerigo/parsers/dns/get_host.rb +26 -0
  138. data/lib/fog/zerigo/parsers/dns/get_zone.rb +56 -0
  139. data/lib/fog/zerigo/parsers/dns/get_zone_stats.rb +26 -0
  140. data/lib/fog/zerigo/parsers/dns/list_hosts.rb +30 -0
  141. data/lib/fog/zerigo/parsers/dns/list_zones.rb +30 -0
  142. data/lib/fog/zerigo/requests/dns/count_hosts.rb +36 -0
  143. data/lib/fog/zerigo/requests/dns/count_zones.rb +36 -0
  144. data/lib/fog/zerigo/requests/dns/create_host.rb +70 -0
  145. data/lib/fog/zerigo/requests/dns/create_zone.rb +97 -0
  146. data/lib/fog/zerigo/requests/dns/delete_host.rb +32 -0
  147. data/lib/fog/zerigo/requests/dns/delete_zone.rb +33 -0
  148. data/lib/fog/zerigo/requests/dns/find_hosts.rb +63 -0
  149. data/lib/fog/zerigo/requests/dns/get_host.rb +47 -0
  150. data/lib/fog/zerigo/requests/dns/get_zone.rb +57 -0
  151. data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +44 -0
  152. data/lib/fog/zerigo/requests/dns/list_hosts.rb +48 -0
  153. data/lib/fog/zerigo/requests/dns/list_zones.rb +53 -0
  154. data/lib/fog/zerigo/requests/dns/update_host.rb +60 -0
  155. data/lib/fog/zerigo/requests/dns/update_zone.rb +78 -0
  156. data/spec/spec_helper.rb +0 -5
  157. data/spec/vcloud/spec_helper.rb +3 -2
  158. data/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +49 -0
  159. data/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +29 -0
  160. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +32 -13
  161. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +7 -4
  162. data/spec/vcloud/terremark/ecloud/models/server_spec.rb +20 -0
  163. data/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +60 -0
  164. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +3 -0
  165. data/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +55 -0
  166. data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +9 -0
  167. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +60 -14
  168. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +2 -0
  169. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +3 -3
  170. data/tests/aws/requests/compute/image_tests.rb +15 -14
  171. data/tests/aws/requests/dns/dns_tests.rb +276 -0
  172. data/tests/brightbox/requests/compute/account_tests.rb +20 -9
  173. data/tests/brightbox/requests/compute/api_client_tests.rb +12 -4
  174. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +20 -6
  175. data/tests/brightbox/requests/compute/image_tests.rb +9 -4
  176. data/tests/brightbox/requests/compute/interface_tests.rb +8 -2
  177. data/tests/brightbox/requests/compute/server_tests.rb +17 -5
  178. data/tests/brightbox/requests/compute/server_type_tests.rb +8 -4
  179. data/tests/brightbox/requests/compute/user_tests.rb +13 -5
  180. data/tests/brightbox/requests/compute/zone_tests.rb +8 -4
  181. data/tests/core/attribute_tests.rb +45 -0
  182. data/tests/helper.rb +0 -2
  183. data/tests/linode/requests/dns/dns_tests.rb +262 -0
  184. data/tests/rackspace/requests/compute/address_tests.rb +1 -1
  185. data/tests/rackspace/requests/compute/image_tests.rb +1 -1
  186. data/tests/slicehost/requests/dns_tests/dns_tests.rb +279 -0
  187. data/tests/zerigo/helper.rb +0 -0
  188. data/tests/zerigo/requests/dns/dns_tests.rb +374 -0
  189. metadata +280 -36
  190. data/spec/compact_progress_bar_formatter.rb +0 -195
  191. data/spec/core/attributes_spec.rb +0 -52
  192. data/spec/lorem.txt +0 -1
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module AWS
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/dns/get_hosted_zone'
7
+
8
+ # retrieve information about a hosted zone
9
+ #
10
+ # ==== Parameters
11
+ # * zone_id<~String> - The ID of the hosted zone
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * 'HostedZone'<~Hash>:
17
+ # * 'Id'<~String> -
18
+ # * 'Name'<~String> -
19
+ # * 'CallerReference'<~String>
20
+ # * 'Comment'<~String> -
21
+ # * 'NameServers'<~Array>
22
+ # * 'NameServer'<~String>
23
+ # * status<~Integer> - 201 when successful
24
+ def get_hosted_zone(zone_id)
25
+
26
+ # AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
27
+ # that form or just the actual id (which is what this request needs)
28
+ zone_id = zone_id.sub('/hostedzone/', '')
29
+
30
+ request({
31
+ :expects => 200,
32
+ :parser => Fog::Parsers::AWS::DNS::GetHostedZone.new,
33
+ :method => 'GET',
34
+ :path => "hostedzone/#{zone_id}"
35
+ })
36
+
37
+ end
38
+
39
+ end
40
+
41
+ class Mock
42
+
43
+ def get_hosted_zone(zone_id)
44
+ Fog::Mock.not_implemented
45
+ end
46
+
47
+
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,63 @@
1
+ module Fog
2
+ module AWS
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/dns/list_hosted_zones'
7
+
8
+ # Describe all or specified instances
9
+ #
10
+ # ==== Parameters
11
+ # * options<~Hash>
12
+ # * marker<~String> - Indicates where to begin in your list of hosted zones.
13
+ # * max_items<~Integer> - The maximum number of hosted zones to be included in the response body
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * 'HostedZones'<~Array>:
19
+ # * 'HostedZone'<~Hash>:
20
+ # * 'Id'<~String> -
21
+ # * 'Name'<~String> -
22
+ # * 'CallerReference'<~String>
23
+ # * 'Comment'<~String> -
24
+ # * 'Marker'<~String> -
25
+ # * 'MaxItems'<~Integer> -
26
+ # * 'IsTruncated'<~String> -
27
+ # * 'NextMarket'<~String>
28
+ # * status<~Integer> - 200 when successful
29
+ def list_hosted_zones(options = {})
30
+
31
+ parameters = {}
32
+ options.each { |option, value|
33
+ case option
34
+ when :marker
35
+ parameters[option] = value
36
+ when :max_items
37
+ parameters[:maxitems] = value
38
+ end
39
+ }
40
+
41
+ request({
42
+ :query => parameters,
43
+ :parser => Fog::Parsers::AWS::DNS::ListHostedZones.new,
44
+ :expects => 200,
45
+ :method => 'GET',
46
+ :path => "hostedzone"
47
+ })
48
+
49
+ end
50
+
51
+ end
52
+
53
+
54
+ class Mock
55
+
56
+ def list_hosted_zones(options = {})
57
+ Fog::Mock.not_implemented
58
+ end
59
+
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,68 @@
1
+ module Fog
2
+ module AWS
3
+ class DNS
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/dns/list_resource_record_sets'
7
+
8
+ # list your resource record sets
9
+ #
10
+ # ==== Parameters
11
+ # * zone_id<~String> -
12
+ # * options<~Hash>
13
+ # * type<~String> -
14
+ # * name<~String> -
15
+ # * max_items<~Integer> -
16
+ #
17
+ # ==== Returns
18
+ # * response<~Excon::Response>:
19
+ # * body<~Hash>:
20
+ # * 'ResourceRecordSet'<~Array>:
21
+ # * 'Name'<~String> -
22
+ # * 'Type'<~String> -
23
+ # * 'TTL'<~Integer> -
24
+ # * 'ResourceRecords'<~Array>
25
+ # * 'Value'<~String> -
26
+ # * 'IsTruncated'<~String> -
27
+ # * 'MaxItems'<~String> -
28
+ # * 'NextRecordName'<~String>
29
+ # * 'NexRecordType'<~String>
30
+ # * status<~Integer> - 201 when successful
31
+ def list_resource_record_sets(zone_id, options = {})
32
+
33
+ # AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
34
+ # that form or just the actual id (which is what this request needs)
35
+ zone_id = zone_id.sub('/hostedzone/', '')
36
+
37
+ parameters = {}
38
+ options.each { |option, value|
39
+ case option
40
+ when :type, :name
41
+ parameters[option]= "#{value}"
42
+ when :max_items
43
+ parameters['maxitems']= "#{value}"
44
+ end
45
+ }
46
+
47
+ request({
48
+ :query => parameters,
49
+ :parser => Fog::Parsers::AWS::DNS::ListResourceRecordSets.new,
50
+ :expects => 200,
51
+ :method => 'GET',
52
+ :path => "hostedzone/#{zone_id}/rrset"
53
+ })
54
+
55
+ end
56
+
57
+ end
58
+
59
+ class Mock
60
+
61
+ def list_resource_record_sets(zone_id, options = {})
62
+ Fog::Mock.not_implemented
63
+ end
64
+
65
+ end
66
+ end
67
+ end
68
+ end
@@ -28,7 +28,7 @@ module Fog
28
28
  :headers => {},
29
29
  :host => @host,
30
30
  :method => 'GET',
31
- :path => [bucket_name, CGI.escape(object_name)].join('/')
31
+ :path => "#{bucket_name}/#{object_name}"
32
32
  }, expires)
33
33
  end
34
34
 
@@ -47,7 +47,7 @@ module Fog
47
47
  :headers => {},
48
48
  :host => @host,
49
49
  :method => 'GET',
50
- :path => [bucket_name, CGI.escape(object_name)].join('/')
50
+ :path => "#{bucket_name}/#{object_name}"
51
51
  }, expires)
52
52
  end
53
53
 
@@ -28,7 +28,7 @@ module Fog
28
28
  :headers => {},
29
29
  :host => @host,
30
30
  :method => 'PUT',
31
- :path => [bucket_name, CGI.escape(object_name)].join('/')
31
+ :path => "#{bucket_name}/#{object_name}"
32
32
  }, expires)
33
33
  end
34
34
 
@@ -47,7 +47,7 @@ module Fog
47
47
  :headers => {},
48
48
  :host => @host,
49
49
  :method => 'PUT',
50
- :path => [bucket_name, CGI.escape(object_name)].join('/')
50
+ :path => "#{bucket_name}/#{object_name}"
51
51
  }, expires)
52
52
  end
53
53
 
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+
6
+ # Sync clock against S3 to avoid skew errors
7
+ #
8
+ def sync_clock
9
+ response = begin
10
+ get_service
11
+ rescue => error
12
+ error.response
13
+ end
14
+ Fog::Time.now = Time.parse(response.headers['Date'])
15
+ end
16
+
17
+ end # Real
18
+
19
+ class Mock # :nodoc:all
20
+
21
+ def sync_clock
22
+ true
23
+ end
24
+
25
+ end # Mock
26
+ end # Storage
27
+ end # AWS
28
+ end # Fog
@@ -2,8 +2,8 @@ module Fog
2
2
  module AWS
3
3
  class SimpleDB < Fog::Service
4
4
 
5
- requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
6
- recognizes :host, :nil_string, :path, :port, :scheme, :persistent, &inject_parameter_specs
5
+ requires :aws_access_key_id, :aws_secret_access_key
6
+ recognizes :host, :nil_string, :path, :port, :scheme, :persistent
7
7
 
8
8
  request_path 'fog/aws/requests/simpledb'
9
9
  request :batch_put_attributes
@@ -2,8 +2,8 @@ module Fog
2
2
  module AWS
3
3
  class Storage < Fog::Service
4
4
 
5
- requires :aws_access_key_id, :aws_secret_access_key, &inject_parameter_specs
6
- recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, &inject_parameter_specs
5
+ requires :aws_access_key_id, :aws_secret_access_key
6
+ recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent
7
7
 
8
8
  model_path 'fog/aws/models/storage'
9
9
  collection :directories
@@ -42,6 +42,7 @@ module Fog
42
42
  request :put_object_acl
43
43
  request :put_object_url
44
44
  request :put_request_payment
45
+ request :sync_clock
45
46
  request :upload_part
46
47
 
47
48
  module Utils
@@ -81,7 +82,8 @@ module Fog
81
82
  query << "Signature=#{CGI.escape(signature(params))}"
82
83
  query << "Expires=#{params[:headers]['Date']}"
83
84
  bucket = params[:host].split('.').first
84
- "https://#{@host}/#{params[:path]}?#{query.join('&')}"
85
+ path = CGI.escape(params[:path]).gsub('%2F', '/')
86
+ "https://#{@host}/#{path}?#{query.join('&')}"
85
87
  end
86
88
 
87
89
  end
@@ -1,3 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'core')
2
+
1
3
  module Fog
2
4
  module Bluebox
3
5
 
@@ -2,8 +2,8 @@ module Fog
2
2
  module Bluebox
3
3
  class Compute < Fog::Service
4
4
 
5
- requires :bluebox_api_key, :bluebox_customer_id, &inject_parameter_specs
6
- recognizes :bluebox_host, :bluebox_port, :bluebox_scheme, :persistent, &inject_parameter_specs
5
+ requires :bluebox_api_key, :bluebox_customer_id
6
+ recognizes :bluebox_host, :bluebox_port, :bluebox_scheme, :persistent
7
7
 
8
8
  model_path 'fog/bluebox/models/compute'
9
9
  model :flavor
@@ -1,3 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'core')
2
+
1
3
  module Fog
2
4
  module Brightbox
3
5
  extend Fog::Provider
@@ -4,8 +4,8 @@ module Fog
4
4
 
5
5
  API_URL = "https://api.gb1.brightbox.com/"
6
6
 
7
- requires :brightbox_client_id, :brightbox_secret, &inject_parameter_specs
8
- recognizes :brightbox_auth_url, :brightbox_api_url, &inject_parameter_specs
7
+ requires :brightbox_client_id, :brightbox_secret
8
+ recognizes :brightbox_auth_url, :brightbox_api_url
9
9
 
10
10
  model_path 'fog/brightbox/models/compute'
11
11
  model :account # Singular resource, no collection
@@ -1,13 +1,33 @@
1
+ __LIB_DIR__ = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
+
3
+ $LOAD_PATH.unshift __LIB_DIR__ unless
4
+ $LOAD_PATH.include?(__LIB_DIR__) ||
5
+ $LOAD_PATH.include?(File.expand_path(__LIB_DIR__))
6
+
7
+ # external core dependencies
8
+ require 'rubygems'
9
+ require 'base64'
10
+ require 'cgi'
11
+ require 'excon'
12
+ require 'formatador'
13
+ require 'time'
14
+ require 'timeout'
15
+
16
+ # internal core dependencies
1
17
  require 'fog/core/attributes'
2
18
  require 'fog/core/collection'
3
19
  require 'fog/core/compute'
4
20
  require 'fog/core/connection'
21
+ require 'fog/core/credentials'
5
22
  require 'fog/core/deprecation'
6
23
  require 'fog/core/errors'
7
24
  require 'fog/core/hmac'
8
25
  require 'fog/core/model'
26
+ require 'fog/core/mock'
9
27
  # require 'fog/core/parser'
10
28
  require 'fog/core/provider'
11
29
  require 'fog/core/service'
12
30
  require 'fog/core/ssh'
13
- require 'fog/core/storage'
31
+ require 'fog/core/storage'
32
+ require 'fog/core/time'
33
+ require 'fog/core/wait_for'
@@ -15,7 +15,8 @@ module Fog
15
15
  ::NewServers,
16
16
  ::Rackspace,
17
17
  ::Slicehost,
18
- ::Terremark
18
+ ::Terremark,
19
+ ::Zerigo
19
20
  ].select {|provider| provider.available?}
20
21
  end
21
22
 
@@ -83,3 +84,4 @@ require 'fog/rackspace/bin'
83
84
  require 'fog/slicehost/bin'
84
85
  require 'fog/terremark/bin'
85
86
  require 'fog/vcloud/bin'
87
+ require 'fog/zerigo/bin'
@@ -2,6 +2,7 @@ module Fog
2
2
  class Compute
3
3
 
4
4
  def self.new(attributes)
5
+ attributes = attributes.dup # prevent delete from having side effects
5
6
  case provider = attributes.delete(:provider)
6
7
  when 'AWS'
7
8
  require 'fog/aws'
@@ -1,61 +1,83 @@
1
1
  require 'yaml'
2
+
2
3
  module Fog
3
- class << self
4
+ require 'fog/core/deprecation'
5
+ extend Fog::Deprecation
6
+ self_deprecate(:config_path, :credentials_path)
4
7
 
5
- def credential=(new_credential)
6
- @credential = new_credential
7
- @credentials = nil
8
- end
8
+ # Assign a new credential to use from configuration file
9
+ # @param [String, Symbol] new_credential name of new credential to use
10
+ # @ return [String, Symbol] name of the new credential
11
+ def self.credential=(new_credential)
12
+ @credential = new_credential
13
+ end
9
14
 
10
- def credential
11
- @credential || :default
12
- end
15
+ # @return [String, Symbol] The credential to use in Fog
16
+ def self.credential
17
+ @credential ||= :default
18
+ end
19
+
20
+ # @return [String] The path for configuration_file
21
+ def self.credentials_path
22
+ @credential_path ||= File.expand_path(ENV["FOG_RC"] || '~/.fog')
23
+ end
24
+
25
+ # @return [String] The new path for credentials file
26
+ def self.credentials_path=(new_credentials_path)
27
+ @credential_path = new_credentials_path
28
+ end
13
29
 
14
- def config_path
15
- ENV["FOG_RC"] || '~/.fog'
30
+ # @return [Hash] The credentials pulled from the configuration file
31
+ # @raise [LoadError] Configuration unavailable in configuration file
32
+ def self.credentials
33
+ @credentials ||= begin
34
+ credentials = YAML.load_file(credentials_path)
35
+ (credentials && credentials[credential]) or raise LoadError.new missing_credentials
16
36
  end
37
+ end
38
+
39
+ private
40
+
41
+ # @return [String] The error message that will be raised, if credentials cannot be found
42
+ def self.missing_credentials
43
+ <<-YML
44
+ Missing Credentials
17
45
 
18
- def credentials
19
- @credentials ||= begin
20
- path = File.expand_path(config_path)
21
- credentials = if File.exists?(path)
22
- File.open(path) do |file|
23
- YAML.load(file.read)
24
- end
25
- else
26
- nil
27
- end
28
- unless credentials && credentials[credential]
29
- print("\n To run as '#{credential}', add the following to #{config_path}\n")
30
- yml = <<-YML
46
+ To run as '#{credential}', add the following to your resource config file: #{config_path}
47
+ An alternate file may be used by placing its path in the FOG_RC environment variable
48
+
49
+ #######################################################
50
+ # Fog Credentials File
51
+ #
52
+ # Key-value pairs should look like:
53
+ # :aws_access_key_id: 022QF06E7MXBSAMPLE
31
54
  :#{credential}:
32
- :aws_access_key_id: INTENTIONALLY_LEFT_BLANK
33
- :aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
34
- :bluebox_api_key: INTENTIONALLY_LEFT_BLANK
35
- :bluebox_customer_id: INTENTIONALLY_LEFT_BLANK
36
- :brightbox_client_id: INTENTIONALLY_LEFT_BLANK
37
- :brightbox_secret: INTENTIONALLY_LEFT_BLANK
38
- :go_grid_api_key: INTENTIONALLY_LEFT_BLANK
39
- :go_grid_shared_secret: INTENTIONALLY_LEFT_BLANK
40
- :google_storage_access_key_id: INTENTIONALLY_LEFT_BLANK
41
- :google_storage_secret_access_key: INTENTIONALLY_LEFT_BLANK
42
- :local_root: INTENTIONALLY_LEFT_BLANK
43
- :new_servers_password: INTENTIONALLY_LEFT_BLANK
44
- :new_servers_username: INTENTIONALLY_LEFT_BLANK
45
- :public_key_path: INTENTIONALLY_LEFT_BLANK
46
- :private_key_path: INTENTIONALLY_LEFT_BLANK
47
- :rackspace_api_key: INTENTIONALLY_LEFT_BLANK
48
- :rackspace_username: INTENTIONALLY_LEFT_BLANK
49
- :slicehost_password: INTENTIONALLY_LEFT_BLANK
50
- :terremark_username: INTENTIONALLY_LEFT_BLANK
51
- :terremark_password: INTENTIONALLY_LEFT_BLANK
52
- YML
53
- print("\n#{yml}\n")
54
- raise(ArgumentError.new("Missing Credentials"))
55
- end
56
- credentials[credential]
57
- end
58
- end
55
+ :aws_access_key_id:
56
+ :aws_secret_access_key:
57
+ :bluebox_api_key:
58
+ :bluebox_customer_id:
59
+ :brightbox_client_id:
60
+ :brightbox_secret:
61
+ :go_grid_api_key:
62
+ :go_grid_shared_secret:
63
+ :google_storage_access_key_id:
64
+ :google_storage_secret_access_key:
65
+ :local_root:
66
+ :new_servers_password:
67
+ :new_servers_username:
68
+ :public_key_path:
69
+ :private_key_path:
70
+ :rackspace_api_key:
71
+ :rackspace_username:
72
+ :slicehost_password:
73
+ :terremark_username:
74
+ :terremark_password:
75
+ :zerigo_email:
76
+ :zerigo_token:
77
+ #
78
+ # End of Fog Credentials File
79
+ #######################################################
59
80
 
81
+ YML
60
82
  end
61
83
  end