bbcloud 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/Gemfile +3 -0
- data/README +11 -1
- data/README.rdoc +11 -1
- data/Rakefile +12 -0
- data/bbcloud.gemspec +10 -10
- data/bin/brightbox-accounts +7 -2
- data/bin/brightbox-cloudips +7 -2
- data/bin/brightbox-config +7 -2
- data/bin/brightbox-images +7 -2
- data/bin/brightbox-lbs +7 -2
- data/bin/brightbox-servers +7 -2
- data/bin/brightbox-types +7 -2
- data/bin/brightbox-users +7 -2
- data/bin/brightbox-zones +7 -2
- data/lib/bbcloud.rb +43 -0
- data/lib/bbcloud/accounts.rb +5 -3
- data/lib/bbcloud/command_generator.rb +50 -0
- data/lib/bbcloud/commands/accounts-list.rb +13 -11
- data/lib/bbcloud/commands/accounts-reset-ftp-password.rb +26 -23
- data/lib/bbcloud/commands/accounts-show.rb +20 -16
- data/lib/bbcloud/commands/cloudips-create.rb +16 -14
- data/lib/bbcloud/commands/cloudips-destroy.rb +29 -26
- data/lib/bbcloud/commands/cloudips-list.rb +13 -11
- data/lib/bbcloud/commands/cloudips-map.rb +48 -46
- data/lib/bbcloud/commands/cloudips-show.rb +15 -12
- data/lib/bbcloud/commands/cloudips-unmap.rb +28 -25
- data/lib/bbcloud/commands/config-client-add.rb +33 -31
- data/lib/bbcloud/commands/config-client-default.rb +18 -16
- data/lib/bbcloud/commands/config-client-list.rb +19 -16
- data/lib/bbcloud/commands/config-client-remove.rb +18 -16
- data/lib/bbcloud/commands/images-destroy.rb +18 -16
- data/lib/bbcloud/commands/images-list.rb +20 -18
- data/lib/bbcloud/commands/images-register.rb +21 -19
- data/lib/bbcloud/commands/images-show.rb +17 -15
- data/lib/bbcloud/commands/lbs-add-nodes.rb +15 -13
- data/lib/bbcloud/commands/lbs-create.rb +65 -63
- data/lib/bbcloud/commands/lbs-destroy.rb +13 -11
- data/lib/bbcloud/commands/lbs-list.rb +13 -11
- data/lib/bbcloud/commands/lbs-remove-nodes.rb +15 -13
- data/lib/bbcloud/commands/lbs-show.rb +15 -13
- data/lib/bbcloud/commands/lbs-update.rb +59 -57
- data/lib/bbcloud/commands/servers-activate-cloud.rb +18 -16
- data/lib/bbcloud/commands/servers-create.rb +80 -77
- data/lib/bbcloud/commands/servers-destroy.rb +17 -15
- data/lib/bbcloud/commands/servers-list.rb +14 -14
- data/lib/bbcloud/commands/servers-show.rb +39 -37
- data/lib/bbcloud/commands/servers-shutdown.rb +14 -12
- data/lib/bbcloud/commands/servers-snapshot.rb +14 -12
- data/lib/bbcloud/commands/servers-start.rb +15 -13
- data/lib/bbcloud/commands/servers-stop.rb +14 -12
- data/lib/bbcloud/commands/types-list.rb +13 -11
- data/lib/bbcloud/commands/types-show.rb +18 -16
- data/lib/bbcloud/commands/users-list.rb +13 -11
- data/lib/bbcloud/commands/users-show.rb +17 -15
- data/lib/bbcloud/commands/users-update.rb +27 -25
- data/lib/bbcloud/commands/zones-list.rb +13 -11
- data/lib/bbcloud/config.rb +125 -111
- data/lib/bbcloud/error_parser.rb +34 -0
- data/lib/bbcloud/fog_extensions.rb +19 -0
- data/lib/bbcloud/gli_global_hooks.rb +56 -0
- data/lib/bbcloud/logging.rb +40 -0
- data/lib/bbcloud/ruby_core_ext.rb +9 -0
- data/lib/bbcloud/servers.rb +7 -2
- data/lib/bbcloud/tables.rb +78 -73
- data/lib/bbcloud/vendor/gli/.gitignore +10 -0
- data/lib/bbcloud/vendor/gli/.rvmrc +1 -0
- data/lib/bbcloud/vendor/gli/Gemfile +5 -0
- data/lib/bbcloud/vendor/gli/LICENSE.txt +201 -0
- data/lib/bbcloud/vendor/gli/README.rdoc +54 -0
- data/lib/bbcloud/vendor/gli/Rakefile +84 -0
- data/lib/bbcloud/vendor/gli/bin/gli +72 -0
- data/lib/bbcloud/vendor/gli/bin/report_on_rake_results +10 -0
- data/lib/bbcloud/vendor/gli/bin/test_all_rubies.sh +2 -0
- data/lib/bbcloud/vendor/gli/features/gli_executable.feature +88 -0
- data/lib/bbcloud/vendor/gli/features/gli_init.feature +122 -0
- data/lib/bbcloud/vendor/gli/features/step_definitions/gli_executable_steps.rb +12 -0
- data/lib/bbcloud/vendor/gli/features/step_definitions/gli_init_steps.rb +4 -0
- data/lib/bbcloud/vendor/gli/features/support/env.rb +21 -0
- data/lib/bbcloud/vendor/gli/gli.cheat +80 -0
- data/lib/bbcloud/vendor/gli/gli.gemspec +46 -0
- data/lib/bbcloud/vendor/gli/gli.rdoc +51 -0
- data/lib/bbcloud/vendor/gli/lib/gli.rb +560 -0
- data/lib/bbcloud/vendor/gli/lib/gli/command.rb +124 -0
- data/lib/bbcloud/vendor/gli/lib/gli/command_line_token.rb +58 -0
- data/lib/bbcloud/vendor/gli/lib/gli/copy_options_to_aliases.rb +33 -0
- data/lib/bbcloud/vendor/gli/lib/gli/exceptions.rb +45 -0
- data/lib/bbcloud/vendor/gli/lib/gli/flag.rb +67 -0
- data/lib/bbcloud/vendor/gli/lib/gli/options.rb +19 -0
- data/lib/bbcloud/vendor/gli/lib/gli/switch.rb +63 -0
- data/lib/bbcloud/vendor/gli/lib/gli/terminal.rb +79 -0
- data/lib/bbcloud/vendor/gli/lib/gli_version.rb +3 -0
- data/lib/bbcloud/vendor/gli/lib/support/help.rb +180 -0
- data/lib/bbcloud/vendor/gli/lib/support/initconfig.rb +34 -0
- data/lib/bbcloud/vendor/gli/lib/support/rdoc.rb +119 -0
- data/lib/bbcloud/vendor/gli/lib/support/scaffold.rb +284 -0
- data/lib/bbcloud/vendor/gli/test/config.yaml +9 -0
- data/lib/bbcloud/vendor/gli/test/gli.reek +116 -0
- data/lib/bbcloud/vendor/gli/test/roodi.yaml +9 -0
- data/lib/bbcloud/vendor/gli/test/tc_command.rb +329 -0
- data/lib/bbcloud/vendor/gli/test/tc_flag.rb +67 -0
- data/lib/bbcloud/vendor/gli/test/tc_gli.rb +429 -0
- data/lib/bbcloud/vendor/gli/test/tc_options.rb +31 -0
- data/lib/bbcloud/vendor/gli/test/tc_parsing.rb +279 -0
- data/lib/bbcloud/vendor/gli/test/tc_switch.rb +80 -0
- data/lib/bbcloud/vendor/gli/test/tc_terminal.rb +91 -0
- data/lib/bbcloud/version.rb +1 -1
- data/pkg/bbcloud-0.12.0.gem +0 -0
- data/spec/fixtures/vcr_cassettes/server_list.yml +117 -0
- data/spec/servers_spec.rb +36 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/common_helpers.rb +47 -0
- metadata +129 -135
- data/lib/bbcloud/cli.rb +0 -160
- data/lib/bbcloud/vendor/fog/lib/fog.rb +0 -14
- data/lib/bbcloud/vendor/fog/lib/fog/compute.rb +0 -43
- data/lib/bbcloud/vendor/fog/lib/fog/compute/brightbox.rb +0 -162
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/account.rb +0 -51
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ip.rb +0 -47
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ips.rb +0 -34
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavor.rb +0 -33
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavors.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/image.rb +0 -56
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/images.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancer.rb +0 -50
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancers.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/server.rb +0 -108
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/servers.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/user.rb +0 -39
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/users.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zone.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zones.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/activate_console_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_listeners_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_nodes_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_api_client.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_cloud_ip.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_image.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_load_balancer.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_server.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_api_client.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_image.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_account.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_api_client.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_image.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_interface.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server_type.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_user.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_zone.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_api_clients.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_cloud_ips.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_images.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_load_balancers.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_server_types.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_servers.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_users.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_zones.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/map_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_listeners_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_nodes_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/reset_ftp_password_account.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/resize_server.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/shutdown_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/snapshot_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/start_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/stop_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/unmap_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_account.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_api_client.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_image.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_load_balancer.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_server.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_user.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/core.rb +0 -32
- data/lib/bbcloud/vendor/fog/lib/fog/core/attributes.rb +0 -178
- data/lib/bbcloud/vendor/fog/lib/fog/core/collection.rb +0 -127
- data/lib/bbcloud/vendor/fog/lib/fog/core/connection.rb +0 -35
- data/lib/bbcloud/vendor/fog/lib/fog/core/credentials.rb +0 -92
- data/lib/bbcloud/vendor/fog/lib/fog/core/deprecation.rb +0 -23
- data/lib/bbcloud/vendor/fog/lib/fog/core/errors.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/core/hmac.rb +0 -48
- data/lib/bbcloud/vendor/fog/lib/fog/core/mock.rb +0 -68
- data/lib/bbcloud/vendor/fog/lib/fog/core/model.rb +0 -57
- data/lib/bbcloud/vendor/fog/lib/fog/core/parser.rb +0 -99
- data/lib/bbcloud/vendor/fog/lib/fog/core/provider.rb +0 -18
- data/lib/bbcloud/vendor/fog/lib/fog/core/scp.rb +0 -67
- data/lib/bbcloud/vendor/fog/lib/fog/core/service.rb +0 -175
- data/lib/bbcloud/vendor/fog/lib/fog/core/ssh.rb +0 -120
- data/lib/bbcloud/vendor/fog/lib/fog/core/time.rb +0 -27
- data/lib/bbcloud/vendor/fog/lib/fog/core/wait_for.rb +0 -17
- data/lib/bbcloud/vendor/fog/lib/fog/providers.rb +0 -9
- data/lib/bbcloud/vendor/fog/lib/fog/providers/brightbox.rb +0 -9
@@ -1,35 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
class Connection
|
3
|
-
|
4
|
-
def initialize(url, persistent=false, params={})
|
5
|
-
@excon = Excon.new(url, params)
|
6
|
-
@persistent = persistent
|
7
|
-
end
|
8
|
-
|
9
|
-
def request(params, &block)
|
10
|
-
unless @persistent
|
11
|
-
reset
|
12
|
-
end
|
13
|
-
unless block_given?
|
14
|
-
if (parser = params.delete(:parser))
|
15
|
-
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
16
|
-
block = lambda { |chunk| body << chunk }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
response = @excon.request(params, &block)
|
21
|
-
|
22
|
-
if parser
|
23
|
-
body.finish
|
24
|
-
response.body = parser.response
|
25
|
-
end
|
26
|
-
|
27
|
-
response
|
28
|
-
end
|
29
|
-
|
30
|
-
def reset
|
31
|
-
@excon.reset
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
require 'fog/core/deprecation'
|
5
|
-
|
6
|
-
# Assign a new credential to use from configuration file
|
7
|
-
# @param [String, Symbol] new_credential name of new credential to use
|
8
|
-
# @ return [String, Symbol] name of the new credential
|
9
|
-
def self.credential=(new_credential)
|
10
|
-
@credentials = nil
|
11
|
-
@credential = new_credential
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [String, Symbol] The credential to use in Fog
|
15
|
-
def self.credential
|
16
|
-
@credential ||= :default
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [String] The path for configuration_file
|
20
|
-
def self.credentials_path
|
21
|
-
@credential_path ||= File.expand_path(ENV["FOG_RC"] || '~/.fog')
|
22
|
-
end
|
23
|
-
|
24
|
-
# @return [String] The new path for credentials file
|
25
|
-
def self.credentials_path=(new_credentials_path)
|
26
|
-
@credentials = nil
|
27
|
-
@credential_path = new_credentials_path
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [Hash] The credentials pulled from the configuration file
|
31
|
-
# @raise [LoadError] Configuration unavailable in configuration file
|
32
|
-
def self.credentials
|
33
|
-
@credentials ||= begin
|
34
|
-
if File.exists?(credentials_path)
|
35
|
-
credentials = YAML.load_file(credentials_path)
|
36
|
-
(credentials && credentials[credential]) or raise LoadError.new(missing_credentials)
|
37
|
-
else
|
38
|
-
{}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
# @return [String] The error message that will be raised, if credentials cannot be found
|
46
|
-
def self.missing_credentials
|
47
|
-
<<-YML
|
48
|
-
Missing Credentials
|
49
|
-
|
50
|
-
To run as '#{credential}', add the following to your resource config file: #{credentials_path}
|
51
|
-
An alternate file may be used by placing its path in the FOG_RC environment variable
|
52
|
-
|
53
|
-
#######################################################
|
54
|
-
# Fog Credentials File
|
55
|
-
#
|
56
|
-
# Key-value pairs should look like:
|
57
|
-
# :aws_access_key_id: 022QF06E7MXBSAMPLE
|
58
|
-
:#{credential}:
|
59
|
-
:aws_access_key_id:
|
60
|
-
:aws_secret_access_key:
|
61
|
-
:bluebox_api_key:
|
62
|
-
:bluebox_customer_id:
|
63
|
-
:brightbox_client_id:
|
64
|
-
:brightbox_secret:
|
65
|
-
:go_grid_api_key:
|
66
|
-
:go_grid_shared_secret:
|
67
|
-
:google_storage_access_key_id:
|
68
|
-
:google_storage_secret_access_key:
|
69
|
-
:linode_api_key:
|
70
|
-
:local_root:
|
71
|
-
:new_servers_password:
|
72
|
-
:new_servers_username:
|
73
|
-
:public_key_path:
|
74
|
-
:private_key_path:
|
75
|
-
:rackspace_api_key:
|
76
|
-
:rackspace_username:
|
77
|
-
:slicehost_password:
|
78
|
-
:terremark_username:
|
79
|
-
:terremark_password:
|
80
|
-
:voxel_api_key:
|
81
|
-
:voxel_api_secret:
|
82
|
-
:zerigo_email:
|
83
|
-
:zerigo_token:
|
84
|
-
:dnsimple_email:
|
85
|
-
:dnsimple_password:
|
86
|
-
#
|
87
|
-
# End of Fog Credentials File
|
88
|
-
#######################################################
|
89
|
-
|
90
|
-
YML
|
91
|
-
end
|
92
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Deprecation
|
3
|
-
|
4
|
-
def deprecate(older, newer)
|
5
|
-
module_eval <<-EOS, __FILE__, __LINE__
|
6
|
-
def #{older}(*args)
|
7
|
-
Formatador.display_line("[yellow][WARN] #{self} => ##{older} is deprecated, use ##{newer} instead[/] [light_black](#{caller.first})[/]")
|
8
|
-
send(:#{newer}, *args)
|
9
|
-
end
|
10
|
-
EOS
|
11
|
-
end
|
12
|
-
|
13
|
-
def self_deprecate(older, newer)
|
14
|
-
module_eval <<-EOS, __FILE__, __LINE__
|
15
|
-
def self.#{older}(*args)
|
16
|
-
Formatador.display_line("[yellow][WARN] #{self} => ##{older} is deprecated, use ##{newer} instead[/] [light_black](#{caller.first})[/]")
|
17
|
-
send(:#{newer}, *args)
|
18
|
-
end
|
19
|
-
EOS
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Errors
|
3
|
-
|
4
|
-
class Error < StandardError
|
5
|
-
attr_accessor :verbose
|
6
|
-
|
7
|
-
def self.slurp(error, message = nil)
|
8
|
-
new_error = new(message)
|
9
|
-
new_error.set_backtrace(error.backtrace)
|
10
|
-
new_error.verbose = error.message
|
11
|
-
new_error
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class MockNotImplemented < Fog::Errors::Error; end
|
16
|
-
|
17
|
-
class NotFound < Fog::Errors::Error; end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
class HMAC
|
3
|
-
|
4
|
-
def initialize(type, key)
|
5
|
-
@key = key
|
6
|
-
case type
|
7
|
-
when 'sha1'
|
8
|
-
setup_sha1
|
9
|
-
when 'sha256'
|
10
|
-
setup_sha256
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def sign(data)
|
15
|
-
@signer.call(data)
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def setup_sha1
|
21
|
-
@digest = OpenSSL::Digest::Digest.new('sha1')
|
22
|
-
@signer = lambda do |data|
|
23
|
-
OpenSSL::HMAC.digest(@digest, @key, data)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def setup_sha256
|
28
|
-
begin
|
29
|
-
@digest = OpenSSL::Digest::Digest.new('sha256')
|
30
|
-
@signer = lambda do |data|
|
31
|
-
OpenSSL::HMAC.digest(@digest, @key, data)
|
32
|
-
end
|
33
|
-
rescue RuntimeError => error
|
34
|
-
unless error.message == 'Unsupported digest algorithm (sha256).'
|
35
|
-
raise error
|
36
|
-
else
|
37
|
-
require 'hmac-sha2'
|
38
|
-
@hmac = ::HMAC::SHA256.new(@key)
|
39
|
-
@signer = lambda do |data|
|
40
|
-
@hmac.update(data)
|
41
|
-
@hmac.digest
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
|
3
|
-
@mocking = false
|
4
|
-
|
5
|
-
def self.mock!
|
6
|
-
@mocking = true
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.mock?
|
10
|
-
@mocking
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.mocking?
|
14
|
-
@mocking
|
15
|
-
end
|
16
|
-
|
17
|
-
module Mock
|
18
|
-
|
19
|
-
@delay = 1
|
20
|
-
def self.delay
|
21
|
-
@delay
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.delay=(new_delay)
|
25
|
-
raise ArgumentError, "delay must be non-negative" unless new_delay >= 0
|
26
|
-
@delay = new_delay
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.not_implemented
|
30
|
-
raise Fog::Errors::MockNotImplemented.new("Contributions welcome!")
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.random_base64(length)
|
34
|
-
random_selection(
|
35
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
36
|
-
length
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.random_hex(length)
|
41
|
-
max = ('f' * length).to_i(16)
|
42
|
-
rand(max).to_s(16).rjust(length, '0')
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.random_letters(length)
|
46
|
-
random_selection(
|
47
|
-
'abcdefghijklmnopqrstuvwxyz',
|
48
|
-
length
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.random_numbers(length)
|
53
|
-
max = ('9' * length).to_i
|
54
|
-
rand(max).to_s
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.random_selection(characters, length)
|
58
|
-
selection = ''
|
59
|
-
length.times do
|
60
|
-
position = rand(characters.length)
|
61
|
-
selection << characters[position..position]
|
62
|
-
end
|
63
|
-
selection
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
class Model
|
3
|
-
|
4
|
-
extend Fog::Attributes::ClassMethods
|
5
|
-
include Fog::Attributes::InstanceMethods
|
6
|
-
|
7
|
-
attr_accessor :collection, :connection
|
8
|
-
|
9
|
-
def initialize(new_attributes = {})
|
10
|
-
merge_attributes(new_attributes)
|
11
|
-
end
|
12
|
-
|
13
|
-
def inspect
|
14
|
-
Thread.current[:formatador] ||= Formatador.new
|
15
|
-
data = "#{Thread.current[:formatador].indentation}<#{self.class.name}"
|
16
|
-
Thread.current[:formatador].indent do
|
17
|
-
unless self.class.attributes.empty?
|
18
|
-
data << "\n#{Thread.current[:formatador].indentation}"
|
19
|
-
data << self.class.attributes.map {|attribute| "#{attribute}=#{send(attribute).inspect}"}.join(",\n#{Thread.current[:formatador].indentation}")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
data << "\n#{Thread.current[:formatador].indentation}>"
|
23
|
-
data
|
24
|
-
end
|
25
|
-
|
26
|
-
def reload
|
27
|
-
requires :identity
|
28
|
-
if data = collection.get(identity)
|
29
|
-
new_attributes = data.attributes
|
30
|
-
merge_attributes(new_attributes)
|
31
|
-
self
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_json
|
36
|
-
require 'json'
|
37
|
-
attributes.to_json
|
38
|
-
end
|
39
|
-
|
40
|
-
def wait_for(timeout=600, interval=1, &block)
|
41
|
-
reload
|
42
|
-
Fog.wait_for(timeout, interval) do
|
43
|
-
retries = 3
|
44
|
-
if reload
|
45
|
-
retries = 3
|
46
|
-
elsif retries > 0
|
47
|
-
retries -= 1
|
48
|
-
sleep(1)
|
49
|
-
elsif retries == 0
|
50
|
-
raise Fog::Errors::Error.new("Reload failed, #{self.class} #{self.identity} went away.")
|
51
|
-
end
|
52
|
-
instance_eval(&block)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Parsers
|
5
|
-
class Base < Nokogiri::XML::SAX::Document
|
6
|
-
|
7
|
-
attr_reader :response
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
reset
|
11
|
-
end
|
12
|
-
|
13
|
-
def reset
|
14
|
-
@response = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
def characters(string)
|
18
|
-
@value ||= ''
|
19
|
-
@value << string.strip
|
20
|
-
end
|
21
|
-
|
22
|
-
def start_element(name, attrs = [])
|
23
|
-
@value = nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def attr_value(name, attrs)
|
27
|
-
(entry = attrs.detect {|a, v| a == name }) && entry.last
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module Fog
|
35
|
-
class ToHashDocument < Nokogiri::XML::SAX::Document
|
36
|
-
|
37
|
-
def initialize
|
38
|
-
@stack = []
|
39
|
-
end
|
40
|
-
|
41
|
-
def characters(string)
|
42
|
-
@value ||= ''
|
43
|
-
@value << string.strip
|
44
|
-
end
|
45
|
-
|
46
|
-
def end_element(name)
|
47
|
-
last = @stack.pop
|
48
|
-
if last.empty? && @value.empty?
|
49
|
-
@stack.last[name.to_sym] = ''
|
50
|
-
elsif last == {:i_nil=>"true"}
|
51
|
-
@stack.last[name.to_sym] = nil
|
52
|
-
elsif !@value.empty?
|
53
|
-
@stack.last[name.to_sym] = @value
|
54
|
-
end
|
55
|
-
@value = ''
|
56
|
-
end
|
57
|
-
|
58
|
-
def body
|
59
|
-
@stack.first
|
60
|
-
end
|
61
|
-
|
62
|
-
def response
|
63
|
-
body
|
64
|
-
end
|
65
|
-
|
66
|
-
def start_element(name, attributes = [])
|
67
|
-
@value = ''
|
68
|
-
parsed_attributes = {}
|
69
|
-
until attributes.empty?
|
70
|
-
if attributes.first.is_a?(Array)
|
71
|
-
key, value = attributes.shift
|
72
|
-
else
|
73
|
-
key, value = attributes.shift, attributes.shift
|
74
|
-
end
|
75
|
-
parsed_attributes[key.gsub(':','_').to_sym] = value
|
76
|
-
end
|
77
|
-
if @stack.last.is_a?(Array)
|
78
|
-
@stack.last << {name.to_sym => parsed_attributes}
|
79
|
-
else
|
80
|
-
data = if @stack.empty?
|
81
|
-
@stack.push(parsed_attributes)
|
82
|
-
parsed_attributes
|
83
|
-
elsif @stack.last[name.to_sym]
|
84
|
-
unless @stack.last[name.to_sym].is_a?(Array)
|
85
|
-
@stack.last[name.to_sym] = [@stack.last[name.to_sym]]
|
86
|
-
end
|
87
|
-
@stack.last[name.to_sym] << parsed_attributes
|
88
|
-
@stack.last[name.to_sym].last
|
89
|
-
else
|
90
|
-
@stack.last[name.to_sym] = {}
|
91
|
-
@stack.last[name.to_sym].merge!(parsed_attributes)
|
92
|
-
@stack.last[name.to_sym]
|
93
|
-
end
|
94
|
-
@stack.push(data)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
end
|