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
@@ -126,7 +126,7 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do
126
126
 
127
127
  @instance_id = nil
128
128
  # Use a MS Windows AMI to test #get_password_data
129
- @windows_ami = 'ami-1cbd4475' # Microsoft Windows Server 2008 R2 Base 64-bit
129
+ @windows_ami = 'ami-62bd440b' # Amazon Public Images - Basic Microsoft Windows Server 2008 64-bit
130
130
 
131
131
  # Create a keypair for decrypting the password
132
132
  key_name = 'fog-test-key'
@@ -138,6 +138,21 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do
138
138
  data
139
139
  end
140
140
 
141
+ if Fog.mocking?
142
+ # Ensure the new instance doesn't show up in mock describe_instances right away
143
+ tests("#describe_instances").formats(@describe_instances_format) do
144
+ body = Fog::Compute[:aws].describe_instances.body
145
+ instance_ids = body['reservationSet'].map {|reservation| reservation['instancesSet'].map {|instance| instance['instanceId'] } }.flatten
146
+ test("doesn't include the new instance") { !instance_ids.include?(@instance_id) }
147
+ body
148
+ end
149
+
150
+ # But querying for the new instance directly should raise an error
151
+ tests("#describe_instances('instance-id' => '#{@instance_id}')").raises(Fog::Compute::AWS::NotFound) do
152
+ Fog::Compute[:aws].describe_instances('instance-id' => @instance_id)
153
+ end
154
+ end
155
+
141
156
  server = Fog::Compute[:aws].servers.get(@instance_id)
142
157
  while server.nil? do
143
158
  # It may take a moment to get the server after launching it
@@ -25,25 +25,207 @@ Shindo.tests('Fog::Compute[:aws] | security group requests', ['aws']) do
25
25
  Fog::Compute[:aws].create_security_group('fog_security_group', 'tests group').body
26
26
  end
27
27
 
28
- tests("#authorize_security_group_ingress('fog_security_group', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::Compute::Formats::BASIC) do
29
- Fog::Compute[:aws].authorize_security_group_ingress(
30
- 'fog_security_group',
28
+ tests("#create_security_group('fog_security_group_two', 'tests group')").formats(AWS::Compute::Formats::BASIC) do
29
+ Fog::Compute[:aws].create_security_group('fog_security_group_two', 'tests group').body
30
+ end
31
+
32
+ to_be_revoked = []
33
+ expected_permissions = []
34
+
35
+ permission = { 'SourceSecurityGroupName' => 'default' }
36
+ tests("#authorize_security_group_ingress('fog_security_group', #{permission.inspect})").formats(AWS::Compute::Formats::BASIC) do
37
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permission).body
38
+ end
39
+
40
+ to_be_revoked.push([permission, expected_permissions.dup])
41
+
42
+ expected_permissions = [
43
+ {"groups"=>[{"groupName"=>"default", "userId"=>@owner_id}],
44
+ "fromPort"=>1,
45
+ "ipRanges"=>[],
46
+ "ipProtocol"=>"tcp",
47
+ "toPort"=>65535},
48
+ {"groups"=>[{"groupName"=>"default", "userId"=>@owner_id}],
49
+ "fromPort"=>1,
50
+ "ipRanges"=>[],
51
+ "ipProtocol"=>"udp",
52
+ "toPort"=>65535},
53
+ {"groups"=>[{"groupName"=>"default", "userId"=>@owner_id}],
54
+ "fromPort"=>-1,
55
+ "ipRanges"=>[],
56
+ "ipProtocol"=>"icmp",
57
+ "toPort"=>-1}
58
+ ]
59
+
60
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
61
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
62
+ end
63
+
64
+ permission = { 'SourceSecurityGroupName' => 'fog_security_group_two', 'SourceSecurityGroupOwnerId' => @owner_id }
65
+ tests("#authorize_security_group_ingress('fog_security_group', #{permission.inspect})").formats(AWS::Compute::Formats::BASIC) do
66
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permission).body
67
+ end
68
+
69
+ to_be_revoked.push([permission, expected_permissions.dup])
70
+
71
+ expected_permissions = [
72
+ {"groups"=>
73
+ [{"userId"=>@owner_id, "groupName"=>"default"},
74
+ {"userId"=>@owner_id, "groupName"=>"fog_security_group_two"}],
75
+ "ipRanges"=>[],
76
+ "ipProtocol"=>"tcp",
77
+ "fromPort"=>1,
78
+ "toPort"=>65535},
79
+ {"groups"=>
80
+ [{"userId"=>@owner_id, "groupName"=>"default"},
81
+ {"userId"=>@owner_id, "groupName"=>"fog_security_group_two"}],
82
+ "ipRanges"=>[],
83
+ "ipProtocol"=>"udp",
84
+ "fromPort"=>1,
85
+ "toPort"=>65535},
86
+ {"groups"=>
87
+ [{"userId"=>@owner_id, "groupName"=>"default"},
88
+ {"userId"=>@owner_id, "groupName"=>"fog_security_group_two"}],
89
+ "ipRanges"=>[],
90
+ "ipProtocol"=>"icmp",
91
+ "fromPort"=>-1,
92
+ "toPort"=>-1}
93
+ ]
94
+
95
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
96
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
97
+ end
98
+
99
+ permission = { 'IpProtocol' => 'tcp', 'FromPort' => '22', 'ToPort' => '22' }
100
+ tests("#authorize_security_group_ingress('fog_security_group', #{permission.inspect})").formats(AWS::Compute::Formats::BASIC) do
101
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permission).body
102
+ end
103
+
104
+ to_be_revoked.push([permission, expected_permissions.dup])
105
+
106
+ # previous did nothing
107
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
108
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
109
+ end
110
+
111
+ permission = { 'IpProtocol' => 'tcp', 'FromPort' => '22', 'ToPort' => '22', 'CidrIp' => '10.0.0.0/8' }
112
+ tests("#authorize_security_group_ingress('fog_security_group', #{permission.inspect})").formats(AWS::Compute::Formats::BASIC) do
113
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permission).body
114
+ end
115
+
116
+ to_be_revoked.push([permission, expected_permissions.dup])
117
+
118
+ expected_permissions += [
119
+ {"groups"=>[],
120
+ "ipRanges"=>[{"cidrIp"=>"10.0.0.0/8"}],
121
+ "ipProtocol"=>"tcp",
122
+ "fromPort"=>22,
123
+ "toPort"=>22}
124
+ ]
125
+
126
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
127
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
128
+ end
129
+
130
+ # authorize with nested IpProtocol without IpRanges or Groups does nothing
131
+ permissions = {
132
+ 'IpPermissions' => [
133
+ { 'IpProtocol' => 'tcp', 'FromPort' => '22', 'ToPort' => '22' }
134
+ ]
135
+ }
136
+ tests("#authorize_security_group_ingress('fog_security_group', #{permissions.inspect})").formats(AWS::Compute::Formats::BASIC) do
137
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permissions).body
138
+ end
139
+
140
+ to_be_revoked.push([permissions, expected_permissions.dup])
141
+
142
+ # previous did nothing
143
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
144
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
145
+ end
146
+
147
+ # authorize with nested IpProtocol with IpRanges
148
+ permissions = {
149
+ 'IpPermissions' => [
31
150
  {
32
- 'FromPort' => 80,
33
- 'IpProtocol' => 'tcp',
34
- 'ToPort' => 80,
151
+ 'IpProtocol' => 'tcp', 'FromPort' => '80', 'ToPort' => '80',
152
+ 'IpRanges' => [{ 'CidrIp' => '192.168.0.0/24' }]
35
153
  }
36
- ).body
154
+ ]
155
+ }
156
+ tests("#authorize_security_group_ingress('fog_security_group', #{permissions.inspect})").formats(AWS::Compute::Formats::BASIC) do
157
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permissions).body
37
158
  end
38
159
 
39
- tests("#authorize_security_group_ingress('fog_security_group', {'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::Compute::Formats::BASIC) do
40
- Fog::Compute[:aws].authorize_security_group_ingress(
41
- 'fog_security_group',
160
+ to_be_revoked.push([permissions, expected_permissions.dup])
161
+
162
+ expected_permissions += [
163
+ {"groups"=>[],
164
+ "ipRanges"=>[{"cidrIp"=>"192.168.0.0/24"}],
165
+ "ipProtocol"=>"tcp",
166
+ "fromPort"=>80,
167
+ "toPort"=>80}
168
+ ]
169
+
170
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
171
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
172
+ end
173
+
174
+ # authorize with nested IpProtocol with Groups
175
+ permissions = {
176
+ 'IpPermissions' => [
42
177
  {
43
- 'SourceSecurityGroupName' => 'fog_security_group',
44
- 'SourceSecurityGroupOwnerId' => @owner_id
178
+ 'IpProtocol' => 'tcp', 'FromPort' => '8000', 'ToPort' => '8000',
179
+ 'Groups' => [{ 'GroupName' => 'fog_security_group_two' }]
180
+ }
181
+ ]
182
+ }
183
+ tests("#authorize_security_group_ingress('fog_security_group', #{permissions.inspect})").formats(AWS::Compute::Formats::BASIC) do
184
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permissions).body
185
+ end
186
+
187
+ to_be_revoked.push([permissions, expected_permissions.dup])
188
+
189
+ expected_permissions += [
190
+ {"groups"=>[{"userId"=>@owner_id, "groupName"=>"fog_security_group_two"}],
191
+ "ipRanges"=>[],
192
+ "ipProtocol"=>"tcp",
193
+ "fromPort"=>8000,
194
+ "toPort"=>8000}
195
+ ]
196
+
197
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
198
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
199
+ end
200
+
201
+ # authorize with nested IpProtocol with IpRanges and Groups
202
+ # try integers on this one instead of strings
203
+ permissions = {
204
+ 'IpPermissions' => [
205
+ {
206
+ 'IpProtocol' => 'tcp', 'FromPort' => 9000, 'ToPort' => 9000,
207
+ 'IpRanges' => [{ 'CidrIp' => '172.16.0.0/24' }],
208
+ 'Groups' => [{ 'GroupName' => 'fog_security_group_two' }]
45
209
  }
46
- ).body
210
+ ]
211
+ }
212
+ tests("#authorize_security_group_ingress('fog_security_group', #{permissions.inspect})").formats(AWS::Compute::Formats::BASIC) do
213
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', permissions).body
214
+ end
215
+
216
+ to_be_revoked.push([permissions, expected_permissions.dup])
217
+
218
+ expected_permissions += [
219
+ {"groups"=>
220
+ [{"userId"=>@owner_id, "groupName"=>"fog_security_group_two"}],
221
+ "ipRanges"=>[{"cidrIp"=>"172.16.0.0/24"}],
222
+ "ipProtocol"=>"tcp",
223
+ "fromPort"=>9000,
224
+ "toPort"=>9000}
225
+ ]
226
+
227
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
228
+ array_differences(expected_permissions, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
47
229
  end
48
230
 
49
231
  tests("#describe_security_groups").formats(@security_groups_format) do
@@ -54,36 +236,29 @@ Shindo.tests('Fog::Compute[:aws] | security group requests', ['aws']) do
54
236
  Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body
55
237
  end
56
238
 
57
- tests("#revoke_security_group_ingress('fog_security_group', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::Compute::Formats::BASIC) do
58
- Fog::Compute[:aws].revoke_security_group_ingress(
59
- 'fog_security_group',
60
- {
61
- 'FromPort' => 80,
62
- 'IpProtocol' => 'tcp',
63
- 'ToPort' => 80,
64
- }
65
- ).body
66
- end
239
+ to_be_revoked.reverse.each do |permission, expected_permissions_after|
240
+ tests("#revoke_security_group_ingress('fog_security_group', #{permission.inspect})").formats(AWS::Compute::Formats::BASIC) do
241
+ Fog::Compute[:aws].revoke_security_group_ingress('fog_security_group', permission).body
242
+ end
67
243
 
68
- tests("#revoke_security_group_ingress('fog_security_group', {'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::Compute::Formats::BASIC) do
69
- Fog::Compute[:aws].revoke_security_group_ingress(
70
- 'fog_security_group',
71
- {
72
- 'GroupName' => 'fog_security_group',
73
- 'SourceSecurityGroupName' => 'fog_security_group',
74
- 'SourceSecurityGroupOwnerId' => @owner_id
75
- }
76
- ).body
244
+ tests("#describe_security_groups('group-name' => 'fog_security_group')").returns([]) do
245
+ array_differences(expected_permissions_after, Fog::Compute[:aws].describe_security_groups('group-name' => 'fog_security_group').body['securityGroupInfo'].first['ipPermissions'])
246
+ end
77
247
  end
78
248
 
79
249
  tests("#delete_security_group('fog_security_group')").formats(AWS::Compute::Formats::BASIC) do
80
250
  Fog::Compute[:aws].delete_security_group('fog_security_group').body
81
251
  end
82
252
 
253
+ tests("#delete_security_group('fog_security_group_two')").formats(AWS::Compute::Formats::BASIC) do
254
+ Fog::Compute[:aws].delete_security_group('fog_security_group_two').body
255
+ end
256
+
83
257
  end
84
258
  tests('failure') do
85
259
 
86
260
  @security_group = Fog::Compute[:aws].security_groups.create(:description => 'tests group', :name => 'fog_security_group')
261
+ @other_security_group = Fog::Compute[:aws].security_groups.create(:description => 'tests group', :name => 'fog_other_security_group')
87
262
 
88
263
  tests("duplicate #create_security_group(#{@security_group.name}, #{@security_group.description})").raises(Fog::Compute::AWS::Error) do
89
264
  Fog::Compute[:aws].create_security_group(@security_group.name, @security_group.description)
@@ -110,6 +285,46 @@ Shindo.tests('Fog::Compute[:aws] | security group requests', ['aws']) do
110
285
  )
111
286
  end
112
287
 
288
+ tests("#authorize_security_group_ingress('fog_security_group', {'IpPermissions' => [{'IpProtocol' => 'tcp', 'FromPort' => 80, 'ToPort' => 80, 'IpRanges' => [{'CidrIp' => '10.0.0.0/8'}]}]})").formats(AWS::Compute::Formats::BASIC) do
289
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', {'IpPermissions' => [{'IpProtocol' => 'tcp', 'FromPort' => 80, 'ToPort' => 80, 'IpRanges' => [{'CidrIp' => '10.0.0.0/8'}]}]}).body
290
+ end
291
+
292
+ tests("#authorize_security_group_ingress('fog_security_group', {'IpPermissions' => [{'IpProtocol' => 'tcp', 'FromPort' => 80, 'ToPort' => 80, 'IpRanges' => [{'CidrIp' => '10.0.0.0/8'}]}]})").raises(Fog::Compute::AWS::Error) do
293
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', {'IpPermissions' => [{'IpProtocol' => 'tcp', 'FromPort' => 80, 'ToPort' => 80, 'IpRanges' => [{'CidrIp' => '10.0.0.0/8'}]}]})
294
+ end
295
+
296
+ tests("#authorize_security_group_ingress('fog_security_group', {'IpPermissions' => [{'Groups' => [{'GroupName' => '#{@other_security_group.name}'}], 'FromPort' => 80, 'ToPort' => 80, 'IpProtocol' => 'tcp'}]})").formats(AWS::Compute::Formats::BASIC) do
297
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', {'IpPermissions' => [{'Groups' => [{'GroupName' => @other_security_group.name}], 'FromPort' => 80, 'ToPort' => 80, 'IpProtocol' => 'tcp'}]}).body
298
+ end
299
+
300
+ tests("#delete_security_group('#{@other_security_group.name}')").raises(Fog::Compute::AWS::Error) do
301
+ Fog::Compute[:aws].delete_security_group(@other_security_group.name)
302
+ end
303
+
304
+ broken_params = [
305
+ {},
306
+ { "IpProtocol" => "what" },
307
+ { "IpProtocol" => "tcp" },
308
+ { "IpProtocol" => "what", "FromPort" => 1, "ToPort" => 1 },
309
+ ]
310
+ broken_params += broken_params.map do |broken_params_item|
311
+ { "IpPermissions" => [broken_params_item] }
312
+ end
313
+ broken_params += [
314
+ { "IpPermissions" => [] },
315
+ { "IpPermissions" => nil }
316
+ ]
317
+
318
+ broken_params.each do |broken_params_item|
319
+ tests("#authorize_security_group_ingress('fog_security_group', #{broken_params_item.inspect})").raises(Fog::Compute::AWS::Error) do
320
+ Fog::Compute[:aws].authorize_security_group_ingress('fog_security_group', broken_params_item)
321
+ end
322
+
323
+ tests("#revoke_security_group_ingress('fog_security_group', #{broken_params_item.inspect})").raises(Fog::Compute::AWS::Error) do
324
+ Fog::Compute[:aws].revoke_security_group_ingress('fog_security_group', broken_params_item)
325
+ end
326
+ end
327
+
113
328
  tests("#revoke_security_group_ingress('not_a_group_name', {'FromPort' => 80, 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::Compute::AWS::NotFound) do
114
329
  Fog::Compute[:aws].revoke_security_group_ingress(
115
330
  'not_a_group_name',
@@ -136,7 +351,11 @@ Shindo.tests('Fog::Compute[:aws] | security group requests', ['aws']) do
136
351
  end
137
352
 
138
353
  @security_group.destroy
354
+ @other_security_group.destroy
139
355
 
356
+ tests("#delete_security_group('default')").raises(Fog::Compute::AWS::Error) do
357
+ Fog::Compute[:aws].delete_security_group('default')
358
+ end
140
359
  end
141
360
 
142
361
  end
@@ -61,6 +61,8 @@ Shindo.tests('Fog::Compute[:aws] | tag requests', ['aws']) do
61
61
  end
62
62
  end
63
63
 
64
+ @volume.destroy
65
+
64
66
  tests("#delete_tags('#{@volume.identity}', 'foo' => 'bar')").formats(AWS::Compute::Formats::BASIC) do
65
67
  Fog::Compute[:aws].delete_tags(@volume.identity, 'foo' => 'bar').body
66
68
  end
@@ -72,6 +74,4 @@ Shindo.tests('Fog::Compute[:aws] | tag requests', ['aws']) do
72
74
  end
73
75
 
74
76
  end
75
-
76
- @volume.destroy
77
77
  end
@@ -0,0 +1,172 @@
1
+ class AWS
2
+
3
+ module EMR
4
+
5
+ module Formats
6
+ BASIC = {
7
+ 'RequestId' => String
8
+ }
9
+
10
+ RUN_JOB_FLOW = BASIC.merge({
11
+ 'JobFlowId' => String
12
+ })
13
+
14
+ ADD_INSTANCE_GROUPS = {
15
+ 'JobFlowId' => String,
16
+ 'InstanceGroupIds' => Array
17
+ }
18
+
19
+ SIMPLE_DESCRIBE_JOB_FLOW = {
20
+ 'JobFlows' => [{
21
+ 'Name' => String,
22
+ 'BootstrapActions' => {
23
+ 'ScriptBootstrapActionConfig' => {
24
+ 'Args' => Array
25
+ }
26
+ },
27
+ 'ExecutionStatusDetail' => {
28
+ 'CreationDateTime' => String,
29
+ 'State' => String,
30
+ 'LastStateChangeReason' => String
31
+ },
32
+ 'Steps' => [{
33
+ 'ActionOnFailure' => String,
34
+ 'Name' => String,
35
+ 'StepConfig' => {
36
+ 'HadoopJarStepConfig' => {
37
+ 'MainClass' => String,
38
+ 'Jar' => String,
39
+ 'Args' => Array,
40
+ 'Properties' => Array
41
+ }
42
+ },
43
+ 'ExecutionStatusDetail' => {
44
+ 'CreationDateTime' => String,
45
+ 'State' => String
46
+ }
47
+ }],
48
+ 'JobFlowId' => String,
49
+ 'Instances' => {
50
+ 'InstanceCount' => String,
51
+ 'NormalizedInstanceHours' => String,
52
+ 'KeepJobFlowAliveWhenNoSteps' => String,
53
+ 'Placement' => {
54
+ 'AvailabilityZone' => String
55
+ },
56
+ 'MasterInstanceType' => String,
57
+ 'SlaveInstanceType' => String,
58
+ 'InstanceGroups' => Array,
59
+ 'TerminationProtected' => String,
60
+ 'HadoopVersion' => String
61
+ }
62
+ }]
63
+ }
64
+
65
+ JOB_FLOW_WITHOUT_CHANGE = {
66
+ 'JobFlows' => [{
67
+ 'Name' => String,
68
+ 'BootstrapActions' => {
69
+ 'ScriptBootstrapActionConfig' => {
70
+ 'Args' => Array
71
+ }
72
+ },
73
+ 'ExecutionStatusDetail' => {
74
+ 'CreationDateTime' => String,
75
+ 'State' => String,
76
+ 'LastStateChangeReason' => NilClass
77
+ },
78
+ 'Steps' => [{
79
+ 'ActionOnFailure' => String,
80
+ 'Name' => String,
81
+ 'StepConfig' => {
82
+ 'HadoopJarStepConfig' => {
83
+ 'MainClass' => String,
84
+ 'Jar' => String,
85
+ 'Args' => Array,
86
+ 'Properties' => Array
87
+ }
88
+ },
89
+ 'ExecutionStatusDetail' => {
90
+ 'CreationDateTime' => String,
91
+ 'State' => String
92
+ }
93
+ }],
94
+ 'JobFlowId' => String,
95
+ 'Instances' => {
96
+ 'InstanceCount' => String,
97
+ 'NormalizedInstanceHours' => String,
98
+ 'KeepJobFlowAliveWhenNoSteps' => String,
99
+ 'Placement' => {
100
+ 'AvailabilityZone' => String
101
+ },
102
+ 'MasterInstanceType' => String,
103
+ 'SlaveInstanceType' => String,
104
+ 'InstanceGroups' => Array,
105
+ 'TerminationProtected' => String,
106
+ 'HadoopVersion' => String
107
+ }
108
+ }]
109
+ }
110
+
111
+ DESCRIBE_JOB_FLOW_WITH_INSTANCE_GROUPS = {
112
+ 'JobFlows' => [{
113
+ 'Name' => String,
114
+ 'BootstrapActions' => {
115
+ 'ScriptBootstrapActionConfig' => {
116
+ 'Args' => Array
117
+ }
118
+ },
119
+ 'ExecutionStatusDetail' => {
120
+ 'CreationDateTime' => String,
121
+ 'State' => String,
122
+ 'LastStateChangeReason' => NilClass
123
+ },
124
+ 'Steps' => [{
125
+ 'ActionOnFailure' => String,
126
+ 'Name' => String,
127
+ 'StepConfig' => {
128
+ 'HadoopJarStepConfig' => {
129
+ 'MainClass' => String,
130
+ 'Jar' => String,
131
+ 'Args' => Array,
132
+ 'Properties' => Array
133
+ }
134
+ },
135
+ 'ExecutionStatusDetail' => {
136
+ 'CreationDateTime' => String,
137
+ 'State' => String
138
+ }
139
+ }],
140
+ 'JobFlowId' => String,
141
+ 'Instances' => {
142
+ 'InstanceCount' => String,
143
+ 'NormalizedInstanceHours' => String,
144
+ 'KeepJobFlowAliveWhenNoSteps' => String,
145
+ 'Placement' => {
146
+ 'AvailabilityZone' => String
147
+ },
148
+ 'InstanceGroups' => [{
149
+ 'Name' => String,
150
+ 'InstanceRole' => String,
151
+ 'CreationDateTime' => String,
152
+ 'LastStateChangeReason' => nil,
153
+ 'InstanceGroupId' => String,
154
+ 'Market' => String,
155
+ 'InstanceType' => String,
156
+ 'State' => String,
157
+ 'InstanceRunningCount' => String,
158
+ 'InstanceRequestCount' => String
159
+ }],
160
+ 'MasterInstanceType' => String,
161
+ 'SlaveInstanceType' => String,
162
+ 'InstanceGroups' => Array,
163
+ 'TerminationProtected' => String,
164
+ 'HadoopVersion' => String
165
+ }
166
+ }]
167
+ }
168
+
169
+ end
170
+ end
171
+
172
+ end
@@ -0,0 +1,106 @@
1
+ Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do
2
+
3
+ pending if Fog.mocking?
4
+
5
+ @job_flow_name = "fog_job_flow_#{Time.now.to_f.to_s.gsub('.','')}"
6
+
7
+ @job_flow_options = {
8
+ 'Instances' => {
9
+ 'MasterInstanceType' => 'm1.small',
10
+ 'SlaveInstanceType' => 'm1.small',
11
+ 'InstanceCount' => 2,
12
+ 'Placement' => {
13
+ 'AvailabilityZone' => 'us-east-1a'
14
+ },
15
+ 'KeepJobFlowAliveWhenNoSteps' => false,
16
+ 'TerminationProtected' => false,
17
+ 'HadoopVersion' => '0.20'
18
+ }
19
+ }
20
+
21
+ @job_flow_steps = {
22
+ 'Steps' => [{
23
+ 'Name' => 'Dummy streaming job',
24
+ 'ActionOnFailure' => 'CONTINUE',
25
+ 'HadoopJarStep' => {
26
+ 'Jar' => '/home/hadoop/contrib/streaming/hadoop-streaming.jar',
27
+ 'MainClass' => nil,
28
+ 'Args' => %w(-input s3n://elasticmapreduce/samples/wordcount/input -output hdfs:///examples/output/2011-11-03T090856 -mapper s3n://elasticmapreduce/samples/wordcount/wordSplitter.py -reducer aggregate)
29
+ }
30
+ }]
31
+ }
32
+
33
+ @instance_group_name = "fog_instance_group_#{Time.now.to_f.to_s.gsub('.','')}"
34
+ @instance_groups = {
35
+ 'InstanceGroups' => [{
36
+ 'Name' => @instance_group_name,
37
+ 'InstanceRole' => 'TASK',
38
+ 'InstanceType' => 'm1.small',
39
+ 'InstanceCount' => 2
40
+ }]
41
+ }
42
+
43
+ result = AWS[:emr].run_job_flow(@job_flow_name, @job_flow_options).body
44
+ @job_flow_id = result['JobFlowId']
45
+
46
+ tests('success') do
47
+
48
+ tests("#add_instance_groups").formats(AWS::EMR::Formats::ADD_INSTANCE_GROUPS) do
49
+ pending if Fog.mocking?
50
+
51
+ result = AWS[:emr].add_instance_groups(@job_flow_id, @instance_groups).body
52
+
53
+ @instance_group_id = result['InstanceGroupIds'].first
54
+
55
+ result
56
+ end
57
+
58
+ tests("#describe_job_flows_with_instance_groups").formats(AWS::EMR::Formats::DESCRIBE_JOB_FLOW_WITH_INSTANCE_GROUPS) do
59
+ pending if Fog.mocking?
60
+
61
+ result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
62
+
63
+ result
64
+ end
65
+
66
+ tests("#modify_instance_groups").formats(AWS::EMR::Formats::BASIC) do
67
+ pending if Fog.mocking?
68
+
69
+ # Add a step so the state doesn't go directly from STARTING to SHUTTING_DOWN
70
+ AWS[:emr].add_job_flow_steps(@job_flow_id, @job_flow_steps)
71
+
72
+ # Wait until job has started before modifying the instance group
73
+ begin
74
+ sleep 10
75
+
76
+ result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
77
+ job_flow = result['JobFlows'].first
78
+ state = job_flow['ExecutionStatusDetail']['State']
79
+ print "."
80
+ end while(state == 'STARTING')
81
+
82
+ # Check results
83
+ result = AWS[:emr].modify_instance_groups('InstanceGroups' => [{'InstanceGroupId' => @instance_group_id, 'InstanceCount' => 4}]).body
84
+
85
+ # Check the it actually modified the instance count
86
+ tests("modify worked?") do
87
+ ig_res = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
88
+
89
+ matched = false
90
+ jf = ig_res['JobFlows'].first
91
+ jf['Instances']['InstanceGroups'].each do | ig |
92
+ if ig['InstanceGroupId'] == @instance_group_id
93
+ matched = true if ig['InstanceRequestCount'].to_i == 4
94
+ end
95
+ end
96
+
97
+ matched
98
+ end
99
+
100
+ result
101
+ end
102
+
103
+ end
104
+
105
+ AWS[:emr].terminate_job_flows('JobFlowIds' => [@job_flow_id])
106
+ end