fog 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +3 -3
  3. data/changelog.txt +213 -0
  4. data/docs/compute/index.markdown +15 -1
  5. data/fog.gemspec +3 -3
  6. data/lib/fog.rb +1 -1
  7. data/lib/fog/aws.rb +9 -0
  8. data/lib/fog/aws/auto_scaling.rb +3 -1
  9. data/lib/fog/aws/cloud_formation.rb +2 -0
  10. data/lib/fog/aws/cloud_watch.rb +2 -0
  11. data/lib/fog/aws/compute.rb +9 -3
  12. data/lib/fog/aws/elasticache.rb +8 -1
  13. data/lib/fog/aws/elb.rb +2 -0
  14. data/lib/fog/aws/models/cloud_watch/metric_statistic.rb +1 -2
  15. data/lib/fog/aws/models/compute/security_group.rb +1 -1
  16. data/lib/fog/aws/models/compute/server.rb +3 -1
  17. data/lib/fog/aws/models/dns/records.rb +3 -3
  18. data/lib/fog/aws/models/elb/load_balancer.rb +6 -0
  19. data/lib/fog/aws/models/storage/file.rb +2 -2
  20. data/lib/fog/aws/models/storage/files.rb +4 -4
  21. data/lib/fog/aws/parsers/compute/describe_instance_status.rb +64 -0
  22. data/lib/fog/aws/parsers/compute/describe_security_groups.rb +1 -1
  23. data/lib/fog/aws/parsers/sqs/receive_message.rb +1 -1
  24. data/lib/fog/aws/parsers/sts/get_session_token.rb +31 -0
  25. data/lib/fog/aws/rds.rb +36 -1
  26. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
  27. data/lib/fog/aws/requests/compute/describe_instance_status.rb +36 -0
  28. data/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -0
  29. data/lib/fog/aws/requests/elb/set_load_balancer_listener_ssl_certificate.rb +27 -0
  30. data/lib/fog/aws/requests/rds/create_db_instance.rb +64 -1
  31. data/lib/fog/aws/requests/rds/delete_db_instance.rb +19 -3
  32. data/lib/fog/aws/requests/rds/describe_db_instances.rb +40 -1
  33. data/lib/fog/aws/requests/rds/describe_db_reserved_instances.rb +1 -1
  34. data/lib/fog/aws/requests/rds/modify_db_instance.rb +24 -1
  35. data/lib/fog/aws/requests/rds/reboot_db_instance.rb +17 -1
  36. data/lib/fog/aws/requests/storage/{hash_to_acl.rb → acl_utils.rb} +8 -0
  37. data/lib/fog/aws/requests/storage/copy_object.rb +8 -0
  38. data/lib/fog/aws/requests/storage/get_bucket_acl.rb +7 -1
  39. data/lib/fog/aws/requests/storage/get_object_acl.rb +7 -1
  40. data/lib/fog/aws/requests/storage/get_object_http_url.rb +4 -3
  41. data/lib/fog/aws/requests/storage/get_object_https_url.rb +4 -3
  42. data/lib/fog/aws/requests/storage/put_bucket_acl.rb +2 -2
  43. data/lib/fog/aws/requests/storage/put_object_acl.rb +1 -1
  44. data/lib/fog/aws/requests/sts/get_federation_token.rb +20 -0
  45. data/lib/fog/aws/requests/sts/get_session_token.rb +18 -0
  46. data/lib/fog/aws/simpledb.rb +5 -1
  47. data/lib/fog/aws/sns.rb +2 -0
  48. data/lib/fog/aws/sqs.rb +5 -1
  49. data/lib/fog/aws/storage.rb +6 -0
  50. data/lib/fog/aws/sts.rb +137 -0
  51. data/lib/fog/bin.rb +1 -0
  52. data/lib/fog/bin/aws.rb +2 -0
  53. data/lib/fog/bin/clodo.rb +31 -0
  54. data/lib/fog/brightbox/compute.rb +7 -0
  55. data/lib/fog/brightbox/models/compute/cloud_ip.rb +10 -2
  56. data/lib/fog/brightbox/models/compute/firewall_policies.rb +29 -0
  57. data/lib/fog/brightbox/models/compute/firewall_policy.rb +65 -0
  58. data/lib/fog/brightbox/models/compute/firewall_rule.rb +54 -0
  59. data/lib/fog/brightbox/models/compute/firewall_rules.rb +24 -0
  60. data/lib/fog/brightbox/models/compute/image.rb +2 -0
  61. data/lib/fog/brightbox/models/compute/server.rb +41 -6
  62. data/lib/fog/brightbox/models/compute/server_group.rb +56 -17
  63. data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +14 -0
  64. data/lib/fog/clodo.rb +34 -0
  65. data/lib/fog/clodo/compute.rb +152 -0
  66. data/lib/fog/clodo/models/compute/image.rb +31 -0
  67. data/lib/fog/clodo/models/compute/images.rb +28 -0
  68. data/lib/fog/clodo/models/compute/server.rb +163 -0
  69. data/lib/fog/clodo/models/compute/servers.rb +36 -0
  70. data/lib/fog/clodo/requests/compute/add_ip_address.rb +49 -0
  71. data/lib/fog/clodo/requests/compute/create_server.rb +112 -0
  72. data/lib/fog/clodo/requests/compute/delete_ip_address.rb +47 -0
  73. data/lib/fog/clodo/requests/compute/delete_server.rb +44 -0
  74. data/lib/fog/clodo/requests/compute/get_image_details.rb +20 -0
  75. data/lib/fog/clodo/requests/compute/get_server_details.rb +49 -0
  76. data/lib/fog/clodo/requests/compute/list_images.rb +48 -0
  77. data/lib/fog/clodo/requests/compute/list_images_detail.rb +61 -0
  78. data/lib/fog/clodo/requests/compute/list_servers.rb +50 -0
  79. data/lib/fog/clodo/requests/compute/list_servers_detail.rb +51 -0
  80. data/lib/fog/clodo/requests/compute/move_ip_address.rb +34 -0
  81. data/lib/fog/clodo/requests/compute/reboot_server.rb +19 -0
  82. data/lib/fog/clodo/requests/compute/rebuild_server.rb +21 -0
  83. data/lib/fog/clodo/requests/compute/server_action.rb +25 -0
  84. data/lib/fog/clodo/requests/compute/start_server.rb +19 -0
  85. data/lib/fog/clodo/requests/compute/stop_server.rb +19 -0
  86. data/lib/fog/compute.rb +3 -0
  87. data/lib/fog/core/credentials.rb +3 -3
  88. data/lib/fog/core/errors.rb +2 -0
  89. data/lib/fog/core/wait_for.rb +1 -1
  90. data/lib/fog/dnsmadeeasy/dns.rb +1 -1
  91. data/lib/fog/libvirt/compute.rb +2 -0
  92. data/lib/fog/libvirt/models/compute/nodes.rb +1 -3
  93. data/lib/fog/libvirt/models/compute/server.rb +8 -1
  94. data/lib/fog/providers.rb +1 -0
  95. data/lib/fog/rackspace/dns.rb +10 -2
  96. data/lib/fog/rackspace/load_balancers.rb +3 -0
  97. data/lib/fog/rackspace/models/compute/server.rb +2 -2
  98. data/lib/fog/rackspace/models/dns/callback.rb +3 -1
  99. data/lib/fog/rackspace/models/dns/record.rb +4 -0
  100. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +18 -8
  101. data/lib/fog/rackspace/requests/load_balancers/delete_nodes.rb +1 -2
  102. data/lib/fog/rackspace/requests/load_balancers/get_error_page.rb +15 -0
  103. data/lib/fog/rackspace/requests/load_balancers/list_load_balancers.rb +8 -2
  104. data/lib/fog/rackspace/requests/load_balancers/remove_error_page.rb +15 -0
  105. data/lib/fog/rackspace/requests/load_balancers/set_error_page.rb +21 -0
  106. data/lib/fog/vcloud/compute.rb +7 -1
  107. data/lib/fog/vcloud/models/compute/catalogs.rb +4 -5
  108. data/lib/fog/vcloud/models/compute/helpers/status.rb +37 -0
  109. data/lib/fog/vcloud/models/compute/network.rb +13 -49
  110. data/lib/fog/vcloud/models/compute/networks.rb +12 -3
  111. data/lib/fog/vcloud/models/compute/organization.rb +44 -0
  112. data/lib/fog/vcloud/models/compute/organizations.rb +29 -0
  113. data/lib/fog/vcloud/models/compute/server.rb +35 -56
  114. data/lib/fog/vcloud/models/compute/servers.rb +11 -13
  115. data/lib/fog/vcloud/models/compute/vapp.rb +41 -0
  116. data/lib/fog/vcloud/models/compute/vapps.rb +32 -0
  117. data/lib/fog/vcloud/models/compute/vdc.rb +11 -26
  118. data/lib/fog/vcloud/models/compute/vdcs.rb +6 -8
  119. data/lib/fog/vcloud/requests/compute/get_server.rb +10 -0
  120. data/lib/fog/vsphere/compute.rb +1 -0
  121. data/lib/fog/vsphere/models/compute/server.rb +18 -0
  122. data/lib/fog/vsphere/models/compute/servers.rb +8 -2
  123. data/lib/fog/vsphere/requests/compute/datacenters.rb +34 -0
  124. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +132 -91
  125. data/lib/fog/vsphere/requests/compute/vm_clone.rb +76 -37
  126. data/spec/lib/fog/aws/parsers/sqs/receive_message_spec.rb +58 -0
  127. data/tests/aws/models/elb/model_tests.rb +5 -0
  128. data/tests/aws/requests/compute/instance_tests.rb +23 -0
  129. data/tests/aws/requests/compute/security_group_tests.rb +1 -0
  130. data/tests/aws/requests/elb/listener_tests.rb +4 -0
  131. data/tests/aws/requests/storage/{hash_to_acl_tests.rb → acl_utils_tests.rb} +38 -2
  132. data/tests/aws/requests/storage/bucket_tests.rb +0 -3
  133. data/tests/aws/requests/storage/object_tests.rb +2 -4
  134. data/tests/aws/requests/sts/get_federation_token_tests.rb +21 -0
  135. data/tests/aws/requests/sts/session_token_tests.rb +16 -0
  136. data/tests/brightbox/requests/compute/account_tests.rb +11 -6
  137. data/tests/brightbox/requests/compute/api_client_tests.rb +23 -12
  138. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +32 -17
  139. data/tests/brightbox/requests/compute/helper.rb +29 -3
  140. data/tests/brightbox/requests/compute/image_tests.rb +17 -14
  141. data/tests/brightbox/requests/compute/interface_tests.rb +3 -2
  142. data/tests/brightbox/requests/compute/load_balancer_tests.rb +57 -11
  143. data/tests/brightbox/requests/compute/server_group_tests.rb +29 -22
  144. data/tests/brightbox/requests/compute/server_tests.rb +41 -22
  145. data/tests/brightbox/requests/compute/server_type_tests.rb +7 -6
  146. data/tests/brightbox/requests/compute/user_tests.rb +11 -16
  147. data/tests/brightbox/requests/compute/zone_tests.rb +7 -6
  148. data/tests/clodo/requests/compute/image_tests.rb +36 -0
  149. data/tests/clodo/requests/compute/server_tests.rb +152 -0
  150. data/tests/compute/helper.rb +1 -1
  151. data/tests/core/credential_tests.rb +2 -2
  152. data/tests/glesys/requests/compute/helper.rb +91 -66
  153. data/tests/glesys/requests/compute/ip_tests.rb +1 -1
  154. data/tests/glesys/requests/compute/server_tests.rb +5 -5
  155. data/tests/helpers/mock_helper.rb +2 -0
  156. data/tests/rackspace/models/dns/zone_tests.rb +14 -0
  157. data/tests/rackspace/models/{access_list_tests.rb → load_balancers/access_list_tests.rb} +0 -0
  158. data/tests/rackspace/models/{access_lists_tests.rb → load_balancers/access_lists_tests.rb} +0 -0
  159. data/tests/rackspace/models/{load_balancer_tests.rb → load_balancers/load_balancer_tests.rb} +25 -0
  160. data/tests/rackspace/models/{load_balancers_tests.rb → load_balancers/load_balancers_tests.rb} +0 -0
  161. data/tests/rackspace/models/{node_tests.rb → load_balancers/node_tests.rb} +0 -0
  162. data/tests/rackspace/models/{nodes_tests.rb → load_balancers/nodes_tests.rb} +0 -0
  163. data/tests/rackspace/models/{virtual_ip_tests.rb → load_balancers/virtual_ip_tests.rb} +0 -0
  164. data/tests/rackspace/models/{virtual_ips_tests.rb → load_balancers/virtual_ips_tests.rb} +0 -0
  165. data/tests/rackspace/requests/dns/dns_tests.rb +4 -2
  166. data/tests/rackspace/requests/load_balancers/error_page_tests.rb +31 -0
  167. data/tests/rackspace/requests/load_balancers/helper.rb +27 -11
  168. data/tests/rackspace/requests/load_balancers/load_balancer_tests.rb +4 -1
  169. data/tests/rackspace/requests/load_balancers/node_tests.rb +24 -25
  170. data/tests/slicehost/requests/compute/slice_tests.rb +2 -2
  171. data/tests/storm_on_demand/requests/compute/server_tests.rb +3 -3
  172. data/tests/vcloud/data/api_+_v1.0_+_admin_+_network_+_2 +110 -0
  173. data/tests/vcloud/data/api_+_v1.0_+_login +5 -0
  174. data/tests/vcloud/data/api_+_v1.0_+_network_+_1 +44 -0
  175. data/tests/vcloud/data/api_+_v1.0_+_network_+_2 +31 -0
  176. data/tests/vcloud/data/api_+_v1.0_+_org_+_1 +17 -0
  177. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vapp-1 +369 -0
  178. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-1 +139 -0
  179. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-2 +155 -0
  180. data/tests/vcloud/data/api_+_v1.0_+_vdc_+_1 +61 -0
  181. data/tests/vcloud/models/compute/conn_helper.rb +20 -0
  182. data/tests/vcloud/models/compute/network_tests.rb +65 -0
  183. data/tests/vcloud/models/compute/networks_tests.rb +42 -0
  184. data/tests/vcloud/models/compute/organization_tests.rb +13 -0
  185. data/tests/vcloud/models/compute/organizations_tests.rb +14 -0
  186. data/tests/vcloud/models/compute/server_tests.rb +136 -0
  187. data/tests/vcloud/models/compute/servers_tests.rb +10 -89
  188. data/tests/vcloud/models/compute/vapp_tests.rb +27 -0
  189. data/tests/vcloud/models/compute/vapps_tests.rb +17 -0
  190. data/tests/vcloud/models/compute/vdc_tests.rb +42 -0
  191. data/tests/vcloud/models/compute/vdcs_tests.rb +17 -0
  192. data/tests/vsphere/requests/compute/vm_clone_tests.rb +2 -6
  193. metadata +151 -55
data/lib/fog/aws/elb.rb CHANGED
@@ -120,6 +120,8 @@ module Fog
120
120
  'elasticloadbalancing.us-west-1.amazonaws.com'
121
121
  when 'us-west-2'
122
122
  'elasticloadbalancing.us-west-2.amazonaws.com'
123
+ when 'sa-east-1'
124
+ 'elasticloadbalancing.sa-east-1.amazonaws.com'
123
125
  else
124
126
  raise ArgumentError, "Unknown region: #{options[:region].inspect}"
125
127
  end
@@ -25,7 +25,6 @@ module Fog
25
25
 
26
26
  put_opts = {'MetricName' => metric_name, 'Unit' => unit}
27
27
  put_opts.merge!('Dimensions' => dimensions) if dimensions
28
- put_opts.merge!('Timestamp' => dimensions) if timestamp
29
28
  if value
30
29
  put_opts.merge!('Value' => value)
31
30
  else
@@ -43,4 +42,4 @@ module Fog
43
42
  end
44
43
  end
45
44
  end
46
- end
45
+ end
@@ -7,8 +7,8 @@ module Fog
7
7
  class SecurityGroup < Fog::Model
8
8
 
9
9
  identity :name, :aliases => 'groupName'
10
-
11
10
  attribute :description, :aliases => 'groupDescription'
11
+ attribute :group_id, :aliases => 'groupId'
12
12
  attribute :ip_permissions, :aliases => 'ipPermissions'
13
13
  attribute :owner_id, :aliases => 'ownerId'
14
14
 
@@ -34,6 +34,7 @@ module Fog
34
34
  attribute :reason
35
35
  attribute :root_device_name, :aliases => 'rootDeviceName'
36
36
  attribute :root_device_type, :aliases => 'rootDeviceType'
37
+ attribute :security_group_ids, :aliases => 'securityGroupIds'
37
38
  attribute :state, :aliases => 'instanceState', :squash => 'name'
38
39
  attribute :state_reason, :aliases => 'stateReason'
39
40
  attribute :subnet_id, :aliases => 'subnetId'
@@ -45,7 +46,7 @@ module Fog
45
46
  attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username
46
47
 
47
48
  def initialize(attributes={})
48
- self.groups ||= ["default"] unless attributes[:subnet_id]
49
+ self.groups ||= ["default"] unless (attributes[:subnet_id] || attributes[:security_group_ids])
49
50
  self.flavor_id ||= 't1.micro'
50
51
  self.image_id ||= begin
51
52
  self.username = 'ubuntu'
@@ -152,6 +153,7 @@ module Fog
152
153
  'Placement.Tenancy' => tenancy,
153
154
  'RamdiskId' => ramdisk_id,
154
155
  'SecurityGroup' => groups,
156
+ 'SecurityGroupId' => security_group_ids,
155
157
  'SubnetId' => subnet_id,
156
158
  'UserData' => user_data
157
159
  }
@@ -20,9 +20,9 @@ module Fog
20
20
 
21
21
  def all(options = {})
22
22
  requires :zone
23
- options['MaxItems'] ||= max_items
24
- options['Name'] ||= name
25
- options['Type'] ||= type
23
+ options['maxitems'] ||= max_items
24
+ options['name'] ||= name
25
+ options['type'] ||= type
26
26
  data = connection.list_resource_record_sets(zone.id, options).body
27
27
  merge_attributes(data.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextRecordName', 'NextRecordType'].include?(key)})
28
28
  # leave out the default, read only records
@@ -96,6 +96,12 @@ module Fog
96
96
  reload
97
97
  end
98
98
 
99
+ def set_listener_ssl_certificate(port, ssl_certificate_id)
100
+ requires :id
101
+ connection.set_load_balancer_listener_ssl_certificate(id, port, ssl_certificate_id)
102
+ reload
103
+ end
104
+
99
105
  def unset_listener_policy(port)
100
106
  set_listener_policy(port, [])
101
107
  end
@@ -123,9 +123,9 @@ module Fog
123
123
  true
124
124
  end
125
125
 
126
- def url(expires)
126
+ def url(expires, options = {})
127
127
  requires :key
128
- collection.get_https_url(key, expires)
128
+ collection.get_https_url(key, expires, options)
129
129
  end
130
130
 
131
131
  private
@@ -78,14 +78,14 @@ module Fog
78
78
  end
79
79
  end
80
80
 
81
- def get_http_url(key, expires)
81
+ def get_http_url(key, expires, options = {})
82
82
  requires :directory
83
- connection.get_object_http_url(directory.key, key, expires)
83
+ connection.get_object_http_url(directory.key, key, expires, options)
84
84
  end
85
85
 
86
- def get_https_url(key, expires)
86
+ def get_https_url(key, expires, options = {})
87
87
  requires :directory
88
- connection.get_object_https_url(directory.key, key, expires)
88
+ connection.get_object_https_url(directory.key, key, expires, options)
89
89
  end
90
90
 
91
91
  def head(key, options = {})
@@ -0,0 +1,64 @@
1
+ module Fog
2
+ module Parsers
3
+ module Compute
4
+ module AWS
5
+ class DescribeInstanceStatus < Fog::Parsers::Base
6
+
7
+ def new_instance
8
+ @instance = { 'eventsSet' => [], 'instanceState' => {} }
9
+ end
10
+
11
+ def new_event
12
+ @event = {}
13
+ end
14
+
15
+ def reset
16
+ @instance_status = {}
17
+ @response = { 'instanceStatusSet' => [] }
18
+ @in_events_set = false
19
+ new_event
20
+ new_instance
21
+ end
22
+
23
+ def start_element(name, attrs=[])
24
+ super
25
+ case name
26
+ when 'eventsSet'
27
+ @in_events_set = true
28
+ end
29
+ end
30
+
31
+
32
+ def end_element(name)
33
+ if @in_events_set
34
+ case name
35
+ when 'code', 'description'
36
+ @event[name] = value
37
+ when 'notAfter', 'notBefore'
38
+ @event[name] = Time.parse(value)
39
+ when 'item'
40
+ @instance['eventsSet'] << @event
41
+ new_event
42
+ when 'eventsSet'
43
+ @in_events_set = false
44
+ end
45
+ else
46
+ case name
47
+ when 'instanceId', 'availabilityZone'
48
+ @instance[name] = value
49
+ when 'name', 'code'
50
+ @instance['instanceState'][name] = value
51
+ when 'item'
52
+ @response['instanceStatusSet'] << @instance
53
+ new_instance
54
+ when 'requestId'
55
+ @response[name] = value
56
+
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -40,7 +40,7 @@ module Fog
40
40
  end
41
41
  when 'groups'
42
42
  @in_groups = false
43
- when 'groupDescription', 'ownerId'
43
+ when 'groupDescription', 'ownerId', 'groupId'
44
44
  @security_group[name] = value
45
45
  when 'groupName'
46
46
  if @in_groups
@@ -24,7 +24,7 @@ module Fog
24
24
  when 'Value'
25
25
  case @current_attribute_name
26
26
  when 'ApproximateFirstReceiveTimestamp', 'SentTimestamp'
27
- @message['Attributes'][@current_attribute_name] = Time.at(@value.to_i)
27
+ @message['Attributes'][@current_attribute_name] = Time.at(@value.to_i / 1000.0)
28
28
  when 'ApproximateReceiveCount'
29
29
  @message['Attributes'][@current_attribute_name] = @value.to_i
30
30
  else
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module STS
5
+
6
+ class GetSessionToken < Fog::Parsers::Base
7
+ # http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?CreatingFedTokens.html
8
+
9
+ def reset
10
+ @response = {}
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'SessionToken', 'SecretAccessKey', 'Expiration', 'AccessKeyId'
16
+ @response[name] = @value.strip
17
+ when 'Arn', 'FederatedUserId'
18
+ @response[name] = @value
19
+ when 'PackedPolicySize'
20
+ @response[name] = @value
21
+ when 'RequestId'
22
+ @response[name] = @value
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
data/lib/fog/aws/rds.rb CHANGED
@@ -57,9 +57,42 @@ module Fog
57
57
 
58
58
  class Mock
59
59
 
60
+ def self.data
61
+ @data ||= Hash.new do |hash, region|
62
+ owner_id = Fog::AWS::Mock.owner_id
63
+ hash[region] = Hash.new do |region_hash, key|
64
+ region_hash[key] = {
65
+ :servers => {}
66
+ }
67
+ end
68
+ end
69
+ end
70
+
71
+ def self.reset
72
+ @data = nil
73
+ end
74
+
60
75
  def initialize(options={})
61
- Fog::Mock.not_implemented
76
+
77
+ @aws_access_key_id = options[:aws_access_key_id]
78
+
79
+ @region = options[:region] || 'us-east-1'
80
+
81
+ unless ['ap-northeast-1', 'ap-southeast-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2'].include?(@region)
82
+ raise ArgumentError, "Unknown region: #{@region.inspect}"
83
+ end
84
+
85
+ end
86
+
87
+ def data
88
+ self.class.data[@region][@aws_access_key_id]
89
+ end
90
+
91
+ def reset_data
92
+ self.class.data[@region].delete(@aws_access_key_id)
62
93
  end
94
+
95
+
63
96
 
64
97
  end
65
98
 
@@ -103,6 +136,8 @@ module Fog
103
136
  'rds.us-west-1.amazonaws.com'
104
137
  when 'us-west-2'
105
138
  'rds.us-west-2.amazonaws.com'
139
+ when 'sa-east-1'
140
+ 'rds.sa-east-1.amazonaws.com'
106
141
  else
107
142
  raise ArgumentError, "Unknown region: #{options[:region].inspect}"
108
143
  end
@@ -57,6 +57,9 @@ module Fog
57
57
 
58
58
  {"messageSet" => [], "regionName" => "us-west-2", "zoneName" => "us-west-2a", "zoneState" => "available"},
59
59
  {"messageSet" => [], "regionName" => "us-west-2", "zoneName" => "us-west-2b", "zoneState" => "available"},
60
+
61
+ {"messageSet" => [], "regionName" => "sa-east-1", "zoneName" => "sa-east-1a", "zoneState" => "available"},
62
+ {"messageSet" => [], "regionName" => "sa-east-1", "zoneName" => "sa-east-1b", "zoneState" => "available"},
60
63
 
61
64
  {"messageSet" => [], "regionName" => "eu-west-1", "zoneName" => "eu-west-1a", "zoneState" => "available"},
62
65
  {"messageSet" => [], "regionName" => "eu-west-1", "zoneName" => "eu-west-1b", "zoneState" => "available"},
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Compute
3
+ class AWS
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/compute/describe_instance_status'
7
+
8
+ def describe_instance_status(filters = {})
9
+ raise ArgumentError.new("Filters must be a hash, but is a #{filters.class}.") unless filters.is_a?(Hash)
10
+
11
+ params = Fog::AWS.indexed_filters(filters)
12
+ request({
13
+ 'Action' => 'DescribeInstanceStatus',
14
+ :idempotent => true,
15
+ :parser => Fog::Parsers::Compute::AWS::DescribeInstanceStatus.new
16
+ }.merge!(params))
17
+ end
18
+ end
19
+
20
+ class Mock
21
+ def describe_instance_status(filters = {})
22
+ response = Excon::Response.new
23
+ response.status = 200
24
+
25
+ response.body = {
26
+ 'instanceStatusSet' => [],
27
+ 'requestId' => Fog::AWS::Mock.request_id
28
+ }
29
+
30
+ response
31
+
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -16,6 +16,7 @@ module Fog
16
16
  # * 'requestId'<~String> - Id of request
17
17
  # * 'securityGroupInfo'<~Array>:
18
18
  # * 'groupDescription'<~String> - Description of security group
19
+ # * 'groupId'<~String> - ID of the security group.
19
20
  # * 'groupName'<~String> - Name of security group
20
21
  # * 'ipPermissions'<~Array>:
21
22
  # * 'fromPort'<~Integer> - Start of port range (or -1 for ICMP wildcard)
@@ -59,6 +60,7 @@ module Fog
59
60
  aliases = {
60
61
  'description' => 'groupDescription',
61
62
  'group-name' => 'groupName',
63
+ 'group-id' => 'groupId',
62
64
  'owner-id' => 'ownerId'
63
65
  }
64
66
  permission_aliases = {
@@ -34,6 +34,33 @@ module Fog
34
34
  end
35
35
 
36
36
  class Mock
37
+ def set_load_balancer_listener_ssl_certificate(lb_name, load_balancer_port, ssl_certificate_id)
38
+ raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
39
+
40
+ certificate_ids = Fog::AWS::IAM::Mock.data[@aws_access_key_id][:server_certificates].map {|n, c| c['Arn'] }
41
+ if !certificate_ids.include? ssl_certificate_id
42
+ raise Fog::AWS::IAM::NotFound.new('CertificateNotFound')
43
+ end
44
+
45
+ response = Excon::Response.new
46
+
47
+ unless listener = load_balancer['ListenerDescriptions'].find { |listener| listener['Listener']['LoadBalancerPort'] == load_balancer_port }
48
+ response.status = 400
49
+ response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>ListenerNotFound</Code><Message>LoadBalancer does not have a listnener configured at the given port.</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>"
50
+ raise Excon::Errors.status_error({:expects => 200}, response)
51
+ end
52
+
53
+ listener['Listener']['SSLCertificateId'] = ssl_certificate_id
54
+
55
+ response.status = 200
56
+ response.body = {
57
+ "ResponseMetadata" => {
58
+ "RequestId" => Fog::AWS::Mock.request_id
59
+ }
60
+ }
61
+
62
+ response
63
+ end
37
64
  end
38
65
  end
39
66
  end
@@ -47,7 +47,70 @@ module Fog
47
47
  class Mock
48
48
 
49
49
  def create_db_instance(db_name, options={})
50
- Fog::Mock.not_implemented
50
+ response = Excon::Response.new
51
+ if self.data[:servers] and self.data[:servers][db_name]
52
+ # I don't know how to raise an exception that contains the excon data
53
+ #response.status = 400
54
+ #response.body = {
55
+ # 'Code' => 'DBInstanceAlreadyExists',
56
+ # 'Message' => "DB Instance already exists"
57
+ #}
58
+ #return response
59
+ raise Fog::AWS::RDS::IdentifierTaken.new("DBInstanceAlreadyExists #{response.body.to_s}")
60
+ end
61
+
62
+ # These are the required parameters according to the API
63
+ required_params = %w{AllocatedStorage DBInstanceClass Engine MasterUserPassword MasterUsername }
64
+ required_params.each do |key|
65
+ unless options.has_key?(key) and options[key] and !options[key].to_s.empty?
66
+ #response.status = 400
67
+ #response.body = {
68
+ # 'Code' => 'MissingParameter',
69
+ # 'Message' => "The request must contain the parameter #{key}"
70
+ #}
71
+ #return response
72
+ raise Fog::AWS::RDS::NotFound.new("The request must contain the parameter #{key}")
73
+ end
74
+ end
75
+
76
+ data =
77
+ {
78
+ "DBInstanceIdentifier"=> db_name,
79
+ "DBName" => options["DBName"],
80
+ "created_at" => nil,
81
+ "AutoMinorVersionUpgrade"=>true,
82
+ "Endpoint"=>{},
83
+ "ReadReplicaDBInstanceIdentifiers"=>[],
84
+ "PreferredMaintenanceWindow"=>"mon:04:30-mon:05:00",
85
+ "Engine"=> options["Engine"],
86
+ "EngineVersion"=> options["EngineVersion"] || "5.1.57",
87
+ "PendingModifiedValues"=>{"MasterUserPassword"=>"****"}, # This clears when is available
88
+ "MultiAZ"=>false,
89
+ "MasterUsername"=> options["MasterUsername"],
90
+ "DBInstanceClass"=> options["DBInstanceClass"],
91
+ "DBInstanceStatus"=>"creating",
92
+ "BackupRetentionPeriod"=> options["BackupRetentionPeriod"] || 1,
93
+ "AllocatedStorage"=> options["AllocatedStorage"],
94
+ "DBParameterGroups"=> # I think groups shoul be in the self.data method
95
+ [{"DBParameterGroupName"=>"default.mysql5.1",
96
+ "ParameterApplyStatus"=>"in-sync"}],
97
+ "DBSecurityGroups"=>
98
+ [{"Status"=>"active",
99
+ "DBSecurityGroupName"=>"default"}],
100
+ "LicenseModel"=>"general-public-license",
101
+ "PreferredBackupWindow"=>"08:00-08:30"
102
+ }
103
+
104
+
105
+ self.data[:servers][db_name] = data
106
+ response.body = {
107
+ "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
108
+ "CreateDBInstanceResult"=> {"DBInstance"=> data}
109
+ }
110
+ response.status = 200
111
+ # This values aren't showed at creating time but at available time
112
+ self.data[:servers][db_name]["created_at"] = Time.now
113
+ response
51
114
  end
52
115
 
53
116
  end