fog-maestrodev 1.14.0.20130806165225 → 1.15.0.20130829165835

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/changelog.txt +296 -0
  2. data/fog.gemspec +2 -2
  3. data/lib/fog/atmos/storage.rb +0 -3
  4. data/lib/fog/aws/cdn.rb +1 -2
  5. data/lib/fog/aws/compute.rb +52 -2
  6. data/lib/fog/aws/dns.rb +0 -1
  7. data/lib/fog/aws/models/auto_scaling/groups.rb +6 -3
  8. data/lib/fog/aws/models/compute/address.rb +1 -0
  9. data/lib/fog/aws/models/compute/flavors.rb +19 -0
  10. data/lib/fog/aws/models/compute/route_table.rb +69 -0
  11. data/lib/fog/aws/models/compute/route_tables.rb +92 -0
  12. data/lib/fog/aws/models/rds/instance_option.rb +21 -0
  13. data/lib/fog/aws/models/rds/instance_options.rb +30 -0
  14. data/lib/fog/aws/parsers/compute/associate_route_table.rb +20 -0
  15. data/lib/fog/aws/parsers/compute/create_route_table.rb +75 -0
  16. data/lib/fog/aws/parsers/compute/describe_account_attributes.rb +42 -0
  17. data/lib/fog/aws/parsers/compute/describe_route_tables.rb +85 -0
  18. data/lib/fog/aws/parsers/rds/describe_orderable_db_instance_options.rb +47 -0
  19. data/lib/fog/aws/rds.rb +5 -0
  20. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb +9 -1
  21. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +15 -1
  22. data/lib/fog/aws/requests/compute/associate_dhcp_options.rb +2 -2
  23. data/lib/fog/aws/requests/compute/associate_route_table.rb +75 -0
  24. data/lib/fog/aws/requests/compute/attach_internet_gateway.rb +2 -2
  25. data/lib/fog/aws/requests/compute/create_route.rb +89 -0
  26. data/lib/fog/aws/requests/compute/create_route_table.rb +70 -0
  27. data/lib/fog/aws/requests/compute/create_vpc.rb +16 -1
  28. data/lib/fog/aws/requests/compute/delete_dhcp_options.rb +2 -2
  29. data/lib/fog/aws/requests/compute/delete_internet_gateway.rb +2 -2
  30. data/lib/fog/aws/requests/compute/delete_network_interface.rb +2 -2
  31. data/lib/fog/aws/requests/compute/delete_route.rb +60 -0
  32. data/lib/fog/aws/requests/compute/delete_route_table.rb +51 -0
  33. data/lib/fog/aws/requests/compute/delete_subnet.rb +2 -2
  34. data/lib/fog/aws/requests/compute/delete_vpc.rb +2 -2
  35. data/lib/fog/aws/requests/compute/describe_account_attributes.rb +49 -0
  36. data/lib/fog/aws/requests/compute/describe_route_tables.rb +87 -0
  37. data/lib/fog/aws/requests/compute/detach_internet_gateway.rb +2 -2
  38. data/lib/fog/aws/requests/compute/detach_network_interface.rb +2 -2
  39. data/lib/fog/aws/requests/compute/disassociate_route_table.rb +57 -0
  40. data/lib/fog/aws/requests/compute/reset_network_interface_attribute.rb +2 -1
  41. data/lib/fog/aws/requests/elb/create_load_balancer.rb +23 -9
  42. data/lib/fog/aws/requests/iam/upload_server_certificate.rb +1 -1
  43. data/lib/fog/aws/requests/rds/describe_orderable_db_instance_options.rb +76 -0
  44. data/lib/fog/aws/storage.rb +0 -2
  45. data/lib/fog/brightbox/models/compute/collaboration.rb +10 -2
  46. data/lib/fog/brightbox/models/compute/collaborations.rb +26 -2
  47. data/lib/fog/brightbox/models/compute/user_collaboration.rb +16 -1
  48. data/lib/fog/brightbox/models/compute/user_collaborations.rb +10 -2
  49. data/lib/fog/cloudstack/models/compute/server.rb +4 -0
  50. data/lib/fog/core/collection.rb +18 -0
  51. data/lib/fog/core/credentials.rb +6 -1
  52. data/lib/fog/google/compute.rb +17 -0
  53. data/lib/fog/google/examples/get_list_images.rb +27 -0
  54. data/lib/fog/google/examples/get_list_snapshots.rb +20 -0
  55. data/lib/fog/google/examples/image_create.rb +18 -0
  56. data/lib/fog/google/examples/launch_micro_instance.rb +10 -5
  57. data/lib/fog/google/examples/network.rb +21 -0
  58. data/lib/fog/google/models/compute/disk.rb +16 -5
  59. data/lib/fog/google/models/compute/image.rb +36 -18
  60. data/lib/fog/google/models/compute/images.rb +36 -10
  61. data/lib/fog/google/models/compute/server.rb +41 -11
  62. data/lib/fog/google/models/compute/servers.rb +1 -1
  63. data/lib/fog/google/models/compute/snapshot.rb +36 -0
  64. data/lib/fog/google/models/compute/snapshots.rb +28 -0
  65. data/lib/fog/google/requests/compute/delete_disk.rb +5 -1
  66. data/lib/fog/google/requests/compute/get_disk.rb +2 -1
  67. data/lib/fog/google/requests/compute/get_snapshot.rb +34 -0
  68. data/lib/fog/google/requests/compute/insert_disk.rb +23 -7
  69. data/lib/fog/google/requests/compute/insert_image.rb +16 -9
  70. data/lib/fog/google/requests/compute/insert_server.rb +22 -10
  71. data/lib/fog/google/requests/compute/list_disks.rb +1 -1
  72. data/lib/fog/google/requests/compute/list_snapshots.rb +30 -0
  73. data/lib/fog/google/storage.rb +1 -3
  74. data/lib/fog/hp/storage.rb +0 -2
  75. data/lib/fog/internet_archive/storage.rb +0 -2
  76. data/lib/fog/local/storage.rb +0 -2
  77. data/lib/fog/ninefold/storage.rb +0 -1
  78. data/lib/fog/openstack/models/storage/file.rb +2 -0
  79. data/lib/fog/openstack/requests/compute/add_flavor_access.rb +1 -1
  80. data/lib/fog/openstack/requests/compute/create_volume.rb +8 -7
  81. data/lib/fog/openstack/requests/compute/list_tenants_with_flavor_access.rb +1 -1
  82. data/lib/fog/openstack/requests/compute/remove_flavor_access.rb +1 -1
  83. data/lib/fog/openstack/requests/image/create_image.rb +23 -23
  84. data/lib/fog/openstack/requests/image/update_image.rb +31 -33
  85. data/lib/fog/openstack/requests/storage/get_object_https_url.rb +3 -3
  86. data/lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb +1 -1
  87. data/lib/fog/openstack/storage.rb +10 -11
  88. data/lib/fog/openstack.rb +10 -1
  89. data/lib/fog/rackspace/cdn.rb +13 -0
  90. data/lib/fog/rackspace/compute.rb +8 -4
  91. data/lib/fog/rackspace/compute_v2.rb +2 -0
  92. data/lib/fog/rackspace/databases.rb +4 -4
  93. data/lib/fog/rackspace/dns.rb +6 -6
  94. data/lib/fog/rackspace/examples/compute_v2/bootstrap_server.rb +98 -0
  95. data/lib/fog/rackspace/load_balancers.rb +5 -4
  96. data/lib/fog/rackspace/models/compute_v2/flavors.rb +1 -2
  97. data/lib/fog/rackspace/models/compute_v2/images.rb +35 -3
  98. data/lib/fog/rackspace/models/compute_v2/metadatum.rb +2 -2
  99. data/lib/fog/rackspace/models/identity/service_catalog.rb +34 -16
  100. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +8 -3
  101. data/lib/fog/rackspace/models/monitoring/alarm.rb +16 -8
  102. data/lib/fog/rackspace/models/monitoring/base.rb +2 -8
  103. data/lib/fog/rackspace/monitoring.rb +14 -6
  104. data/lib/fog/rackspace/requests/compute_v2/list_flavors_detail.rb +39 -0
  105. data/lib/fog/rackspace/requests/compute_v2/list_images.rb +15 -5
  106. data/lib/fog/rackspace/requests/compute_v2/list_images_detail.rb +53 -0
  107. data/lib/fog/rackspace/requests/identity/create_token.rb +1 -1
  108. data/lib/fog/rackspace/requests/load_balancers/create_load_balancer.rb +12 -0
  109. data/lib/fog/rackspace/requests/load_balancers/get_stats.rb +31 -0
  110. data/lib/fog/rackspace/requests/monitoring/get_entity.rb +33 -0
  111. data/lib/fog/rackspace/service.rb +7 -0
  112. data/lib/fog/rackspace/storage.rb +6 -3
  113. data/lib/fog/rackspace.rb +8 -5
  114. data/lib/fog/riakcs/provisioning.rb +0 -1
  115. data/lib/fog/riakcs/usage.rb +2 -3
  116. data/lib/fog/storage.rb +2 -0
  117. data/lib/fog/vcloud/examples/README.md +54 -0
  118. data/lib/fog/vcloud/examples/creating_a_connection.md +20 -0
  119. data/lib/fog/vcloud/examples/creating_a_vapp.md +17 -0
  120. data/lib/fog/vcloud/examples/get_network_information.md +10 -0
  121. data/lib/fog/vcloud/examples/get_vapp_information.md +10 -0
  122. data/lib/fog/vcloud/examples/more_on_vapps.md +23 -0
  123. data/lib/fog/version.rb +1 -1
  124. data/lib/tasks/changelog_task.rb +1 -0
  125. data/tests/aws/models/elb/model_tests.rb +5 -0
  126. data/tests/aws/models/rds/instance_option_tests.rb +14 -0
  127. data/tests/aws/requests/compute/client_tests.rb +25 -0
  128. data/tests/aws/requests/compute/route_tests.rb +277 -0
  129. data/tests/aws/requests/rds/helper.rb +22 -0
  130. data/tests/aws/requests/rds/instance_option_tests.rb +21 -0
  131. data/tests/core/credential_tests.rb +21 -0
  132. data/tests/core/service_tests.rb +26 -0
  133. data/tests/openstack/authenticate_tests.rb +22 -0
  134. data/tests/openstack/models/storage/file_tests.rb +20 -1
  135. data/tests/openstack/requests/compute/flavor_tests.rb +27 -12
  136. data/tests/openstack/requests/compute/volume_tests.rb +10 -12
  137. data/tests/openstack/requests/image/image_tests.rb +30 -15
  138. data/tests/rackspace/block_storage_tests.rb +9 -4
  139. data/tests/rackspace/cdn_tests.rb +14 -0
  140. data/tests/rackspace/compute_tests.rb +10 -4
  141. data/tests/rackspace/compute_v2_tests.rb +9 -4
  142. data/tests/rackspace/databases_tests.rb +9 -4
  143. data/tests/rackspace/dns_tests.rb +9 -4
  144. data/tests/rackspace/helper.rb +21 -2
  145. data/tests/rackspace/identity_tests.rb +9 -4
  146. data/tests/rackspace/load_balancer_tests.rb +8 -4
  147. data/tests/rackspace/models/compute_v2/server_tests.rb +18 -21
  148. data/tests/rackspace/models/identity/service_catalog_tests.rb +54 -29
  149. data/tests/rackspace/models/load_balancers/load_balancer_tests.rb +5 -0
  150. data/tests/rackspace/models/monitoring/alarm_examples_tests.rb +1 -1
  151. data/tests/rackspace/models/monitoring/alarm_tests.rb +2 -2
  152. data/tests/rackspace/monitoring_tests.rb +9 -4
  153. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +6 -0
  154. data/tests/rackspace/requests/compute_v2/image_tests.rb +4 -0
  155. data/tests/rackspace/requests/compute_v2/server_tests.rb +2 -2
  156. data/tests/rackspace/requests/load_balancers/get_stats_tests.rb +13 -0
  157. data/tests/rackspace/requests/load_balancers/helper.rb +9 -0
  158. data/tests/rackspace/requests/monitoring/alarm_tests.rb +4 -5
  159. data/tests/rackspace/requests/monitoring/entity_tests.rb +9 -1
  160. data/tests/rackspace/requests/storage/large_object_tests.rb +12 -4
  161. data/tests/rackspace/storage_tests.rb +23 -4
  162. data/tests/rackspace/url_encoding_tests.rb +3 -1
  163. metadata +117 -133
  164. checksums.yaml +0 -15
  165. data/lib/fog/aws/parsers/compute/associate_dhcp_options.rb +0 -24
  166. data/lib/fog/aws/parsers/compute/attach_internet_gateway.rb +0 -24
  167. data/lib/fog/aws/parsers/compute/delete_dhcp_options.rb +0 -24
  168. data/lib/fog/aws/parsers/compute/delete_internet_gateway.rb +0 -24
  169. data/lib/fog/aws/parsers/compute/delete_network_interface.rb +0 -24
  170. data/lib/fog/aws/parsers/compute/delete_subnet.rb +0 -24
  171. data/lib/fog/aws/parsers/compute/delete_vpc.rb +0 -24
  172. data/lib/fog/aws/parsers/compute/detach_internet_gateway.rb +0 -24
  173. data/lib/fog/aws/parsers/compute/detach_network_interface.rb +0 -24
@@ -4,18 +4,17 @@ module Fog
4
4
  class Real
5
5
 
6
6
  def update_image(attributes)
7
-
8
- data = {
9
- "x-image-meta-name" => attributes[:name],
10
- "x-image-meta-disk-format" => attributes[:disk_format],
11
- "x-image-meta-container-format" => attributes[:container_format],
12
- "x-image-meta-size" => attributes[:size],
13
- "x-image-meta-is-public" => attributes[:is_public],
14
- "x-image-meta-min-ram" => attributes[:min_ram],
15
- "x-image-meta-min-disk" => attributes[:min_disk],
16
- "x-image-meta-checksum" => attributes[:checksum],
17
- "x-image-meta-owner" => attributes[:owner]
18
- }
7
+ data = {
8
+ 'x-image-meta-name' => attributes[:name],
9
+ 'x-image-meta-disk-format' => attributes[:disk_format],
10
+ 'x-image-meta-container-format' => attributes[:container_format],
11
+ 'x-image-meta-size' => attributes[:size],
12
+ 'x-image-meta-is-public' => attributes[:is_public],
13
+ 'x-image-meta-min-ram' => attributes[:min_ram],
14
+ 'x-image-meta-min-disk' => attributes[:min_disk],
15
+ 'x-image-meta-checksum' => attributes[:checksum],
16
+ 'x-image-meta-owner' => attributes[:owner]
17
+ }.reject {|k,v| v.nil? }
19
18
 
20
19
  unless attributes[:properties].nil?
21
20
  attributes[:properties].each do |key,value|
@@ -40,28 +39,27 @@ module Fog
40
39
  response.status = 200
41
40
  image = self.images.last
42
41
  response.body = {
43
- 'image'=> {
44
- 'name' => attributes[:name] || image.name,
45
- 'size' => image.size,
46
- 'min_disk' => (attributes[:min_disk] || image.min_disk).to_i,
47
- 'disk_format' => attributes[:disk_format] || image.disk_format,
48
- 'created_at' => image.created_at,
49
- 'container_format' => attributes[:container_format] || image.container_format,
50
- 'deleted_at' => nil,
51
- 'updated_at' => Time.now.to_s,
52
- 'checksum' => image.checksum,
53
- 'id' => attributes[:id],
54
- 'deleted' => false,
55
- 'protected' => false,
56
- 'is_public' => attributes[:is_public] || image.is_public,
57
- 'status' => image.status,
58
- 'min_ram' => (attributes[:min_ram] || image.min_ram).to_i,
59
- 'owner' => attributes[:owner] || image.owner,
60
- 'properties' => attributes[:properties] || image.properties
61
- }
62
- }
42
+ 'image'=> {
43
+ 'name' => attributes[:name] || image.name,
44
+ 'size' => image.size,
45
+ 'min_disk' => (attributes[:min_disk] || image.min_disk).to_i,
46
+ 'disk_format' => attributes[:disk_format] || image.disk_format,
47
+ 'created_at' => image.created_at,
48
+ 'container_format' => attributes[:container_format] || image.container_format,
49
+ 'deleted_at' => nil,
50
+ 'updated_at' => Time.now.to_s,
51
+ 'checksum' => image.checksum,
52
+ 'id' => attributes[:id],
53
+ 'deleted' => false,
54
+ 'protected' => false,
55
+ 'is_public' => attributes[:is_public] || image.is_public,
56
+ 'status' => image.status,
57
+ 'min_ram' => (attributes[:min_ram] || image.min_ram).to_i,
58
+ 'owner' => attributes[:owner] || image.owner,
59
+ 'properties' => attributes[:properties] || image.properties
60
+ }
61
+ }
63
62
  response
64
-
65
63
  end
66
64
 
67
65
  end
@@ -18,8 +18,8 @@ module Fog
18
18
  # ==== See Also
19
19
  # http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
20
20
  def get_object_https_url(container, object, expires, options = {})
21
- if @rackspace_temp_url_key.nil?
22
- raise ArgumentError, "Storage must my instantiated with the :rackspace_temp_url_key option"
21
+ if @openstack_temp_url_key.nil?
22
+ raise ArgumentError, "Storage must my instantiated with the :openstack_temp_url_key option"
23
23
  end
24
24
 
25
25
  method = 'GET'
@@ -28,7 +28,7 @@ module Fog
28
28
  object_path_unescaped = "#{@path}/#{Fog::OpenStack.escape(container)}/#{object}"
29
29
  string_to_sign = "#{method}\n#{expires}\n#{object_path_unescaped}"
30
30
 
31
- hmac = Fog::HMAC.new('sha1', @rackspace_temp_url_key)
31
+ hmac = Fog::HMAC.new('sha1', @openstack_temp_url_key)
32
32
  sig = sig_to_hex(hmac.sign(string_to_sign))
33
33
 
34
34
  "https://#{@host}#{object_path_escaped}?temp_url_sig=#{sig}&temp_url_expires=#{expires}"
@@ -8,7 +8,7 @@ module Fog
8
8
  # used to generate signed expiring URLs.
9
9
  #
10
10
  # Once the key has been set with this request you should create new
11
- # Storage objects with the :rackspace_temp_url_key option then use
11
+ # Storage objects with the :openstack_temp_url_key option then use
12
12
  # the get_object_https_url method to generate expiring URLs.
13
13
  #
14
14
  # *** CAUTION *** changing this secret key will invalidate any expiring
@@ -9,7 +9,7 @@ module Fog
9
9
  :openstack_api_key
10
10
  recognizes :persistent, :openstack_service_name,
11
11
  :openstack_service_type, :openstack_tenant,
12
- :openstack_region
12
+ :openstack_region, :openstack_temp_url_key
13
13
 
14
14
  model_path 'fog/openstack/models/storage'
15
15
  model :directory
@@ -45,7 +45,6 @@ module Fog
45
45
  end
46
46
 
47
47
  def initialize(options={})
48
- require 'mime/types'
49
48
  @openstack_api_key = options[:openstack_api_key]
50
49
  @openstack_username = options[:openstack_username]
51
50
  @path = '/v1/AUTH_1234'
@@ -58,7 +57,7 @@ module Fog
58
57
  def reset_data
59
58
  self.class.data.delete(@openstack_username)
60
59
  end
61
-
60
+
62
61
  def change_account(account)
63
62
  @original_path ||= @path
64
63
  version_string = @original_path.split('/')[1]
@@ -74,7 +73,6 @@ module Fog
74
73
  class Real
75
74
 
76
75
  def initialize(options={})
77
- require 'mime/types'
78
76
  @openstack_api_key = options[:openstack_api_key]
79
77
  @openstack_username = options[:openstack_username]
80
78
  @openstack_auth_url = options[:openstack_auth_url]
@@ -86,6 +84,7 @@ module Fog
86
84
  @openstack_region = options[:openstack_region]
87
85
  @openstack_tenant = options[:openstack_tenant]
88
86
  @connection_options = options[:connection_options] || {}
87
+ @openstack_temp_url_key = options[:openstack_temp_url_key]
89
88
  authenticate
90
89
  @persistent = options[:persistent] || false
91
90
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@@ -105,7 +104,7 @@ module Fog
105
104
  # # List current user account details
106
105
  # service = Fog::Storage[:openstack]
107
106
  # service.request :method => 'HEAD'
108
- #
107
+ #
109
108
  # Would return something like:
110
109
  #
111
110
  # Account: AUTH_1234
@@ -118,9 +117,9 @@ module Fog
118
117
  #
119
118
  # service.change_account('AUTH_3333')
120
119
  # service.request :method => 'HEAD'
121
- #
120
+ #
122
121
  # Would return something like:
123
- #
122
+ #
124
123
  # Account: AUTH_3333
125
124
  # Date: Tue, 05 Mar 2013 16:51:53 GMT
126
125
  # X-Account-Bytes-Used: 23423433
@@ -130,9 +129,9 @@ module Fog
130
129
  # If we wan't to go back to our original admin account:
131
130
  #
132
131
  # service.reset_account_name
133
- #
132
+ #
134
133
  def change_account(account)
135
- @original_path ||= @path
134
+ @original_path ||= @path
136
135
  version_string = @path.split('/')[1]
137
136
  @path = "/#{version_string}/#{account}"
138
137
  end
@@ -174,7 +173,7 @@ module Fog
174
173
  end
175
174
 
176
175
  private
177
-
176
+
178
177
  def authenticate
179
178
  if !@openstack_management_url || @openstack_must_reauthenticate
180
179
  options = {
@@ -188,7 +187,7 @@ module Fog
188
187
  :openstack_endpoint_type => 'publicURL'
189
188
  }
190
189
 
191
- credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
190
+ credentials = Fog::OpenStack.authenticate(options, @connection_options)
192
191
 
193
192
  @current_user = credentials[:user]
194
193
  @current_tenant = credentials[:tenant]
data/lib/fog/openstack.rb CHANGED
@@ -49,6 +49,15 @@ module Fog
49
49
  service(:volume, 'openstack/volume', 'Volume')
50
50
  service(:metering, 'openstack/metering', 'Metering')
51
51
 
52
+ def self.authenticate(options, connection_options = {})
53
+ case options[:openstack_auth_uri].path
54
+ when /v1(\.\d+)?/
55
+ authenticate_v1(options, connection_options)
56
+ else
57
+ authenticate_v2(options, connection_options)
58
+ end
59
+ end
60
+
52
61
  # legacy v1.0 style auth
53
62
  def self.authenticate_v1(options, connection_options = {})
54
63
  uri = options[:openstack_auth_uri]
@@ -69,7 +78,7 @@ module Fog
69
78
 
70
79
  return {
71
80
  :token => response.headers['X-Auth-Token'],
72
- :server_management_url => response.headers['X-Server-Management-Url'],
81
+ :server_management_url => response.headers['X-Server-Management-Url'] || response.headers['X-Storage-Url'],
73
82
  :identity_public_endpoint => response.headers['X-Keystone']
74
83
  }
75
84
  end
@@ -119,6 +119,10 @@ module Fog
119
119
  include Base
120
120
 
121
121
  def initialize(options={})
122
+ # api_key and username missing from instance variable sets
123
+ @rackspace_api_key = options[:rackspace_api_key]
124
+ @rackspace_username = options[:rackspace_username]
125
+
122
126
  @connection_options = options[:connection_options] || {}
123
127
  @rackspace_auth_url = options[:rackspace_auth_url]
124
128
  @rackspace_cdn_url = options[:rackspace_cdn_url]
@@ -176,6 +180,15 @@ module Fog
176
180
  @auth_token = credentials['X-Auth-Token']
177
181
  end
178
182
 
183
+ # Fix for invalid auth_token, likely after 24 hours.
184
+ def authenticate(options={})
185
+ super({
186
+ :rackspace_api_key => @rackspace_api_key,
187
+ :rackspace_username => @rackspace_username,
188
+ :rackspace_auth_url => @rackspace_auth_url,
189
+ :connection_options => @connection_options
190
+ })
191
+ end
179
192
  end
180
193
  end
181
194
  end
@@ -6,6 +6,10 @@ module Fog
6
6
  class Rackspace < Fog::Service
7
7
  include Fog::Rackspace::Errors
8
8
 
9
+ class ServiceError < Fog::Rackspace::Errors::ServiceError; end
10
+ class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end
11
+ class BadRequest < Fog::Rackspace::Errors::BadRequest; end
12
+
9
13
  requires :rackspace_api_key, :rackspace_username
10
14
  recognizes :rackspace_auth_url, :rackspace_servicenet, :persistent
11
15
  recognizes :rackspace_auth_token, :rackspace_management_url, :rackspace_compute_v1_url, :rackspace_region
@@ -204,13 +208,13 @@ module Fog
204
208
  def request(params, parse_json = true, &block)
205
209
  super(params, parse_json, &block)
206
210
  rescue Excon::Errors::NotFound => error
207
- raise NotFound.slurp(error, region)
211
+ raise NotFound.slurp(error, self)
208
212
  rescue Excon::Errors::BadRequest => error
209
- raise BadRequest.slurp error
213
+ raise BadRequest.slurp(error, self)
210
214
  rescue Excon::Errors::InternalServerError => error
211
- raise InternalServerError.slurp error
215
+ raise InternalServerError.slurp(error, self)
212
216
  rescue Excon::Errors::HTTPStatusError => error
213
- raise ServiceError.slurp error
217
+ raise ServiceError.slurp(error, self)
214
218
  end
215
219
 
216
220
  def service_net?
@@ -76,10 +76,12 @@ module Fog
76
76
 
77
77
  request :create_image
78
78
  request :list_images
79
+ request :list_images_detail
79
80
  request :get_image
80
81
  request :delete_image
81
82
 
82
83
  request :list_flavors
84
+ request :list_flavors_detail
83
85
  request :get_flavor
84
86
 
85
87
  request :attach_volume
@@ -88,13 +88,13 @@ module Fog
88
88
  def request(params, parse_json = true, &block)
89
89
  super(params, parse_json, &block)
90
90
  rescue Excon::Errors::NotFound => error
91
- raise NotFound.slurp(error, region)
91
+ raise NotFound.slurp(error, self)
92
92
  rescue Excon::Errors::BadRequest => error
93
- raise BadRequest.slurp error
93
+ raise BadRequest.slurp(error, self)
94
94
  rescue Excon::Errors::InternalServerError => error
95
- raise InternalServerError.slurp error
95
+ raise InternalServerError.slurp(error, self)
96
96
  rescue Excon::Errors::HTTPStatusError => error
97
- raise ServiceError.slurp error
97
+ raise ServiceError.slurp(error, self)
98
98
  end
99
99
 
100
100
  def endpoint_uri(service_endpoint_url=nil)
@@ -115,17 +115,17 @@ module Fog
115
115
  begin
116
116
  super(params, parse_json, &block)
117
117
  rescue Excon::Errors::NotFound => error
118
- raise NotFound.slurp(error, region)
118
+ raise NotFound.slurp(error, self)
119
119
  rescue Excon::Errors::BadRequest => error
120
- raise BadRequest.slurp error
120
+ raise BadRequest.slurp(error, self)
121
121
  rescue Excon::Errors::InternalServerError => error
122
- raise InternalServerError.slurp error
122
+ raise InternalServerError.slurp(error, self)
123
123
  rescue Excon::Errors::ServiceUnavailable => error
124
- raise ServiceUnavailable.slurp error
124
+ raise ServiceUnavailable.slurp(error, self)
125
125
  rescue Excon::Errors::Conflict => error
126
- raise Conflict.slurp error
126
+ raise Conflict.slurp(error, self)
127
127
  rescue Excon::Errors::HTTPStatusError => error
128
- raise ServiceError.slurp error
128
+ raise ServiceError.slurp(error, self)
129
129
  end
130
130
  end
131
131
 
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This example demonstrates creating a server with the Rackpace Open Cloud
4
+
5
+ require 'rubygems' #required for Ruby 1.8.x
6
+ require 'fog'
7
+ require 'base64' #required to encode files for personality functionality
8
+ require 'sshkey' #required to generate ssh keys. 'gem install sshkey'
9
+
10
+ def get_user_input(prompt)
11
+ print "#{prompt}: "
12
+ gets.chomp
13
+ end
14
+
15
+ # Use username defined in ~/.fog file, if absent prompt for username.
16
+ # For more details on ~/.fog refer to http://fog.io/about/getting_started.html
17
+ def rackspace_username
18
+ Fog.credentials[:rackspace_username] || get_user_input("Enter Rackspace Username")
19
+ end
20
+
21
+ # Use api key defined in ~/.fog file, if absent prompt for api key
22
+ # For more details on ~/.fog refer to http://fog.io/about/getting_started.html
23
+ def rackspace_api_key
24
+ Fog.credentials[:rackspace_api_key] || get_user_input("Enter Rackspace API key")
25
+ end
26
+
27
+ # Generates a ssh key using the SSHKey library. The private key is avaialble via
28
+ # the '.private_key' and the public key is avaialble via '.ssh_public_key'
29
+ def generate_ssh_key
30
+ SSHKey.generate
31
+ end
32
+
33
+ # create Next Generation Cloud Server service
34
+ service = Fog::Compute.new({
35
+ :provider => 'rackspace',
36
+ :rackspace_username => rackspace_username,
37
+ :rackspace_api_key => rackspace_api_key,
38
+ :version => :v2, # Use Next Gen Cloud Servers
39
+ :rackspace_region => :ord #Use Chicago Region
40
+ })
41
+
42
+ # pick the first flavor
43
+ flavor = service.flavors.first
44
+
45
+ # pick the first Ubuntu image we can find
46
+ image = service.images.find {|image| image.name =~ /Ubuntu/}
47
+
48
+ # prompt for server name
49
+ server_name = get_user_input "\nEnter Server Name"
50
+
51
+ # generate the ssh key
52
+ ssh_key = generate_ssh_key
53
+
54
+ # reload flavor in order to retrieve all of its attributes
55
+ flavor.reload
56
+
57
+ puts "\nNow creating server '#{server_name}' the following with specifications:\n"
58
+ puts "\t* #{flavor.ram} MB RAM"
59
+ puts "\t* #{flavor.disk} GB"
60
+ puts "\t* #{flavor.vcpus} CPU(s)"
61
+ puts "\t* #{image.name}"
62
+ puts "\n"
63
+
64
+ begin
65
+ # bootstrap server
66
+ server = service.servers.bootstrap :name => server_name,
67
+ :flavor_id => flavor.id,
68
+ :image_id => image.id,
69
+ :private_key => ssh_key.private_key,
70
+ :public_key => ssh_key.ssh_public_key
71
+
72
+ if server.ready?
73
+ puts "[DONE]\n\n"
74
+
75
+ puts "The server has been successfully created.\n"
76
+ puts "Write the following ssh keys to you ~/.ssh directory in order to log in\n\n"
77
+ puts "+++++++++++PRIVATE_KEY (~/.ssh/fog_key)++++++++++++"
78
+ puts ssh_key.private_key
79
+ puts "++++++++++PUBLIC_KEY (~/.ssh/fog_key.pub)++++++++++"
80
+ puts ssh_key.ssh_public_key
81
+ puts "+++++++++++++++++++++++++++++++++++++++++++++++++++i\n\n"
82
+
83
+ puts "You can then log into the server using the following command\n"
84
+ puts "ssh #{server.username}@#{server.public_ip_address}\n\n"
85
+ else
86
+ puts "An error occured, please try again"
87
+ end
88
+
89
+ rescue Fog::Errors::TimeoutError
90
+ puts "[TIMEOUT]\n\n"
91
+
92
+ puts "This server is currently #{server.progress}% into the build process and is taking longer to complete than expected."
93
+ puts "You can continute to monitor the build process through the web console at https://mycloud.rackspace.com/\n\n"
94
+ end
95
+
96
+ puts "To delete the server please execute the delete_server.rb script\n\n"
97
+
98
+
@@ -73,6 +73,7 @@ module Fog
73
73
  request :get_error_page
74
74
  request :set_error_page
75
75
  request :remove_error_page
76
+ request :get_stats
76
77
 
77
78
  module Shared
78
79
 
@@ -122,13 +123,13 @@ module Fog
122
123
  def request(params, parse_json = true, &block)
123
124
  super(params, parse_json, &block)
124
125
  rescue Excon::Errors::NotFound => error
125
- raise NotFound.slurp(error, region)
126
+ raise NotFound.slurp(error, self)
126
127
  rescue Excon::Errors::BadRequest => error
127
- raise BadRequest.slurp error
128
+ raise BadRequest.slurp(error, self)
128
129
  rescue Excon::Errors::InternalServerError => error
129
- raise InternalServerError.slurp error
130
+ raise InternalServerError.slurp(error, self)
130
131
  rescue Excon::Errors::HTTPStatusError => error
131
- raise ServiceError.slurp error
132
+ raise ServiceError.slurp(error, self)
132
133
  end
133
134
 
134
135
  def authenticate(options={})
@@ -15,9 +15,8 @@ module Fog
15
15
  # @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
16
16
  # @raise [Fog::Compute::RackspaceV2::ServiceError]
17
17
  # @note Fog's currentl implementation only returns 1000 flavors.
18
- # @note Fog does not retrieve all flavor details. Please use #get to retrieve all details for a specific flavor.
19
18
  def all
20
- data = service.list_flavors.body['flavors']
19
+ data = service.list_flavors_detail.body['flavors']
21
20
  load(data)
22
21
  end
23
22
 
@@ -5,6 +5,30 @@ module Fog
5
5
  module Compute
6
6
  class RackspaceV2
7
7
  class Images < Fog::Collection
8
+
9
+ # @!attribute [rw] name
10
+ # @return [String] Given a string value x, filters the list of images by image name.
11
+ attribute :name
12
+
13
+ # @!attribute [rw] status
14
+ # @return [String] Given a string value x, filters the list of images by status.
15
+ # @note Possible values are ACTIVE, DELETED, ERROR, SAVING, and UNKNOWN.
16
+ attribute :status
17
+
18
+ # @!attribute [rw] marker
19
+ # @return [String] Given a string value x, return object names greater in value than the specified marker.
20
+ # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Large_Number_of_Objects-d1e1521.html
21
+ attribute :marker
22
+
23
+ # @!attribute [rw] limit
24
+ # @return [Integer] For an integer value n, limits the number of results to at most n values.
25
+ # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Large_Number_of_Objects-d1e1521.html
26
+ attribute :limit
27
+
28
+ # @!attribute [rw] type
29
+ # @return [String] Given a string value x, filters the list of images by type.
30
+ # @note Valid values are BASE and SNAPSHOT
31
+ attribute :type
8
32
 
9
33
  model Fog::Compute::RackspaceV2::Image
10
34
 
@@ -15,10 +39,18 @@ module Fog
15
39
  # @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
16
40
  # @raise [Fog::Compute::RackspaceV2::ServiceError]
17
41
  # @note Fog's current implementation only returns 1000 images.
18
- # @note Fog does not retrieve all image details. Please use get to retrieve all details for a specific image.
19
42
  # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Images-d1e4435.html
20
- def all
21
- data = service.list_images.body['images']
43
+ def all(options = {})
44
+ options = {
45
+ 'name' => name,
46
+ 'status' => status,
47
+ 'marker' => marker,
48
+ 'limit' => limit,
49
+ 'type' => type
50
+ }.merge!(options)
51
+ merge_attributes(options)
52
+
53
+ data = service.list_images_detail(options).body['images']
22
54
  load(data)
23
55
  end
24
56
 
@@ -19,7 +19,7 @@ module Fog
19
19
  # @raise [Fog::Compute::RackspaceV2::ServiceError]
20
20
  def destroy
21
21
  requires :identity
22
- connection.delete_metadata_item(collection_name, parent.id, key)
22
+ service.delete_metadata_item(collection_name, parent.id, key)
23
23
  true
24
24
  end
25
25
 
@@ -31,7 +31,7 @@ module Fog
31
31
  # @raise [Fog::Compute::RackspaceV2::ServiceError]
32
32
  def save
33
33
  requires :identity, :value
34
- connection.set_metadata_item(collection_name, parent.id, key, value)
34
+ service.set_metadata_item(collection_name, parent.id, key, value)
35
35
  true
36
36
  end
37
37
 
@@ -22,7 +22,7 @@ module Fog
22
22
 
23
23
  def display_service_regions(service_type)
24
24
  endpoints = get_endpoints(service_type)
25
- endpoints.collect { |k,v| ":#{k}" }.join(", ")
25
+ endpoints.collect { |k,v| ":#{k}" }.join(", ")
26
26
  end
27
27
 
28
28
  def get_endpoint(service_type, region=nil)
@@ -32,7 +32,7 @@ module Fog
32
32
  return endpoint if endpoint.is_a?(String) #There is only one endpoint for service
33
33
 
34
34
  unless region
35
- raise "There are multiple endpoints avaliable for #{service_type}. Please specify one of the following regions: #{display_service_regions(service_type)}."
35
+ raise "There are multiple endpoints available for #{service_type}. Please specify one of the following regions: #{display_service_regions(service_type)}."
36
36
  end
37
37
  region = region.is_a?(String) ? region.to_sym : region
38
38
  endpoint = get_endpoints(service_type)[region]
@@ -48,10 +48,16 @@ module Fog
48
48
 
49
49
  def self.from_response(service, hash)
50
50
  service_catalog = ServiceCatalog.new :service => service
51
- services = hash["access"]["serviceCatalog"]
52
- services.each do |serv|
53
- name = serv["name"].to_sym
54
- service_catalog.send(:add_endpoints, name, serv)
51
+ begin
52
+ services = hash["access"]["serviceCatalog"]
53
+ services.each do |serv|
54
+ name = serv["name"] ? serv["name"].to_sym : nil
55
+ next unless name
56
+ service_catalog.send(:add_endpoints, name, serv)
57
+ end
58
+ rescue => e
59
+ Logger.warning "Exception occurred while loading service catalog - #{e.inspect}"
60
+ Logger.warning "Unable to load service catalog. Please specify endpoints manually"
55
61
  end
56
62
  service_catalog
57
63
  end
@@ -59,20 +65,32 @@ module Fog
59
65
  private
60
66
 
61
67
  def add_endpoints(service_name, hash)
62
- endpoints = hash["endpoints"]
63
- if endpoints.size == 1
64
- catalog[service_name] = endpoints[0]["publicURL"].freeze
65
- else
66
- catalog[service_name] = endpoints_from_array(endpoints)
68
+ begin
69
+ endpoints = hash["endpoints"]
70
+ if endpoints.size == 1
71
+ catalog[service_name] = endpoints[0]["publicURL"].freeze
72
+ else
73
+ catalog[service_name] = endpoints_from_array(service_name, endpoints)
74
+ end
75
+ rescue => e
76
+ Logger.warning "Exception occurred while loading #{service_name} service endpoints - #{e.inspect}"
77
+ Logger.warning "Unable to load service endpoints for #{service_name}. Please specify #{service_name} endpoints manually."
67
78
  end
68
79
  end
69
80
 
70
- def endpoints_from_array(endpoints)
81
+ def endpoints_from_array(service_name, endpoints)
71
82
  hash = {}
72
83
  endpoints.each do |endpoint|
73
- region = endpoint["region"].downcase.to_sym
74
- url = endpoint["publicURL"].freeze
75
- hash[region] = url
84
+ begin
85
+ region_name = endpoint["region"]
86
+ region = region_name ? region_name.downcase.to_sym : :global
87
+ url = endpoint["publicURL"].freeze
88
+ hash[region] = url
89
+ rescue => e
90
+ Logger.warning "Exception occurred while loading #{service_name} service endpoints - #{e.inspect}"
91
+ Logger.warning "Unable to parse #{service_name} endpoint - #{endpoint}"
92
+ Logger.warning "You may need to specify #{service_name} endpoints manually."
93
+ end
76
94
  end
77
95
  hash
78
96
  end
@@ -80,4 +98,4 @@ module Fog
80
98
  end
81
99
  end
82
100
  end
83
- end
101
+ end