fog 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/.document +1 -1
  2. data/.irbrc +5 -10
  3. data/{README.rdoc → README.md} +66 -61
  4. data/Rakefile +4 -6
  5. data/changelog.txt +491 -0
  6. data/docs/about/users.markdown +1 -0
  7. data/fog.gemspec +4 -4
  8. data/lib/fog.rb +1 -1
  9. data/lib/fog/aws.rb +4 -0
  10. data/lib/fog/aws/auto_scaling.rb +3 -0
  11. data/lib/fog/aws/cloud_watch.rb +28 -0
  12. data/lib/fog/aws/compute.rb +7 -1
  13. data/lib/fog/aws/elasticache.rb +64 -6
  14. data/lib/fog/aws/models/auto_scaling/configuration.rb +3 -1
  15. data/lib/fog/aws/models/auto_scaling/group.rb +10 -9
  16. data/lib/fog/aws/models/auto_scaling/policies.rb +33 -0
  17. data/lib/fog/aws/models/auto_scaling/policy.rb +46 -0
  18. data/lib/fog/aws/models/cloud_watch/alarm.rb +50 -2
  19. data/lib/fog/aws/models/cloud_watch/alarms.rb +18 -1
  20. data/lib/fog/aws/models/compute/address.rb +2 -2
  21. data/lib/fog/aws/models/dns/records.rb +5 -0
  22. data/lib/fog/aws/models/elasticache/cluster.rb +1 -1
  23. data/lib/fog/aws/models/iam/users.rb +26 -4
  24. data/lib/fog/aws/parsers/auto_scaling/describe_policies.rb +7 -5
  25. data/lib/fog/aws/parsers/elb/describe_load_balancers.rb +1 -1
  26. data/lib/fog/aws/rds.rb +1 -1
  27. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  28. data/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +1 -2
  29. data/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb +10 -2
  30. data/lib/fog/aws/requests/auto_scaling/delete_launch_configuration.rb +1 -1
  31. data/lib/fog/aws/requests/auto_scaling/delete_policy.rb +10 -1
  32. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb +0 -1
  33. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +13 -1
  34. data/lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb +20 -1
  35. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +1 -1
  36. data/lib/fog/aws/requests/cloud_watch/delete_alarms.rb +19 -1
  37. data/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +20 -2
  38. data/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +9 -0
  39. data/lib/fog/aws/requests/compute/allocate_address.rb +4 -5
  40. data/lib/fog/aws/requests/compute/create_dhcp_options.rb +6 -5
  41. data/lib/fog/aws/requests/compute/create_internet_gateway.rb +7 -6
  42. data/lib/fog/aws/requests/compute/create_subnet.rb +11 -10
  43. data/lib/fog/aws/requests/compute/create_vpc.rb +8 -7
  44. data/lib/fog/aws/requests/compute/delete_dhcp_options.rb +1 -0
  45. data/lib/fog/aws/requests/compute/delete_internet_gateway.rb +1 -0
  46. data/lib/fog/aws/requests/compute/delete_subnet.rb +1 -0
  47. data/lib/fog/aws/requests/compute/delete_vpc.rb +2 -1
  48. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +1 -0
  49. data/lib/fog/aws/requests/compute/describe_dhcp_options.rb +1 -8
  50. data/lib/fog/aws/requests/compute/describe_instances.rb +3 -1
  51. data/lib/fog/aws/requests/compute/describe_internet_gateways.rb +1 -8
  52. data/lib/fog/aws/requests/compute/describe_subnets.rb +1 -9
  53. data/lib/fog/aws/requests/compute/describe_vpcs.rb +1 -8
  54. data/lib/fog/aws/requests/compute/release_address.rb +12 -4
  55. data/lib/fog/aws/requests/compute/start_instances.rb +1 -0
  56. data/lib/fog/aws/requests/compute/stop_instances.rb +1 -0
  57. data/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +26 -2
  58. data/lib/fog/aws/requests/elasticache/delete_cache_cluster.rb +10 -1
  59. data/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb +16 -1
  60. data/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb +35 -3
  61. data/lib/fog/aws/requests/elasticache/reboot_cache_cluster.rb +10 -2
  62. data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
  63. data/lib/fog/aws/requests/rds/describe_db_instances.rb +3 -3
  64. data/lib/fog/aws/sqs.rb +1 -1
  65. data/lib/fog/aws/storage.rb +1 -1
  66. data/lib/fog/bin/rackspace.rb +4 -0
  67. data/lib/fog/cloudstack/compute.rb +25 -18
  68. data/lib/fog/cloudstack/models/compute/image.rb +34 -34
  69. data/lib/fog/cloudstack/models/compute/job.rb +14 -1
  70. data/lib/fog/cloudstack/models/compute/jobs.rb +1 -1
  71. data/lib/fog/cloudstack/models/compute/security_group.rb +50 -0
  72. data/lib/fog/cloudstack/models/compute/security_group_rule.rb +62 -0
  73. data/lib/fog/cloudstack/models/compute/security_group_rules.rb +37 -0
  74. data/lib/fog/cloudstack/models/compute/security_groups.rb +27 -0
  75. data/lib/fog/cloudstack/models/compute/server.rb +63 -39
  76. data/lib/fog/cloudstack/models/compute/volume.rb +3 -7
  77. data/lib/fog/cloudstack/models/compute/zone.rb +1 -2
  78. data/lib/fog/cloudstack/requests/compute/assign_virtual_machine.rb +18 -0
  79. data/lib/fog/cloudstack/requests/compute/authorize_security_group_egress.rb +68 -0
  80. data/lib/fog/cloudstack/requests/compute/authorize_security_group_ingress.rb +55 -4
  81. data/lib/fog/cloudstack/requests/compute/create_security_group.rb +12 -4
  82. data/lib/fog/cloudstack/requests/compute/create_zone.rb +20 -0
  83. data/lib/fog/cloudstack/requests/compute/delete_security_group.rb +17 -0
  84. data/lib/fog/cloudstack/requests/compute/destroy_virtual_machine.rb +23 -1
  85. data/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb +15 -0
  86. data/lib/fog/cloudstack/requests/compute/list_security_groups.rb +22 -4
  87. data/lib/fog/cloudstack/requests/compute/query_async_job_result.rb +15 -3
  88. data/lib/fog/cloudstack/requests/compute/revoke_security_group_egress.rb +42 -0
  89. data/lib/fog/cloudstack/requests/compute/revoke_security_group_ingress.rb +29 -3
  90. data/lib/fog/core.rb +1 -0
  91. data/lib/fog/core/attributes.rb +1 -1
  92. data/lib/fog/core/current_machine.rb +2 -2
  93. data/lib/fog/core/scp.rb +8 -0
  94. data/lib/fog/core/ssh.rb +8 -0
  95. data/lib/fog/dynect/dns.rb +14 -5
  96. data/lib/fog/ibm/requests/compute/create_instance.rb +1 -1
  97. data/lib/fog/libvirt/requests/compute/create_volume.rb +1 -1
  98. data/lib/fog/libvirt/requests/compute/list_volumes.rb +1 -1
  99. data/lib/fog/local/models/storage/file.rb +12 -1
  100. data/lib/fog/local/storage.rb +25 -1
  101. data/lib/fog/ninefold/compute.rb +1 -0
  102. data/lib/fog/openstack.rb +3 -1
  103. data/lib/fog/openstack/compute.rb +13 -2
  104. data/lib/fog/openstack/models/compute/servers.rb +10 -2
  105. data/lib/fog/openstack/requests/compute/create_flavor.rb +2 -2
  106. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  107. data/lib/fog/openstack/requests/compute/create_server.rb +1 -1
  108. data/lib/fog/openstack/requests/compute/create_volume.rb +1 -1
  109. data/lib/fog/openstack/requests/compute/get_flavor_details.rb +7 -7
  110. data/lib/fog/openstack/requests/compute/get_quota.rb +1 -12
  111. data/lib/fog/openstack/requests/compute/get_quota_defaults.rb +1 -12
  112. data/lib/fog/openstack/requests/compute/get_volume_details.rb +1 -1
  113. data/lib/fog/openstack/requests/compute/list_flavors.rb +7 -7
  114. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +7 -7
  115. data/lib/fog/openstack/requests/compute/list_security_groups.rb +7 -7
  116. data/lib/fog/openstack/requests/compute/list_servers_detail.rb +4 -3
  117. data/lib/fog/openstack/requests/compute/list_volumes.rb +6 -8
  118. data/lib/fog/openstack/requests/compute/update_quota.rb +2 -15
  119. data/lib/fog/openstack/requests/identity/delete_role.rb +1 -1
  120. data/lib/fog/openstack/requests/identity/list_roles.rb +1 -1
  121. data/lib/fog/openstack/requests/image/create_image.rb +3 -1
  122. data/lib/fog/openstack/requests/image/list_public_images.rb +19 -1
  123. data/lib/fog/openstack/requests/image/list_public_images_detailed.rb +20 -2
  124. data/lib/fog/openstack/requests/image/update_image.rb +1 -1
  125. data/lib/fog/rackspace.rb +2 -0
  126. data/lib/fog/rackspace/databases.rb +121 -0
  127. data/lib/fog/rackspace/identity.rb +83 -0
  128. data/lib/fog/rackspace/load_balancers.rb +3 -0
  129. data/lib/fog/rackspace/models/databases/database.rb +32 -0
  130. data/lib/fog/rackspace/models/databases/databases.rb +31 -0
  131. data/lib/fog/rackspace/models/databases/flavor.rb +15 -0
  132. data/lib/fog/rackspace/models/databases/flavors.rb +25 -0
  133. data/lib/fog/rackspace/models/databases/instance.rb +104 -0
  134. data/lib/fog/rackspace/models/databases/instances.rb +25 -0
  135. data/lib/fog/rackspace/models/databases/user.rb +32 -0
  136. data/lib/fog/rackspace/models/databases/users.rb +31 -0
  137. data/lib/fog/rackspace/models/identity/credential.rb +13 -0
  138. data/lib/fog/rackspace/models/identity/credentials.rb +32 -0
  139. data/lib/fog/rackspace/models/identity/role.rb +14 -0
  140. data/lib/fog/rackspace/models/identity/roles.rb +32 -0
  141. data/lib/fog/rackspace/models/identity/tenant.rb +15 -0
  142. data/lib/fog/rackspace/models/identity/tenants.rb +28 -0
  143. data/lib/fog/rackspace/models/identity/user.rb +53 -0
  144. data/lib/fog/rackspace/models/identity/users.rb +36 -0
  145. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +17 -0
  146. data/lib/fog/rackspace/requests/databases/check_root_user.rb +15 -0
  147. data/lib/fog/rackspace/requests/databases/create_database.rb +24 -0
  148. data/lib/fog/rackspace/requests/databases/create_instance.rb +26 -0
  149. data/lib/fog/rackspace/requests/databases/create_user.rb +24 -0
  150. data/lib/fog/rackspace/requests/databases/delete_database.rb +15 -0
  151. data/lib/fog/rackspace/requests/databases/delete_instance.rb +15 -0
  152. data/lib/fog/rackspace/requests/databases/delete_user.rb +15 -0
  153. data/lib/fog/rackspace/requests/databases/enable_root_user.rb +15 -0
  154. data/lib/fog/rackspace/requests/databases/get_flavor.rb +15 -0
  155. data/lib/fog/rackspace/requests/databases/get_instance.rb +15 -0
  156. data/lib/fog/rackspace/requests/databases/list_databases.rb +15 -0
  157. data/lib/fog/rackspace/requests/databases/list_flavors.rb +15 -0
  158. data/lib/fog/rackspace/requests/databases/list_instances.rb +15 -0
  159. data/lib/fog/rackspace/requests/databases/list_users.rb +15 -0
  160. data/lib/fog/rackspace/requests/databases/resize_instance.rb +22 -0
  161. data/lib/fog/rackspace/requests/databases/resize_instance_volume.rb +24 -0
  162. data/lib/fog/rackspace/requests/databases/restart_instance.rb +20 -0
  163. data/lib/fog/rackspace/requests/identity/create_token.rb +25 -0
  164. data/lib/fog/rackspace/requests/identity/create_user.rb +25 -0
  165. data/lib/fog/rackspace/requests/identity/delete_user.rb +15 -0
  166. data/lib/fog/rackspace/requests/identity/get_credentials.rb +15 -0
  167. data/lib/fog/rackspace/requests/identity/get_user_by_id.rb +15 -0
  168. data/lib/fog/rackspace/requests/identity/get_user_by_name.rb +15 -0
  169. data/lib/fog/rackspace/requests/identity/list_credentials.rb +22 -0
  170. data/lib/fog/rackspace/requests/identity/list_tenants.rb +22 -0
  171. data/lib/fog/rackspace/requests/identity/list_user_roles.rb +22 -0
  172. data/lib/fog/rackspace/requests/identity/list_users.rb +22 -0
  173. data/lib/fog/rackspace/requests/identity/update_user.rb +24 -0
  174. data/lib/fog/rackspace/requests/load_balancers/get_ssl_termination.rb +15 -0
  175. data/lib/fog/rackspace/requests/load_balancers/remove_ssl_termination.rb +15 -0
  176. data/lib/fog/rackspace/requests/load_balancers/set_ssl_termination.rb +31 -0
  177. data/lib/fog/rackspace/storage.rb +1 -1
  178. data/lib/fog/vsphere/models/compute/server.rb +1 -0
  179. data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -2
  180. data/tests/aws/models/compute/address_tests.rb +2 -1
  181. data/tests/aws/models/compute/volume_tests.rb +1 -1
  182. data/tests/aws/models/dns/records_tests.rb +19 -1
  183. data/tests/aws/models/storage/directory_tests.rb +1 -1
  184. data/tests/aws/models/storage/url_tests.rb +7 -1
  185. data/tests/aws/requests/auto_scaling/auto_scaling_tests.rb +4 -2
  186. data/tests/aws/requests/compute/address_tests.rb +19 -1
  187. data/tests/aws/requests/elasticache/cache_cluster_tests.rb +4 -4
  188. data/tests/aws/requests/elb/helper.rb +13 -2
  189. data/tests/aws/requests/iam/access_key_tests.rb +1 -3
  190. data/tests/cloudstack/compute/models/security_group_rule_tests.rb +29 -0
  191. data/tests/cloudstack/compute/models/security_group_tests.rb +16 -0
  192. data/tests/cloudstack/compute/models/security_groups_tests.rb +19 -0
  193. data/tests/cloudstack/compute/models/server_tests.rb +18 -0
  194. data/tests/cloudstack/compute/models/volume_tests.rb +34 -0
  195. data/tests/cloudstack/compute/models/volumes_tests.rb +17 -0
  196. data/tests/compute/helper.rb +10 -3
  197. data/tests/core/current_machine_tests.rb +32 -0
  198. data/tests/helper.rb +1 -1
  199. data/tests/helpers/mock_helper.rb +3 -0
  200. data/tests/hp/requests/compute/address_tests.rb +2 -1
  201. data/tests/joyent/requests/compute/datasets_tests.rb +12 -3
  202. data/tests/local/models/file_tests.rb +43 -0
  203. data/tests/local/storage_tests.rb +40 -0
  204. data/tests/openstack/requests/compute/flavor_tests.rb +1 -1
  205. data/tests/openstack/requests/compute/server_tests.rb +3 -3
  206. data/tests/openstack/requests/compute/volume_tests.rb +1 -1
  207. data/tests/openstack/requests/identity/role_tests.rb +1 -1
  208. data/tests/rackspace/databases_tests.rb +26 -0
  209. data/tests/rackspace/models/databases/database_tests.rb +17 -0
  210. data/tests/rackspace/models/databases/databases_tests.rb +17 -0
  211. data/tests/rackspace/models/databases/flavors_tests.rb +20 -0
  212. data/tests/rackspace/models/databases/instance_tests.rb +43 -0
  213. data/tests/rackspace/models/databases/instances_tests.rb +14 -0
  214. data/tests/rackspace/models/databases/user_tests.rb +21 -0
  215. data/tests/rackspace/models/databases/users_tests.rb +21 -0
  216. data/tests/rackspace/models/identity/credentials_tests.rb +16 -0
  217. data/tests/rackspace/models/identity/roles_tests.rb +16 -0
  218. data/tests/rackspace/models/identity/tenants_tests.rb +21 -0
  219. data/tests/rackspace/models/identity/user_tests.rb +17 -0
  220. data/tests/rackspace/models/identity/users_tests.rb +17 -0
  221. data/tests/rackspace/models/load_balancers/load_balancer_tests.rb +20 -0
  222. data/tests/rackspace/requests/databases/database_tests.rb +36 -0
  223. data/tests/rackspace/requests/databases/flavor_tests.rb +16 -0
  224. data/tests/rackspace/requests/databases/helper.rb +84 -0
  225. data/tests/rackspace/requests/databases/instance_tests.rb +77 -0
  226. data/tests/rackspace/requests/databases/user_tests.rb +37 -0
  227. data/tests/rackspace/requests/identity/tenants_tests.rb +21 -0
  228. data/tests/rackspace/requests/identity/token_tests.rb +63 -0
  229. data/tests/rackspace/requests/identity/user_tests.rb +107 -0
  230. data/tests/rackspace/requests/load_balancers/helper.rb +70 -1
  231. data/tests/rackspace/requests/load_balancers/ssl_termination_tests.rb +38 -0
  232. data/tests/storage/models/file_tests.rb +1 -1
  233. metadata +129 -13
  234. data/spec/core/current_machine_spec.rb +0 -32
  235. data/spec/lib/fog/aws/parsers/sqs/receive_message_spec.rb +0 -58
  236. data/spec/spec_helper.rb +0 -8
@@ -22,7 +22,7 @@ module Fog
22
22
  def destroy
23
23
  requires :public_ip
24
24
 
25
- connection.release_address(public_ip)
25
+ connection.release_address(allocation_id || public_ip)
26
26
  true
27
27
  end
28
28
 
@@ -33,7 +33,7 @@ module Fog
33
33
  disassociate
34
34
  end
35
35
  end
36
-
36
+
37
37
  def server
38
38
  connection.servers.get(server_id)
39
39
  end
@@ -44,6 +44,11 @@ module Fog
44
44
  def all!
45
45
  data = []
46
46
 
47
+ merge_attributes({'NextRecordName' => nil,
48
+ 'NextRecordType' => nil,
49
+ 'NextRecordIdentifier' => nil,
50
+ 'IsTruncated' => nil})
51
+
47
52
  begin
48
53
  options = {
49
54
  :name => next_record_name,
@@ -53,7 +53,7 @@ module Fog
53
53
  :auto_minor_version_upgrade => auto_upgrade,
54
54
  :engine => engine,
55
55
  :engine_version => engine_version,
56
- :notification_topic_arn => (notification_config['TopicArn']).strip,
56
+ :notification_topic_arn => notification_config['TopicArn'],
57
57
  :port => port,
58
58
  :preferred_availablility_zone => zone,
59
59
  :preferred_maintenance_window => maintenance_window,
@@ -7,11 +7,16 @@ module Fog
7
7
 
8
8
  class Users < Fog::Collection
9
9
 
10
+ attribute :is_truncated, :aliases => 'IsTruncated'
11
+ attribute :marker, :aliases => 'Marker'
12
+
10
13
  model Fog::AWS::IAM::User
11
14
 
12
- def all
13
- data = connection.list_users.body['Users']
14
- load(data) # data is an array of attribute hashes
15
+ def all(options = {})
16
+ merge_attributes(options)
17
+ data = connection.list_users(options).body
18
+ merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'])
19
+ load(data['Users']) # data is an array of attribute hashes
15
20
  end
16
21
 
17
22
  def get(identity)
@@ -21,7 +26,24 @@ module Fog
21
26
  nil
22
27
  end
23
28
 
29
+ alias :each_user_this_page :each
30
+
31
+ def each
32
+ if !block_given?
33
+ self
34
+ else
35
+ subset = dup.all
36
+
37
+ subset.each_user_this_page {|f| yield f}
38
+ while subset.is_truncated
39
+ subset = subset.all('Marker' => subset.marker, 'MaxItems' => 1000)
40
+ subset.each_user_this_page {|f| yield f}
41
+ end
42
+
43
+ self
44
+ end
45
+ end
24
46
  end
25
47
  end
26
48
  end
27
- end
49
+ end
@@ -49,13 +49,15 @@ module Fog
49
49
  @response['DescribePoliciesResult'] = @results
50
50
 
51
51
  when 'Alarms'
52
- if @in_alarms == true
52
+ @in_alarms = false
53
+ when 'member'
54
+ if @in_alarms
53
55
  @scaling_policy['Alarms'] << @alarm
54
56
  reset_alarm
55
- end
56
- when 'member'
57
- @results['ScalingPolicies'] << @scaling_policy
58
- reset_scaling_policy
57
+ else
58
+ @results['ScalingPolicies'] << @scaling_policy
59
+ reset_scaling_policy
60
+ end
59
61
  end
60
62
  end
61
63
 
@@ -83,7 +83,7 @@ module Fog
83
83
  @in_listeners = false
84
84
  when 'PolicyNames'
85
85
  @in_policy_names = false
86
- when 'Protocol', 'SSLCertificateId'
86
+ when 'Protocol', 'SSLCertificateId', 'InstanceProtocol'
87
87
  @listener_description['Listener'][name] = value
88
88
  when 'LoadBalancerPort', 'InstancePort'
89
89
  @listener_description['Listener'][name] = value.to_i
data/lib/fog/aws/rds.rb CHANGED
@@ -90,7 +90,7 @@ module Fog
90
90
  @use_iam_profile = options[:use_iam_profile]
91
91
  @region = options[:region] || 'us-east-1'
92
92
 
93
- unless ['ap-northeast-1', 'ap-southeast-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2'].include?(@region)
93
+ unless ['ap-northeast-1', 'ap-southeast-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
94
94
  raise ArgumentError, "Unknown region: #{@region.inspect}"
95
95
  end
96
96
 
@@ -49,9 +49,17 @@ module Fog
49
49
  #
50
50
  def create_auto_scaling_group(auto_scaling_group_name, availability_zones, launch_configuration_name, max_size, min_size, options = {})
51
51
  options.merge!(AWS.indexed_param('AvailabilityZones.member.%d', [*availability_zones]))
52
+ options.delete('AvailabilityZones')
52
53
  if load_balancer_names = options.delete('LoadBalancerNames')
53
54
  options.merge!(AWS.indexed_param('LoadBalancerNames.member.%d', [*load_balancer_names]))
54
55
  end
56
+ if tags = options.delete('Tags')
57
+ tags.each_with_index do |tag, i|
58
+ tag.each do |key, value|
59
+ options["Tags.member.#{i + 1}.#{key.to_s.capitalize}"] = value
60
+ end
61
+ end
62
+ end
55
63
  request({
56
64
  'Action' => 'CreateAutoScalingGroup',
57
65
  'AutoScalingGroupName' => auto_scaling_group_name,
@@ -78,9 +78,8 @@ module Fog
78
78
  data[:launch_configurations][launch_configuration_name] = {
79
79
  'BlockDeviceMappings' => [],
80
80
  'CreatedTime' => Time.now.utc,
81
- 'IamInstanceProfile' => nil,
82
81
  'ImageId' => image_id,
83
- 'InstanceMonitoring.Enabled' => true,
82
+ 'InstanceMonitoring' => {'Enabled' => true},
84
83
  'InstanceType' => instance_type,
85
84
  'KernelId' => nil,
86
85
  'KeyName' => nil,
@@ -35,9 +35,17 @@ module Fog
35
35
  class Mock
36
36
 
37
37
  def delete_auto_scaling_group(auto_scaling_group_name)
38
- Fog::Mock.not_implemented
38
+ unless self.data[:auto_scaling_groups].delete(auto_scaling_group_name)
39
+ raise Fog::AWS::Autoscaling::NotFound, "The auto scaling group '#{auto_scaling_group_name}' does not exist."
40
+ end
41
+
42
+ response = Excon::Response.new
43
+ response.status = 200
44
+ response.body = {
45
+ 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
46
+ }
47
+ response
39
48
  end
40
-
41
49
  end
42
50
 
43
51
  end
@@ -39,7 +39,7 @@ module Fog
39
39
 
40
40
  def delete_launch_configuration(launch_configuration_name)
41
41
  unless self.data[:launch_configurations].delete(launch_configuration_name)
42
- raise Fog::AWS::AutoScaling::ValidationError, "Launch configuration name not found - Launch configuration #{launch_configuration_name} not found"
42
+ raise Fog::AWS::AutoScaling::NotFound, "The launch configuration '#{launch_configuration_name}' does not exist."
43
43
  end
44
44
 
45
45
  response = Excon::Response.new
@@ -37,7 +37,16 @@ module Fog
37
37
  class Mock
38
38
 
39
39
  def delete_policy(auto_scaling_group_name, policy_name)
40
- Fog::Mock.not_implemented
40
+ unless data[:scaling_policies].delete(policy_name)
41
+ raise Fog::AWS::AutoScaling::NotFound, "The scaling policy '#{policy_name}' does not exist."
42
+ end
43
+
44
+ response = Excon::Response.new
45
+ response.status = 200
46
+ response.body = {
47
+ 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
48
+ }
49
+ response
41
50
  end
42
51
 
43
52
  end
@@ -73,7 +73,6 @@ module Fog
73
73
  def describe_auto_scaling_instances(options = {})
74
74
  results = { 'AutoScalingInstances' => [] }
75
75
  data[:auto_scaling_groups].each do |asg_name, asg_data|
76
- lc_name = data[asg_data][lc_name]
77
76
  asg_data['Instances'].each do |instance|
78
77
  results['AutoScalingInstances'] << {
79
78
  'AutoScalingGroupName' => asg_name
@@ -75,7 +75,19 @@ module Fog
75
75
  class Mock
76
76
 
77
77
  def describe_policies(options = {})
78
- Fog::Mock.not_implemented
78
+ results = { 'ScalingPolicies' => [] }
79
+ data[:scaling_policies].each do |asp_name, asp_data|
80
+ results['ScalingPolicies'] << {
81
+ 'PolicyName' => asp_name
82
+ }.merge!(asp_data)
83
+ end
84
+ response = Excon::Response.new
85
+ response.status = 200
86
+ response.body = {
87
+ 'DescribePoliciesResult' => results,
88
+ 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
89
+ }
90
+ response
79
91
  end
80
92
 
81
93
  end
@@ -56,7 +56,26 @@ module Fog
56
56
  class Mock
57
57
 
58
58
  def put_scaling_policy(adjustment_type, auto_scaling_group_name, policy_name, scaling_adjustment, options = {})
59
- Fog::Mock.not_implemented
59
+ unless data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
60
+ raise Fog::AWS::AutoScaling::ValidationError.new('Auto Scaling Group name not found - null')
61
+ end
62
+ data[:scaling_policies][policy_name] = {
63
+ 'AdjustmentType' => adjustment_type,
64
+ 'Alarms' => [],
65
+ 'AutoScalingGroupName' => auto_scaling_group_name,
66
+ 'Cooldown' => 0,
67
+ 'MinAdjustmentStep' => 0,
68
+ 'PolicyARN' => "arn:aws:autoscaling:eu-west-1:000000000000:scalingPolicy:00000000-0000-0000-0000-000000000000:autoScalingGroupName/#{auto_scaling_group_name}:policyName/#{policy_name}",
69
+ 'PolicyName' => policy_name,
70
+ 'ScalingAdjustment' => scaling_adjustment
71
+ }.merge!(options)
72
+
73
+ response = Excon::Response.new
74
+ response.status = 200
75
+ response.body = {
76
+ 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
77
+ }
78
+ response
60
79
  end
61
80
 
62
81
  end
@@ -62,7 +62,7 @@ module Fog
62
62
  unless data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
63
63
  raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null')
64
64
  end
65
- data[:auto_scaling_group_name][auto_scaling_group_name].merge!(options)
65
+ data[:auto_scaling_groups][auto_scaling_group_name].merge!(options)
66
66
 
67
67
  response = Excon::Response.new
68
68
  response.status = 200
@@ -24,7 +24,25 @@ module Fog
24
24
  :parser => Fog::Parsers::AWS::CloudWatch::DeleteAlarms.new
25
25
  }.merge(options))
26
26
  end
27
- end
27
+ end
28
+
29
+ class Mock
30
+ def delete_alarms(alarm_names)
31
+ [*alarm_names].each do |alarm_name|
32
+ unless data[:metric_alarms].has_key?(alarm_name)
33
+ raise Fog::AWS::AutoScaling::NotFound, "The alarm '#{alarm_name}' does not exist."
34
+ end
35
+ end
36
+
37
+ [*alarm_names].each { |alarm_name| data[:metric_alarms].delete(alarm_name) }
38
+ response = Excon::Response.new
39
+ response.status = 200
40
+ response.body = {
41
+ 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
42
+ }
43
+ response
44
+ end
45
+ end
28
46
  end
29
47
  end
30
48
  end
@@ -1,7 +1,7 @@
1
1
  module Fog
2
2
  module AWS
3
3
  class CloudWatch
4
- class Real
4
+ class Real
5
5
 
6
6
  require 'fog/aws/parsers/cloud_watch/describe_alarms'
7
7
 
@@ -32,7 +32,25 @@ module Fog
32
32
  :parser => Fog::Parsers::AWS::CloudWatch::DescribeAlarms.new
33
33
  }.merge(options))
34
34
  end
35
- end
35
+ end
36
+
37
+ class Mock
38
+ def describe_alarms(options={})
39
+ results = { 'MetricAlarms' => [] }
40
+ data[:metric_alarms].each do |alarm_name, alarm_data|
41
+ results['MetricAlarms'] << {
42
+ 'AlarmName' => alarm_name
43
+ }.merge!(alarm_data)
44
+ end
45
+ response = Excon::Response.new
46
+ response.status = 200
47
+ response.body = {
48
+ 'DescribeAlarmsResult' => results,
49
+ 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
50
+ }
51
+ response
52
+ end
53
+ end
36
54
  end
37
55
  end
38
56
  end
@@ -71,6 +71,15 @@ module Fog
71
71
  end
72
72
  end
73
73
 
74
+ data[:metric_alarms][options['AlarmName']] = {
75
+ 'AlarmARN' => "arn:aws:cloudwatch:eu-west-1:000000000000:metricAlarm:00000000-0000-0000-0000-000000000000:alarmName/#{options['AlarmName']}",
76
+ 'ActionsEnabled' => false,
77
+ 'AlarmActions' => [],
78
+ 'AlarmConfigurationUpdatedTimestamp' => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
79
+ 'Dimensions' => [],
80
+ 'OKActions' => [],
81
+ }.merge!(options)
82
+
74
83
  response = Excon::Response.new
75
84
  response.status = 200
76
85
  response.body = {
@@ -40,12 +40,11 @@ module Fog
40
40
  'publicIp' => public_ip,
41
41
  'domain' => domain
42
42
  }
43
+ if domain == 'vpc'
44
+ data['allocationId'] = "eipalloc-#{Fog::Mock.random_hex(8)}"
45
+ end
43
46
  self.data[:addresses][public_ip] = data
44
- response.body = {
45
- 'domain' => domain,
46
- 'publicIp' => public_ip,
47
- 'requestId' => Fog::AWS::Mock.request_id
48
- }
47
+ response.body = data.reject {|k, v| k == 'instanceId' }.merge('requestId' => Fog::AWS::Mock.request_id)
49
48
  response
50
49
  else
51
50
  response.status = 400
@@ -45,13 +45,14 @@ module Fog
45
45
  params.merge!(indexed_multidimensional_params(dhcp_configurations))
46
46
  Excon::Response.new.tap do |response|
47
47
  response.status = 200
48
+ self.data[:dhcp_options].push({
49
+ 'dhcpOptionsId' => Fog::AWS::Mock.dhcp_options_id,
50
+ 'dhcpConfigurationSet' => {},
51
+ 'tagSet' => {}
52
+ })
48
53
  response.body = {
49
54
  'requestId' => Fog::AWS::Mock.request_id,
50
- 'dhcpOptionsSet' => [
51
- 'dhcpOptionsId' => Fog::AWS::Mock.dhcp_options_id,
52
- 'dhcpConfigurationSet' => {},
53
- 'tagSet' => {}
54
- ]
55
+ 'dhcpOptionsSet' => self.data[:dhcp_options]
55
56
  }
56
57
  end
57
58
  end
@@ -33,15 +33,16 @@ module Fog
33
33
 
34
34
  class Mock
35
35
  def create_internet_gateway()
36
- Excon::Response.new(
36
+ self.data[:internet_gateways].push({
37
+ 'internetGatewayId' => Fog::AWS::Mock.request_id,
38
+ 'attachmentSet' => {},
39
+ 'tagSet' => {}
40
+ })
41
+ Excon::Response.new(
37
42
  :status => 200,
38
43
  :body => {
39
44
  'requestId' => Fog::AWS::Mock.request_id,
40
- 'internetGatewaySet' => [
41
- 'internetGatewayId' => Fog::AWS::Mock.request_id,
42
- 'attachmentSet' => {},
43
- 'tagSet' => {}
44
- ]
45
+ 'internetGatewaySet' => self.data[:internet_gateways]
45
46
  }
46
47
  )
47
48
  end
@@ -46,18 +46,19 @@ module Fog
46
46
  Excon::Response.new.tap do |response|
47
47
  if cidrBlock && vpcId
48
48
  response.status = 200
49
-
49
+ self.data[:subnets].push({
50
+ 'subnetId' => Fog::AWS::Mock.request_id,
51
+ 'state' => 'pending',
52
+ 'vpcId' => Fog::AWS::Mock.request_id,
53
+ 'cidrBlock' => cidrBlock,
54
+ 'availableIpAddressCount' => "255",
55
+ 'availabilityZone' => av_zone,
56
+ 'tagSet' => {}
57
+ })
58
+
50
59
  response.body = {
51
60
  'requestId' => Fog::AWS::Mock.request_id,
52
- 'subnetSet' => [
53
- 'subnetId' => Fog::AWS::Mock.request_id,
54
- 'state' => 'pending',
55
- 'vpcId' => Fog::AWS::Mock.request_id,
56
- 'cidrBlock' => cidrBlock,
57
- 'availableIpAddressCount' => 16,
58
- 'availabilityZone' => av_zone,
59
- 'tagSet' => {}
60
- ]
61
+ 'subnetSet' => self.data[:subnets]
61
62
  }
62
63
  else
63
64
  response.status = 400