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,18 +0,0 @@
1
- module Fog
2
- module Provider
3
-
4
- def self.extended(base)
5
- Fog.providers << base.to_s.split('::').last
6
- end
7
-
8
- def service(new_service, path)
9
- services << new_service
10
- require File.join('fog', path)
11
- end
12
-
13
- def services
14
- @services ||= []
15
- end
16
-
17
- end
18
- end
@@ -1,67 +0,0 @@
1
- module Fog
2
- module SCP
3
-
4
- def self.new(address, username, options = {})
5
- if Fog.mocking?
6
- Fog::SCP::Mock.new(address, username, options)
7
- else
8
- Fog::SCP::Real.new(address, username, options)
9
- end
10
- end
11
-
12
- def self.reset_data(keys=Mock.data.keys)
13
- Mock.reset_data(keys)
14
- end
15
-
16
- class Mock
17
-
18
- def self.data
19
- @data ||= Hash.new do |hash, key|
20
- hash[key] = {}
21
- end
22
- end
23
-
24
- def initialize(address, username, options)
25
- @address = address
26
- @username = username
27
- @options = options
28
- end
29
-
30
- def upload(local_path, remote_path)
31
- Fog::Mock.not_implemented
32
- end
33
-
34
- end
35
-
36
- class Real
37
-
38
- def initialize(address, username, options)
39
- require 'net/scp'
40
-
41
- key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
42
-
43
- unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
44
- raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH')
45
- end
46
-
47
- @address = address
48
- @username = username
49
- @options = { :paranoid => false }.merge(options)
50
- end
51
-
52
- def upload(local_path, remote_path)
53
- begin
54
- Net::SCP.start(@address, @username, @options) do |scp|
55
- scp.upload!(local_path, remote_path) do |ch, name, sent, total|
56
- # TODO: handle progress display?
57
- end
58
- end
59
- rescue Exception => error
60
- raise error
61
- end
62
- end
63
-
64
- end
65
-
66
- end
67
- end
@@ -1,175 +0,0 @@
1
- module Fog
2
- class Service
3
-
4
- class Error < Fog::Errors::Error; end
5
- class NotFound < Fog::Errors::NotFound; end
6
-
7
- module Collections
8
-
9
- def collections
10
- service.collections
11
- end
12
-
13
- def mocked_requests
14
- service.mocked_requests
15
- end
16
-
17
- def requests
18
- service.requests
19
- end
20
-
21
- end
22
-
23
- class << self
24
-
25
- def inherited(child)
26
- child.class_eval <<-EOS, __FILE__, __LINE__
27
- module Collections
28
- include Fog::Service::Collections
29
-
30
- def service
31
- #{child}
32
- end
33
- end
34
-
35
- def self.service
36
- #{child}
37
- end
38
- EOS
39
- end
40
-
41
- def new(options={})
42
- # attempt to load credentials from config file
43
- begin
44
- default_credentials = Fog.credentials.reject {|key, value| !(recognized | requirements).include?(key)}
45
- options = default_credentials.merge(options)
46
- rescue LoadError
47
- # if there are no configured credentials, do nothing
48
- end
49
-
50
- validate_options(options)
51
- setup_requirements
52
-
53
- if Fog.mocking?
54
- service::Mock.send(:include, service::Collections)
55
- service::Mock.new(options)
56
- else
57
- service::Real.send(:include, service::Collections)
58
- service::Real.new(options)
59
- end
60
- end
61
-
62
- def setup_requirements
63
- if superclass.respond_to?(:setup_requirements)
64
- superclass.setup_requirements
65
- end
66
-
67
- @required ||= false
68
- unless @required
69
- for collection in collections
70
- require [@model_path, collection].join('/')
71
- constant = collection.to_s.split('_').map {|characters| characters[0...1].upcase << characters[1..-1]}.join('')
72
- service::Collections.module_eval <<-EOS, __FILE__, __LINE__
73
- def #{collection}(attributes = {})
74
- #{service}::#{constant}.new({:connection => self}.merge(attributes))
75
- end
76
- EOS
77
- end
78
- for model in models
79
- require [@model_path, model].join('/')
80
- end
81
- for request in requests
82
- require [@request_path, request].join('/')
83
- if service::Mock.method_defined?(request)
84
- mocked_requests << request
85
- else
86
- service::Mock.module_eval <<-EOS, __FILE__, __LINE__
87
- def #{request}(*args)
88
- Fog::Mock.not_implemented
89
- end
90
- EOS
91
- end
92
- end
93
- @required = true
94
- end
95
- end
96
-
97
- def model_path(new_path)
98
- @model_path = new_path
99
- end
100
-
101
- def collection(new_collection)
102
- collections << new_collection
103
- end
104
-
105
- def collections
106
- @collections ||= []
107
- end
108
-
109
- def mocked_requests
110
- @mocked_requests ||= []
111
- end
112
-
113
- def model(new_model)
114
- models << new_model
115
- end
116
-
117
- def models
118
- @models ||= []
119
- end
120
-
121
- def request_path(new_path)
122
- @request_path = new_path
123
- end
124
-
125
- def request(new_request)
126
- requests << new_request
127
- end
128
-
129
- def requests
130
- @requests ||= []
131
- end
132
-
133
- def requires(*args)
134
- requirements.concat(args)
135
- end
136
-
137
- def requirements
138
- @requirements ||= []
139
- end
140
-
141
- def recognizes(*args)
142
- recognized.concat(args)
143
- end
144
-
145
- def recognized
146
- @recognized ||= []
147
- end
148
-
149
- def reset_data(keys=Mock.data.keys)
150
- Mock.reset_data(keys)
151
- end
152
-
153
- def reset_data(keys=Mock.data.keys)
154
- Mock.reset_data(keys)
155
- end
156
-
157
- def validate_options(options)
158
- missing = requirements - options.keys
159
- unless missing.empty?
160
- raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
161
- end
162
-
163
- unless recognizes.empty?
164
- unrecognized = options.keys - requirements - recognized
165
- unless unrecognized.empty?
166
- raise ArgumentError, "Unrecognized arguments: #{unrecognized.join(', ')}"
167
- end
168
- end
169
- end
170
-
171
- end
172
-
173
- end
174
- end
175
-
@@ -1,120 +0,0 @@
1
- module Fog
2
- module SSH
3
-
4
- def self.new(address, username, options = {})
5
- if Fog.mocking?
6
- Fog::SSH::Mock.new(address, username, options)
7
- else
8
- Fog::SSH::Real.new(address, username, options)
9
- end
10
- end
11
-
12
- def self.reset_data(keys=Mock.data.keys)
13
- Mock.reset_data(keys)
14
- end
15
-
16
- class Mock
17
-
18
- def self.data
19
- @data ||= Hash.new do |hash, key|
20
- hash[key] = {}
21
- end
22
- end
23
-
24
- def initialize(address, username, options)
25
- @address = address
26
- @username = username
27
- @options = options
28
- end
29
-
30
- def run(commands)
31
- Fog::Mock.not_implemented
32
- end
33
-
34
- end
35
-
36
- class Real
37
-
38
- def initialize(address, username, options)
39
- require 'net/ssh'
40
-
41
- key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
42
-
43
- unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
44
- raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH')
45
- end
46
-
47
- @address = address
48
- @username = username
49
- @options = { :paranoid => false }.merge(options)
50
- end
51
-
52
- def run(commands)
53
- commands = [*commands]
54
- results = []
55
- begin
56
- Net::SSH.start(@address, @username, @options) do |ssh|
57
- commands.each do |command|
58
- escaped_command = command.sub(/'/, %{'"'"'})
59
- result = Result.new(escaped_command)
60
- ssh.open_channel do |ssh_channel|
61
- ssh_channel.request_pty
62
- ssh_channel.exec(%{bash -lc '#{escaped_command}'}) do |channel, success|
63
- unless success
64
- raise "Could not execute command: #{command.inspect}"
65
- end
66
-
67
- channel.on_data do |ch, data|
68
- result.stdout << data
69
- end
70
-
71
- channel.on_extended_data do |ch, type, data|
72
- next unless type == 1
73
- result.stderr << data
74
- end
75
-
76
- channel.on_request('exit-status') do |ch, data|
77
- result.status = data.read_long
78
- end
79
-
80
- channel.on_request('exit-signal') do |ch, data|
81
- result.status = 255
82
- end
83
- end
84
- end
85
- ssh.loop
86
- results << result
87
- end
88
- end
89
- rescue Net::SSH::HostKeyMismatch => exception
90
- exception.remember_host!
91
- sleep 0.2
92
- retry
93
- end
94
- results
95
- end
96
-
97
- end
98
-
99
- class Result
100
-
101
- attr_accessor :command, :stderr, :stdout, :status
102
-
103
- def display_stdout
104
- Formatador.display_line(stdout.split("\r\n"))
105
- end
106
-
107
- def display_stderr
108
- Formatador.display_line(stderr.split("\r\n"))
109
- end
110
-
111
- def initialize(command)
112
- @command = command
113
- @stderr = ''
114
- @stdout = ''
115
- end
116
-
117
- end
118
-
119
- end
120
- end
@@ -1,27 +0,0 @@
1
- module Fog
2
- class Time < ::Time
3
-
4
- DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
5
- MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
6
-
7
- def self.now
8
- at((::Time.now - offset).to_i)
9
- end
10
-
11
- def self.now=(new_now)
12
- old_now = ::Time.now
13
- @offset = old_now - new_now
14
- new_now
15
- end
16
-
17
- def self.offset
18
- @offset ||= 0
19
- end
20
-
21
- def to_date_header
22
- now = self.class.now.utc
23
- now.strftime("#{DAYS[now.wday]}, %d #{MONTHS[now.month - 1]} %Y %H:%M:%S +0000")
24
- end
25
-
26
- end
27
- end
@@ -1,17 +0,0 @@
1
- module Fog
2
-
3
- def self.wait_for(timeout=600, interval=1, &block)
4
- duration = 0
5
- start = Time.now
6
- until yield || duration > timeout
7
- sleep(interval)
8
- duration = Time.now - start
9
- end
10
- if duration > timeout
11
- false
12
- else
13
- { :duration => duration }
14
- end
15
- end
16
-
17
- end
@@ -1,9 +0,0 @@
1
- module Fog
2
-
3
- def self.providers
4
- @providers ||= []
5
- end
6
-
7
- end
8
-
9
- require 'fog/providers/brightbox'
@@ -1,9 +0,0 @@
1
- require 'fog/core'
2
-
3
- module Fog
4
- module Brightbox
5
- extend Fog::Provider
6
-
7
- service(:compute, 'compute/brightbox')
8
- end
9
- end