bbcloud 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/.gitignore +3 -2
  2. data/Gemfile +3 -0
  3. data/README +11 -1
  4. data/README.rdoc +11 -1
  5. data/Rakefile +12 -0
  6. data/bbcloud.gemspec +10 -10
  7. data/bin/brightbox-accounts +7 -2
  8. data/bin/brightbox-cloudips +7 -2
  9. data/bin/brightbox-config +7 -2
  10. data/bin/brightbox-images +7 -2
  11. data/bin/brightbox-lbs +7 -2
  12. data/bin/brightbox-servers +7 -2
  13. data/bin/brightbox-types +7 -2
  14. data/bin/brightbox-users +7 -2
  15. data/bin/brightbox-zones +7 -2
  16. data/lib/bbcloud.rb +43 -0
  17. data/lib/bbcloud/accounts.rb +5 -3
  18. data/lib/bbcloud/command_generator.rb +50 -0
  19. data/lib/bbcloud/commands/accounts-list.rb +13 -11
  20. data/lib/bbcloud/commands/accounts-reset-ftp-password.rb +26 -23
  21. data/lib/bbcloud/commands/accounts-show.rb +20 -16
  22. data/lib/bbcloud/commands/cloudips-create.rb +16 -14
  23. data/lib/bbcloud/commands/cloudips-destroy.rb +29 -26
  24. data/lib/bbcloud/commands/cloudips-list.rb +13 -11
  25. data/lib/bbcloud/commands/cloudips-map.rb +48 -46
  26. data/lib/bbcloud/commands/cloudips-show.rb +15 -12
  27. data/lib/bbcloud/commands/cloudips-unmap.rb +28 -25
  28. data/lib/bbcloud/commands/config-client-add.rb +33 -31
  29. data/lib/bbcloud/commands/config-client-default.rb +18 -16
  30. data/lib/bbcloud/commands/config-client-list.rb +19 -16
  31. data/lib/bbcloud/commands/config-client-remove.rb +18 -16
  32. data/lib/bbcloud/commands/images-destroy.rb +18 -16
  33. data/lib/bbcloud/commands/images-list.rb +20 -18
  34. data/lib/bbcloud/commands/images-register.rb +21 -19
  35. data/lib/bbcloud/commands/images-show.rb +17 -15
  36. data/lib/bbcloud/commands/lbs-add-nodes.rb +15 -13
  37. data/lib/bbcloud/commands/lbs-create.rb +65 -63
  38. data/lib/bbcloud/commands/lbs-destroy.rb +13 -11
  39. data/lib/bbcloud/commands/lbs-list.rb +13 -11
  40. data/lib/bbcloud/commands/lbs-remove-nodes.rb +15 -13
  41. data/lib/bbcloud/commands/lbs-show.rb +15 -13
  42. data/lib/bbcloud/commands/lbs-update.rb +59 -57
  43. data/lib/bbcloud/commands/servers-activate-cloud.rb +18 -16
  44. data/lib/bbcloud/commands/servers-create.rb +80 -77
  45. data/lib/bbcloud/commands/servers-destroy.rb +17 -15
  46. data/lib/bbcloud/commands/servers-list.rb +14 -14
  47. data/lib/bbcloud/commands/servers-show.rb +39 -37
  48. data/lib/bbcloud/commands/servers-shutdown.rb +14 -12
  49. data/lib/bbcloud/commands/servers-snapshot.rb +14 -12
  50. data/lib/bbcloud/commands/servers-start.rb +15 -13
  51. data/lib/bbcloud/commands/servers-stop.rb +14 -12
  52. data/lib/bbcloud/commands/types-list.rb +13 -11
  53. data/lib/bbcloud/commands/types-show.rb +18 -16
  54. data/lib/bbcloud/commands/users-list.rb +13 -11
  55. data/lib/bbcloud/commands/users-show.rb +17 -15
  56. data/lib/bbcloud/commands/users-update.rb +27 -25
  57. data/lib/bbcloud/commands/zones-list.rb +13 -11
  58. data/lib/bbcloud/config.rb +125 -111
  59. data/lib/bbcloud/error_parser.rb +34 -0
  60. data/lib/bbcloud/fog_extensions.rb +19 -0
  61. data/lib/bbcloud/gli_global_hooks.rb +56 -0
  62. data/lib/bbcloud/logging.rb +40 -0
  63. data/lib/bbcloud/ruby_core_ext.rb +9 -0
  64. data/lib/bbcloud/servers.rb +7 -2
  65. data/lib/bbcloud/tables.rb +78 -73
  66. data/lib/bbcloud/vendor/gli/.gitignore +10 -0
  67. data/lib/bbcloud/vendor/gli/.rvmrc +1 -0
  68. data/lib/bbcloud/vendor/gli/Gemfile +5 -0
  69. data/lib/bbcloud/vendor/gli/LICENSE.txt +201 -0
  70. data/lib/bbcloud/vendor/gli/README.rdoc +54 -0
  71. data/lib/bbcloud/vendor/gli/Rakefile +84 -0
  72. data/lib/bbcloud/vendor/gli/bin/gli +72 -0
  73. data/lib/bbcloud/vendor/gli/bin/report_on_rake_results +10 -0
  74. data/lib/bbcloud/vendor/gli/bin/test_all_rubies.sh +2 -0
  75. data/lib/bbcloud/vendor/gli/features/gli_executable.feature +88 -0
  76. data/lib/bbcloud/vendor/gli/features/gli_init.feature +122 -0
  77. data/lib/bbcloud/vendor/gli/features/step_definitions/gli_executable_steps.rb +12 -0
  78. data/lib/bbcloud/vendor/gli/features/step_definitions/gli_init_steps.rb +4 -0
  79. data/lib/bbcloud/vendor/gli/features/support/env.rb +21 -0
  80. data/lib/bbcloud/vendor/gli/gli.cheat +80 -0
  81. data/lib/bbcloud/vendor/gli/gli.gemspec +46 -0
  82. data/lib/bbcloud/vendor/gli/gli.rdoc +51 -0
  83. data/lib/bbcloud/vendor/gli/lib/gli.rb +560 -0
  84. data/lib/bbcloud/vendor/gli/lib/gli/command.rb +124 -0
  85. data/lib/bbcloud/vendor/gli/lib/gli/command_line_token.rb +58 -0
  86. data/lib/bbcloud/vendor/gli/lib/gli/copy_options_to_aliases.rb +33 -0
  87. data/lib/bbcloud/vendor/gli/lib/gli/exceptions.rb +45 -0
  88. data/lib/bbcloud/vendor/gli/lib/gli/flag.rb +67 -0
  89. data/lib/bbcloud/vendor/gli/lib/gli/options.rb +19 -0
  90. data/lib/bbcloud/vendor/gli/lib/gli/switch.rb +63 -0
  91. data/lib/bbcloud/vendor/gli/lib/gli/terminal.rb +79 -0
  92. data/lib/bbcloud/vendor/gli/lib/gli_version.rb +3 -0
  93. data/lib/bbcloud/vendor/gli/lib/support/help.rb +180 -0
  94. data/lib/bbcloud/vendor/gli/lib/support/initconfig.rb +34 -0
  95. data/lib/bbcloud/vendor/gli/lib/support/rdoc.rb +119 -0
  96. data/lib/bbcloud/vendor/gli/lib/support/scaffold.rb +284 -0
  97. data/lib/bbcloud/vendor/gli/test/config.yaml +9 -0
  98. data/lib/bbcloud/vendor/gli/test/gli.reek +116 -0
  99. data/lib/bbcloud/vendor/gli/test/roodi.yaml +9 -0
  100. data/lib/bbcloud/vendor/gli/test/tc_command.rb +329 -0
  101. data/lib/bbcloud/vendor/gli/test/tc_flag.rb +67 -0
  102. data/lib/bbcloud/vendor/gli/test/tc_gli.rb +429 -0
  103. data/lib/bbcloud/vendor/gli/test/tc_options.rb +31 -0
  104. data/lib/bbcloud/vendor/gli/test/tc_parsing.rb +279 -0
  105. data/lib/bbcloud/vendor/gli/test/tc_switch.rb +80 -0
  106. data/lib/bbcloud/vendor/gli/test/tc_terminal.rb +91 -0
  107. data/lib/bbcloud/version.rb +1 -1
  108. data/pkg/bbcloud-0.12.0.gem +0 -0
  109. data/spec/fixtures/vcr_cassettes/server_list.yml +117 -0
  110. data/spec/servers_spec.rb +36 -0
  111. data/spec/spec_helper.rb +24 -0
  112. data/spec/support/common_helpers.rb +47 -0
  113. metadata +129 -135
  114. data/lib/bbcloud/cli.rb +0 -160
  115. data/lib/bbcloud/vendor/fog/lib/fog.rb +0 -14
  116. data/lib/bbcloud/vendor/fog/lib/fog/compute.rb +0 -43
  117. data/lib/bbcloud/vendor/fog/lib/fog/compute/brightbox.rb +0 -162
  118. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/account.rb +0 -51
  119. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ip.rb +0 -47
  120. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ips.rb +0 -34
  121. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavor.rb +0 -33
  122. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavors.rb +0 -28
  123. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/image.rb +0 -56
  124. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/images.rb +0 -28
  125. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancer.rb +0 -50
  126. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancers.rb +0 -28
  127. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/server.rb +0 -108
  128. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/servers.rb +0 -29
  129. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/user.rb +0 -39
  130. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/users.rb +0 -29
  131. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zone.rb +0 -21
  132. data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zones.rb +0 -29
  133. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/activate_console_server.rb +0 -20
  134. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_listeners_load_balancer.rb +0 -20
  135. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_nodes_load_balancer.rb +0 -20
  136. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_api_client.rb +0 -19
  137. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_cloud_ip.rb +0 -19
  138. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_image.rb +0 -19
  139. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_load_balancer.rb +0 -19
  140. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_server.rb +0 -19
  141. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_api_client.rb +0 -20
  142. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_cloud_ip.rb +0 -20
  143. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_image.rb +0 -20
  144. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_load_balancer.rb +0 -20
  145. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_server.rb +0 -20
  146. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_account.rb +0 -19
  147. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_api_client.rb +0 -20
  148. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_cloud_ip.rb +0 -20
  149. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_image.rb +0 -20
  150. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_interface.rb +0 -20
  151. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_load_balancer.rb +0 -20
  152. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server.rb +0 -20
  153. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server_type.rb +0 -20
  154. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_user.rb +0 -20
  155. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_zone.rb +0 -20
  156. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_api_clients.rb +0 -19
  157. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_cloud_ips.rb +0 -19
  158. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_images.rb +0 -19
  159. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_load_balancers.rb +0 -19
  160. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_server_types.rb +0 -19
  161. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_servers.rb +0 -19
  162. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_users.rb +0 -19
  163. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_zones.rb +0 -19
  164. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/map_cloud_ip.rb +0 -20
  165. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_listeners_load_balancer.rb +0 -20
  166. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_nodes_load_balancer.rb +0 -20
  167. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/reset_ftp_password_account.rb +0 -19
  168. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/resize_server.rb +0 -19
  169. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/shutdown_server.rb +0 -20
  170. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/snapshot_server.rb +0 -20
  171. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/start_server.rb +0 -20
  172. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/stop_server.rb +0 -20
  173. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/unmap_cloud_ip.rb +0 -20
  174. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_account.rb +0 -20
  175. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_api_client.rb +0 -21
  176. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_image.rb +0 -21
  177. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_load_balancer.rb +0 -21
  178. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_server.rb +0 -21
  179. data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_user.rb +0 -21
  180. data/lib/bbcloud/vendor/fog/lib/fog/core.rb +0 -32
  181. data/lib/bbcloud/vendor/fog/lib/fog/core/attributes.rb +0 -178
  182. data/lib/bbcloud/vendor/fog/lib/fog/core/collection.rb +0 -127
  183. data/lib/bbcloud/vendor/fog/lib/fog/core/connection.rb +0 -35
  184. data/lib/bbcloud/vendor/fog/lib/fog/core/credentials.rb +0 -92
  185. data/lib/bbcloud/vendor/fog/lib/fog/core/deprecation.rb +0 -23
  186. data/lib/bbcloud/vendor/fog/lib/fog/core/errors.rb +0 -20
  187. data/lib/bbcloud/vendor/fog/lib/fog/core/hmac.rb +0 -48
  188. data/lib/bbcloud/vendor/fog/lib/fog/core/mock.rb +0 -68
  189. data/lib/bbcloud/vendor/fog/lib/fog/core/model.rb +0 -57
  190. data/lib/bbcloud/vendor/fog/lib/fog/core/parser.rb +0 -99
  191. data/lib/bbcloud/vendor/fog/lib/fog/core/provider.rb +0 -18
  192. data/lib/bbcloud/vendor/fog/lib/fog/core/scp.rb +0 -67
  193. data/lib/bbcloud/vendor/fog/lib/fog/core/service.rb +0 -175
  194. data/lib/bbcloud/vendor/fog/lib/fog/core/ssh.rb +0 -120
  195. data/lib/bbcloud/vendor/fog/lib/fog/core/time.rb +0 -27
  196. data/lib/bbcloud/vendor/fog/lib/fog/core/wait_for.rb +0 -17
  197. data/lib/bbcloud/vendor/fog/lib/fog/providers.rb +0 -9
  198. data/lib/bbcloud/vendor/fog/lib/fog/providers/brightbox.rb +0 -9
@@ -1,24 +1,26 @@
1
- desc 'Set the default api client in the config'
2
- arg_name 'alias'
3
- command [:client_default] do |c|
1
+ module Brightbox
2
+ desc 'Set the default api client in the config'
3
+ arg_name 'alias'
4
+ command [:client_default] do |c|
4
5
 
5
- c.action do |global_options, options, args|
6
+ c.action do |global_options, options, args|
6
7
 
7
- info "Using config file #{CONFIG.config_filename}"
8
- calias = args.shift
8
+ info "Using config file #{CONFIG.config_filename}"
9
+ calias = args.shift
9
10
 
10
- if calias.nil?
11
- raise "You must specify the api alias you want to set as the default"
12
- end
11
+ if calias.nil?
12
+ raise "You must specify the api alias you want to set as the default"
13
+ end
13
14
 
14
- client_config = CONFIG[calias]
15
- if client_config.empty?
16
- raise "An api client with the alias #{calias} does not exist in the config"
17
- end
15
+ client_config = CONFIG[calias]
16
+ if client_config.empty?
17
+ raise "An api client with the alias #{calias} does not exist in the config"
18
+ end
18
19
 
19
- info "Setting #{calias} as default api client"
20
- CONFIG['core']['default_client'] = calias
21
- CONFIG.save!
20
+ info "Setting #{calias} as default api client"
21
+ CONFIG['core']['default_client'] = calias
22
+ CONFIG.save!
22
23
 
24
+ end
23
25
  end
24
26
  end
@@ -1,22 +1,25 @@
1
- desc 'Lists the api clients defined in the config'
2
- command [:client_list] do |c|
1
+ module Brightbox
2
+ desc 'Lists the api clients defined in the config'
3
+ command [:client_list] do |c|
3
4
 
4
- c.action do |global_options, options, args|
5
+ c.action do |global_options, options, args|
5
6
 
6
- info "Using config file #{CONFIG.config_filename}"
7
+ info "Using config file #{CONFIG.config_filename}"
7
8
 
8
- clients = CONFIG.clients.collect do |calias|
9
- c = CONFIG[calias]
10
- calias = calias + "*" if CONFIG.client_name == calias and CONFIG.clients.size > 1
11
- {
12
- :alias => calias,
13
- :client_id => c["client_id"],
14
- :secret => c["secret"],
15
- :api_url => c["api_url"],
16
- :auth_url => c["auth_url"] || c["api_url"]
17
- }
18
- end
9
+ clients = CONFIG.clients.collect do |calias|
10
+ c = CONFIG[calias]
11
+ calias = calias + "*" if CONFIG.client_name == calias and CONFIG.clients.size > 1
12
+ {
13
+ :alias => calias,
14
+ :client_id => c["client_id"],
15
+ :secret => c["secret"],
16
+ :api_url => c["api_url"],
17
+ :auth_url => c["auth_url"] || c["api_url"]
18
+ }
19
+ end
19
20
 
20
- render_table clients, :fields => [:alias, :client_id, :secret, :api_url, :auth_url]
21
+ render_table clients, :fields => [:alias, :client_id, :secret, :api_url, :auth_url]
22
+ end
21
23
  end
24
+
22
25
  end
@@ -1,25 +1,27 @@
1
- desc 'Remove api client details from config'
2
- arg_name 'alias'
3
- command [:client_remove] do |c|
1
+ module Brightbox
2
+ desc 'Remove api client details from config'
3
+ arg_name 'alias'
4
+ command [:client_remove] do |c|
4
5
 
5
- c.action do |global_options, options, args|
6
+ c.action do |global_options, options, args|
6
7
 
7
- info "Using config file #{CONFIG.config_filename}"
8
+ info "Using config file #{CONFIG.config_filename}"
8
9
 
9
- calias = args.shift
10
+ calias = args.shift
10
11
 
11
- if calias.nil?
12
- raise "You must specify the api alias you want to remove"
13
- end
12
+ if calias.nil?
13
+ raise "You must specify the api alias you want to remove"
14
+ end
14
15
 
15
- client_config = CONFIG[calias]
16
- if client_config.empty?
17
- raise "An api client with alias #{calias} does not exist in the config"
18
- end
16
+ client_config = CONFIG[calias]
17
+ if client_config.empty?
18
+ raise "An api client with alias #{calias} does not exist in the config"
19
+ end
19
20
 
20
- info "Removing api client #{calias}"
21
- CONFIG.delete_section calias
22
- CONFIG.save!
21
+ info "Removing api client #{calias}"
22
+ CONFIG.delete_section calias
23
+ CONFIG.save!
23
24
 
25
+ end
24
26
  end
25
27
  end
@@ -1,24 +1,26 @@
1
- desc 'Destroy images'
2
- arg_name 'image-id...'
3
- command [:destroy] do |c|
1
+ module Brightbox
2
+ desc 'Destroy images'
3
+ arg_name 'image-id...'
4
+ command [:destroy] do |c|
4
5
 
5
- c.action do |global_options,options,args|
6
+ c.action do |global_options,options,args|
6
7
 
7
- if args.empty?
8
- raise "You must specify the images you want to destroy"
9
- end
8
+ if args.empty?
9
+ raise "You must specify the images you want to destroy"
10
+ end
10
11
 
11
- images = Image.find_or_call(args) do |id|
12
- raise "Couldn't find image #{id}"
13
- end
12
+ images = Image.find_or_call(args) do |id|
13
+ raise "Couldn't find image #{id}"
14
+ end
14
15
 
15
- images.each do |i|
16
- info "Destroying image #{i}"
17
- i.destroy
18
- i.reload
19
- end
16
+ images.each do |i|
17
+ info "Destroying image #{i}"
18
+ i.destroy
19
+ i.reload
20
+ end
20
21
 
21
- render_table(images)
22
+ render_table(images)
22
23
 
24
+ end
23
25
  end
24
26
  end
@@ -1,26 +1,28 @@
1
- desc 'List available images'
2
- arg_name '[image-id...]'
3
- command [:list] do |c|
4
- c.action do |global_options, options, args|
1
+ module Brightbox
2
+ desc 'List available images'
3
+ arg_name '[image-id...]'
4
+ command [:list] do |c|
5
+ c.action do |global_options, options, args|
5
6
 
6
- if args.empty?
7
- images = Image.find(:all)
8
- else
9
- images = Image.find_or_call(args) do |id|
10
- warn "Couldn't find image #{id}"
7
+ if args.empty?
8
+ images = Image.find(:all)
9
+ else
10
+ images = Image.find_or_call(args) do |id|
11
+ warn "Couldn't find image #{id}"
12
+ end
11
13
  end
12
- end
13
14
 
14
- snapshots = images.select { |i| i.source_type == 'snapshot' }
15
+ snapshots = images.select { |i| i.source_type == 'snapshot' }
15
16
 
16
- images = images - snapshots
17
+ images = images - snapshots
17
18
 
18
- images.sort! do |a,b|
19
- [a.official ? 0 : 1, a.name, a.arch] <=> [b.official ? 0 : 1, b.name, b.arch]
20
- end
19
+ images.sort! do |a,b|
20
+ [a.official ? 0 : 1, a.name, a.arch] <=> [b.official ? 0 : 1, b.name, b.arch]
21
+ end
21
22
 
22
- snapshots.sort! { |a, b| a.created_at <=> b.created_at }
23
-
24
- render_table(images + snapshots, global_options)
23
+ snapshots.sort! { |a, b| a.created_at <=> b.created_at }
24
+
25
+ render_table(images + snapshots, global_options)
26
+ end
25
27
  end
26
28
  end
@@ -1,31 +1,33 @@
1
- desc 'Register an image'
2
- command [:register] do |c|
1
+ module Brightbox
2
+ desc 'Register an image'
3
+ command [:register] do |c|
3
4
 
4
- c.desc "Name to give the image"
5
- c.flag [:n, "name"]
5
+ c.desc "Name to give the image"
6
+ c.flag [:n, "name"]
6
7
 
7
- c.desc "Archtecture of the image (i686 or x86_64)"
8
- c.flag [:a, "arch"]
8
+ c.desc "Archtecture of the image (i686 or x86_64)"
9
+ c.flag [:a, "arch"]
9
10
 
10
- c.desc "Source filename of the image you uploaded to the image library"
11
- c.flag [:s, "source"]
11
+ c.desc "Source filename of the image you uploaded to the image library"
12
+ c.flag [:s, "source"]
12
13
 
13
- c.desc "This image does not support virtio so needs 'compatibility mode'"
14
- c.switch [:c, "compatibility"]
14
+ c.desc "This image does not support virtio so needs 'compatibility mode'"
15
+ c.switch [:c, "compatibility"]
15
16
 
16
- c.desc "Image description"
17
- c.flag [:d, "description"]
17
+ c.desc "Image description"
18
+ c.flag [:d, "description"]
18
19
 
19
- c.action do |global_options,options,args|
20
+ c.action do |global_options,options,args|
20
21
 
21
- raise "You must specify the architecture" unless options[:a]
22
- raise "You must specify the source filename" unless options[:s]
22
+ raise "You must specify the architecture" unless options[:a]
23
+ raise "You must specify the source filename" unless options[:s]
23
24
 
24
- image = Image.register :name => options[:n], :arch => options[:a],
25
- :source => options[:s], :compatibility_mode => options[:c],
26
- :description => options[:d]
25
+ image = Image.register :name => options[:n], :arch => options[:a],
26
+ :source => options[:s], :compatibility_mode => options[:c],
27
+ :description => options[:d]
27
28
 
28
- render_table([image])
29
+ render_table([image])
29
30
 
31
+ end
30
32
  end
31
33
  end
@@ -1,23 +1,25 @@
1
- desc 'Show detailed image info'
2
- arg_name 'image-id...'
3
- command [:show] do |c|
1
+ module Brightbox
2
+ desc 'Show detailed image info'
3
+ arg_name 'image-id...'
4
+ command [:show] do |c|
4
5
 
5
- c.action do |global_options,options,args|
6
+ c.action do |global_options,options,args|
6
7
 
7
- if args.empty?
8
- raise "You must specify the images you want to show"
9
- end
8
+ if args.empty?
9
+ raise "You must specify the images you want to show"
10
+ end
10
11
 
11
- images = Image.find_or_call(args) do |id|
12
- warn "Couldn't find image #{id}"
13
- end
12
+ images = Image.find_or_call(args) do |id|
13
+ warn "Couldn't find image #{id}"
14
+ end
14
15
 
15
- table_opts = global_options.merge({
16
- :vertical => true,
17
- :fields => [:id, :type, :owner, :created_at, :status, :arch, :name, :description, :virtual_size, :disk_size, "compatibility_mode", :official, :ancestor_id ]
18
- })
16
+ table_opts = global_options.merge({
17
+ :vertical => true,
18
+ :fields => [:id, :type, :owner, :created_at, :status, :arch, :name, :description, :virtual_size, :disk_size, "compatibility_mode", :official, :ancestor_id ]
19
+ })
19
20
 
20
- render_table(images, table_opts)
21
+ render_table(images, table_opts)
21
22
 
23
+ end
22
24
  end
23
25
  end
@@ -1,20 +1,22 @@
1
- desc 'Add nodes to a load balancer'
2
- arg_name 'lb-id node-id...'
3
- command [:add_nodes] do |c|
1
+ module Brightbox
2
+ desc 'Add nodes to a load balancer'
3
+ arg_name 'lb-id node-id...'
4
+ command [:add_nodes] do |c|
4
5
 
5
- c.action do |global_options, options, args|
6
+ c.action do |global_options, options, args|
6
7
 
7
- raise "You must specify the load balancer and the node ids to add" if args.size < 2
8
+ raise "You must specify the load balancer and the node ids to add" if args.size < 2
8
9
 
9
- lb = LoadBalancer.find(args.shift)
10
+ lb = LoadBalancer.find(args.shift)
10
11
 
11
- nodes = Server.find_or_call(args) do |id|
12
- raise "Couldn't find server #{id}"
13
- end
12
+ nodes = Server.find_or_call(args) do |id|
13
+ raise "Couldn't find server #{id}"
14
+ end
14
15
 
15
- info "Adding #{nodes.size} nodes to load balancer #{lb.id}"
16
- lb.add_nodes nodes
17
- lb.reload
18
- render_table([lb], global_options)
16
+ info "Adding #{nodes.size} nodes to load balancer #{lb.id}"
17
+ lb.add_nodes nodes
18
+ lb.reload
19
+ render_table([lb], global_options)
20
+ end
19
21
  end
20
22
  end
@@ -1,87 +1,89 @@
1
- desc 'Create a load balancer'
2
- long_desc "All intervals and timeouts are in milliseconds"
3
- arg_name 'srv-id...'
4
- command [:create] do |c|
1
+ module Brightbox
2
+ desc 'Create a load balancer'
3
+ long_desc "All intervals and timeouts are in milliseconds"
4
+ arg_name 'srv-id...'
5
+ command [:create] do |c|
5
6
 
6
- c.desc "Friendly name of load balancer"
7
- c.flag [:n, :name]
7
+ c.desc "Friendly name of load balancer"
8
+ c.flag [:n, :name]
8
9
 
9
- c.desc "Load balancer policy"
10
- c.default_value "least-connections"
11
- c.flag [:p, :policy]
10
+ c.desc "Load balancer policy"
11
+ c.default_value "least-connections"
12
+ c.flag [:p, :policy]
12
13
 
13
- c.desc "Listeners. Format: in-port:out-port:type. Comma separate multiple listeners."
14
- c.default_value "80:80:http,443:443:tcp"
15
- c.flag [:l, :listeners]
14
+ c.desc "Listeners. Format: in-port:out-port:type. Comma separate multiple listeners."
15
+ c.default_value "80:80:http,443:443:tcp"
16
+ c.flag [:l, :listeners]
16
17
 
17
- c.desc "Healthcheck port. Defaults to first listener out port."
18
- c.flag [:k, "hc-port"]
18
+ c.desc "Healthcheck port. Defaults to first listener out port."
19
+ c.flag [:k, "hc-port"]
19
20
 
20
- c.desc "Healthcheck type. Defaults to first listener protocol."
21
- c.flag [:y, "hc-type"]
21
+ c.desc "Healthcheck type. Defaults to first listener protocol."
22
+ c.flag [:y, "hc-type"]
22
23
 
23
- c.desc "Healthcheck timeout"
24
- c.default_value "5000"
25
- c.flag [:t, "hc-timeout"]
24
+ c.desc "Healthcheck timeout"
25
+ c.default_value "5000"
26
+ c.flag [:t, "hc-timeout"]
26
27
 
27
- c.desc "Healthcheck request. When the type is 'http' this is the url to request."
28
- c.default_value "/"
29
- c.flag [:s, "hc-request"]
28
+ c.desc "Healthcheck request. When the type is 'http' this is the url to request."
29
+ c.default_value "/"
30
+ c.flag [:s, "hc-request"]
30
31
 
31
- c.desc "Healthcheck interval"
32
- c.default_value "5000"
33
- c.flag [:e, "hc-interval"]
32
+ c.desc "Healthcheck interval"
33
+ c.default_value "5000"
34
+ c.flag [:e, "hc-interval"]
34
35
 
35
- c.desc "Healthcheck threshold up. Number of successful healthchecks for the node to be considered up."
36
- c.default_value "3"
37
- c.flag [:u, "hc-up"]
36
+ c.desc "Healthcheck threshold up. Number of successful healthchecks for the node to be considered up."
37
+ c.default_value "3"
38
+ c.flag [:u, "hc-up"]
38
39
 
39
- c.desc "Healthcheck threshold down. Number of failed healthchecks for the node to be considered down."
40
- c.default_value "3"
41
- c.flag [:d, "hc-down"]
40
+ c.desc "Healthcheck threshold down. Number of failed healthchecks for the node to be considered down."
41
+ c.default_value "3"
42
+ c.flag [:d, "hc-down"]
42
43
 
43
- c.action do |global_options, options, args|
44
+ c.action do |global_options, options, args|
44
45
 
45
- raise "You must specify which servers to balance connections to" if args.empty?
46
+ raise "You must specify which servers to balance connections to" if args.empty?
46
47
 
47
- listeners = options[:l].split(",").collect do |l|
48
- inport, outport, protocol = l.split ":"
49
- raise "listener '#{l}' is invalid" if inport.nil? or outport.nil? or protocol.nil?
50
- { :in => inport, :out => outport, :protocol => protocol }
51
- end
48
+ listeners = options[:l].split(",").collect do |l|
49
+ inport, outport, protocol = l.split ":"
50
+ raise "listener '#{l}' is invalid" if inport.nil? or outport.nil? or protocol.nil?
51
+ { :in => inport, :out => outport, :protocol => protocol }
52
+ end
52
53
 
53
- raise "You must specify at least one listener" if listeners.empty?
54
+ raise "You must specify at least one listener" if listeners.empty?
54
55
 
55
- # Setup default healthcheck port if not specified
56
- if options[:k].nil?
57
- options[:k] = listeners.first[:out]
58
- end
56
+ # Setup default healthcheck port if not specified
57
+ if options[:k].nil?
58
+ options[:k] = listeners.first[:out]
59
+ end
59
60
 
60
- if options[:y].nil?
61
- options[:y] = listeners.first[:protocol]
62
- end
61
+ if options[:y].nil?
62
+ options[:y] = listeners.first[:protocol]
63
+ end
63
64
 
64
- hc_arg_lookup = { :k => :port, :y => :type, :t => :timeout, :s =>
65
- :request, :e => :interval, :u => :threshold_up, :d =>
66
- :threshold_down }
65
+ hc_arg_lookup = { :k => :port, :y => :type, :t => :timeout, :s =>
66
+ :request, :e => :interval, :u => :threshold_up, :d =>
67
+ :threshold_down }
67
68
 
68
- healthcheck = {}
69
+ healthcheck = {}
69
70
 
70
- options.keys.each do |k|
71
- if options[k] and hc_arg_lookup[k]
72
- healthcheck[hc_arg_lookup[k]] = options[k]
71
+ options.keys.each do |k|
72
+ if options[k] and hc_arg_lookup[k]
73
+ healthcheck[hc_arg_lookup[k]] = options[k]
74
+ end
73
75
  end
74
- end
75
76
 
76
- nodes = args.collect { |i| { :node => i } }
77
+ nodes = args.collect { |i| { :node => i } }
77
78
 
78
- msg = "Creating a new load balancer"
79
- info msg
80
- lb = LoadBalancer.create(:policy => options[:policy],
81
- :name => options[:n],
82
- :healthcheck => healthcheck,
83
- :listeners => listeners,
84
- :nodes => nodes)
85
- render_table([lb], global_options)
79
+ msg = "Creating a new load balancer"
80
+ info msg
81
+ lb = LoadBalancer.create(:policy => options[:policy],
82
+ :name => options[:n],
83
+ :healthcheck => healthcheck,
84
+ :listeners => listeners,
85
+ :nodes => nodes)
86
+ render_table([lb], global_options)
87
+ end
86
88
  end
87
89
  end