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/lib/bbcloud/cli.rb DELETED
@@ -1,160 +0,0 @@
1
- os_config = File.join(File.dirname(__FILE__), 'os_config.rb')
2
- require os_config if File.exist? os_config
3
-
4
- vendor_dir = File.join(File.dirname(__FILE__), 'vendor/')
5
-
6
- unless defined?(DISABLE_RUBYGEMS)
7
- require "rubygems"
8
- gem "json", "=1.4.6"
9
- gem "json_pure", "=1.4.6"
10
- gem "fog", "=0.4.0" unless File.exist? vendor_dir + 'fog'
11
- end
12
-
13
- # Add any vendored libraries into search path
14
- Dir.glob(vendor_dir + '*').each do |f|
15
- $:.unshift File.join(f, 'lib')
16
- end
17
-
18
- begin
19
- require 'json/ext'
20
- rescue LoadError
21
- require 'json/pure'
22
- end
23
-
24
- require 'date'
25
- require 'gli'
26
- require 'bbcloud/tables'
27
- require 'fog'
28
-
29
- # Hack to force persistent connections in fog
30
- module Fog
31
- class Connection
32
- def initialize(url, persistent=false)
33
- @excon = Excon.new(url)
34
- @persistent = true
35
- end
36
- end
37
- end
38
-
39
- module Fog
40
- module Brightbox
41
- class Compute
42
- class Real
43
- attr_accessor :oauth_token
44
- end
45
- end
46
- end
47
- end
48
-
49
- %w{api servers images types zones cloud_ips users accounts config version load_balancers}.each do |f|
50
- require File.join(File.dirname(__FILE__), f)
51
- end
52
-
53
- CONFIG = BBConfig.new
54
-
55
- include Brightbox
56
- include GLI
57
-
58
- class Time
59
- def rfc8601
60
- self.strftime("%Y-%m-%dT%H:%M")
61
- end
62
- def to_s
63
- rfc8601
64
- end
65
- end
66
-
67
- def error(s='')
68
- STDERR.write s
69
- STDERR.write "\n"
70
- STDERR.flush
71
- end
72
-
73
- def info(s='')
74
- STDERR.write s
75
- STDERR.write "\n"
76
- STDERR.flush
77
- end
78
-
79
- def warn(s='')
80
- info "WARN: #{s}"
81
- end
82
-
83
- def data(s)
84
- STDOUT.write s
85
- STDOUT.write "\n"
86
- end
87
-
88
- def debug(s)
89
- if ENV['DEBUG']
90
- STDERR.write "DEBUG: "
91
- STDERR.write s
92
- STDERR.write "\n"
93
- end
94
- end
95
-
96
- # Global options
97
- desc "Simple output (tab separated, don't draw fancy tables)"
98
- switch [:s, :simple]
99
-
100
- desc "Set the api client to use (named in #{CONFIG.config_filename})"
101
- flag [:c, :client]
102
-
103
- desc "Disable peer SSL certificate verification"
104
- switch [:k, :insecure]
105
-
106
- # Load the command libraries for the current group
107
- cmd_group_name = File.basename($0).gsub(/brightbox\-/,'')
108
- cmd_group_files = File.join(File.dirname(__FILE__), "commands/#{cmd_group_name}*.rb")
109
- Dir.glob(cmd_group_files).each do |f|
110
- load f
111
- end
112
-
113
- pre do |global_options,command,options,args|
114
- CONFIG.client_name = global_options[:c] if global_options[:c]
115
- Excon.ssl_verify_peer = false if global_options[:k]
116
- info "INFO: client_id: #{CONFIG.client_name}" if CONFIG.clients.size > 1
117
- true
118
- end
119
-
120
- on_error do |e|
121
- case e
122
- when Excon::Errors::ServiceUnavailable
123
- error "Api currently unavailable"
124
- when Excon::Errors::Error
125
- if e.respond_to?(:response) and e.response.respond_to?(:body)
126
- r = JSON.parse(e.response.body) rescue {}
127
- if r['error']
128
- if r['error'].is_a? Hash
129
- # Most API errors
130
- r = r['error']
131
- error "ERROR: #{e.class}: #{r['name']}: #{r['summary']}"
132
- else
133
- # Auth error
134
- error "ERROR: #{e.class}: #{r['error']}: #{r['error_description']}"
135
- end
136
- else
137
- error "ERROR: #{e}"
138
- end
139
- else
140
- error "ERROR: #{e}"
141
- end
142
- else
143
- error "ERROR: #{e}"
144
- end
145
- debug e
146
- debug e.class.to_s
147
- debug e.backtrace.join("\n")
148
- exit 1
149
- end
150
-
151
- desc 'Display version information'
152
- command [:version] do |c|
153
- c.action do |global_options, options, args|
154
- info "Brightbox CLI version: #{Brightbox::VERSION}, Fog version: #{Fog::VERSION}"
155
- end
156
- end
157
-
158
- run ARGV
159
-
160
- CONFIG.finish
@@ -1,14 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'fog', 'core')
2
-
3
- module Fog
4
-
5
- unless const_defined?(:VERSION)
6
- VERSION = '0.6.0'
7
- end
8
-
9
- end
10
-
11
- # FIXME: these should go away (force usage of Fog::[Compute, CDN, DNS, Storage] etc)
12
- require 'fog/providers'
13
-
14
- require 'fog/compute'
@@ -1,43 +0,0 @@
1
- module Fog
2
- class Compute
3
-
4
- def self.new(attributes)
5
- attributes = attributes.dup # prevent delete from having side effects
6
- case provider = attributes[:provider] # attributes.delete(:provider)
7
- when 'AWS'
8
- require 'fog/compute/aws'
9
- Fog::AWS::Compute.new(attributes)
10
- when 'Bluebox'
11
- require 'fog/compute/bluebox'
12
- Fog::Bluebox::Compute.new(attributes)
13
- when 'Brightbox'
14
- require 'fog/compute/brightbox'
15
- Fog::Brightbox::Compute.new(attributes)
16
- when 'Ecloud'
17
- require 'fog/compute/ecloud'
18
- Fog::Ecloud::Compute.new(attributes)
19
- when 'GoGrid'
20
- require 'fog/compute/go_grid'
21
- Fog::GoGrid::Compute.new(attributes)
22
- when 'Linode'
23
- require 'fog/compute/linode'
24
- Fog::Linode::Compute.new(attributes)
25
- when 'NewServers'
26
- require 'fog/compute/new_servers'
27
- Fog::NewServers::Compute.new(attributes)
28
- when 'Rackspace'
29
- require 'fog/compute/rackspace'
30
- Fog::Rackspace::Compute.new(attributes)
31
- when 'Voxel'
32
- require 'fog/compute/voxel'
33
- Fog::Voxel::Compute.new(attributes)
34
- when 'Slicehost'
35
- require 'fog/compute/slicehost'
36
- Fog::Slicehost::Compute.new(attributes)
37
- else
38
- raise ArgumentError.new("#{provider} is not a recognized compute provider")
39
- end
40
- end
41
-
42
- end
43
- end
@@ -1,162 +0,0 @@
1
- module Fog
2
- module Brightbox
3
- class Compute < Fog::Service
4
-
5
- API_URL = "https://api.gb1.brightbox.com/"
6
-
7
- requires :brightbox_client_id, :brightbox_secret
8
- recognizes :brightbox_auth_url, :brightbox_api_url
9
- recognizes :provider # remove post deprecation
10
-
11
- model_path 'fog/compute/models/brightbox'
12
- model :account # Singular resource, no collection
13
- collection :servers
14
- model :server
15
- collection :flavors
16
- model :flavor
17
- collection :images
18
- model :image
19
- collection :load_balancers
20
- model :load_balancer
21
- collection :zones
22
- model :zone
23
- collection :cloud_ips
24
- model :cloud_ip
25
- collection :users
26
- model :user
27
-
28
- request_path 'fog/compute/requests/brightbox'
29
- request :activate_console_server
30
- request :add_listeners_load_balancer
31
- request :add_nodes_load_balancer
32
- request :create_api_client
33
- request :create_cloud_ip
34
- request :create_image
35
- request :create_load_balancer
36
- request :create_server
37
- request :destroy_api_client
38
- request :destroy_cloud_ip
39
- request :destroy_image
40
- request :destroy_load_balancer
41
- request :destroy_server
42
- request :get_account
43
- request :get_api_client
44
- request :get_cloud_ip
45
- request :get_image
46
- request :get_interface
47
- request :get_load_balancer
48
- request :get_server
49
- request :get_server_type
50
- request :get_user
51
- request :get_zone
52
- request :list_api_clients
53
- request :list_cloud_ips
54
- request :list_images
55
- request :list_load_balancers
56
- request :list_server_types
57
- request :list_servers
58
- request :list_users
59
- request :list_zones
60
- request :map_cloud_ip
61
- request :remove_listeners_load_balancer
62
- request :remove_nodes_load_balancer
63
- request :reset_ftp_password_account
64
- request :resize_server
65
- request :shutdown_server
66
- request :snapshot_server
67
- request :start_server
68
- request :stop_server
69
- request :unmap_cloud_ip
70
- request :update_account
71
- request :update_api_client
72
- request :update_image
73
- request :update_load_balancer
74
- request :update_server
75
- request :update_user
76
-
77
- class Mock
78
-
79
- def initialize(options)
80
- unless options.delete(:provider)
81
- location = caller.first
82
- warning = "[yellow][WARN] Fog::Brightbox::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Brightbox') instead[/]"
83
- warning << " [light_black](" << location << ")[/] "
84
- Formatador.display_line(warning)
85
- end
86
-
87
- @brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
88
- @brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
89
- end
90
-
91
- def request(options)
92
- raise "Not implemented"
93
- end
94
- end
95
-
96
- class Real
97
-
98
- def initialize(options)
99
- unless options.delete(:provider)
100
- location = caller.first
101
- warning = "[yellow][WARN] Fog::Brightbox::Compute.new is deprecated, use Fog::Compute.new(:provider => 'Brightbox') instead[/]"
102
- warning << " [light_black](" << location << ")[/] "
103
- Formatador.display_line(warning)
104
- end
105
-
106
- require "json"
107
- # Currently authentication and api endpoints are the same but may change
108
- @auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
109
- @api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
110
- @brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
111
- @brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
112
- @connection = Fog::Connection.new(@api_url)
113
- end
114
-
115
- def request(params)
116
- begin
117
- get_oauth_token if @oauth_token.nil?
118
- response = authenticated_request(params)
119
- rescue Excon::Errors::Unauthorized => e
120
- get_oauth_token
121
- response = authenticated_request(params)
122
- end
123
- unless response.body.empty?
124
- response = JSON.parse(response.body)
125
- end
126
- end
127
-
128
- def account
129
- Fog::Brightbox::Compute::Account.new(get_account)
130
- end
131
-
132
- private
133
- def get_oauth_token(options = {})
134
- auth_url = options[:brightbox_auth_url] || @auth_url
135
-
136
- connection = Fog::Connection.new(auth_url)
137
- @authentication_body = {'client_id' => @brightbox_client_id, 'grant_type' => 'none'}.to_json
138
-
139
- response = connection.request({
140
- :path => "/token",
141
- :expects => 200,
142
- :headers => {
143
- 'Authorization' => "Basic " + Base64.encode64("#{@brightbox_client_id}:#{@brightbox_secret}").chomp,
144
- 'Content-Type' => 'application/json'
145
- },
146
- :method => 'POST',
147
- :body => @authentication_body
148
- })
149
- @oauth_token = JSON.parse(response.body)["access_token"]
150
- return @oauth_token
151
- end
152
-
153
- def authenticated_request(options)
154
- headers = options[:headers] || {}
155
- headers.merge!("Authorization" => "OAuth #{@oauth_token}")
156
- options[:headers] = headers
157
- @connection.request(options)
158
- end
159
- end
160
- end
161
- end
162
- end
@@ -1,51 +0,0 @@
1
- require 'fog/core/model'
2
-
3
- module Fog
4
- module Brightbox
5
- class Compute
6
-
7
- class Account < Fog::Model
8
-
9
- identity :id
10
- attribute :resource_type
11
- attribute :url
12
- attribute :name
13
- attribute :status
14
- attribute :address_1
15
- attribute :address_2
16
- attribute :city
17
- attribute :county
18
- attribute :postcode
19
- attribute :country_code
20
- attribute :country_name
21
- attribute :vat_registration_number
22
- attribute :telephone_number
23
- attribute :telephone_verified
24
- attribute :ram_limit
25
- attribute :ram_used
26
- attribute :limits_cloudips
27
- attribute :library_ftp_host
28
- attribute :library_ftp_user
29
- # This is always returned as null/nil unless performing a reset_ftp_password request
30
- attribute :library_ftp_password
31
- attribute :created_at, :type => :time
32
-
33
-
34
-
35
- attribute :owner_id, :aliases => "owner", :squash => "id"
36
- attribute :clients
37
- attribute :images
38
- attribute :servers
39
- attribute :users
40
- attribute :zones
41
-
42
- def reset_ftp_password
43
- requires :identity
44
- connection.reset_ftp_password_account(identity)["library_ftp_password"]
45
- end
46
-
47
- end
48
-
49
- end
50
- end
51
- end
@@ -1,47 +0,0 @@
1
- require 'fog/core/model'
2
-
3
- module Fog
4
- module Brightbox
5
- class Compute
6
-
7
- class CloudIp < Fog::Model
8
-
9
- identity :id
10
-
11
- attribute :url
12
- attribute :name
13
- attribute :status
14
- attribute :resource_type
15
- attribute :description
16
-
17
- attribute :reverse_dns
18
- attribute :public_ip
19
-
20
- attribute :account_id, :aliases => "account", :squash => "id"
21
- attribute :interface_id, :aliases => "interface", :squash => "id"
22
- attribute :server_id, :aliases => "server", :squash => "id"
23
-
24
- def map(interface_to_map)
25
- requires :identity
26
- connection.map_cloud_ip(identity, :interface => interface_to_map)
27
- end
28
-
29
- def mapped?
30
- status == "mapped"
31
- end
32
-
33
- def unmap
34
- requires :identity
35
- connection.unmap_cloud_ip(identity)
36
- end
37
-
38
- def destroy
39
- requires :identity
40
- connection.destroy_cloud_ip(identity)
41
- end
42
-
43
- end
44
-
45
- end
46
- end
47
- end