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
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
- pkg/*
2
- *.gem
3
1
  .bundle
2
+ Gemfile.lock
3
+ local
4
+ vendor/fog-0.8.2/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/README CHANGED
@@ -7,11 +7,21 @@ http://beta.brightbox.com
7
7
 
8
8
  http://docs.brightbox.com/cli
9
9
 
10
+ == Dependencies
11
+
12
+ It has following dependencies and if you are trying to install the gem from
13
+ a gem file (rather than via gem command), you might have to install the
14
+ following:
15
+
16
+ * fog - 0.8.2
17
+ * json - 1.5.3
18
+ * hirb - 0.3.5
19
+
10
20
  == Packaging
11
21
 
12
22
  === Vendoring libraries
13
23
 
14
- gems can be vendored into lib/bbcloud/vendor for packaging and will be
24
+ gems can be vendored into vendor/ for packaging and will be
15
25
  prioritized over any gems.
16
26
 
17
27
  === Debian/Ubuntu packaging
data/README.rdoc CHANGED
@@ -7,11 +7,21 @@ http://beta.brightbox.com
7
7
 
8
8
  http://docs.brightbox.com/cli
9
9
 
10
+ == Dependencies
11
+
12
+ It has following dependencies and if you are trying to install the gem from
13
+ a gem file (rather than via gem command), you might have to install the
14
+ following:
15
+
16
+ * fog - 0.8.2
17
+ * json - 1.5.3
18
+ * hirb - 0.3.5
19
+
10
20
  == Packaging
11
21
 
12
22
  === Vendoring libraries
13
23
 
14
- gems can be vendored into lib/bbcloud/vendor for packaging and will be
24
+ gems can be vendored into vendor/ for packaging and will be
15
25
  prioritized over any gems.
16
26
 
17
27
  === Debian/Ubuntu packaging
data/Rakefile CHANGED
@@ -1,2 +1,14 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ bbcloud_path = File.expand_path('./lib', File.dirname(__FILE__))
5
+ $:.unshift(bbcloud_path)
6
+ require "bbcloud/command_generator"
7
+
8
+ desc "generate brightbox-commands"
9
+ task :generate_commands do
10
+ Brightbox::CommandGenerator.new(bbcloud_path)
11
+ end
12
+
13
+ require 'rspec/core/rake_task'
14
+ RSpec::Core::RakeTask.new
data/bbcloud.gemspec CHANGED
@@ -18,14 +18,14 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # To work around a bug with json using the wrong json_pure
22
- s.add_dependency 'json', '=1.4.6'
23
- s.add_dependency 'json_pure', '=1.4.6'
24
-
25
- s.add_dependency 'gli', '1.2.5'
26
- s.add_dependency 'hirb', '0.3.5'
27
- s.add_dependency 'formatador', '=0.0.16'
28
- s.add_dependency 'excon', '=0.5.6'
29
- s.add_dependency 'ini', '0.1.1'
30
-
21
+ s.add_dependency 'json', '~> 1.5.3'
22
+ s.add_dependency 'hirb', '0.3.5'
23
+ s.add_dependency 'formatador', '~> 0.1.4'
24
+ s.add_dependency 'excon', '~> 0.6.1'
25
+ s.add_dependency 'fog', '~> 0.8.0'
26
+ s.add_development_dependency('rake', '~> 0.8.0')
27
+ s.add_development_dependency('vcr')
28
+ s.add_development_dependency('rspec')
29
+ s.add_development_dependency('mocha')
31
30
  end
31
+
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/bin/brightbox-config CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/bin/brightbox-images CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/bin/brightbox-lbs CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/bin/brightbox-types CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/bin/brightbox-users CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/bin/brightbox-zones CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
- require "bbcloud/cli"
4
+ require "bbcloud"
5
5
  rescue LoadError
6
6
  bbcloud_path = File.expand_path('../../lib', __FILE__)
7
7
  $:.unshift(bbcloud_path)
8
- require "bbcloud/cli"
8
+ require "bbcloud"
9
+ end
10
+
11
+ Brightbox::BBConfig.config do
12
+ include GLI
13
+ run ARGV
9
14
  end
data/lib/bbcloud.rb ADDED
@@ -0,0 +1,43 @@
1
+ lib_dir = File.expand_path(File.dirname(__FILE__))
2
+
3
+ $LOAD_PATH.unshift lib_dir unless $LOAD_PATH.include?(lib_dir)
4
+
5
+ os_config = File.join(lib_dir,"bbcloud","os_config.rb")
6
+ require os_config if File.exist? os_config
7
+
8
+ vendor_dir = File.expand_path(File.join(lib_dir, 'bbcloud','vendor'))
9
+
10
+ unless defined?(DISABLE_RUBYGEMS)
11
+ require "rubygems"
12
+ gem "json", "~> 1.5.3"
13
+ gem "fog", "~> 0.8.0"
14
+ end
15
+
16
+ # Add any vendored libraries into search path
17
+ Dir.glob(vendor_dir + '/*').each do |f|
18
+ $:.unshift File.join(f, 'lib')
19
+ end
20
+
21
+ require "json"
22
+ require 'date'
23
+ require 'gli'
24
+ require 'fog'
25
+
26
+
27
+ require 'bbcloud/tables'
28
+ require "bbcloud/fog_extensions"
29
+ require "bbcloud/logging"
30
+ require "bbcloud/api"
31
+ require "bbcloud/servers"
32
+ require "bbcloud/images"
33
+ require "bbcloud/types"
34
+ require "bbcloud/zones"
35
+ require "bbcloud/cloud_ips"
36
+ require "bbcloud/users"
37
+ require "bbcloud/accounts"
38
+ require "bbcloud/config"
39
+ require "bbcloud/version"
40
+ require "bbcloud/load_balancers"
41
+ require "bbcloud/ruby_core_ext"
42
+ require "bbcloud/error_parser"
43
+
@@ -5,10 +5,12 @@ module Brightbox
5
5
  [ram_limit.to_i - ram_used.to_i, 0].max
6
6
  end
7
7
 
8
+ def cloud_ip_limit
9
+ attributes['cloud_ips_limit']
10
+ end
11
+
8
12
  def to_row
9
- attributes.merge({ :ram_free => ram_free,
10
- :cloud_ip_limit => limits_cloudips
11
- })
13
+ attributes.merge(:ram_free => ram_free, :cloud_ip_limit => cloud_ip_limit)
12
14
  end
13
15
 
14
16
  def self.all
@@ -0,0 +1,50 @@
1
+ module Brightbox
2
+ class CommandGenerator
3
+ COMMAND_LIST = [
4
+ 'brightbox-accounts',
5
+ 'brightbox-cloudips',
6
+ 'brightbox-config',
7
+ 'brightbox-images',
8
+ 'brightbox-lbs',
9
+ 'brightbox-servers',
10
+ 'brightbox-types',
11
+ 'brightbox-users',
12
+ 'brightbox-zones'
13
+ ]
14
+
15
+ def initialize(bbcloud_path)
16
+ @bbcloud_path = bbcloud_path
17
+ COMMAND_LIST.each do |command|
18
+ File.open("#{cli_binary_path}/#{command}","w+") do |fl|
19
+ fl.write(command_template)
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+ def command_template
26
+ brightbox_command =<<-EOF
27
+ #!/usr/bin/env ruby
28
+
29
+ begin
30
+ require "bbcloud"
31
+ rescue LoadError
32
+ bbcloud_path = File.expand_path('../../lib', __FILE__)
33
+ $:.unshift(bbcloud_path)
34
+ require "bbcloud"
35
+ end
36
+
37
+ Brightbox::BBConfig.config do
38
+ include GLI
39
+ run ARGV
40
+ end
41
+ EOF
42
+ brightbox_command
43
+ end
44
+
45
+ def cli_binary_path
46
+ File.join(@bbcloud_path,"..","bin")
47
+ end
48
+
49
+ end
50
+ end
@@ -1,16 +1,18 @@
1
- desc 'List accounts'
2
- arg_name '[account-id...]'
3
- command [:list] do |c|
4
- c.action do |global_options, options, args|
1
+ module Brightbox
2
+ desc 'List accounts'
3
+ arg_name '[account-id...]'
4
+ command [:list] do |c|
5
+ c.action do |global_options, options, args|
5
6
 
6
- if args.empty?
7
- accounts = Account.find(:all)
8
- else
9
- accounts = Account.find_or_call(args) do |id|
10
- warn "Couldn't find account #{id}"
7
+ if args.empty?
8
+ accounts = Account.find(:all)
9
+ else
10
+ accounts = Account.find_or_call(args) do |id|
11
+ warn "Couldn't find account #{id}"
12
+ end
11
13
  end
12
- end
13
14
 
14
- render_table(accounts, global_options)
15
+ render_table(accounts, global_options)
16
+ end
15
17
  end
16
18
  end
@@ -1,33 +1,36 @@
1
- desc 'Reset FTP Library password'
2
- arg_name 'account-id...'
3
- command [:reset_ftp_password] do |c|
1
+ module Brightbox
2
+ desc 'Reset FTP Library password'
3
+ arg_name 'account-id...'
4
+ command [:reset_ftp_password] 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 accounts to reset ftp passwords for"
9
- end
8
+ if args.empty?
9
+ raise "You must specify the accounts to reset ftp passwords for"
10
+ end
10
11
 
11
- accounts = Account.find_or_call(args) do |id|
12
- raise "Couldn't find account #{id}"
13
- end
12
+ accounts = Account.find_or_call(args) do |id|
13
+ raise "Couldn't find account #{id}"
14
+ end
14
15
 
15
- rows = []
16
+ rows = []
16
17
 
17
- accounts.each do |s|
18
- info "Resetting ftp password for #{s}"
19
- new_password = s.reset_ftp_password
20
- o = s.to_row
21
- o[:library_ftp_password] = new_password
22
- rows << o
23
- end
18
+ accounts.each do |s|
19
+ info "Resetting ftp password for #{s}"
20
+ new_password = s.reset_ftp_password
21
+ o = s.to_row
22
+ o[:library_ftp_password] = new_password
23
+ rows << o
24
+ end
24
25
 
25
- table_opts = global_options.merge({
26
- :vertical => true,
27
- :fields => [:id, :name, :library_ftp_host, :library_ftp_user, :library_ftp_password ]
28
- })
26
+ table_opts = global_options.merge({
27
+ :vertical => true,
28
+ :fields => [:id, :name, :library_ftp_host, :library_ftp_user, :library_ftp_password ]
29
+ })
29
30
 
30
- render_table(rows, table_opts)
31
+ render_table(rows, table_opts)
31
32
 
33
+ end
32
34
  end
33
35
  end
36
+