brightbox-cli 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. data/README +13 -17
  2. data/README.rdoc +13 -17
  3. data/brightbox-cli.gemspec +1 -1
  4. data/lib/brightbox-cli/accounts.rb +7 -0
  5. data/lib/brightbox-cli/api.rb +3 -0
  6. data/lib/brightbox-cli/commands/config-client-list.rb +1 -1
  7. data/lib/brightbox-cli/commands/firewall-rules-create.rb +4 -0
  8. data/lib/brightbox-cli/commands/firewall-rules-update.rb +49 -0
  9. data/lib/brightbox-cli/commands/groups-show.rb +1 -1
  10. data/lib/brightbox-cli/commands/groups-update.rb +3 -1
  11. data/lib/brightbox-cli/commands/images-destroy.rb +1 -1
  12. data/lib/brightbox-cli/commands/images-list.rb +9 -3
  13. data/lib/brightbox-cli/commands/images-register.rb +1 -1
  14. data/lib/brightbox-cli/commands/images-update.rb +3 -1
  15. data/lib/brightbox-cli/commands/lbs-update.rb +4 -2
  16. data/lib/brightbox-cli/commands/{servers-activate-cloud.rb → servers-activate-console.rb} +2 -1
  17. data/lib/brightbox-cli/commands/servers-update.rb +2 -1
  18. data/lib/brightbox-cli/config.rb +17 -2
  19. data/lib/brightbox-cli/detailed_server.rb +1 -1
  20. data/lib/brightbox-cli/firewall_rule.rb +6 -0
  21. data/lib/brightbox-cli/gli_global_hooks.rb +8 -1
  22. data/lib/brightbox-cli/images.rb +22 -1
  23. data/lib/brightbox-cli/nilable_hash.rb +7 -0
  24. data/lib/brightbox-cli/server_groups.rb +0 -6
  25. data/lib/brightbox-cli/servers.rb +6 -2
  26. data/lib/brightbox-cli/tables.rb +13 -0
  27. data/lib/brightbox-cli/vendor/fog/README.rdoc +2 -9
  28. data/lib/brightbox-cli/vendor/fog/Rakefile +3 -2
  29. data/lib/brightbox-cli/vendor/fog/changelog.txt +213 -0
  30. data/lib/brightbox-cli/vendor/fog/docs/_layouts/default.html +1 -1
  31. data/lib/brightbox-cli/vendor/fog/docs/about/contributing.markdown +1 -1
  32. data/lib/brightbox-cli/vendor/fog/docs/about/getting_started.markdown +28 -3
  33. data/lib/brightbox-cli/vendor/fog/docs/dns/index.markdown +1 -1
  34. data/lib/brightbox-cli/vendor/fog/docs/index.markdown +2 -10
  35. data/lib/brightbox-cli/vendor/fog/docs/storage/index.markdown +2 -2
  36. data/lib/brightbox-cli/vendor/fog/fog.gemspec +6 -5
  37. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/auto_scaling.rb +3 -1
  38. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/cloud_formation.rb +3 -0
  39. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/cloud_watch.rb +3 -1
  40. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/compute.rb +5 -3
  41. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/elb.rb +4 -2
  42. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/emr.rb +133 -0
  43. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/addresses.rb +1 -1
  44. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/key_pairs.rb +1 -1
  45. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/security_groups.rb +1 -1
  46. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/server.rb +4 -2
  47. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/servers.rb +1 -1
  48. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/snapshots.rb +1 -1
  49. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/spot_request.rb +21 -4
  50. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/spot_requests.rb +45 -1
  51. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/volumes.rb +1 -1
  52. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/load_balancer.rb +2 -0
  53. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/models/storage/file.rb +1 -1
  54. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/cdn/get_invalidation_list.rb +0 -1
  55. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/cloud_formation/update_stack.rb +19 -0
  56. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/add_instance_groups.rb +28 -0
  57. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/add_job_flow_steps.rb +17 -0
  58. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/describe_job_flows.rb +140 -0
  59. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/modify_instance_groups.rb +17 -0
  60. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/run_job_flow.rb +19 -0
  61. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/set_termination_protection.rb +17 -0
  62. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/parsers/emr/terminate_job_flows.rb +17 -0
  63. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/rds.rb +3 -1
  64. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/cloud_formation/create_stack.rb +6 -0
  65. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/cloud_formation/update_stack.rb +62 -0
  66. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +141 -36
  67. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/delete_security_group.rb +25 -0
  68. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/delete_tags.rb +1 -1
  69. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_addresses.rb +2 -2
  70. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_availability_zones.rb +5 -2
  71. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_images.rb +1 -1
  72. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_instances.rb +15 -6
  73. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_key_pairs.rb +2 -2
  74. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_regions.rb +2 -2
  75. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -1
  76. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -2
  77. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_snapshots.rb +4 -4
  78. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/describe_volumes.rb +2 -2
  79. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/modify_instance_attribute.rb +1 -1
  80. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/compute/revoke_security_group_ingress.rb +41 -29
  81. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/elb/describe_load_balancers.rb +3 -3
  82. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +1 -1
  83. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/add_instance_groups.rb +46 -0
  84. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/add_job_flow_steps.rb +49 -0
  85. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/describe_job_flows.rb +108 -0
  86. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/modify_instance_groups.rb +40 -0
  87. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/run_job_flow.rb +106 -0
  88. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/set_termination_protection.rb +39 -0
  89. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/emr/terminate_job_flows.rb +37 -0
  90. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -2
  91. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/simpledb/select.rb +1 -1
  92. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/acl_utils.rb +62 -0
  93. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/get_bucket_acl.rb +7 -1
  94. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/get_object_acl.rb +7 -1
  95. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
  96. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/put_bucket_acl.rb +2 -2
  97. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/put_object_acl.rb +1 -1
  98. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/ses.rb +1 -1
  99. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/simpledb.rb +2 -0
  100. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/sns.rb +3 -1
  101. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/sqs.rb +4 -2
  102. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/storage.rb +10 -2
  103. data/lib/brightbox-cli/vendor/fog/lib/fog/aws.rb +26 -1
  104. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/aws.rb +8 -4
  105. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/bluebox.rb +2 -2
  106. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/brightbox.rb +1 -1
  107. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/dnsimple.rb +1 -1
  108. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/dnsmadeeasy.rb +1 -1
  109. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/ecloud.rb +1 -1
  110. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/glesys.rb +1 -1
  111. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/go_grid.rb +1 -1
  112. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/google.rb +1 -1
  113. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/libvirt.rb +1 -1
  114. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/linode.rb +2 -2
  115. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/local.rb +1 -1
  116. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/new_servers.rb +1 -1
  117. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/ninefold.rb +2 -2
  118. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/openstack.rb +1 -1
  119. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/rackspace.rb +3 -3
  120. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/slicehost.rb +1 -1
  121. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/stormondemand.rb +1 -1
  122. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/virtual_box.rb +1 -1
  123. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/vmfusion.rb +1 -1
  124. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/voxel.rb +1 -1
  125. data/lib/brightbox-cli/vendor/fog/lib/fog/bin/zerigo.rb +1 -1
  126. data/lib/brightbox-cli/vendor/fog/lib/fog/bin.rb +1 -1
  127. data/lib/brightbox-cli/vendor/fog/lib/fog/brightbox/compute.rb +2 -0
  128. data/lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/cloud_ip.rb +10 -2
  129. data/lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/server.rb +11 -3
  130. data/lib/brightbox-cli/vendor/fog/lib/fog/brightbox/models/compute/server_group.rb +9 -0
  131. data/lib/brightbox-cli/vendor/fog/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +13 -0
  132. data/lib/brightbox-cli/vendor/fog/lib/fog/core/connection.rb +1 -1
  133. data/lib/brightbox-cli/vendor/fog/lib/fog/core/credentials.rb +3 -3
  134. data/lib/brightbox-cli/vendor/fog/lib/fog/core/deprecation.rb +2 -2
  135. data/lib/brightbox-cli/vendor/fog/lib/fog/core/logger.rb +8 -3
  136. data/lib/brightbox-cli/vendor/fog/lib/fog/core/mock.rb +4 -0
  137. data/lib/brightbox-cli/vendor/fog/lib/fog/core/provider.rb +7 -2
  138. data/lib/brightbox-cli/vendor/fog/lib/fog/core/service.rb +8 -2
  139. data/lib/brightbox-cli/vendor/fog/lib/fog/dnsmadeeasy/models/dns/record.rb +3 -2
  140. data/lib/brightbox-cli/vendor/fog/lib/fog/dynect/dns.rb +25 -3
  141. data/lib/brightbox-cli/vendor/fog/lib/fog/ecloud/compute.rb +1 -1
  142. data/lib/brightbox-cli/vendor/fog/lib/fog/go_grid/requests/compute/grid_server_power.rb +1 -1
  143. data/lib/brightbox-cli/vendor/fog/lib/fog/google/models/storage/file.rb +1 -1
  144. data/lib/brightbox-cli/vendor/fog/lib/fog/google/requests/storage/get_object_url.rb +2 -2
  145. data/lib/brightbox-cli/vendor/fog/lib/fog/google/storage.rb +1 -1
  146. data/lib/brightbox-cli/vendor/fog/lib/fog/ninefold/models/storage/file.rb +8 -6
  147. data/lib/brightbox-cli/vendor/fog/lib/fog/ninefold/models/storage/files.rb +3 -2
  148. data/lib/brightbox-cli/vendor/fog/lib/fog/ninefold/requests/storage/head_namespace.rb +20 -0
  149. data/lib/brightbox-cli/vendor/fog/lib/fog/ninefold/storage.rb +4 -2
  150. data/lib/brightbox-cli/vendor/fog/lib/fog/openstack/models/compute/server.rb +7 -1
  151. data/lib/brightbox-cli/vendor/fog/lib/fog/openstack/requests/compute/create_server.rb +6 -11
  152. data/lib/brightbox-cli/vendor/fog/lib/fog/rackspace/load_balancers.rb +1 -0
  153. data/lib/brightbox-cli/vendor/fog/lib/fog/rackspace/models/dns/callback.rb +1 -1
  154. data/lib/brightbox-cli/vendor/fog/lib/fog/rackspace/models/dns/record.rb +1 -1
  155. data/lib/brightbox-cli/vendor/fog/lib/fog/rackspace/models/dns/zone.rb +1 -1
  156. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/dns.rb +1 -0
  157. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb +7 -3
  158. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/zone.rb +1 -1
  159. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/parsers/dns/create_record.rb +8 -2
  160. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/parsers/dns/get_record.rb +17 -5
  161. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/parsers/dns/get_records.rb +10 -2
  162. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/requests/dns/get_record.rb +1 -1
  163. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/requests/dns/get_records.rb +7 -8
  164. data/lib/brightbox-cli/vendor/fog/lib/fog/slicehost/requests/dns/update_record.rb +43 -0
  165. data/lib/brightbox-cli/vendor/fog/lib/fog/storm_on_demand/models/compute/balancers.rb +1 -1
  166. data/lib/brightbox-cli/vendor/fog/lib/fog/storm_on_demand/models/compute/configs.rb +1 -1
  167. data/lib/brightbox-cli/vendor/fog/lib/fog/storm_on_demand/models/compute/images.rb +1 -1
  168. data/lib/brightbox-cli/vendor/fog/lib/fog/storm_on_demand/models/compute/servers.rb +1 -1
  169. data/lib/brightbox-cli/vendor/fog/lib/fog/storm_on_demand/models/compute/templates.rb +1 -1
  170. data/lib/brightbox-cli/vendor/fog/lib/fog/terremark/vcloud.rb +1 -1
  171. data/lib/brightbox-cli/vendor/fog/lib/fog/vsphere/compute.rb +41 -23
  172. data/lib/brightbox-cli/vendor/fog/lib/fog/vsphere/models/compute/server.rb +19 -0
  173. data/lib/brightbox-cli/vendor/fog/lib/fog/vsphere/models/compute/servers.rb +8 -2
  174. data/lib/brightbox-cli/vendor/fog/lib/fog/vsphere/requests/compute/datacenters.rb +34 -0
  175. data/lib/brightbox-cli/vendor/fog/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +83 -10
  176. data/lib/brightbox-cli/vendor/fog/lib/fog/vsphere/requests/compute/vm_clone.rb +76 -37
  177. data/lib/brightbox-cli/vendor/fog/lib/fog.rb +1 -1
  178. data/lib/brightbox-cli/vendor/fog/tests/aws/models/cloud_watch/alarm_data_tests.rb +8 -6
  179. data/lib/brightbox-cli/vendor/fog/tests/aws/models/cloud_watch/alarm_history_tests.rb +3 -1
  180. data/lib/brightbox-cli/vendor/fog/tests/aws/models/compute/security_group_tests.rb +15 -10
  181. data/lib/brightbox-cli/vendor/fog/tests/aws/models/elb/model_tests.rb +4 -4
  182. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/cloud_formation/stack_tests.rb +14 -0
  183. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/compute/instance_tests.rb +16 -1
  184. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/compute/security_group_tests.rb +251 -32
  185. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/compute/tag_tests.rb +2 -2
  186. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/emr/helper.rb +172 -0
  187. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/emr/instance_group_tests.rb +106 -0
  188. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/emr/job_flow_tests.rb +88 -0
  189. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/storage/acl_utils_tests.rb +209 -0
  190. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/storage/bucket_tests.rb +80 -55
  191. data/lib/brightbox-cli/vendor/fog/tests/aws/requests/storage/object_tests.rb +42 -24
  192. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/account_tests.rb +11 -6
  193. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/api_client_tests.rb +23 -12
  194. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/cloud_ip_tests.rb +29 -20
  195. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/helper.rb +70 -14
  196. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/image_tests.rb +17 -14
  197. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/interface_tests.rb +3 -2
  198. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/load_balancer_tests.rb +57 -11
  199. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/server_group_tests.rb +29 -22
  200. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/server_tests.rb +38 -21
  201. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/server_type_tests.rb +7 -6
  202. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/user_tests.rb +11 -16
  203. data/lib/brightbox-cli/vendor/fog/tests/brightbox/requests/compute/zone_tests.rb +7 -6
  204. data/lib/brightbox-cli/vendor/fog/tests/compute/helper.rb +1 -1
  205. data/lib/brightbox-cli/vendor/fog/tests/core/credential_tests.rb +2 -2
  206. data/lib/brightbox-cli/vendor/fog/tests/core/mocking_tests.rb +60 -0
  207. data/lib/brightbox-cli/vendor/fog/tests/dns/models/record_tests.rb +4 -2
  208. data/lib/brightbox-cli/vendor/fog/tests/dns/models/records_tests.rb +4 -2
  209. data/lib/brightbox-cli/vendor/fog/tests/dns/models/zone_tests.rb +3 -1
  210. data/lib/brightbox-cli/vendor/fog/tests/dns/models/zones_tests.rb +4 -2
  211. data/lib/brightbox-cli/vendor/fog/tests/glesys/requests/compute/helper.rb +4 -2
  212. data/lib/brightbox-cli/vendor/fog/tests/glesys/requests/compute/server_tests.rb +1 -1
  213. data/lib/brightbox-cli/vendor/fog/tests/helper.rb +4 -0
  214. data/lib/brightbox-cli/vendor/fog/tests/rackspace/requests/dns/dns_tests.rb +16 -12
  215. data/lib/brightbox-cli/vendor/fog/tests/rackspace/requests/dns/records_tests.rb +13 -11
  216. data/lib/brightbox-cli/vendor/fog/tests/slicehost/requests/dns/dns_tests.rb +58 -11
  217. data/lib/brightbox-cli/vendor/fog/tests/vsphere/compute_tests.rb +18 -10
  218. data/lib/brightbox-cli/vendor/fog/tests/vsphere/requests/compute/vm_clone_tests.rb +3 -7
  219. data/lib/brightbox-cli/version.rb +1 -1
  220. data/lib/brightbox_cli.rb +1 -0
  221. data/spec/fixtures/vcr_cassettes/list_server_groups.yml +37 -6
  222. data/spec/nilable_hash_spec.rb +30 -0
  223. metadata +48 -18
  224. data/lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/storage/hash_to_acl.rb +0 -44
@@ -13,11 +13,23 @@ module Fog
13
13
  # * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
14
14
  # * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
15
15
  # or
16
- # * 'CidrIp' - CIDR range
17
- # * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
18
- # * 'GroupName' - Name of group to modify
19
- # * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
20
- # * 'ToPort' - End of port range (or -1 for ICMP wildcard)
16
+ # * 'CidrIp'<~String> - CIDR range
17
+ # * 'FromPort'<~Integer> - Start of port range (or -1 for ICMP wildcard)
18
+ # * 'IpProtocol'<~String> - Ip protocol, must be in ['tcp', 'udp', 'icmp']
19
+ # * 'ToPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
20
+ # or
21
+ # * 'IpPermissions'<~Array>:
22
+ # * permission<~Hash>:
23
+ # * 'FromPort'<~Integer> - Start of port range (or -1 for ICMP wildcard)
24
+ # * 'Groups'<~Array>:
25
+ # * group<~Hash>:
26
+ # * 'GroupName'<~String> - Name of security group to authorize
27
+ # * 'UserId'<~String> - Name of owner to authorize
28
+ # * 'IpProtocol'<~String> - Ip protocol, must be in ['tcp', 'udp', 'icmp']
29
+ # * 'IpRanges'<~Array>:
30
+ # * ip_range<~Hash>:
31
+ # * 'CidrIp'<~String> - CIDR range
32
+ # * 'ToPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
21
33
  #
22
34
  # === Returns
23
35
  # * response<~Excon::Response>:
@@ -28,10 +40,15 @@ module Fog
28
40
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html]
29
41
  def authorize_security_group_ingress(group_name, options = {})
30
42
  if group_name.is_a?(Hash)
31
- Fog::Logger.warning("Fog::AWS::Compute#authorize_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
43
+ Fog::Logger.deprecation("Fog::AWS::Compute#authorize_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
32
44
  options = group_name
33
- group_name = options['GroupName']
45
+ group_name = options.delete('GroupName')
46
+ end
47
+
48
+ if ip_permissions = options.delete('IpPermissions')
49
+ options.merge!(indexed_ip_permissions_params(ip_permissions))
34
50
  end
51
+
35
52
  request({
36
53
  'Action' => 'AuthorizeSecurityGroupIngress',
37
54
  'GroupName' => group_name,
@@ -40,51 +57,69 @@ module Fog
40
57
  }.merge!(options))
41
58
  end
42
59
 
60
+ private
61
+
62
+ def indexed_ip_permissions_params(ip_permissions)
63
+ params = {}
64
+ ip_permissions.each_with_index do |permission, key_index|
65
+ key_index += 1
66
+ params[format('IpPermissions.%d.IpProtocol', key_index)] = permission['IpProtocol']
67
+ params[format('IpPermissions.%d.FromPort', key_index)] = permission['FromPort']
68
+ params[format('IpPermissions.%d.ToPort', key_index)] = permission['ToPort']
69
+ (permission['Groups'] || []).each_with_index do |group, group_index|
70
+ group_index += 1
71
+ params[format('IpPermissions.%d.Groups.%d.UserId', key_index, group_index)] = group['UserId']
72
+ params[format('IpPermissions.%d.Groups.%d.GroupName', key_index, group_index)] = group['GroupName']
73
+ params[format('IpPermissions.%d.Groups.%d.GroupId', key_index, group_index)] = group['GroupId']
74
+ end
75
+ (permission['IpRanges'] || []).each_with_index do |ip_range, range_index|
76
+ range_index += 1
77
+ params[format('IpPermissions.%d.IpRanges.%d.CidrIp', key_index, range_index)] = ip_range['CidrIp']
78
+ end
79
+ end
80
+ params.reject {|k, v| v.nil? }
81
+ end
82
+
43
83
  end
44
84
 
45
85
  class Mock
46
86
 
47
87
  def authorize_security_group_ingress(group_name, options = {})
48
88
  if group_name.is_a?(Hash)
49
- Fog::Logger.warning("Fog::AWS::Compute#authorize_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
89
+ Fog::Logger.deprecation("Fog::AWS::Compute#authorize_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
50
90
  options = group_name
51
- group_name = options['GroupName']
91
+ group_name = options.delete('GroupName')
52
92
  end
53
93
 
94
+ verify_permission_options(options)
95
+
54
96
  response = Excon::Response.new
55
97
  group = self.data[:security_groups][group_name]
56
98
 
57
99
  if group
58
- group['ipPermissions'] ||= []
59
- if group_name && source_group_name = options['SourceSecurityGroupName']
60
- ['tcp', 'udp'].each do |protocol|
61
- group['ipPermissions'] << {
62
- 'groups' => [{'groupName' => source_group_name, 'userId' => (options['SourceSecurityGroupOwnerId'] || self.data[:owner_id]) }],
63
- 'fromPort' => 1,
64
- 'ipRanges' => [],
65
- 'ipProtocol' => protocol,
66
- 'toPort' => 65535
67
- }
100
+ normalized_permissions = normalize_permissions(options)
101
+
102
+ normalized_permissions.each do |permission|
103
+ if matching_group_permission = find_matching_permission(group, permission)
104
+ if permission['groups'].any? {|pg| matching_group_permission['groups'].include?(pg) }
105
+ raise Fog::Compute::AWS::Error, "InvalidPermission.Duplicate => The permission '123' has already been authorized in the specified group"
106
+ end
107
+
108
+ if permission['ipRanges'].any? {|pr| matching_group_permission['ipRanges'].include?(pr) }
109
+ raise Fog::Compute::AWS::Error, "InvalidPermission.Duplicate => The permission '123' has already been authorized in the specified group"
110
+ end
68
111
  end
69
- group['ipPermissions'] << {
70
- 'groups' => [{'groupName' => source_group_name, 'userId' => (options['SourceSecurityGroupOwnerId'] || self.data[:owner_id]) }],
71
- 'fromPort' => -1,
72
- 'ipRanges' => [],
73
- 'ipProtocol' => 'icmp',
74
- 'toPort' => -1
75
- }
76
- else
77
- group['ipPermissions'] << {
78
- 'groups' => [],
79
- 'fromPort' => options['FromPort'],
80
- 'ipRanges' => [],
81
- 'ipProtocol' => options['IpProtocol'],
82
- 'toPort' => options['ToPort']
83
- }
84
- if options['CidrIp']
85
- group['ipPermissions'].last['ipRanges'] << { 'cidrIp' => options['CidrIp'] }
112
+ end
113
+
114
+ normalized_permissions.each do |permission|
115
+ if matching_group_permission = find_matching_permission(group, permission)
116
+ matching_group_permission['groups'] += permission['groups']
117
+ matching_group_permission['ipRanges'] += permission['ipRanges']
118
+ else
119
+ group['ipPermissions'] << permission
86
120
  end
87
121
  end
122
+
88
123
  response.status = 200
89
124
  response.body = {
90
125
  'requestId' => Fog::AWS::Mock.request_id,
@@ -96,6 +131,76 @@ module Fog
96
131
  end
97
132
  end
98
133
 
134
+ private
135
+
136
+ def verify_permission_options(options)
137
+ if options.empty?
138
+ raise Fog::Compute::AWS::Error.new("InvalidRequest => The request received was invalid.")
139
+ end
140
+ if options['IpProtocol'] && !['tcp', 'udp', 'icmp'].include?(options['IpProtocol'])
141
+ raise Fog::Compute::AWS::Error.new("InvalidPermission.Malformed => Unsupported IP protocol \"#{options['IpProtocol']}\" - supported: [tcp, udp, icmp]")
142
+ end
143
+ if options['IpProtocol'] && (!options['FromPort'] || !options['ToPort'])
144
+ raise Fog::Compute::AWS::Error.new("InvalidPermission.Malformed => TCP/UDP port (-1) out of range")
145
+ end
146
+ if options.has_key?('IpPermissions')
147
+ if !options['IpPermissions'].is_a?(Array) || options['IpPermissions'].empty?
148
+ raise Fog::Compute::AWS::Error.new("InvalidRequest => The request received was invalid.")
149
+ end
150
+ options['IpPermissions'].each {|p| verify_permission_options(p) }
151
+ end
152
+ end
153
+
154
+ def normalize_permissions(options)
155
+ normalized_permissions = []
156
+
157
+ if options['SourceSecurityGroupName']
158
+ ['tcp', 'udp'].each do |protocol|
159
+ normalized_permissions << {
160
+ 'ipProtocol' => protocol,
161
+ 'fromPort' => 1,
162
+ 'toPort' => 65535,
163
+ 'groups' => [{'groupName' => options['SourceSecurityGroupName'], 'userId' => options['SourceSecurityGroupOwnerId'] || self.data[:owner_id]}],
164
+ 'ipRanges' => []
165
+ }
166
+ end
167
+ normalized_permissions << {
168
+ 'ipProtocol' => 'icmp',
169
+ 'fromPort' => -1,
170
+ 'toPort' => -1,
171
+ 'groups' => [{'groupName' => options['SourceSecurityGroupName'], 'userId' => options['SourceSecurityGroupOwnerId'] || self.data[:owner_id]}],
172
+ 'ipRanges' => []
173
+ }
174
+ elsif options['CidrIp']
175
+ normalized_permissions << {
176
+ 'ipProtocol' => options['IpProtocol'],
177
+ 'fromPort' => Integer(options['FromPort']),
178
+ 'toPort' => Integer(options['ToPort']),
179
+ 'groups' => [],
180
+ 'ipRanges' => [{'cidrIp' => options['CidrIp']}]
181
+ }
182
+ elsif options['IpPermissions']
183
+ options['IpPermissions'].each do |permission|
184
+ normalized_permissions << {
185
+ 'ipProtocol' => permission['IpProtocol'],
186
+ 'fromPort' => Integer(permission['FromPort']),
187
+ 'toPort' => Integer(permission['ToPort']),
188
+ 'groups' => (permission['Groups'] || []).map {|g| {'groupName' => g['GroupName'], 'userId' => g['UserId'] || self.data[:owner_id]} },
189
+ 'ipRanges' => (permission['IpRanges'] || []).map {|r| { 'cidrIp' => r['CidrIp'] } }
190
+ }
191
+ end
192
+ end
193
+
194
+ normalized_permissions
195
+ end
196
+
197
+ def find_matching_permission(group, permission)
198
+ group['ipPermissions'].detect {|group_permission|
199
+ permission['ipProtocol'] == group_permission['ipProtocol'] &&
200
+ permission['fromPort'] == group_permission['fromPort'] &&
201
+ permission['toPort'] == group_permission['toPort'] }
202
+ end
203
+
99
204
  end
100
205
  end
101
206
  end
@@ -30,8 +30,33 @@ module Fog
30
30
 
31
31
  class Mock
32
32
  def delete_security_group(name)
33
+ if name == 'default'
34
+ raise Fog::Compute::AWS::Error.new("InvalidGroup.Reserved => The security group 'default' is reserved")
35
+ end
36
+
33
37
  response = Excon::Response.new
34
38
  if self.data[:security_groups][name]
39
+
40
+ used_by_groups = []
41
+ self.region_data.each do |access_key, key_data|
42
+ key_data[:security_groups].each do |group_name, group|
43
+ next if group == self.data[:security_groups][name]
44
+
45
+ group['ipPermissions'].each do |group_ip_permission|
46
+ group_ip_permission['groups'].each do |group_group_permission|
47
+ if group_group_permission['groupName'] == name &&
48
+ group_group_permission['userId'] == self.data[:owner_id]
49
+ used_by_groups << "#{key_data[:owner_id]}:#{group_name}"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ unless used_by_groups.empty?
57
+ raise Fog::Compute::AWS::Error.new("InvalidGroup.InUse => Group #{self.data[:owner_id]}:#{name} is used by groups: #{used_by_groups.uniq.join(" ")}")
58
+ end
59
+
35
60
  self.data[:security_groups].delete(name)
36
61
  response.status = 200
37
62
  response.body = {
@@ -28,7 +28,7 @@ module Fog
28
28
  index += 1 # should start at 1 instead of 0
29
29
  params.merge!("Tag.#{index}.Key" => key)
30
30
  unless tags[key].nil?
31
- params.merge("Tag.#{index}.Value" => tags[key])
31
+ params.merge!("Tag.#{index}.Value" => tags[key])
32
32
  end
33
33
  end
34
34
 
@@ -21,7 +21,7 @@ module Fog
21
21
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAddresses.html]
22
22
  def describe_addresses(filters = {})
23
23
  unless filters.is_a?(Hash)
24
- Fog::Logger.warning("describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead [light_black](#{caller.first})[/]")
24
+ Fog::Logger.deprecation("describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead [light_black](#{caller.first})[/]")
25
25
  filters = {'public-ip' => [*filters]}
26
26
  end
27
27
  params = Fog::AWS.indexed_filters(filters)
@@ -38,7 +38,7 @@ module Fog
38
38
 
39
39
  def describe_addresses(filters = {})
40
40
  unless filters.is_a?(Hash)
41
- Fog::Logger.warning("describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead [light_black](#{caller.first})[/]")
41
+ Fog::Logger.deprecation("describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead [light_black](#{caller.first})[/]")
42
42
  filters = {'public-ip' => [*filters]}
43
43
  end
44
44
 
@@ -22,7 +22,7 @@ module Fog
22
22
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeAvailabilityZones.html]
23
23
  def describe_availability_zones(filters = {})
24
24
  unless filters.is_a?(Hash)
25
- Fog::Logger.warning("describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead [light_black](#{caller.first})[/]")
25
+ Fog::Logger.deprecation("describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead [light_black](#{caller.first})[/]")
26
26
  filters = {'public-ip' => [*filters]}
27
27
  end
28
28
  params = Fog::AWS.indexed_filters(filters)
@@ -39,7 +39,7 @@ module Fog
39
39
 
40
40
  def describe_availability_zones(filters = {})
41
41
  unless filters.is_a?(Hash)
42
- Fog::Logger.warning("describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead [light_black](#{caller.first})[/]")
42
+ Fog::Logger.deprecation("describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead [light_black](#{caller.first})[/]")
43
43
  filters = {'public-ip' => [*filters]}
44
44
  end
45
45
 
@@ -55,6 +55,9 @@ module Fog
55
55
  {"messageSet" => [], "regionName" => "us-west-1", "zoneName" => "us-west-1b", "zoneState" => "available"},
56
56
  {"messageSet" => [], "regionName" => "us-west-1", "zoneName" => "us-west-1c", "zoneState" => "available"},
57
57
 
58
+ {"messageSet" => [], "regionName" => "us-west-2", "zoneName" => "us-west-2a", "zoneState" => "available"},
59
+ {"messageSet" => [], "regionName" => "us-west-2", "zoneName" => "us-west-2b", "zoneState" => "available"},
60
+
58
61
  {"messageSet" => [], "regionName" => "eu-west-1", "zoneName" => "eu-west-1a", "zoneState" => "available"},
59
62
  {"messageSet" => [], "regionName" => "eu-west-1", "zoneName" => "eu-west-1b", "zoneState" => "available"},
60
63
  {"messageSet" => [], "regionName" => "eu-west-1", "zoneName" => "eu-west-1c", "zoneState" => "available"},
@@ -60,7 +60,7 @@ module Fog
60
60
 
61
61
  def describe_images(filters = {})
62
62
  unless filters.is_a?(Hash)
63
- Fog::Logger.warning("describe_images with #{filters.class} param is deprecated, use describe_images('image-id' => []) instead [light_black](#{caller.first})[/]")
63
+ Fog::Logger.deprecation("describe_images with #{filters.class} param is deprecated, use describe_images('image-id' => []) instead [light_black](#{caller.first})[/]")
64
64
  filters = {'image-id' => [*filters]}
65
65
  end
66
66
 
@@ -55,7 +55,7 @@ module Fog
55
55
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html]
56
56
  def describe_instances(filters = {})
57
57
  unless filters.is_a?(Hash)
58
- Fog::Logger.warning("describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead [light_black](#{caller.first})[/]")
58
+ Fog::Logger.deprecation("describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead [light_black](#{caller.first})[/]")
59
59
  filters = {'instance-id' => [*filters]}
60
60
  end
61
61
  params = {}
@@ -81,7 +81,7 @@ module Fog
81
81
 
82
82
  def describe_instances(filters = {})
83
83
  unless filters.is_a?(Hash)
84
- Fog::Logger.warning("describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead [light_black](#{caller.first})[/]")
84
+ Fog::Logger.deprecation("describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead [light_black](#{caller.first})[/]")
85
85
  filters = {'instance-id' => [*filters]}
86
86
  end
87
87
 
@@ -154,16 +154,25 @@ module Fog
154
154
  end
155
155
  end
156
156
 
157
+ brand_new_instances = instance_set.find_all do |instance|
158
+ instance['instanceState']['name'] == 'pending' &&
159
+ Time.now - instance['launchTime'] < Fog::Mock.delay * 2
160
+ end
161
+
162
+ # Error if filtering for a brand new instance directly
163
+ if (filters['instance-id'] || filters['instanceId']) && !brand_new_instances.empty?
164
+ raise Fog::Compute::AWS::NotFound.new("The instance ID '#{brand_new_instances.first['instanceId']}' does not exist")
165
+ end
166
+
167
+ # Otherwise don't include it in the list
168
+ instance_set = instance_set.reject {|instance| brand_new_instances.include?(instance) }
169
+
157
170
  response.status = 200
158
171
  reservation_set = {}
159
172
 
160
173
  instance_set.each do |instance|
161
174
  case instance['instanceState']['name']
162
175
  when 'pending'
163
- if Time.now - instance['launchTime'] < Fog::Mock.delay * 2
164
- raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance['instanceId']}' does not exist")
165
- end
166
-
167
176
  if Time.now - instance['launchTime'] >= Fog::Mock.delay * 2
168
177
  instance['ipAddress'] = Fog::AWS::Mock.ip_address
169
178
  instance['originalIpAddress'] = instance['ipAddress']
@@ -21,7 +21,7 @@ module Fog
21
21
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html]
22
22
  def describe_key_pairs(filters = {})
23
23
  unless filters.is_a?(Hash)
24
- Fog::Logger.warning("describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead [light_black](#{caller.first})[/]")
24
+ Fog::Logger.deprecation("describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead [light_black](#{caller.first})[/]")
25
25
  filters = {'key-name' => [*filters]}
26
26
  end
27
27
  params = Fog::AWS.indexed_filters(filters)
@@ -38,7 +38,7 @@ module Fog
38
38
 
39
39
  def describe_key_pairs(filters = {})
40
40
  unless filters.is_a?(Hash)
41
- Fog::Logger.warning("describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead [light_black](#{caller.first})[/]")
41
+ Fog::Logger.deprecation("describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead [light_black](#{caller.first})[/]")
42
42
  filters = {'key-name' => [*filters]}
43
43
  end
44
44
 
@@ -21,7 +21,7 @@ module Fog
21
21
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeRegions.html]
22
22
  def describe_regions(filters = {})
23
23
  unless filters.is_a?(Hash)
24
- Fog::Logger.warning("describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead [light_black](#{caller.first})[/]")
24
+ Fog::Logger.deprecation("describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead [light_black](#{caller.first})[/]")
25
25
  filters = {'region-name' => [*filters]}
26
26
  end
27
27
  params = Fog::AWS.indexed_filters(filters)
@@ -38,7 +38,7 @@ module Fog
38
38
 
39
39
  def describe_regions(filters = {})
40
40
  unless filters.is_a?(Hash)
41
- Fog::Logger.warning("describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead [light_black](#{caller.first})[/]")
41
+ Fog::Logger.deprecation("describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead [light_black](#{caller.first})[/]")
42
42
  filters = {'region-name' => [*filters]}
43
43
  end
44
44
 
@@ -29,7 +29,7 @@ module Fog
29
29
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstances.html]
30
30
  def describe_reserved_instances(filters = {})
31
31
  unless filters.is_a?(Hash)
32
- Fog::Logger.warning("describe_reserved_instances with #{filters.class} param is deprecated, use describe_reserved_instances('reserved-instances-id' => []) instead [light_black](#{caller.first})[/]")
32
+ Fog::Logger.deprecation("describe_reserved_instances with #{filters.class} param is deprecated, use describe_reserved_instances('reserved-instances-id' => []) instead [light_black](#{caller.first})[/]")
33
33
  filters = {'reserved-instances-id' => [*filters]}
34
34
  end
35
35
  params = Fog::AWS.indexed_filters(filters)
@@ -31,7 +31,7 @@ module Fog
31
31
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html]
32
32
  def describe_security_groups(filters = {})
33
33
  unless filters.is_a?(Hash)
34
- Fog::Logger.warning("describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead [light_black](#{caller.first})[/]")
34
+ Fog::Logger.deprecation("describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead [light_black](#{caller.first})[/]")
35
35
  filters = {'group-name' => [*filters]}
36
36
  end
37
37
  params = Fog::AWS.indexed_filters(filters)
@@ -48,7 +48,7 @@ module Fog
48
48
 
49
49
  def describe_security_groups(filters = {})
50
50
  unless filters.is_a?(Hash)
51
- Fog::Logger.warning("describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead [light_black](#{caller.first})[/]")
51
+ Fog::Logger.deprecation("describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead [light_black](#{caller.first})[/]")
52
52
  filters = {'group-name' => [*filters]}
53
53
  end
54
54
 
@@ -27,11 +27,11 @@ module Fog
27
27
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSnapshots.html]
28
28
  def describe_snapshots(filters = {}, options = {})
29
29
  unless filters.is_a?(Hash)
30
- Fog::Logger.warning("describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead [light_black](#{caller.first})[/]")
30
+ Fog::Logger.deprecation("describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead [light_black](#{caller.first})[/]")
31
31
  filters = {'snapshot-id' => [*filters]}
32
32
  end
33
33
  unless options.empty?
34
- Fog::Logger.warning("describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead [light_black](#{caller.first})[/]")
34
+ Fog::Logger.deprecation("describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead [light_black](#{caller.first})[/]")
35
35
  end
36
36
 
37
37
  for key in ['ExecutableBy', 'ImageId', 'Owner', 'RestorableBy']
@@ -54,11 +54,11 @@ module Fog
54
54
 
55
55
  def describe_snapshots(filters = {}, options = {})
56
56
  unless filters.is_a?(Hash)
57
- Fog::Logger.warning("describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead [light_black](#{caller.first})[/]")
57
+ Fog::Logger.deprecation("describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead [light_black](#{caller.first})[/]")
58
58
  filters = {'snapshot-id' => [*filters]}
59
59
  end
60
60
  unless options.empty?
61
- Fog::Logger.warning("describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead [light_black](#{caller.first})[/]")
61
+ Fog::Logger.deprecation("describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead [light_black](#{caller.first})[/]")
62
62
  end
63
63
 
64
64
  response = Excon::Response.new
@@ -31,7 +31,7 @@ module Fog
31
31
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVolumes.html]
32
32
  def describe_volumes(filters = {})
33
33
  unless filters.is_a?(Hash)
34
- Fog::Logger.warning("describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead [light_black](#{caller.first})[/]")
34
+ Fog::Logger.deprecation("describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead [light_black](#{caller.first})[/]")
35
35
  filters = {'volume-id' => [*filters]}
36
36
  end
37
37
  params = Fog::AWS.indexed_filters(filters)
@@ -48,7 +48,7 @@ module Fog
48
48
 
49
49
  def describe_volumes(filters = {})
50
50
  unless filters.is_a?(Hash)
51
- Fog::Logger.warning("describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead [light_black](#{caller.first})[/]")
51
+ Fog::Logger.deprecation("describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead [light_black](#{caller.first})[/]")
52
52
  filters = {'volume-id' => [*filters]}
53
53
  end
54
54
 
@@ -34,7 +34,7 @@ module Fog
34
34
  end
35
35
 
36
36
  def modify_instance_attributes(instance_id, attributes)
37
- Fog::Logger.warning("modify_instance_attributes method is deprecated, use 'modify_instance_attribute' instead")
37
+ Fog::Logger.deprecation("modify_instance_attributes method is deprecated, use 'modify_instance_attribute' instead")
38
38
  modify_instance_attribute(instance_id, attributes)
39
39
  end
40
40
 
@@ -8,15 +8,28 @@ module Fog
8
8
  # Remove permissions from a security group
9
9
  #
10
10
  # ==== Parameters
11
- # * 'GroupName'<~String> - Name of group
11
+ # * group_name<~String> - Name of group
12
12
  # * options<~Hash>:
13
13
  # * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
14
14
  # * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
15
15
  # or
16
- # * 'CidrIp' - CIDR range
17
- # * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
18
- # * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
19
- # * 'ToPort' - End of port range (or -1 for ICMP wildcard)
16
+ # * 'CidrIp'<~String> - CIDR range
17
+ # * 'FromPort'<~Integer> - Start of port range (or -1 for ICMP wildcard)
18
+ # * 'IpProtocol'<~String> - Ip protocol, must be in ['tcp', 'udp', 'icmp']
19
+ # * 'ToPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
20
+ # or
21
+ # * 'IpPermissions'<~Array>:
22
+ # * permission<~Hash>:
23
+ # * 'FromPort'<~Integer> - Start of port range (or -1 for ICMP wildcard)
24
+ # * 'Groups'<~Array>:
25
+ # * group<~Hash>:
26
+ # * 'GroupName'<~String> - Name of security group to authorize
27
+ # * 'UserId'<~String> - Name of owner to authorize
28
+ # * 'IpProtocol'<~String> - Ip protocol, must be in ['tcp', 'udp', 'icmp']
29
+ # * 'IpRanges'<~Array>:
30
+ # * ip_range<~Hash>:
31
+ # * 'CidrIp'<~String> - CIDR range
32
+ # * 'ToPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
20
33
  #
21
34
  # === Returns
22
35
  # * response<~Excon::Response>:
@@ -27,10 +40,15 @@ module Fog
27
40
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RevokeSecurityGroupIngress.html]
28
41
  def revoke_security_group_ingress(group_name, options = {})
29
42
  if group_name.is_a?(Hash)
30
- Fog::Logger.warning("Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
43
+ Fog::Logger.deprecation("Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
31
44
  options = group_name
32
- group_name = options['GroupName']
45
+ group_name = options.delete('GroupName')
46
+ end
47
+
48
+ if ip_permissions = options.delete('IpPermissions')
49
+ options.merge!(indexed_ip_permissions_params(ip_permissions))
33
50
  end
51
+
34
52
  request({
35
53
  'Action' => 'RevokeSecurityGroupIngress',
36
54
  'GroupName' => group_name,
@@ -45,36 +63,30 @@ module Fog
45
63
 
46
64
  def revoke_security_group_ingress(group_name, options = {})
47
65
  if group_name.is_a?(Hash)
48
- Fog::Logger.warning("Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
66
+ Fog::Logger.deprecation("Fog::AWS::Compute#revoke_security_group_ingress now requires the 'group_name' parameter. Only specifying an options hash is now deprecated [light_black](#{caller.first})[/]")
49
67
  options = group_name
50
- group_name = options['GroupName']
68
+ group_name = options.delete('GroupName')
51
69
  end
70
+
71
+ verify_permission_options(options)
72
+
52
73
  response = Excon::Response.new
53
74
  group = self.data[:security_groups][group_name]
75
+
54
76
  if group
55
- if source_group_name = options['SourceSecurityGroupName']
56
- group['ipPermissions'].delete_if do |permission|
57
- if source_owner_id = options['SourceSecurityGroupOwnerId']
58
- permission['groups'].first['groupName'] == source_group_name && permission['groups'].first['userId'] == source_owner_id
59
- else
60
- permission['groups'].first['groupName'] == source_group_name
77
+ normalized_permissions = normalize_permissions(options)
78
+
79
+ normalized_permissions.each do |permission|
80
+ if matching_permission = find_matching_permission(group, permission)
81
+ matching_permission['ipRanges'] -= permission['ipRanges']
82
+ matching_permission['groups'] -= permission['groups']
83
+
84
+ if matching_permission['ipRanges'].empty? && matching_permission['groups'].empty?
85
+ group['ipPermissions'].delete(matching_permission)
61
86
  end
62
87
  end
63
- else
64
- ingress = group['ipPermissions'].select {|permission|
65
- permission['fromPort'] == options['FromPort'] &&
66
- permission['ipProtocol'] == options['IpProtocol'] &&
67
- permission['toPort'] == options['ToPort'] &&
68
- (
69
- permission['ipRanges'].empty? ||
70
- (
71
- permission['ipRanges'].first &&
72
- permission['ipRanges'].first['cidrIp'] == options['CidrIp']
73
- )
74
- )
75
- }.first
76
- group['ipPermissions'].delete(ingress)
77
88
  end
89
+
78
90
  response.status = 200
79
91
  response.body = {
80
92
  'requestId' => Fog::AWS::Mock.request_id,
@@ -59,10 +59,10 @@ module Fog
59
59
  lb_names.map do |lb_name|
60
60
  lb = self.data[:load_balancers].find { |name, data| name == lb_name }
61
61
  raise Fog::AWS::ELB::NotFound unless lb
62
- lb[1]
62
+ lb[1].dup
63
63
  end.compact
64
64
  else
65
- self.data[:load_balancers].values
65
+ self.data[:load_balancers].map { |lb, values| values.dup }
66
66
  end
67
67
 
68
68
  response = Excon::Response.new
@@ -73,7 +73,7 @@ module Fog
73
73
  'RequestId' => Fog::AWS::Mock.request_id
74
74
  },
75
75
  'DescribeLoadBalancersResult' => {
76
- 'LoadBalancerDescriptions' => load_balancers
76
+ 'LoadBalancerDescriptions' => load_balancers.map { |lb| lb['Instances'] = lb['Instances'].map { |i| i['InstanceId'] }; lb }
77
77
  }
78
78
  }
79
79