fog 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. data/README.rdoc +2 -9
  2. data/Rakefile +3 -2
  3. data/docs/_layouts/default.html +13 -13
  4. data/docs/about/contributing.markdown +1 -1
  5. data/docs/about/getting_started.markdown +28 -3
  6. data/docs/dns/index.markdown +4 -4
  7. data/docs/index.markdown +2 -10
  8. data/docs/public/css/fog.css +14 -1
  9. data/docs/storage/index.markdown +2 -2
  10. data/fog.gemspec +6 -5
  11. data/lib/fog.rb +1 -1
  12. data/lib/fog/aws.rb +26 -1
  13. data/lib/fog/aws/auto_scaling.rb +3 -1
  14. data/lib/fog/aws/cloud_formation.rb +3 -0
  15. data/lib/fog/aws/cloud_watch.rb +17 -1
  16. data/lib/fog/aws/compute.rb +50 -18
  17. data/lib/fog/aws/elb.rb +4 -2
  18. data/lib/fog/aws/emr.rb +133 -0
  19. data/lib/fog/aws/models/cloud_watch/alarm.rb +12 -0
  20. data/lib/fog/aws/models/cloud_watch/alarm_data.rb +39 -0
  21. data/lib/fog/aws/models/cloud_watch/alarm_datum.rb +66 -0
  22. data/lib/fog/aws/models/cloud_watch/alarm_histories.rb +18 -0
  23. data/lib/fog/aws/models/cloud_watch/alarm_history.rb +16 -0
  24. data/lib/fog/aws/models/cloud_watch/alarms.rb +30 -0
  25. data/lib/fog/aws/models/compute/addresses.rb +1 -1
  26. data/lib/fog/aws/models/compute/key_pairs.rb +1 -1
  27. data/lib/fog/aws/models/compute/security_groups.rb +1 -1
  28. data/lib/fog/aws/models/compute/server.rb +4 -2
  29. data/lib/fog/aws/models/compute/servers.rb +1 -1
  30. data/lib/fog/aws/models/compute/snapshots.rb +1 -1
  31. data/lib/fog/aws/models/compute/spot_request.rb +21 -4
  32. data/lib/fog/aws/models/compute/spot_requests.rb +45 -1
  33. data/lib/fog/aws/models/compute/volumes.rb +1 -1
  34. data/lib/fog/aws/models/elb/load_balancer.rb +2 -0
  35. data/lib/fog/aws/models/storage/file.rb +1 -1
  36. data/lib/fog/aws/parsers/cdn/get_invalidation_list.rb +0 -1
  37. data/lib/fog/aws/parsers/cloud_formation/update_stack.rb +19 -0
  38. data/lib/fog/aws/parsers/cloud_watch/delete_alarms.rb +26 -0
  39. data/lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb +40 -0
  40. data/lib/fog/aws/parsers/cloud_watch/describe_alarms.rb +73 -0
  41. data/lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb +71 -0
  42. data/lib/fog/aws/parsers/cloud_watch/disable_alarm_actions.rb +26 -0
  43. data/lib/fog/aws/parsers/cloud_watch/enable_alarm_actions.rb +26 -0
  44. data/lib/fog/aws/parsers/cloud_watch/get_metric_statistics.rb +1 -0
  45. data/lib/fog/aws/parsers/cloud_watch/put_metric_alarm.rb +26 -0
  46. data/lib/fog/aws/parsers/cloud_watch/set_alarm_state.rb +26 -0
  47. data/lib/fog/aws/parsers/compute/spot_instance_requests.rb +2 -2
  48. data/lib/fog/aws/parsers/emr/add_instance_groups.rb +28 -0
  49. data/lib/fog/aws/parsers/emr/add_job_flow_steps.rb +17 -0
  50. data/lib/fog/aws/parsers/emr/describe_job_flows.rb +140 -0
  51. data/lib/fog/aws/parsers/emr/modify_instance_groups.rb +17 -0
  52. data/lib/fog/aws/parsers/emr/run_job_flow.rb +19 -0
  53. data/lib/fog/aws/parsers/emr/set_termination_protection.rb +17 -0
  54. data/lib/fog/aws/parsers/emr/terminate_job_flows.rb +17 -0
  55. data/lib/fog/aws/rds.rb +3 -1
  56. data/lib/fog/aws/requests/cloud_formation/create_stack.rb +6 -0
  57. data/lib/fog/aws/requests/cloud_formation/update_stack.rb +62 -0
  58. data/lib/fog/aws/requests/cloud_watch/delete_alarms.rb +30 -0
  59. data/lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb +33 -0
  60. data/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +38 -0
  61. data/lib/fog/aws/requests/cloud_watch/describe_alarms_for_metric.rb +39 -0
  62. data/lib/fog/aws/requests/cloud_watch/disable_alarm_actions.rb +30 -0
  63. data/lib/fog/aws/requests/cloud_watch/enable_alarm_actions.rb +30 -0
  64. data/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +84 -0
  65. data/lib/fog/aws/requests/cloud_watch/set_alarm_state.rb +31 -0
  66. data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +141 -36
  67. data/lib/fog/aws/requests/compute/create_snapshot.rb +2 -3
  68. data/lib/fog/aws/requests/compute/create_tags.rb +5 -3
  69. data/lib/fog/aws/requests/compute/create_volume.rb +0 -1
  70. data/lib/fog/aws/requests/compute/delete_security_group.rb +25 -0
  71. data/lib/fog/aws/requests/compute/delete_tags.rb +3 -4
  72. data/lib/fog/aws/requests/compute/describe_addresses.rb +2 -2
  73. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +5 -2
  74. data/lib/fog/aws/requests/compute/describe_images.rb +6 -9
  75. data/lib/fog/aws/requests/compute/describe_instances.rb +17 -8
  76. data/lib/fog/aws/requests/compute/describe_key_pairs.rb +2 -2
  77. data/lib/fog/aws/requests/compute/describe_regions.rb +2 -2
  78. data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -1
  79. data/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -2
  80. data/lib/fog/aws/requests/compute/describe_snapshots.rb +7 -5
  81. data/lib/fog/aws/requests/compute/describe_volumes.rb +5 -4
  82. data/lib/fog/aws/requests/compute/modify_image_attribute.rb +32 -0
  83. data/lib/fog/aws/requests/compute/modify_instance_attribute.rb +1 -1
  84. data/lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb +1 -1
  85. data/lib/fog/aws/requests/compute/register_image.rb +0 -1
  86. data/lib/fog/aws/requests/compute/revoke_security_group_ingress.rb +41 -29
  87. data/lib/fog/aws/requests/compute/run_instances.rb +1 -2
  88. data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
  89. data/lib/fog/aws/requests/elb/create_load_balancer_listeners.rb +1 -1
  90. data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +1 -1
  91. data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -2
  92. data/lib/fog/aws/requests/elb/describe_load_balancers.rb +3 -3
  93. data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -2
  94. data/lib/fog/aws/requests/emr/add_instance_groups.rb +46 -0
  95. data/lib/fog/aws/requests/emr/add_job_flow_steps.rb +49 -0
  96. data/lib/fog/aws/requests/emr/describe_job_flows.rb +108 -0
  97. data/lib/fog/aws/requests/emr/modify_instance_groups.rb +40 -0
  98. data/lib/fog/aws/requests/emr/run_job_flow.rb +106 -0
  99. data/lib/fog/aws/requests/emr/set_termination_protection.rb +39 -0
  100. data/lib/fog/aws/requests/emr/terminate_job_flows.rb +37 -0
  101. data/lib/fog/aws/requests/iam/get_server_certificate.rb +5 -7
  102. data/lib/fog/aws/requests/iam/upload_server_certificate.rb +1 -0
  103. data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -2
  104. data/lib/fog/aws/requests/simpledb/select.rb +1 -1
  105. data/lib/fog/aws/requests/storage/copy_object.rb +1 -1
  106. data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
  107. data/lib/fog/aws/requests/storage/hash_to_acl.rb +35 -25
  108. data/lib/fog/aws/ses.rb +1 -1
  109. data/lib/fog/aws/simpledb.rb +2 -0
  110. data/lib/fog/aws/sns.rb +3 -1
  111. data/lib/fog/aws/sqs.rb +4 -2
  112. data/lib/fog/aws/storage.rb +12 -3
  113. data/lib/fog/bin.rb +1 -1
  114. data/lib/fog/bin/aws.rb +8 -4
  115. data/lib/fog/bin/bluebox.rb +2 -2
  116. data/lib/fog/bin/brightbox.rb +1 -1
  117. data/lib/fog/bin/dnsimple.rb +1 -1
  118. data/lib/fog/bin/dnsmadeeasy.rb +1 -1
  119. data/lib/fog/bin/ecloud.rb +1 -1
  120. data/lib/fog/bin/glesys.rb +1 -1
  121. data/lib/fog/bin/go_grid.rb +1 -1
  122. data/lib/fog/bin/google.rb +1 -1
  123. data/lib/fog/bin/libvirt.rb +1 -1
  124. data/lib/fog/bin/linode.rb +2 -2
  125. data/lib/fog/bin/local.rb +1 -1
  126. data/lib/fog/bin/new_servers.rb +1 -1
  127. data/lib/fog/bin/ninefold.rb +2 -2
  128. data/lib/fog/bin/openstack.rb +1 -1
  129. data/lib/fog/bin/rackspace.rb +3 -3
  130. data/lib/fog/bin/slicehost.rb +1 -1
  131. data/lib/fog/bin/stormondemand.rb +1 -1
  132. data/lib/fog/bin/virtual_box.rb +1 -1
  133. data/lib/fog/bin/vmfusion.rb +1 -1
  134. data/lib/fog/bin/voxel.rb +1 -1
  135. data/lib/fog/bin/zerigo.rb +1 -1
  136. data/lib/fog/brightbox/models/compute/account.rb +1 -1
  137. data/lib/fog/compute/models/server.rb +1 -2
  138. data/lib/fog/core/attributes.rb +5 -5
  139. data/lib/fog/core/connection.rb +1 -1
  140. data/lib/fog/core/deprecation.rb +2 -2
  141. data/lib/fog/core/logger.rb +8 -3
  142. data/lib/fog/core/mock.rb +4 -0
  143. data/lib/fog/core/provider.rb +7 -2
  144. data/lib/fog/core/service.rb +8 -2
  145. data/lib/fog/dnsmadeeasy/models/dns/record.rb +3 -2
  146. data/lib/fog/dynect/dns.rb +25 -3
  147. data/lib/fog/ecloud/compute.rb +2 -6
  148. data/lib/fog/go_grid/requests/compute/grid_server_power.rb +1 -1
  149. data/lib/fog/google/models/storage/file.rb +1 -1
  150. data/lib/fog/google/requests/storage/get_object_url.rb +2 -2
  151. data/lib/fog/google/storage.rb +1 -1
  152. data/lib/fog/libvirt/models/compute/uri.rb +7 -3
  153. data/lib/fog/linode/models/compute/server.rb +10 -0
  154. data/lib/fog/ninefold/models/storage/file.rb +8 -6
  155. data/lib/fog/ninefold/models/storage/files.rb +3 -2
  156. data/lib/fog/ninefold/requests/storage/head_namespace.rb +20 -0
  157. data/lib/fog/ninefold/storage.rb +4 -2
  158. data/lib/fog/openstack.rb +4 -3
  159. data/lib/fog/openstack/compute.rb +8 -5
  160. data/lib/fog/openstack/models/compute/server.rb +10 -1
  161. data/lib/fog/openstack/requests/compute/create_server.rb +6 -8
  162. data/lib/fog/rackspace/load_balancers.rb +1 -0
  163. data/lib/fog/rackspace/models/dns/callback.rb +1 -1
  164. data/lib/fog/rackspace/models/dns/record.rb +1 -1
  165. data/lib/fog/rackspace/models/dns/zone.rb +1 -1
  166. data/lib/fog/slicehost/dns.rb +1 -0
  167. data/lib/fog/slicehost/models/dns/record.rb +7 -3
  168. data/lib/fog/slicehost/models/dns/zone.rb +1 -1
  169. data/lib/fog/slicehost/parsers/dns/create_record.rb +8 -2
  170. data/lib/fog/slicehost/parsers/dns/get_record.rb +17 -5
  171. data/lib/fog/slicehost/parsers/dns/get_records.rb +10 -2
  172. data/lib/fog/slicehost/requests/dns/get_record.rb +1 -1
  173. data/lib/fog/slicehost/requests/dns/get_records.rb +7 -8
  174. data/lib/fog/slicehost/requests/dns/update_record.rb +43 -0
  175. data/lib/fog/storm_on_demand/models/compute/balancers.rb +1 -1
  176. data/lib/fog/storm_on_demand/models/compute/configs.rb +1 -1
  177. data/lib/fog/storm_on_demand/models/compute/images.rb +1 -1
  178. data/lib/fog/storm_on_demand/models/compute/servers.rb +1 -1
  179. data/lib/fog/storm_on_demand/models/compute/templates.rb +1 -1
  180. data/lib/fog/terremark/vcloud.rb +1 -1
  181. data/lib/fog/vsphere/compute.rb +40 -23
  182. data/lib/fog/vsphere/models/compute/server.rb +1 -0
  183. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +36 -4
  184. data/lib/fog/zerigo/dns.rb +14 -3
  185. data/lib/fog/zerigo/models/dns/record.rb +1 -1
  186. data/lib/fog/zerigo/models/dns/records.rb +5 -0
  187. data/lib/fog/zerigo/models/dns/zones.rb +2 -2
  188. data/lib/fog/zerigo/requests/dns/count_hosts.rb +20 -1
  189. data/lib/fog/zerigo/requests/dns/count_zones.rb +12 -1
  190. data/lib/fog/zerigo/requests/dns/create_host.rb +67 -1
  191. data/lib/fog/zerigo/requests/dns/create_zone.rb +44 -1
  192. data/lib/fog/zerigo/requests/dns/delete_host.rb +19 -0
  193. data/lib/fog/zerigo/requests/dns/delete_zone.rb +17 -0
  194. data/lib/fog/zerigo/requests/dns/find_hosts.rb +22 -1
  195. data/lib/fog/zerigo/requests/dns/get_host.rb +18 -1
  196. data/lib/fog/zerigo/requests/dns/get_zone.rb +19 -2
  197. data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +23 -0
  198. data/lib/fog/zerigo/requests/dns/list_hosts.rb +20 -1
  199. data/lib/fog/zerigo/requests/dns/list_zones.rb +15 -0
  200. data/lib/fog/zerigo/requests/dns/update_host.rb +20 -1
  201. data/lib/fog/zerigo/requests/dns/update_zone.rb +20 -1
  202. data/tests/aws/models/cloud_watch/alarm_data_tests.rb +42 -0
  203. data/tests/aws/models/cloud_watch/alarm_history_tests.rb +22 -0
  204. data/tests/aws/models/compute/security_group_tests.rb +15 -10
  205. data/tests/aws/models/elb/model_tests.rb +4 -4
  206. data/tests/aws/requests/cloud_formation/stack_tests.rb +14 -0
  207. data/tests/aws/requests/cloud_watch/list_metrics_test.rb +5 -5
  208. data/tests/aws/requests/compute/image_tests.rb +33 -2
  209. data/tests/aws/requests/compute/instance_tests.rb +16 -1
  210. data/tests/aws/requests/compute/security_group_tests.rb +251 -32
  211. data/tests/aws/requests/compute/tag_tests.rb +42 -2
  212. data/tests/aws/requests/emr/helper.rb +172 -0
  213. data/tests/aws/requests/emr/instance_group_tests.rb +106 -0
  214. data/tests/aws/requests/emr/job_flow_tests.rb +88 -0
  215. data/tests/aws/requests/iam/server_certificate_tests.rb +20 -7
  216. data/tests/aws/requests/storage/bucket_tests.rb +82 -54
  217. data/tests/aws/requests/storage/hash_to_acl_tests.rb +173 -0
  218. data/tests/aws/requests/storage/object_tests.rb +44 -24
  219. data/tests/brightbox/requests/compute/helper.rb +15 -6
  220. data/tests/core/attribute_tests.rb +29 -0
  221. data/tests/core/mocking_tests.rb +60 -0
  222. data/tests/dns/models/record_tests.rb +4 -2
  223. data/tests/dns/models/records_tests.rb +4 -2
  224. data/tests/dns/models/zone_tests.rb +3 -1
  225. data/tests/dns/models/zones_tests.rb +4 -2
  226. data/tests/helper.rb +4 -0
  227. data/tests/rackspace/requests/dns/dns_tests.rb +16 -12
  228. data/tests/rackspace/requests/dns/records_tests.rb +13 -11
  229. data/tests/slicehost/requests/dns/dns_tests.rb +58 -11
  230. data/tests/vsphere/compute_tests.rb +18 -10
  231. data/tests/vsphere/requests/compute/vm_clone_tests.rb +1 -1
  232. metadata +214 -221
@@ -17,7 +17,7 @@ module Fog
17
17
 
18
18
  def all(filters = self.filters)
19
19
  unless filters.is_a?(Hash)
20
- Fog::Logger.warning("all with #{filters.class} param is deprecated, use all('spot-instance-request-id' => []) instead [light_black](#{caller.first})[/]")
20
+ Fog::Logger.deprecation("all with #{filters.class} param is deprecated, use all('spot-instance-request-id' => []) instead [light_black](#{caller.first})[/]")
21
21
  filters = {'spot-instance-request-id' => [*filters]}
22
22
  end
23
23
  self.filters = filters
@@ -34,6 +34,50 @@ module Fog
34
34
  )
35
35
  end
36
36
 
37
+ def bootstrap(new_attributes = {})
38
+ spot_request = connection.spot_requests.new(new_attributes)
39
+
40
+ unless new_attributes[:key_name]
41
+ # first or create fog_#{credential} keypair
42
+ name = Fog.respond_to?(:credential) && Fog.credential || :default
43
+ unless spot_request.key_pair = connection.key_pairs.get("fog_#{name}")
44
+ spot_request.key_pair = connection.key_pairs.create(
45
+ :name => "fog_#{name}",
46
+ :public_key => server.public_key
47
+ )
48
+ end
49
+ end
50
+
51
+ # make sure port 22 is open in the first security group
52
+ security_group = connection.security_groups.get(spot_request.groups.first)
53
+ authorized = security_group.ip_permissions.detect do |ip_permission|
54
+ ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
55
+ ip_permission['fromPort'] == 22 &&
56
+ ip_permission['ipProtocol'] == 'tcp' &&
57
+ ip_permission['toPort'] == 22
58
+ end
59
+ unless authorized
60
+ security_group.authorize_port_range(22..22)
61
+ end
62
+
63
+ spot_request.save
64
+ spot_request.wait_for { ready? }
65
+ Fog.wait_for { server = connection.servers.get(spot_request.instance_id) }
66
+ server = connection.servers.get(spot_request.instance_id)
67
+ if spot_request.tags
68
+ for key, value in spot_request.tags
69
+ connection.tags.create(
70
+ :key => key,
71
+ :resource_id => spot_request.instance_id,
72
+ :value => value
73
+ )
74
+ end
75
+ end
76
+ server.wait_for { ready? }
77
+ server.setup(:key_data => [server.private_key])
78
+ server
79
+ end
80
+
37
81
  def get(spot_request_id)
38
82
  if spot_request_id
39
83
  self.class.new(:connection => connection).all('spot-instance-request-id' => spot_request_id).first
@@ -64,7 +64,7 @@ module Fog
64
64
 
65
65
  def all(filters = filters)
66
66
  unless filters.is_a?(Hash)
67
- Fog::Logger.warning("all with #{filters.class} param is deprecated, use all('volume-id' => []) instead [light_black](#{caller.first})[/]")
67
+ Fog::Logger.deprecation("all with #{filters.class} param is deprecated, use all('volume-id' => []) instead [light_black](#{caller.first})[/]")
68
68
  filters = {'volume-id' => [*filters]}
69
69
  end
70
70
  self.filters = filters
@@ -12,6 +12,8 @@ module Fog
12
12
  attribute :health_check, :aliases => 'HealthCheck'
13
13
  attribute :instances, :aliases => 'Instances'
14
14
  attribute :source_group, :aliases => 'SourceSecurityGroup'
15
+ attribute :hosted_zone_name, :aliases => 'CanonicalHostedZoneName'
16
+ attribute :hosted_zone_name_id, :aliases => 'CanonicalHostedZoneNameID'
15
17
 
16
18
  def initialize(attributes={})
17
19
  attributes[:availability_zones] ||= attributes['AvailabilityZones'] || %w(us-east-1a us-east-1b us-east-1c us-east-1d)
@@ -104,7 +104,7 @@ module Fog
104
104
  def save(options = {})
105
105
  requires :body, :directory, :key
106
106
  if options != {}
107
- Fog::Logger.warning("options param is deprecated, use acl= instead [light_black](#{caller.first})[/]")
107
+ Fog::Logger.deprecation("options param is deprecated, use acl= instead [light_black](#{caller.first})[/]")
108
108
  end
109
109
  options['x-amz-acl'] ||= @acl if @acl
110
110
  options['Cache-Control'] = cache_control if cache_control
@@ -15,7 +15,6 @@ module Fog
15
15
  end
16
16
 
17
17
  def end_element(name)
18
- puts name
19
18
  case name
20
19
  when 'InvalidationSummary'
21
20
  @response['InvalidationSummary'] << @invalidation_summary
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudFormation
5
+
6
+ class UpdateStack < Fog::Parsers::Base
7
+
8
+ def end_element(name)
9
+ case name
10
+ when 'RequestId', 'StackId'
11
+ @response[name] = value
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class DeleteAlarms < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def start_element(name, attrs = [])
13
+ super
14
+ end
15
+
16
+ def end_element(name)
17
+ case name
18
+ when 'RequestId'
19
+ @response['ResponseMetadata'][name] = @value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class DescribeAlarmHistory < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'DescribeAlarmHistoryResult' => {'AlarmHistoryItems' => []}, 'ResponseMetadata' => {} }
10
+ reset_alarm_history_item
11
+ end
12
+
13
+ def reset_alarm_history_item
14
+ @alarm_history_item = {}
15
+ end
16
+
17
+ def start_element(name, attrs = [])
18
+ super
19
+ end
20
+
21
+ def end_element(name)
22
+ case name
23
+ when 'AlarmName', 'HistoryItemType', 'HistorySummary'
24
+ @alarm_history_item[name] = value
25
+ when 'Timestamp'
26
+ @alarm_history_item[name] = Time.parse value
27
+ when 'RequestId'
28
+ @response['ResponseMetadata'][name] = value
29
+ when 'NextToken'
30
+ @response['ResponseMetadata'][name] = value
31
+ when 'member'
32
+ @response['DescribeAlarmHistoryResult']['AlarmHistoryItems'] << @alarm_history_item
33
+ reset_alarm_history_item
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,73 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class DescribeAlarms < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'DescribeAlarmsResult' => {'MetricAlarms' => []}, 'ResponseMetadata' => {} }
10
+ reset_metric_alarms
11
+ end
12
+
13
+ def reset_metric_alarms
14
+ @metric_alarms = {'Dimensions' => []}
15
+ end
16
+
17
+ def reset_dimension
18
+ @dimension = {}
19
+ end
20
+
21
+ def start_element(name, attrs = [])
22
+ super
23
+ case name
24
+ when 'Dimensions'
25
+ @in_dimensions = true
26
+ when 'member'
27
+ if @in_dimensions
28
+ reset_dimension
29
+ end
30
+ end
31
+ end
32
+
33
+ def end_element(name)
34
+ case name
35
+ when 'Name', 'Value'
36
+ @dimension[name] = value
37
+ when 'AlarmConfigurationUpdatedTimestamp', 'StateUpdatedTimestamp'
38
+ @metric_alarms[name] = Time.parse value
39
+ when 'Period', 'EvaluationPeriods'
40
+ @metric_alarms[name] = value.to_i
41
+ when 'Threshold'
42
+ @metric_alarms[name] = value.to_f
43
+ when 'AlarmActions', 'OKActions', 'InsufficientDataActions'
44
+ @metric_alarms[name] = value.to_s.strip
45
+ when 'AlarmName', 'Namespace', 'MetricName', 'AlarmDescription', 'AlarmArn', 'Unit',
46
+ 'StateValue', 'Statistic', 'ComparisonOperator', 'StateReason', 'ActionsEnabled'
47
+ @metric_alarms[name] = value
48
+ when 'StateUpdatedTimestamp', 'AlarmConfigurationUpdatedTimestamp'
49
+ @metric_alarms[name] = Time.parse value
50
+ when 'Dimensions'
51
+ @in_dimensions = false
52
+ when 'RequestId'
53
+ @response['ResponseMetadata'][name] = value
54
+ when 'NextToken'
55
+ @response['ResponseMetadata'][name] = value
56
+ when 'member'
57
+ if !@in_dimensions
58
+ if @metric_alarms.has_key?('AlarmName')
59
+ @response['DescribeAlarmsResult']['MetricAlarms'] << @metric_alarms
60
+ reset_metric_alarms
61
+ elsif @response['DescribeAlarmsResult']['MetricAlarms'].last != nil
62
+ @response['DescribeAlarmsResult']['MetricAlarms'].last.merge!( @metric_alarms)
63
+ end
64
+ else
65
+ @metric_alarms['Dimensions'] << @dimension
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,71 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class DescribeAlarmsForMetric < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'DescribeAlarmsForMetricResult' => {'MetricAlarms' => []}, 'ResponseMetadata' => {} }
10
+ reset_metric_alarms
11
+ end
12
+
13
+ def reset_metric_alarms
14
+ @metric_alarms = {'Dimensions' => []}
15
+ end
16
+
17
+ def reset_dimension
18
+ @dimension = {}
19
+ end
20
+
21
+ def start_element(name, attrs = [])
22
+ super
23
+ case name
24
+ when 'Dimensions'
25
+ @in_dimensions = true
26
+ when 'member'
27
+ if @in_dimensions
28
+ reset_dimension
29
+ end
30
+ end
31
+ end
32
+
33
+ def end_element(name)
34
+ case name
35
+ when 'Name', 'Value'
36
+ @dimension[name] = value
37
+ when 'Period', 'EvaluationPeriods'
38
+ @metric_alarms[name] = value.to_i
39
+ when 'Threshold'
40
+ @metric_alarms[name] = value.to_f
41
+ when 'AlarmActions', 'OKActions', 'InsufficientDataActions'
42
+ @metric_alarms[name] = value.to_s.strip
43
+ when 'AlarmName', 'Namespace', 'MetricName', 'AlarmDescription', 'AlarmArn', 'Unit',
44
+ 'StateValue', 'Statistic', 'ComparisonOperator', 'StateReason', 'ActionsEnabled'
45
+ @metric_alarms[name] = value
46
+ when 'StateUpdatedTimestamp', 'AlarmConfigurationUpdatedTimestamp'
47
+ @metric_alarms[name] = Time.parse value
48
+ when 'Dimensions'
49
+ @in_dimensions = false
50
+ when 'NextToken'
51
+ @response['ResponseMetadata'][name] = value
52
+ when 'RequestId'
53
+ @response['ResponseMetadata'][name] = value
54
+ when 'member'
55
+ if !@in_dimensions
56
+ if @metric_alarms.has_key?('AlarmName')
57
+ @response['DescribeAlarmsForMetricResult']['MetricAlarms'] << @metric_alarms
58
+ reset_metric_alarms
59
+ elsif @response['DescribeAlarmsForMetricResult']['MetricAlarms'].last != nil
60
+ @response['DescribeAlarmsForMetricResult']['MetricAlarms'].last.merge!( @metric_alarms)
61
+ end
62
+ else
63
+ @metric_alarms['Dimensions'] << @dimension
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class DisableAlarmActions < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def start_element(name, attrs = [])
13
+ super
14
+ end
15
+
16
+ def end_element(name)
17
+ case name
18
+ when 'RequestId'
19
+ @response['ResponseMetadata'][name] = value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class EnableAlarmActions < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def start_element(name, attrs = [])
13
+ super
14
+ end
15
+
16
+ def end_element(name)
17
+ case name
18
+ when 'RequestId'
19
+ @response['ResponseMetadata'][name] = value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -40,3 +40,4 @@ module Fog
40
40
  end
41
41
  end
42
42
  end
43
+
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class PutMetricAlarm < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def start_element(name, attrs = [])
13
+ super
14
+ end
15
+
16
+ def end_element(name)
17
+ case name
18
+ when 'RequestId'
19
+ @response['ResponseMetadata'][name] = value.strip
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module CloudWatch
5
+
6
+ class SetAlarmState < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def start_element(name, attrs = [])
13
+ super
14
+ end
15
+
16
+ def end_element(name)
17
+ case name
18
+ when 'RequestId'
19
+ @response['ResponseMetadata'][name] = value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end