fog 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. data/Gemfile.lock +11 -6
  2. data/changelog.txt +49 -0
  3. data/fog.gemspec +5 -4
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/cloud_formation.rb +124 -0
  6. data/lib/fog/aws/elb.rb +4 -1
  7. data/lib/fog/aws/iam.rb +6 -0
  8. data/lib/fog/aws/parsers/cloud_formation/basic.rb +12 -0
  9. data/lib/fog/aws/parsers/cloud_formation/create_stack.rb +19 -0
  10. data/lib/fog/aws/parsers/cloud_formation/describe_stack_events.rb +31 -0
  11. data/lib/fog/aws/parsers/cloud_formation/describe_stack_resources.rb +31 -0
  12. data/lib/fog/aws/parsers/cloud_formation/describe_stacks.rb +72 -0
  13. data/lib/fog/aws/parsers/cloud_formation/get_template.rb +19 -0
  14. data/lib/fog/aws/parsers/cloud_formation/validate_template.rb +52 -0
  15. data/lib/fog/aws/parsers/iam/login_profile.rb +27 -0
  16. data/lib/fog/aws/parsers/iam/upload_server_certificate.rb +26 -0
  17. data/lib/fog/aws/parsers/rds/authorize_db_security_group_ingress.rb +38 -0
  18. data/lib/fog/aws/parsers/rds/create_db_instance.rb +34 -0
  19. data/lib/fog/aws/parsers/rds/create_db_instance_read_replica.rb +34 -0
  20. data/lib/fog/aws/parsers/rds/create_db_parameter_group.rb +35 -0
  21. data/lib/fog/aws/parsers/rds/create_db_security_group.rb +38 -0
  22. data/lib/fog/aws/parsers/rds/create_db_snapshot.rb +35 -0
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +123 -0
  24. data/lib/fog/aws/parsers/rds/delete_db_instance.rb +35 -0
  25. data/lib/fog/aws/parsers/rds/delete_db_parameter_group.rb +27 -0
  26. data/lib/fog/aws/parsers/rds/delete_db_security_group.rb +33 -0
  27. data/lib/fog/aws/parsers/rds/delete_db_snapshot.rb +34 -0
  28. data/lib/fog/aws/parsers/rds/describe_db_instances.rb +36 -0
  29. data/lib/fog/aws/parsers/rds/describe_db_parameter_groups.rb +38 -0
  30. data/lib/fog/aws/parsers/rds/describe_db_parameters.rb +44 -0
  31. data/lib/fog/aws/parsers/rds/describe_db_security_groups.rb +39 -0
  32. data/lib/fog/aws/parsers/rds/describe_db_snapshots.rb +39 -0
  33. data/lib/fog/aws/parsers/rds/modify_db_instance.rb +34 -0
  34. data/lib/fog/aws/parsers/rds/modify_db_parameter_group.rb +28 -0
  35. data/lib/fog/aws/parsers/rds/reboot_db_instance.rb +35 -0
  36. data/lib/fog/aws/parsers/rds/restore_db_instance_from_db_snapshot.rb +34 -0
  37. data/lib/fog/aws/parsers/rds/restore_db_instance_to_point_in_time.rb +35 -0
  38. data/lib/fog/aws/parsers/rds/revoke_db_security_group_ingress.rb +39 -0
  39. data/lib/fog/aws/parsers/rds/security_group_parser.rb +39 -0
  40. data/lib/fog/aws/parsers/rds/snapshot_parser.rb +40 -0
  41. data/lib/fog/aws/rds.rb +161 -0
  42. data/lib/fog/aws/rds/models/parameter.rb +21 -0
  43. data/lib/fog/aws/rds/models/parameter_group.rb +36 -0
  44. data/lib/fog/aws/rds/models/parameter_groups.rb +27 -0
  45. data/lib/fog/aws/rds/models/parameters.rb +37 -0
  46. data/lib/fog/aws/rds/models/security_group.rb +73 -0
  47. data/lib/fog/aws/rds/models/security_groups.rb +43 -0
  48. data/lib/fog/aws/rds/models/server.rb +105 -0
  49. data/lib/fog/aws/rds/models/servers.rb +27 -0
  50. data/lib/fog/aws/rds/models/snapshot.rb +49 -0
  51. data/lib/fog/aws/rds/models/snapshots.rb +45 -0
  52. data/lib/fog/aws/requests/cloud_formation/create_stack.rb +71 -0
  53. data/lib/fog/aws/requests/cloud_formation/delete_stack.rb +30 -0
  54. data/lib/fog/aws/requests/cloud_formation/describe_stack_events.rb +44 -0
  55. data/lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb +43 -0
  56. data/lib/fog/aws/requests/cloud_formation/describe_stacks.rb +42 -0
  57. data/lib/fog/aws/requests/cloud_formation/get_template.rb +32 -0
  58. data/lib/fog/aws/requests/cloud_formation/validate_template.rb +34 -0
  59. data/lib/fog/aws/requests/elb/create_load_balancer.rb +4 -0
  60. data/lib/fog/aws/requests/iam/create_login_profile.rb +36 -0
  61. data/lib/fog/aws/requests/iam/delete_login_profile.rb +31 -0
  62. data/lib/fog/aws/requests/iam/delete_server_certificate.rb +32 -0
  63. data/lib/fog/aws/requests/iam/get_login_profile.rb +35 -0
  64. data/lib/fog/aws/requests/iam/update_login_profile.rb +33 -0
  65. data/lib/fog/aws/requests/iam/upload_server_certificate.rb +45 -0
  66. data/lib/fog/aws/requests/rds/authorize_db_security_group_ingress.rb +43 -0
  67. data/lib/fog/aws/requests/rds/create_db_instance.rb +56 -0
  68. data/lib/fog/aws/requests/rds/create_db_instance_read_replica.rb +42 -0
  69. data/lib/fog/aws/requests/rds/create_db_parameter_group.rb +41 -0
  70. data/lib/fog/aws/requests/rds/create_db_security_group.rb +37 -0
  71. data/lib/fog/aws/requests/rds/create_db_snapshot.rb +36 -0
  72. data/lib/fog/aws/requests/rds/delete_db_instance.rb +40 -0
  73. data/lib/fog/aws/requests/rds/delete_db_parameter_group.rb +36 -0
  74. data/lib/fog/aws/requests/rds/delete_db_security_group.rb +36 -0
  75. data/lib/fog/aws/requests/rds/delete_db_snapshot.rb +36 -0
  76. data/lib/fog/aws/requests/rds/describe_db_instances.rb +42 -0
  77. data/lib/fog/aws/requests/rds/describe_db_parameter_groups.rb +45 -0
  78. data/lib/fog/aws/requests/rds/describe_db_parameters.rb +46 -0
  79. data/lib/fog/aws/requests/rds/describe_db_security_groups.rb +39 -0
  80. data/lib/fog/aws/requests/rds/describe_db_snapshots.rb +42 -0
  81. data/lib/fog/aws/requests/rds/modify_db_instance.rb +54 -0
  82. data/lib/fog/aws/requests/rds/modify_db_parameter_group.rb +55 -0
  83. data/lib/fog/aws/requests/rds/reboot_db_instance.rb +34 -0
  84. data/lib/fog/aws/requests/rds/restore_db_instance_from_db_snapshot.rb +34 -0
  85. data/lib/fog/aws/requests/rds/restore_db_instance_to_point_in_time.rb +35 -0
  86. data/lib/fog/aws/requests/rds/revoke_db_security_group_ingress.rb +44 -0
  87. data/lib/fog/aws/simpledb.rb +21 -7
  88. data/lib/fog/bin.rb +2 -1
  89. data/lib/fog/bin/aws.rb +8 -0
  90. data/lib/fog/bin/virtual_box.rb +52 -0
  91. data/lib/fog/cdn/aws.rb +9 -8
  92. data/lib/fog/cdn/rackspace.rb +6 -6
  93. data/lib/fog/cdn/requests/rackspace/post_container.rb +30 -0
  94. data/lib/fog/cdn/requests/rackspace/put_container.rb +1 -1
  95. data/lib/fog/compute.rb +6 -3
  96. data/lib/fog/compute/aws.rb +11 -7
  97. data/lib/fog/compute/bluebox.rb +5 -6
  98. data/lib/fog/compute/brightbox.rb +3 -0
  99. data/lib/fog/compute/go_grid.rb +5 -6
  100. data/lib/fog/compute/linode.rb +5 -6
  101. data/lib/fog/compute/models/aws/flavors.rb +19 -18
  102. data/lib/fog/compute/models/aws/server.rb +23 -0
  103. data/lib/fog/compute/models/aws/tag.rb +1 -1
  104. data/lib/fog/compute/models/brightbox/server.rb +7 -1
  105. data/lib/fog/compute/models/virtual_box/medium.rb +87 -0
  106. data/lib/fog/compute/models/virtual_box/medium_format.rb +34 -0
  107. data/lib/fog/compute/models/virtual_box/mediums.rb +32 -0
  108. data/lib/fog/compute/models/virtual_box/nat_engine.rb +65 -0
  109. data/lib/fog/compute/models/virtual_box/nat_redirect.rb +91 -0
  110. data/lib/fog/compute/models/virtual_box/nat_redirects.rb +41 -0
  111. data/lib/fog/compute/models/virtual_box/network_adapter.rb +82 -0
  112. data/lib/fog/compute/models/virtual_box/network_adapters.rb +42 -0
  113. data/lib/fog/compute/models/virtual_box/server.rb +241 -0
  114. data/lib/fog/compute/models/virtual_box/servers.rb +41 -0
  115. data/lib/fog/compute/models/virtual_box/storage_controller.rb +83 -0
  116. data/lib/fog/compute/models/virtual_box/storage_controllers.rb +38 -0
  117. data/lib/fog/compute/models/voxel/servers.rb +7 -6
  118. data/lib/fog/compute/new_servers.rb +5 -6
  119. data/lib/fog/compute/parsers/aws/monitor_unmonitor_instances.rb +35 -0
  120. data/lib/fog/compute/rackspace.rb +7 -7
  121. data/lib/fog/compute/requests/aws/delete_tags.rb +12 -9
  122. data/lib/fog/compute/requests/aws/monitor_instances.rb +52 -0
  123. data/lib/fog/compute/requests/aws/revoke_security_group_ingress.rb +24 -8
  124. data/lib/fog/compute/requests/aws/unmonitor_instances.rb +53 -0
  125. data/lib/fog/compute/requests/brightbox/activate_console_server.rb +20 -0
  126. data/lib/fog/compute/requests/brightbox/add_listeners_load_balancer.rb +20 -0
  127. data/lib/fog/compute/requests/brightbox/remove_listeners_load_balancer.rb +20 -0
  128. data/lib/fog/compute/slicehost.rb +5 -6
  129. data/lib/fog/compute/virtual_box.rb +48 -0
  130. data/lib/fog/compute/voxel.rb +30 -27
  131. data/lib/fog/core.rb +1 -0
  132. data/lib/fog/core/attributes.rb +3 -1
  133. data/lib/fog/core/collection.rb +2 -2
  134. data/lib/fog/core/credentials.rb +13 -3
  135. data/lib/fog/core/scp.rb +0 -4
  136. data/lib/fog/core/service.rb +0 -8
  137. data/lib/fog/core/ssh.rb +0 -4
  138. data/lib/fog/dns.rb +3 -3
  139. data/lib/fog/dns/aws.rb +8 -8
  140. data/lib/fog/dns/bluebox.rb +5 -7
  141. data/lib/fog/dns/dnsimple.rb +7 -7
  142. data/lib/fog/dns/linode.rb +5 -6
  143. data/lib/fog/dns/models/dnsimple/record.rb +11 -1
  144. data/lib/fog/dns/models/dnsimple/records.rb +7 -7
  145. data/lib/fog/dns/models/dnsimple/zones.rb +2 -1
  146. data/lib/fog/dns/requests/dnsimple/get_record.rb +34 -0
  147. data/lib/fog/dns/slicehost.rb +5 -6
  148. data/lib/fog/dns/zerigo.rb +5 -7
  149. data/lib/fog/providers.rb +2 -1
  150. data/lib/fog/providers/aws.rb +10 -8
  151. data/lib/fog/providers/virtual_box.rb +11 -0
  152. data/lib/fog/storage.rb +21 -0
  153. data/lib/fog/storage/aws.rb +16 -32
  154. data/lib/fog/storage/google.rb +6 -27
  155. data/lib/fog/storage/local.rb +7 -7
  156. data/lib/fog/storage/models/rackspace/directory.rb +1 -1
  157. data/lib/fog/storage/models/rackspace/file.rb +1 -0
  158. data/lib/fog/storage/rackspace.rb +5 -27
  159. data/lib/fog/storage/requests/aws/put_object.rb +2 -2
  160. data/lib/fog/storage/requests/aws/upload_part.rb +1 -1
  161. data/lib/fog/storage/requests/google/put_object.rb +2 -2
  162. data/lib/fog/storage/requests/rackspace/put_object.rb +1 -1
  163. data/tests/aws/requests/cloud_formation/stack_tests.rb +130 -0
  164. data/tests/aws/requests/iam/login_profile_tests.rb +64 -0
  165. data/tests/aws/requests/rds/helper.rb +169 -0
  166. data/tests/aws/requests/rds/instance_tests.rb +129 -0
  167. data/tests/aws/requests/rds/model_tests.rb +98 -0
  168. data/tests/aws/requests/rds/parameter_group_tests.rb +68 -0
  169. data/tests/aws/requests/rds/parameter_request_tests.rb +35 -0
  170. data/tests/compute/models/aws/server_monitor_tests.rb +47 -0
  171. data/tests/compute/models/server_tests.rb +7 -23
  172. data/tests/compute/parsers/aws/monitor_unmonitor_instances_tests.rb +49 -0
  173. data/tests/compute/requests/aws/security_group_tests.rb +69 -52
  174. data/tests/compute/requests/aws/tag_tests.rb +5 -5
  175. data/tests/compute/requests/brightbox/helper.rb +7 -6
  176. data/tests/compute/requests/brightbox/server_tests.rb +5 -0
  177. data/tests/compute/requests/voxel/server_tests.rb +2 -3
  178. data/tests/storage/requests/aws/bucket_tests.rb +10 -0
  179. metadata +148 -12
@@ -0,0 +1,41 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/compute/models/virtual_box/server'
3
+
4
+ module Fog
5
+ module VirtualBox
6
+ class Compute
7
+
8
+ class Servers < Fog::Collection
9
+
10
+ model Fog::VirtualBox::Compute::Server
11
+
12
+ def all
13
+ data = connection.machines.map do |machine|
14
+ {
15
+ :raw => machine
16
+ }
17
+ end
18
+ load(data)
19
+ end
20
+
21
+ def bootstrap(new_attributes = {})
22
+ raise 'Not Implemented'
23
+ # server = create(new_attributes)
24
+ # server.start
25
+ # server.wait_for { ready? }
26
+ # server.setup(:password => server.password)
27
+ # server
28
+ end
29
+
30
+ def get(server_id)
31
+ machine = connection.find_machine(server_id)
32
+ new(:raw => machine)
33
+ rescue ::VirtualBox::Exceptions::ObjectNotFoundException
34
+ nil
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,83 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module VirtualBox
5
+ class Compute
6
+
7
+ class StorageController < Fog::Model
8
+
9
+ identity :name
10
+
11
+ attribute :bootable
12
+ attribute :bus
13
+ attribute :controller_type
14
+ attribute :instance
15
+ attribute :max_devices_per_port_count
16
+ attribute :max_port_count
17
+ attribute :min_port_count
18
+ attribute :port_count
19
+ attribute :use_host_io_cache
20
+
21
+ attr_accessor :machine
22
+
23
+ def attach(medium, port, device = 0)
24
+ requires :identity, :machine
25
+ with_session do |session|
26
+ session.machine.attach_device(identity, port, device, medium.device_type, medium.instance_variable_get(:@raw))
27
+ session.machine.save_settings
28
+ end
29
+ true
30
+ end
31
+
32
+ def destroy
33
+ requires :identity, :machine
34
+ with_session do |session|
35
+ session.machine.remove_storage_controller(identity)
36
+ session.machine.save_settings
37
+ end
38
+ true
39
+ end
40
+
41
+ def save
42
+ requires :bus, :identity, :machine
43
+ with_session do |session|
44
+ self.raw = session.machine.add_storage_controller(identity, bus)
45
+ raw.port_count = 1
46
+ session.machine.save_settings
47
+ end
48
+ true
49
+ end
50
+
51
+ private
52
+
53
+ def raw
54
+ @raw
55
+ end
56
+
57
+ def raw=(new_raw)
58
+ @raw = new_raw
59
+ raw_attributes = {}
60
+ # TODO: pending my patches being accepted :bootable,
61
+ for key in [:bus, :controller_type, :instance, :max_devices_per_port_count, :max_port_count, :min_port_count, :port_count, :use_host_io_cache]
62
+ raw_attributes[key] = @raw.send(key)
63
+ end
64
+ merge_attributes(raw_attributes)
65
+ end
66
+
67
+ def session
68
+ ::VirtualBox::Lib.lib.session
69
+ end
70
+
71
+ def with_session
72
+ raw_machine = machine.instance_variable_get(:@raw)
73
+ raw_machine.lock_machine(session, :write)
74
+ yield session
75
+ session.unlock_machine
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+ end
82
+
83
+ end
@@ -0,0 +1,38 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/compute/models/virtual_box/storage_controller'
3
+
4
+ module Fog
5
+ module VirtualBox
6
+ class Compute
7
+
8
+ class StorageControllers < Fog::Collection
9
+
10
+ model Fog::VirtualBox::Compute::StorageController
11
+
12
+ attr_accessor :machine
13
+
14
+ def all
15
+ requires :machine
16
+ data = machine.instance_variable_get(:@raw).storage_controllers.map do |storage_controller|
17
+ {:raw => storage_controller}
18
+ end
19
+ load(data)
20
+ end
21
+
22
+ def get(storage_controller_name)
23
+ requires :machine
24
+ all.detect do |storage_controller|
25
+ storage_controller.name == storage_controller_name
26
+ end
27
+ end
28
+
29
+ def new(attributes = {})
30
+ requires :machine
31
+ super({ :machine => machine }.merge!(attributes))
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -15,12 +15,13 @@ module Fog
15
15
 
16
16
  def get(device_id)
17
17
  if device_id && server = connection.devices_list(device_id).body['devices']
18
-
19
- if server.empty?
20
- nil
21
- else
22
- new(server.first)
23
- end
18
+ new(server.first)
19
+ end
20
+ rescue Fog::Service::Error => error
21
+ if error.message == "The device_id passed in can't be matched to a valid device."
22
+ nil
23
+ else
24
+ raise error
24
25
  end
25
26
  end
26
27
 
@@ -25,12 +25,6 @@ module Fog
25
25
  end
26
26
  end
27
27
 
28
- def self.reset_data(keys=data.keys)
29
- for key in [*keys]
30
- data.delete(key)
31
- end
32
- end
33
-
34
28
  def initialize(options={})
35
29
  unless options.delete(:provider)
36
30
  location = caller.first
@@ -40,6 +34,11 @@ module Fog
40
34
  end
41
35
 
42
36
  @new_server_username = options[:new_servers_username]
37
+ reset_data
38
+ end
39
+
40
+ def reset_data
41
+ self.class.data.delete(@new_server_username)
43
42
  @data = self.class.data[@new_server_username]
44
43
  end
45
44
 
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module Compute
5
+
6
+ class MonitorUnmonitorInstances < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = {}
10
+ @instance_set = []
11
+ @current_instance_set = {}
12
+ end
13
+
14
+ def end_element(name)
15
+ case name
16
+ when 'requestId'
17
+ @response['requestId'] = @value
18
+ when 'instanceId'
19
+ @current_instance_set['instanceId'] = @value
20
+ when 'item'
21
+ @instance_set << @current_instance_set
22
+ @current_instance_set = {}
23
+ when 'state'
24
+ @current_instance_set['monitoring'] = @value
25
+ when 'instancesSet'
26
+ @response['instancesSet'] = @instance_set
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -53,12 +53,6 @@ module Fog
53
53
  end
54
54
  end
55
55
 
56
- def self.reset_data(keys=data.keys)
57
- for key in [*keys]
58
- data.delete(key)
59
- end
60
- end
61
-
62
56
  def initialize(options={})
63
57
  unless options.delete(:provider)
64
58
  location = caller.first
@@ -68,6 +62,11 @@ module Fog
68
62
  end
69
63
 
70
64
  @rackspace_username = options[:rackspace_username]
65
+ reset_data
66
+ end
67
+
68
+ def reset_data
69
+ self.class.data.delete(@rackspace_username)
71
70
  @data = self.class.data[@rackspace_username]
72
71
  end
73
72
 
@@ -103,7 +102,8 @@ module Fog
103
102
  'X-Auth-Token' => @auth_token
104
103
  }.merge!(params[:headers] || {}),
105
104
  :host => @host,
106
- :path => "#{@path}/#{params[:path]}"
105
+ :path => "#{@path}/#{params[:path]}",
106
+ :query => ('ignore_awful_caching' << Time.now.to_i.to_s)
107
107
  }))
108
108
  rescue Excon::Errors::Unauthorized => error
109
109
  if JSON.parse(response.body)['unauthorized']['message'] == 'Invalid authentication token. Please renew.'
@@ -8,8 +8,8 @@ module Fog
8
8
  # Remove tags from resources
9
9
  #
10
10
  # ==== Parameters
11
- # * resources<~String> - One or more resources to tag
12
- # * tags<~String> - hash of key value tag pairs to assign
11
+ # * resources<~String> - One or more resources to remove tags from
12
+ # * tags<~String> - hash of key value tag pairs to remove
13
13
  #
14
14
  # ==== Returns
15
15
  # * response<~Excon::Response>:
@@ -18,15 +18,18 @@ module Fog
18
18
  # * 'return'<~Boolean> - success?
19
19
  def delete_tags(resources, tags)
20
20
  resources = [*resources]
21
- for key, value in tags
22
- if value.nil?
23
- tags[key] = ''
24
- end
25
- end
26
21
  params = {}
27
22
  params.merge!(AWS.indexed_param('ResourceId', resources))
28
- params.merge!(AWS.indexed_param('Tag.%d.Key', tags.keys))
29
- params.merge!(AWS.indexed_param('Tag.%d.Value', tags.values))
23
+
24
+ # can not rely on indexed_param because nil values should be omitted
25
+ tags.keys.each_with_index do |key, index|
26
+ index += 1 # should start at 1 instead of 0
27
+ params.merge!("Tag.#{index}.Key" => key)
28
+ unless tags[key].nil?
29
+ params.merge("Tag.#{index}.Value" => tags[key])
30
+ end
31
+ end
32
+
30
33
  request({
31
34
  'Action' => 'DeleteTags',
32
35
  :parser => Fog::Parsers::AWS::Compute::Basic.new
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module AWS
3
+ class Compute
4
+
5
+ class Real
6
+
7
+ require 'fog/compute/parsers/aws/monitor_unmonitor_instances'
8
+
9
+ # Monitor specified instance
10
+ # http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-MonitorInstances.html
11
+ #
12
+ # ==== Parameters
13
+ # * instance_ids<~Array> - Arrays of instances Ids to monitor
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * 'requestId'<~String> - Id of request
19
+ # * 'instancesSet': http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-MonitorInstancesResponseSetItemType.html
20
+ def monitor_instances(instance_ids)
21
+ params = AWS.indexed_param('InstanceId', instance_ids)
22
+ request({
23
+ 'Action' => 'MonitorInstances',
24
+ :idempotent => true,
25
+ :parser => Fog::Parsers::AWS::Compute::MonitorUnmonitorInstances.new
26
+ }.merge!(params))
27
+ end
28
+
29
+ end
30
+
31
+ class Mock
32
+
33
+ def monitor_instances(instance_ids)
34
+ response = Excon::Response.new
35
+ response.status = 200
36
+ [*instance_ids].each do |instance_id|
37
+ if instance = @data[:instances][instance_id]
38
+ instance['monitoring']['state'] = 'enabled'
39
+ else
40
+ raise Fog::AWS::Compute::NotFound.new("The instance ID '#{instance_ids}' does not exist")
41
+ end
42
+ end
43
+ instances_set = [*instance_ids].inject([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'enabled'} }
44
+ response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
45
+ response
46
+ end
47
+
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -8,14 +8,13 @@ module Fog
8
8
  # Remove permissions from a security group
9
9
  #
10
10
  # ==== Parameters
11
+ # * 'GroupName'<~String> - Name of group
11
12
  # * options<~Hash>:
12
- # * 'GroupName'<~String> - Name of group
13
13
  # * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
14
14
  # * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
15
15
  # or
16
16
  # * 'CidrIp' - CIDR range
17
17
  # * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
18
- # * 'GroupName' - Name of group to modify
19
18
  # * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
20
19
  # * 'ToPort' - End of port range (or -1 for ICMP wildcard)
21
20
  #
@@ -24,9 +23,18 @@ module Fog
24
23
  # * body<~Hash>:
25
24
  # * 'requestId'<~String> - Id of request
26
25
  # * 'return'<~Boolean> - success?
27
- def revoke_security_group_ingress(options = {})
26
+ def revoke_security_group_ingress(group_name, options = {})
27
+ if group_name.is_a?(Hash)
28
+ location = caller.first
29
+ warning = "[yellow][WARN] Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated"
30
+ warning << " [light_black](" << location << ")[/] "
31
+ Formatador.display_line(warning)
32
+ options = group_name
33
+ group_name = options['GroupName']
34
+ end
28
35
  request({
29
36
  'Action' => 'RevokeSecurityGroupIngress',
37
+ 'GroupName' => group_name,
30
38
  :idempotent => true,
31
39
  :parser => Fog::Parsers::AWS::Compute::Basic.new
32
40
  }.merge!(options))
@@ -36,13 +44,21 @@ module Fog
36
44
 
37
45
  class Mock
38
46
 
39
- def revoke_security_group_ingress(options = {})
47
+ def revoke_security_group_ingress(group_name, options = {})
48
+ if group_name.is_a?(Hash)
49
+ location = caller.first
50
+ warning = "[yellow][WARN] Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated"
51
+ warning << " [light_black](" << location << ")[/] "
52
+ Formatador.display_line(warning)
53
+ options = group_name
54
+ group_name = options['GroupName']
55
+ end
40
56
  response = Excon::Response.new
41
- group = @data[:security_groups][options['GroupName']]
57
+ group = @data[:security_groups][group_name]
42
58
  if group
43
- if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
59
+ if options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
44
60
  group['ipPermissions'].delete_if {|permission|
45
- permission['groups'].first['groupName'] == options['GroupName']
61
+ permission['groups'].first['groupName'] == group_name
46
62
  }
47
63
  else
48
64
  ingress = group['ipPermissions'].select {|permission|
@@ -66,7 +82,7 @@ module Fog
66
82
  }
67
83
  response
68
84
  else
69
- raise Fog::AWS::Compute::NotFound.new("The security group '#{options['GroupName']}' does not exist")
85
+ raise Fog::AWS::Compute::NotFound.new("The security group '#{group_name}' does not exist")
70
86
  end
71
87
  end
72
88
 
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module AWS
3
+ class Compute
4
+
5
+ class Real
6
+
7
+ require 'fog/compute/parsers/aws/monitor_unmonitor_instances'
8
+
9
+ # UnMonitor specified instance
10
+ # http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html
11
+ #
12
+ # ==== Parameters
13
+ # * instance_ids<~Array> - Arrays of instances Ids to monitor
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * 'requestId'<~String> - Id of request
19
+ # * 'instancesSet': http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-MonitorInstancesResponseSetItemType.html
20
+ def unmonitor_instances(instance_ids)
21
+ params = AWS.indexed_param('InstanceId', instance_ids)
22
+ request({
23
+ 'Action' => 'UnmonitorInstances',
24
+ :idempotent => true,
25
+ :parser => Fog::Parsers::AWS::Compute::MonitorUnmonitorInstances.new
26
+ }.merge!(params))
27
+ end
28
+
29
+ end
30
+
31
+ class Mock
32
+
33
+ def unmonitor_instances(instance_ids)
34
+ response = Excon::Response.new
35
+ response.status = 200
36
+ [*instance_ids].each do |instance_id|
37
+ if instance = @data[:instances][instance_id]
38
+ instance['monitoring']['state'] = 'enabled'
39
+ else
40
+ raise Fog::AWS::Compute::NotFound.new("The instance ID '#{instance_ids}' does not exist")
41
+ end
42
+ end
43
+ instances_set = [*instance_ids].inject([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'disabled'} }
44
+ response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
45
+ response
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end